source: trunk/TestCase/SimpleTestCase/StringTest.ab@ 373

Last change on this file since 373 was 272, checked in by イグトランス (egtra), 17 years ago

StringBuilderを追加。String不変へ。共通の文字列操作関数をActiveBasic.Strings内に配置(設計に検討の余地あり)。

File size: 2.0 KB
Line 
1'--------------------------------------------------------------------
2' Test case of String Class
3'--------------------------------------------------------------------
4
5Namespace StringTest
6
7Sub TestMain()
8 Dim s1 = Nothing As String
9
10
11 s1 = New String("hello")
12
13 UnitTest("String.GetType", s1.GetType().Name = "String")
14
15
16 UnitTest("String.String (case 0)", (memcmp(s1.StrPtr, "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
64End Sub
65
66End Namespace
67
68StringTest.TestMain()
Note: See TracBrowser for help on using the repository browser.