diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-01-01 23:20:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-01-01 23:20:42 (GMT) |
commit | dcd5e0b104143b110997029aa0728731f4087ad8 (patch) | |
tree | 141a79ade5eae6e469ba9e5255882039e9c29a3e /tests | |
parent | 7b320516abf871eefe009ff6fe4fb86ed921fed9 (diff) |
Managed GObject references each time a configuration parameter is accessed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/glibext/configuration.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/glibext/configuration.py b/tests/glibext/configuration.py index 786fc9e..880b445 100644 --- a/tests/glibext/configuration.py +++ b/tests/glibext/configuration.py @@ -4,7 +4,7 @@ gi.require_version('Gdk', '3.0') from gi.repository import Gdk from chrysacase import ChrysalideTestCase -from pychrysalide.glibext import ConfigParam +from pychrysalide.glibext import ConfigParam, GenConfig class TestConfiguration(ChrysalideTestCase): @@ -69,3 +69,38 @@ class TestConfiguration(ChrysalideTestCase): self.assertTrue('|' in str(param.state)) self.assertTrue('.' in str(param.type)) + + + def testConfiguration(self): + """Feed and browse a basic configuration.""" + + config = GenConfig() + self.assertIsNotNone(config) + self.assertIsNone(config.filename) + + for i in range(5): + param = ConfigParam('config.int.%u' % i, ConfigParam.ConfigParamType.INTEGER, i) + config.add(param) + + chain = '' + + for p in config.params: + chain += '%u' % p.value + + self.assertTrue(chain == ''.join([ '%u' % i for i in range(5) ])) + + found = config.search('config.int.3') + self.assertTrue(found.value == 3) + + found = config.search('config.int.33') + self.assertIsNone(found) + + for p in config.params: + p.value *= 10 + + chain = '' + + for p in config.params: + chain += '%u' % p.value + + self.assertTrue(chain == ''.join([ '%u' % (i * 10) for i in range(5) ])) |