]> gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/Tests/Unit/StringUtilsTest.py
Added a unique index on the tiger_lines "tlid" column.
[dead/census-tools.git] / src / Tests / Unit / StringUtilsTest.py
1 import unittest
2
3 import Tests.Fixtures
4 import SummaryFile1
5 import GPS
6 import StringUtils
7
8
9 class IsTypeTest(unittest.TestCase):
10
11 def testIntegersPassIsInteger(self):
12 """
13 If we take a bunch of integers, is_integer() should
14 return True for all of then, right?
15 """
16 for x in [ '0', '1', '902733', '-2142', '114', '65535', '65536', '-99999999' ]:
17 self.assertTrue(StringUtils.is_integer(x))
18
19
20 def testNonIntegersFailIsInteger(self):
21 """
22 Likewise, if we take a bunch of floats or whatever,
23 is_integer() should return False.
24 """
25 for x in [ '0.235', '-0235.021', 'string', GPS.Coordinates() ]:
26 self.assertFalse(StringUtils.is_integer(x))
27
28
29 def testFloatsPassIsFloat(self):
30 """
31 Do the same thing we did for is_integer(), only
32 now we check floats to make sure they pass.
33 """
34
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))
39
40
41 def testNonFloatsFailIsFloat(self):
42 """
43 Pass some strings and other objects to is_float(), and hope
44 that they fail.
45 """
46
47 for x in [ 'cinnammon0.024', '1.024letters234',
48 'nothing but string', GPS.Coordinates() ]:
49 self.assertFalse(StringUtils.is_float(x))
50
51
52
53 def suite():
54 suite = unittest.TestSuite()
55 suite.addTest(unittest.makeSuite(IsTypeTest))
56 return suite