source: TestCase/SimpleTestCase/StringTest.ab@ 235

Last change on this file since 235 was 230, checked in by イグトランス (egtra), 18 years ago

GCHandleTestの追加、全てのテスト処理を関数に入れる

File size: 2.0 KB
RevLine 
[226]1'--------------------------------------------------------------------
2' Test case of String Class
3'--------------------------------------------------------------------
4
5Namespace StringTest
6
[230]7Sub TestMain()
[226]8 Dim s1 = Nothing As String
9
10
11 s1 = New String("hello")
12
[227]13 UnitTest("String.GetType", s1.GetType().Name = "String")
[226]14
15
16 UnitTest("String.String (case 0)", (memcmp(s1.Chars, "hello", SizeOf (StrChar) * 6) = 0))
17
18 UnitTest("String.String (case 1)", (s1 = "hello"))
19
20 Dim nsz[2] = [&h31, &h32, &h33] As SByte
21 s1 = New String(nsz, 3)
22 UnitTest("String.String (case 2)", (s1 = "123"))
23
24 Dim wsz[4] = [&h31, &h32, &h33, &h34, &h35] As WCHAR
25 s1 = New String(wsz, 5)
26 UnitTest("String.String (case 3)", (s1 = "12345"))
27
28 s1 = New String(&h30 As StrChar, 4)
29 UnitTest("String.String (case 4)", (s1 = "0000"))
30
31 s1 = "literal"
32 UnitTest("String.String (case 5)", (s1 = "literal"))
33
34 UnitTest("String.Length", (s1.Length = 7))
35
36 UnitTest("String.ToString", (s1.ToString() = "literal"))
37 UnitTest("String.Clone", (s1.Clone() = "literal"))
38
39 UnitTest("String.Operator []", (s1[7] = 0))
40
41 s1 = New String("abc")
42
43 UnitTest("String.IsNullOrEmpty (case 1)", (String.IsNullOrEmpty(Nothing) = True))
44 UnitTest("String.IsNullOrEmpty (case 2)", (String.IsNullOrEmpty("") = True))
45 UnitTest("String.IsNullOrEmpty (case 3)", (String.IsNullOrEmpty(s1) = False))
46
47 UnitTest("String.Compare (case 1)", (String.Compare("ABC", "ABC") = 0))
48 UnitTest("String.Compare (case 2)", (String.Compare("ABD", "ABC") > 0))
49 UnitTest("String.Compare (case 3)", (String.Compare("ABC", "ABCD") < 0))
50
51 Dim o1 = New Object
52 Dim o2 = s1 As Object
53 UnitTest("String.Concat", (String.Concat(o1, o2) = "Objectabc"))
54
55 UnitTest("String.Operator +", ((s1 + "def") = "abcdef"))
56 UnitTest("String.Operator &", ((s1 + "xyz") = "abcxyz"))
57
58 s1 = "へのへの"
59 UnitTest("String.Contains (case 1)", (s1.Contains("のへ") = True))
60 UnitTest("String.Contains (case 2)", (s1.Contains("もへ") = False))
61
62 ' まだまだ追加求む
63
[230]64End Sub
65
[226]66End Namespace
[230]67
68StringTest.TestMain()
Note: See TracBrowser for help on using the repository browser.