-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_text_processing2.py
More file actions
85 lines (64 loc) · 2.52 KB
/
test_text_processing2.py
File metadata and controls
85 lines (64 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf8 -*-
import unittest
import random
import text_processing2 as tp
class TestTextProcessing(unittest.TestCase):
def test_digits_to_words(self):
test_str = ""
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "")
test_str = "Zip Code: 19104"
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "one nine one zero four")
test_str = "Pi is 3.1415..."
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "three one four one five")
test_str = "There are 3 jellies."
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "three")
test_str = "Your room number is 205."
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "two zero five")
test_str = "1588-1588"
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "one five eight eight one five eight eight")
test_str = "My number: 010-1234-5678"
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "zero one zero one two three four five six seven eight")
test_str = "No digits"
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "")
test_str = "No digits here too!?$%"
pred = tp.digits_to_words(test_str)
self.assertEqual(pred, "")
def test_to_camel_case(self):
test_str = "to_camel_case"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "toCamelCase")
test_str = "__EXAMPLE__NAME__"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "exampleName")
test_str = "alreadyCamel"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "alreadyCamel")
test_str = "_______"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "")
test_str = ""
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "")
test_str = "not_Camel_Yet"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "notCamelYet")
test_str = "NOT_CAMEL_Yet"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "notCamelYet")
test_str = "abc_def_ghi"
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, "abcDefGhi")
test_str = " "
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, " ")
test_str = "....."
pred = tp.to_camel_case(test_str)
self.assertEqual(pred, ".....")