summaryrefslogtreecommitdiff
path: root/basic/qa/vba_tests/strconv.vb
blob: 0a9e5628a96691d1713932328d169310c956514a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Option VBASupport 1
Option Explicit

Function doUnitTest() As String
verify_testStrConv
doUnitTest = TestUtilModule.GetResult()
End Function

Sub verify_testStrConv()

    TestUtilModule.TestInit

    Dim testName As String
    Dim srcStr, retStr As String
    Dim x() As Byte
    srcStr = "abc EFG hij"
    testName = "Test StrConv function"
    On Error GoTo errorHandler

    retStr = StrConv(srcStr, vbUpperCase)
    'MsgBox retStr
    TestUtilModule.AssertTrue(retStr = "ABC EFG HIJ", "Converts the string to uppercase characters:" & retStr)

    retStr = StrConv(srcStr, vbLowerCase)
    'MsgBox retStr
    TestUtilModule.AssertTrue(retStr = "abc efg hij", "Converts the string to lowercase characters:" & retStr)

    retStr = StrConv(srcStr, vbProperCase)
    'MsgBox retStr
    TestUtilModule.AssertTrue(retStr = "Abc Efg Hij", "Converts the first letter of every word in string to uppercase:" & retStr)

    'retStr = StrConv("ABCDEVB¥ì¥¹¥­¥å©`", vbWide)
    'MsgBox retStr
    'TestUtilModule.AssertTrue(retStr = "£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", "Converts narrow (single-byte) characters in string to wide")

    'retStr = StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", vbNarrow)
    'MsgBox retStr
    'TestUtilModule.AssertTrue(retStr = "ABCDEVB¥ì¥¹¥­¥å©`", "Converts wide (double-byte) characters in string to narrow (single-byte) characters." & retStr)

    'retStr = StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana)
    'MsgBox retStr
    'TestUtilModule.AssertTrue(retStr = "¥Ï¥Ê¥Á¥ã¥ó", "Converts Hiragana characters in string to Katakana characters.." & retStr)

   ' retStr = StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana)
    'MsgBox retStr
   ' TestUtilModule.AssertTrue(retStr = "¤Ï¤Ê¤Á¤ã¤ó", "Converts Katakana characters in string to Hiragana characters.." & retStr)

    'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
    'MsgBox retStr
    'TestUtilModule.AssertTrue(UBound(x) = 8, "Converts the string from Unicode, the length is : " & UBound(x) + 1)

   ' retStr = StrConv(x, vbUnicode)
    'MsgBox retStr
   ' TestUtilModule.AssertTrue(retStr = "ÉϺ£ÊÐABC", "Converts the string to Unicode: " & retStr)

    TestUtilModule.TestEnd

    Exit Sub
errorHandler:
        TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub