Changeset 6415 for branches/numpy/anuga/utilities/test_system_tools.py
- Timestamp:
- Feb 25, 2009, 11:44:06 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/utilities/test_system_tools.py
r6410 r6415 183 183 184 184 ################################################################################ 185 # Test the string_to_char() and char_to_string() utility functions. 186 ################################################################################ 187 188 def test_string_to_char(self): 189 import random 190 191 MAX_CHARS = 10 192 MAX_ENTRIES = 100000 193 A_INT = ord('a') 194 Z_INT = ord('z') 195 196 # generate some random strings in a list, with guaranteed lengths 197 str_list = ['x' * MAX_CHARS] # make first maximum length 198 for entry in xrange(MAX_ENTRIES): 199 length = random.randint(1, MAX_CHARS) 200 s = '' 201 for c in range(length): 202 s += chr(random.randint(A_INT, Z_INT)) 203 str_list.append(s) 204 205 x = string_to_char(str_list) 206 new_str_list = char_to_string(x) 207 208 self.failUnlessEqual(new_str_list, str_list) 209 210 211 ################################################################################ 212 # Test the raw I/O to NetCDF files of string data encoded/decoded with 213 # string_to_char() and char_to_string(). 214 ################################################################################ 215 216 ################################################################################ 185 217 186 218 if __name__ == "__main__": 187 suite = unittest.makeSuite(Test_system_tools, 'test') 219 #suite = unittest.makeSuite(Test_system_tools, 'test') 220 suite = unittest.makeSuite(Test_system_tools, 'test_string_to_char') 188 221 runner = unittest.TextTestRunner() 189 222 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.