3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testStrConv()
9 If failCount
<> 0 And passCount
> 0 Then
16 Function verify_testStrConv() as String
20 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
22 Dim testName
As String
23 Dim srcStr
, retStr
As String
25 srcStr
= "abc EFG hij"
26 testName
= "Test StrConv function"
27 On Error GoTo errorHandler
29 retStr
= StrConv(srcStr
, vbUpperCase
)
31 TestLog_ASSERT retStr
= "ABC EFG HIJ", "Converts the string to uppercase characters:" & retStr
33 retStr
= StrConv(srcStr
, vbLowerCase
)
35 TestLog_ASSERT retStr
= "abc efg hij", "Converts the string to lowercase characters:" & retStr
37 retStr
= StrConv(srcStr
, vbProperCase
)
39 TestLog_ASSERT retStr
= "Abc Efg Hij", "Converts the first letter of every word in string to uppercase:" & retStr
41 'retStr = StrConv("ABCDEVB¥ì¥¹¥¥å©`", vbWide)
43 'TestLog_ASSERT retStr = "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", "Converts narrow (single-byte) characters in string to wide"
45 'retStr = StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥¥å©`", vbNarrow)
47 'TestLog_ASSERT retStr = "ABCDEVB¥ì¥¹¥¥å©`", "Converts wide (double-byte) characters in string to narrow (single-byte) characters." & retStr
49 'retStr = StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana)
51 'TestLog_ASSERT retStr = "¥Ï¥Ê¥Á¥ã¥ó", "Converts Hiragana characters in string to Katakana characters.." & retStr
53 ' retStr = StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana)
55 ' TestLog_ASSERT retStr = "¤Ï¤Ê¤Á¤ã¤ó", "Converts Katakana characters in string to Hiragana characters.." & retStr
57 'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
59 'TestLog_ASSERT UBound(x) = 8, "Converts the string from Unicode, the lenght is : " & UBound(x) + 1
61 ' retStr = StrConv(x, vbUnicode)
63 ' TestLog_ASSERT retStr = "ÉϺ£ÊÐABC", "Converts the string to Unicode: " & retStr
65 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
66 verify_testStrConv
= result
70 TestLog_ASSERT (False), testName
& ": hit error handler"
73 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
75 If assertion
= True Then
76 passCount
= passCount
+ 1
79 If Not IsMissing(testId
) Then
80 testMsg
= testMsg
+ " : " + testId
82 If Not IsMissing(testComment
) And Not (testComment
= "") Then
83 testMsg
= testMsg
+ " (" + testComment
+ ")"
86 result
= result
& Chr
$(10) & " Failed: " & testMsg
87 failCount
= failCount
+ 1