source: TestCase/SimpleTestCase/StringTest.ab@ 227

Last change on this file since 227 was 227, checked in by dai, 18 years ago

文字列の比較演算子の戻り値がLong型になっていたので、Booleanに修正した。
String.GetTypeのテストケースを修正。

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