]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/Tests/Unit/StringUtilsTest.py
9 class IsTypeTest(unittest
.TestCase
):
11 def testIntegersPassIsInteger(self
):
13 If we take a bunch of integers, is_integer() should
14 return True for all of then, right?
16 for x
in [ '0', '1', '902733', '-2142', '114', '65535', '65536', '-99999999' ]:
17 self
.assertTrue(StringUtils
.is_integer(x
))
20 def testNonIntegersFailIsInteger(self
):
22 Likewise, if we take a bunch of floats or whatever,
23 is_integer() should return False.
25 for x
in [ '0.235', '-0235.021', 'string', GPS
.Coordinates() ]:
26 self
.assertFalse(StringUtils
.is_integer(x
))
29 def testFloatsPassIsFloat(self
):
31 Do the same thing we did for is_integer(), only
32 now we check floats to make sure they pass.
35 # Note that integers can be converted to floats successfully.
36 for x
in [ '0.024', '1.024234', '-12.902733',
37 '-2142', '114', '65535', '65536', '-99999999' ]:
38 self
.assertTrue(StringUtils
.is_float(x
))
41 def testNonFloatsFailIsFloat(self
):
43 Pass some strings and other objects to is_float(), and hope
47 for x
in [ 'cinnammon0.024', '1.024letters234',
48 'nothing but string', GPS
.Coordinates() ]:
49 self
.assertFalse(StringUtils
.is_float(x
))
54 suite
= unittest
.TestSuite()
55 suite
.addTest(unittest
.makeSuite(IsTypeTest
))