Пример #1
0
 def test_gen_stats_ascii_two_chunk(self):
     teststr = 'the quick brown fox jumps over the lazy dog\n'
     out1 = gen_stats(teststr)
     out2 = gen_stats(teststr)
     combstr = teststr + teststr
     for i in range(128):
         numfound = out1[0][i] + out2[0][i]
         numactual = combstr.count(chr(i))
         self.assertEqual(numactual, numfound)
Пример #2
0
 def test_gen_stats_ascii_two_chunk(self):
     teststr = 'the quick brown fox jumps over the lazy dog\n'
     out1 = gen_stats(teststr)
     out2 = gen_stats(teststr)
     combstr = teststr + teststr
     for i in range(128):
         numfound = out1[0][i] + out2[0][i]
         numactual = combstr.count(chr(i))
         self.assertEqual(numactual, numfound)
 def test_get_mode_chars(self):
     teststr = 'the quick brown fox jumps over the lazy dog'
     out = gen_stats(teststr)
     combinedresults = combine_resultsets(out[0].tolist(), out[1])
     modefound = get_mode_chars(combinedresults)
     modeactual = ['o']
     self.assertEqual(modeactual, modefound)
 def test_get_num_lines_two_multi(self):
     teststr = 'the quick brown fox\n\f\vjumps over the lazy dog'
     out = gen_stats(teststr)
     numfound = 4
     numactual = teststr.count('\n') + teststr.count('\f') + teststr.count(
         '\v') + 1
     self.assertEqual(numfound, numactual)
 def test_get_num_words_two_chunk(self):
     teststr = 'the quick brown fox \n \njumps over the lazy dog'
     out1 = gen_stats(teststr)
     out2 = out1
     numfound = get_num_words(out1[0]) + get_num_words(out2[0])
     numactual = 18
     self.assertEqual(numactual, numfound)
Пример #6
0
 def test_gen_stats_ascii_two_line(self):
     teststr = 'the quick brown fox jumps over the lazy dog\n\nthe quick brown fox jumps over the lazy dog\n'
     out = gen_stats(teststr)
     for i in range(128):
         numfound = out[0][i]
         numactual = teststr.count(chr(i))
         self.assertEqual(numactual, numfound)
Пример #7
0
 def test_gen_stats_ascii_two_line(self):
     teststr = 'the quick brown fox jumps over the lazy dog\n\nthe quick brown fox jumps over the lazy dog\n'
     out = gen_stats(teststr)
     for i in range(128):
         numfound = out[0][i]
         numactual = teststr.count(chr(i))
         self.assertEqual(numactual, numfound)
Пример #8
0
 def test_gen_stats_utf_simple(self):
     # trad chinese quick brown.... fyi
     teststr = u'快速的棕色狐狸跳過懶狗'
     out = gen_stats(teststr)
     for char in teststr:
         numfound = out[1][char]
         numactual = teststr.count(char)
         self.assertEqual(numactual, numfound)
Пример #9
0
 def test_gen_stats_utf_simple(self):
     # trad chinese quick brown.... fyi
     teststr = u'快速的棕色狐狸跳過懶狗'
     out = gen_stats(teststr)
     for char in teststr:
         numfound = out[1][char]
         numactual = teststr.count(char)
         self.assertEqual(numactual, numfound)
Пример #10
0
 def test_get_num_lines_two(self):
     teststr = 'the quick brown fox\njumps over the lazy dog'
     out = gen_stats(teststr)
     numfound = get_num_lines(out[0])
     numactual = 2
     self.assertEqual(numfound, numactual)
Пример #11
0
 def test_get_num_words_double_newline(self):
     teststr = 'the quick brown fox \n \njumps over the lazy dog'
     out = gen_stats(teststr)
     numfound = get_num_words(out[0])
     numactual = 9
     self.assertEqual(numactual, numfound)
Пример #12
0
 def test_get_num_words(self):
     teststr = 'the quick brown fox jumps over the lazy dog'
     out1 = gen_stats(teststr)
     numfound = get_num_words(out1[0])
     numactual = 9
     self.assertEqual(numactual, numfound)