-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathFrmTextTests.sb
More file actions
130 lines (119 loc) · 2.88 KB
/
FrmTextTests.sb
File metadata and controls
130 lines (119 loc) · 2.88 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Function Test_Append()
x = "."
y = "test"
Return Unittest.AssertTrue(
{
y.Append(x) = "test.",
Text.Append(y, x) = "test.",
"." + "1" + 4 = 4.1,
Text.Append(".", {"1", "4"}) = ".14",
x.Append({"1", "4"}) = ".14"
},
"Text.Append"
)
EndFunction
Function Test_IndexOf()
a = "This is a test. Is not it?"
Return Unittest.AssertTrue(
{
Text.IndexOf(a, "This", 0, False) = 1,
a.IndexOf("", 1, False) = 0,
a.IndexOf("This", 6, False) = 0,
a.IndexOf("E", 1, False) = 0,
a.IndexOf("i", 1, False) = 3,
a.IndexOf("i", 4, False) = 6,
a.IndexOf("i", 100, True) = 24,
a.IndexOf("Adam", 1, False) = 0,
a.IndexOf("is", 1, False) = 3,
a.IndexOf("is", a.Length, True) = 6,
a.IndexOf("is", 5, True) = 3,
a.IndexOf("Is", 1, False) = 17,
a.IndexOf("Is", 100, True) = 17,
a.IndexOf("Is", 16, True) = 0,
a.IndexOf("Is", 16, False) = 17
},
"Text.IndexOf"
)
EndFunction
Function Test_StringMult()
a = {1, 2, 3}
Return Unittest.AssertTrue({
"abc" * 2 = "abcabc",
"200" * 2 = 400,
2 * "abc" = "abcabc",
2 * "200" = 400,
"abc" * "2" = "abcabc",
"200" * "2" = 400,
"2" * "abc" = "abcabc",
"2" * "200" = 400,
"a" * "b" = "",
2 * 200 = 400,
#+1.3:0# * 2 = #+2.6:0#,
a * 2 = ""
},
"StringMult")
EndFunction
Function Test_TextIndexerStringKeys()
x = ""
x["Ali"] = 1
x["Sara"] = "Hello"
x[123] = "NumericKey"
x[""] = "EmptyKey"
x["Ali"] = 99 ' إعادة الكتابة على نفس المفتاح
Return Unittest.AssertEqual(
{x["Ali"], x["Sara"], x[123], x[""]},
{"99", "Hello", "NumericKey", "EmptyKey"},
"Text Indexer String Keys"
)
EndFunction
Function Test_TextIndexerRead()
s = "abc"
Return Unittest.AssertTrue({
s[0] = "",
s[1] = "a",
s[2] = "b",
s[3] = "c",
s[0] = "",
s[4] = ""
}, "Text Indexer Read")
EndFunction
Function Test_TextIndexerWrite()
s = "abc"
s[1] = "X"
s[2] = "Y"
s[3] = "Z"
x = "abc"
x[-1] = "Q"
y = "abc"
y[0] = "Q"
z = "abc"
z[5] = "W"
Return Unittest.AssertEqual(
{s, x, y, z},
{"XYZ", "Q abc", "Qabc", "abc W"},
"Text Indexer Write")
EndFunction
Function Test_TextNumericIndexer()
s = 123
s[2] = 9
x = 123
x["test"] = 9
Return Unittest.AssertTrue({
s = "193",
s[1] = 1,
s[4] = "",
x[1] = "",
x["test"] = 9
}, "Numeric Indexer"
)
EndFunction
Function Test_IndexerEmptyString()
s = ""
s[1] = "A"
s[3] = "B"
Return Unittest.AssertEqual(
{s[1], s[2], s[3]},
{"A", "", "B"},
"Indexer for Empty String"
)
EndFunction