File: TestChar1632T.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (120 lines) | stat: -rw-r--r-- 3,843 bytes parent folder | download | duplicates (7)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# coding=utf8
"""
Test that the C++11 support for char16_t and char32_t works correctly.
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class Char1632TestCase(TestBase):
    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)
        # Find the line number to break for main.cpp.
        self.source = "main.cpp"
        self.lines = [
            line_number(self.source, "// breakpoint1"),
            line_number(self.source, "// breakpoint2"),
        ]

    @expectedFailureAll(
        compiler="icc",
        bugnumber="ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.",
    )
    def test(self):
        """Test that the C++11 support for char16_t and char32_t works correctly."""
        self.build()
        exe = self.getBuildArtifact("a.out")

        # Create a target by the debugger.
        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)

        # Set breakpoints
        for line in self.lines:
            lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line)

        # Now launch the process, and do not stop at entry point and stop at
        # breakpoint1
        process = target.LaunchSimple(None, None, self.get_process_working_directory())

        if not process:
            self.fail("SBTarget.Launch() failed")

        if self.TraceOn():
            self.runCmd("frame variable")

        # Check that we correctly report the const types
        self.expect(
            "frame variable cs16 cs32",
            substrs=[
                "(const char16_t *) cs16 = ",
                'u"hello world ྒྙྐ"',
                "(const char32_t *) cs32 = ",
                'U"hello world ྒྙྐ"',
            ],
        )

        # Check that we correctly report the non-const types
        self.expect(
            "frame variable s16 s32",
            substrs=[
                "(char16_t *) s16 = ",
                'u"ﺸﺵۻ"',
                "(char32_t *) s32 = ",
                'U"ЕЙРГЖО"',
            ],
        )

        # Check that we correctly report the array types
        self.expect(
            "frame variable as16 as32",
            patterns=[
                "\(char16_t\[[0-9]+\]\) as16 = ",
                "\(char32_t\[[0-9]+\]\) as32 = ",
            ],
            substrs=['u"ﺸﺵۻ"', 'U"ЕЙРГЖО"'],
        )

        self.runCmd("next")  # step to after the string is nullified

        # check that we don't crash on NULL
        self.expect("frame variable s32", substrs=["(char32_t *) s32 = 0x00000000"])

        # continue and hit breakpoint2
        self.runCmd("continue")

        # check that the new strings show
        self.expect(
            "frame variable s16 s32",
            substrs=[
                "(char16_t *) s16 = 0x",
                '"色ハ匂ヘト散リヌルヲ"',
                "(char32_t *) s32 = ",
                '"෴"',
            ],
        )

        # check the same as above for arrays
        self.expect(
            "frame variable as16 as32",
            patterns=[
                "\(char16_t\[[0-9]+\]\) as16 = ",
                "\(char32_t\[[0-9]+\]\) as32 = ",
            ],
            substrs=['"色ハ匂ヘト散リヌルヲ"', '"෴"'],
        )

        # check that zero values are properly handles
        self.expect_expr("cs16_zero", result_summary="U+0000 u'\\0'")
        self.expect_expr("cs32_zero", result_summary="U+0x00000000 U'\\0'")

        # Check that we can run expressions that return charN_t
        self.expect_expr("u'a'", result_type="char16_t", result_summary="U+0061 u'a'")
        self.expect_expr(
            "U'a'", result_type="char32_t", result_summary="U+0x00000061 U'a'"
        )