diff options
author | cmtice <cmtice@google.com> | 2014-05-07 13:22:37 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-05-08 01:20:38 +0000 |
commit | 2fca8ce27632ebce63627b5a51e9749e68bcf8b9 (patch) | |
tree | 1b1721fc6357a07861e097257767d3eec0cf66fa /crosperf/config_unittest.py | |
parent | 6ffbb92f0913f990b6a5c7ef706aee9bfb4faa9e (diff) | |
download | toolchain-utils-2fca8ce27632ebce63627b5a51e9749e68bcf8b9.tar.gz |
Add 3 unittests, for test_flag.py, config.py and benchmark.py
BUG=None
TEST=Ran unittests.
Change-Id: I2c421f8322e58173932656da9ae7a5af1bf3febd
Reviewed-on: https://chrome-internal-review.googlesource.com/162886
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Commit-Queue: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf/config_unittest.py')
-rw-r--r-- | crosperf/config_unittest.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crosperf/config_unittest.py b/crosperf/config_unittest.py new file mode 100644 index 00000000..af2b8fc9 --- /dev/null +++ b/crosperf/config_unittest.py @@ -0,0 +1,45 @@ +#!/usr/bi/python +# +# Copyright 2014 Google Inc. All Rights Reserved. + +import config + +import unittest + +class ConfigTestCase(unittest.TestCase): + + def test_config(self): + # Verify that config exists, that it's a dictionary, and that it's + # empty. + self.assertTrue(type(config.config) is dict) + self.assertEqual(len(config.config), 0) + + # Verify that attempting to get a non-existant key out of the + # dictionary returns None. + self.assertIsNone(config.GetConfig('rabbit')) + self.assertIsNone(config.GetConfig('key1')) + + config.AddConfig('key1', 16) + config.AddConfig('key2', 32) + config.AddConfig('key3', 'third value') + + # Verify that after 3 calls to AddConfig we have 3 values in the + # dictionary. + self.assertEqual(len(config.config), 3) + + # Verify that GetConfig works and gets the expected values. + self.assertIs(config.GetConfig('key2'), 32) + self.assertIs(config.GetConfig('key3'), 'third value') + self.assertIs(config.GetConfig('key1'), 16) + + # Re-set config. + config.config.clear() + + # Verify that config exists, that it's a dictionary, and that it's + # empty. + self.assertTrue(type(config.config) is dict) + self.assertEqual(len(config.config), 0) + + +if __name__ == '__main__': + unittest.main() |