|
@@ -71,6 +71,43 @@ class GitConfigUnitTest(unittest.TestCase):
|
|
|
val = config.GetString('empty')
|
|
val = config.GetString('empty')
|
|
|
self.assertEqual(val, None)
|
|
self.assertEqual(val, None)
|
|
|
|
|
|
|
|
|
|
+ def test_GetBoolean_undefined(self):
|
|
|
|
|
+ """Test GetBoolean on key that doesn't exist."""
|
|
|
|
|
+ self.assertIsNone(self.config.GetBoolean('section.missing'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetBoolean_invalid(self):
|
|
|
|
|
+ """Test GetBoolean on invalid boolean value."""
|
|
|
|
|
+ self.assertIsNone(self.config.GetBoolean('section.boolinvalid'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetBoolean_true(self):
|
|
|
|
|
+ """Test GetBoolean on valid true boolean."""
|
|
|
|
|
+ self.assertTrue(self.config.GetBoolean('section.booltrue'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetBoolean_false(self):
|
|
|
|
|
+ """Test GetBoolean on valid false boolean."""
|
|
|
|
|
+ self.assertFalse(self.config.GetBoolean('section.boolfalse'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetInt_undefined(self):
|
|
|
|
|
+ """Test GetInt on key that doesn't exist."""
|
|
|
|
|
+ self.assertIsNone(self.config.GetInt('section.missing'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetInt_invalid(self):
|
|
|
|
|
+ """Test GetInt on invalid integer value."""
|
|
|
|
|
+ self.assertIsNone(self.config.GetBoolean('section.intinvalid'))
|
|
|
|
|
+
|
|
|
|
|
+ def test_GetInt_valid(self):
|
|
|
|
|
+ """Test GetInt on valid integers."""
|
|
|
|
|
+ TESTS = (
|
|
|
|
|
+ ('inthex', 16),
|
|
|
|
|
+ ('inthexk', 16384),
|
|
|
|
|
+ ('int', 10),
|
|
|
|
|
+ ('intk', 10240),
|
|
|
|
|
+ ('intm', 10485760),
|
|
|
|
|
+ ('intg', 10737418240),
|
|
|
|
|
+ )
|
|
|
|
|
+ for key, value in TESTS:
|
|
|
|
|
+ self.assertEqual(value, self.config.GetInt('section.%s' % (key,)))
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|
|
unittest.main()
|