source: TestCase/SimpleTestCase/ActiveBasic.StringsTest.ab@ 298

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

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

File size: 1.9 KB
Line 
1#require <Classes/ActiveBasic/Strings/Strings.ab>
2
3'--------------------------------------------------------------------
4' Test case of AcitveBasic.Strings Namespace
5'--------------------------------------------------------------------
6
7Imports ActiveBasic.Strings
8
9Namespace ActiveBasic_StringsTest
10
11Sub TestMain()
12 Dim w[3] = [3, 2, 1, 0] As WCHAR
13 Dim m[3] = [3, 2, 1, 0] As CHAR
14 Dim tw[1] = [2, 1] As WCHAR
15 Dim tm[1] = [1, 0] As CHAR
16
17
18 UnitTest("ChrCmp WC =", ChrCmp(VarPtr(w[1]), tw, 2 As SIZE_T) = 0)
19 UnitTest("ChrCmp MB =", ChrCmp(VarPtr(m[2]), tm, 2 As SIZE_T) = 0)
20 UnitTest("ChrCmp WC >", ChrCmp(VarPtr(w[0]), tw, 2 As SIZE_T) > 0)
21 UnitTest("ChrCmp MB >", ChrCmp(VarPtr(m[0]), tm, 2 As SIZE_T) > 0)
22 UnitTest("ChrCmp WC <", ChrCmp(VarPtr(w[2]), tw, 2 As SIZE_T) < 0)
23 UnitTest("ChrCmp MB <", ChrCmp(VarPtr(m[3]), tm, 1 As SIZE_T) < 0)
24
25 Dim w2[3] As WCHAR
26 Dim m2[3] As CHAR
27 ChrCopy(w2, w, 4 As SIZE_T)
28 ChrCopy(m2, m, 4 As SIZE_T)
29 UnitTest("ChrCopy WC", ChrCmp(w, w2, 4 As SIZE_T) = 0)
30 UnitTest("ChrCopy MB", ChrCmp(m, m2, 4 As SIZE_T) = 0)
31
32 Dim wf[3] = [10, 10, 10, 10] As WCHAR
33 Dim mf[3] = [77, 77, 77, 77] As CHAR
34 ChrFill(w2, 4 As SIZE_T, 10 As WCHAR)
35 ChrFill(m2, 4 As SIZE_T, 77 As CHAR)
36 UnitTest("ChrFill WC", ChrCmp(w2, wf, 4 As SIZE_T) = 0)
37 UnitTest("ChrFill MB", ChrCmp(m2, mf, 4 As SIZE_T) = 0)
38
39 UnitTest("ChrFind WC c", ChrFind(w, 4, 1 As WCHAR) = 2)
40 UnitTest("ChrFind MB c", ChrFind(m, 4, 2 As CHAR) = 1)
41 UnitTest("ChrFind WC s", ChrFind(w, 4 As SIZE_T, tw, 2 As SIZE_T) = 1)
42 UnitTest("ChrFind MB s", ChrFind(m, 4 As SIZE_T, tm, 2 As SIZE_T) = 2)
43 UnitTest("ChrPBrk WC", ChrPBrk(ToWCStr("a1b2c3"), 6 As SIZE_T, ToWCStr("123"), 3 As SIZE_T) = 1)
44 UnitTest("ChrPBrk MB", ChrPBrk(ToMBStr("a1b2c3"), 6 As SIZE_T, ToMBStr("abc"), 3 As SIZE_T) = 0)
45End Sub
46
47End Namespace 'ActiveBasic_StringsTest
48
49ActiveBasic_StringsTest.TestMain()
Note: See TracBrowser for help on using the repository browser.