1 | '--------------------------------------------------------------------
|
---|
2 | ' Test case of SPrintF Function and etc...
|
---|
3 | '--------------------------------------------------------------------
|
---|
4 |
|
---|
5 | #require <Classes/ActiveBasic/Strings/SPrintF.ab>
|
---|
6 |
|
---|
7 | Imports ActiveBasic.Strings
|
---|
8 | Imports ActiveBasic.Strings.Detail
|
---|
9 |
|
---|
10 | Namespace SPrintFTest
|
---|
11 |
|
---|
12 | Sub TestMain()
|
---|
13 | Dim s = Nothing As String, e As Long, sign As Boolean
|
---|
14 |
|
---|
15 | s = FloatToChars(1., e, sign)
|
---|
16 | UnitTest("FloatToChars(1)", s = "10000000000000000" And e = 0 And sign = False)
|
---|
17 |
|
---|
18 | s = FloatToChars(-93.75e-3, e, sign)
|
---|
19 | UnitTest("FloatToChars(-93.75e-3)", s = "93750000000000000" And e = 1 - 3 And sign = True)
|
---|
20 |
|
---|
21 | s = FloatToChars(.0, e, sign)
|
---|
22 | UnitTest("FloatToChars(0)", s = "00000000000000000" And e = 0 And sign = False)
|
---|
23 |
|
---|
24 | s = FormatFloatE(9.876543e021, 6, 0, None)
|
---|
25 | UnitTest("FormatFloatE(9876543e+21)", s = "9.876543e+21")
|
---|
26 |
|
---|
27 | s = FormatFloatE(7.81250000E-03, 8, 0, Cap)
|
---|
28 | UnitTest("FormatFloatE(7.81250000E-03)", s = "7.81250000E-03")
|
---|
29 |
|
---|
30 | s = FormatFloatE(1.2345e67, 4, 15, 0)
|
---|
31 | UnitTest("FormatFloatE(1.2345e+67, field width = 15)", s = " 1.2345e+67")
|
---|
32 | s = FormatFloatE(1.2345e67, 4, 15, Zero)
|
---|
33 | UnitTest("FormatFloatE(1.2345e+67, field width = 15, Zero)", s = "000001.2345e+67")
|
---|
34 | s = FormatFloatE(-1.2345e67, 4, 15, 0)
|
---|
35 | UnitTest("FormatFloatE(-1.2345e+67, field width = 15)", s = " -1.2345e+67")
|
---|
36 | s = FormatFloatE(-1.2345e67, 4, 15, Zero)
|
---|
37 | UnitTest("FormatFloatE(-1.2345e+67, field width = 15, Zero)", s = "-00001.2345e+67")
|
---|
38 | s = FormatFloatE(1.2345e67, 4, 15, Sign)
|
---|
39 | UnitTest("FormatFloatE(1.2345e+67, field width = 15, Sign)", s = " +1.2345e+67")
|
---|
40 | s = FormatFloatE(1.2345e67, 4, 15, Zero Or Sign)
|
---|
41 | UnitTest("FormatFloatE(1.2345e+67, field width = 15, Zero Or Sign)", s = "+00001.2345e+67")
|
---|
42 | s = FormatFloatE(1.2345e67, 4, 15, Zero Or Blank)
|
---|
43 | UnitTest("FormatFloatE(1.2345e+67, field width = 15, Zero Or Blank)", s = " 00001.2345e+67")
|
---|
44 | s = FormatFloatE(-1.2345e67, 4, 15, Zero Or Sign)
|
---|
45 | UnitTest("FormatFloatE(-1.2345e+67, field width = 15, Zero Or Sign)", s = "-00001.2345e+67")
|
---|
46 | s = FormatFloatE(-1.2345e67, 4, 15, Zero Or Blank)
|
---|
47 | UnitTest("FormatFloatE(-1.2345e+67, field width = 15, Zero Or Blank)", s = "-00001.2345e+67")
|
---|
48 |
|
---|
49 | s = FormatFloatE(1.2345e+67, 4, 0, Cap)
|
---|
50 | UnitTest("FormatFloatE(1.2345E+67, Cap)", s = "1.2345E+67")
|
---|
51 |
|
---|
52 | s = FormatFloatE(1.2345e67, 3, 0, None)
|
---|
53 | UnitTest("FormatFloatE(1.2345e+67, precision = 3)", s = "1.234e+67")
|
---|
54 |
|
---|
55 |
|
---|
56 | s = FormatIntegerU(777, 0, 0, None)
|
---|
57 | UnitTest("FormatIntegerU(777)", s = "777")
|
---|
58 |
|
---|
59 | s = FormatIntegerU(513, 0, 5, None)
|
---|
60 | UnitTest("FormatIntegerU(513, field width = 5)", s = " 513")
|
---|
61 |
|
---|
62 | s = FormatIntegerD(-3, 2, 0, Sign)
|
---|
63 | UnitTest("FormatIntegerD(-3, precision = 2)", s = "-03")
|
---|
64 |
|
---|
65 | s = FormatIntegerD(3, 0, 5, Sign)
|
---|
66 | UnitTest("FormatIntegerD(+3, field width = 5)", s = " +3")
|
---|
67 |
|
---|
68 | ' s = FormatIntegerLU(8589934590, DWORD_MAX, 0, None)
|
---|
69 | ' UnitTest("FormatIntegerLU(8589934590)", s = "8589934590")
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 | End Sub
|
---|
74 |
|
---|
75 | End Namespace 'SPrintFTest
|
---|
76 |
|
---|
77 | SPrintFTest.TestMain()
|
---|