xref: /llvm-project/lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1# coding=utf8
2"""
3Test that C++ supports wchar_t correctly.
4"""
5
6
7import lldb
8from lldbsuite.test.lldbtest import *
9import lldbsuite.test.lldbutil as lldbutil
10
11
12class CxxWCharTTestCase(TestBase):
13    def test(self):
14        """Test that C++ supports wchar_t correctly."""
15        self.build()
16        lldbutil.run_to_source_breakpoint(
17            self, "// break here", lldb.SBFileSpec("main.cpp")
18        )
19
20        # Check that we correctly report templates on wchar_t
21        self.expect_var_path("foo_y", type="Foo<wchar_t>")
22
23        # Check that we correctly report templates on int
24        self.expect_var_path("foo_x", type="Foo<int>")
25
26        # Check that we correctly report wchar_t
27        self.expect_var_path("foo_y.object", type="wchar_t")
28
29        # Check that we correctly report int
30        self.expect_var_path("foo_x.object", type="int")
31
32        # Check that we can run expressions that return wchar_t
33        self.expect("expression L'a'", substrs=["(wchar_t) $", "L'a'"])
34
35        # Mazel Tov if this works!
36        self.expect(
37            "frame variable mazeltov",
38            substrs=["(const wchar_t *) mazeltov = ", 'L"מזל טוב"'],
39        )
40
41        self.expect("frame variable ws_NULL", substrs=["(wchar_t *) ws_NULL = 0x0"])
42        self.expect("frame variable ws_empty", substrs=[' L""'])
43
44        self.expect(
45            "frame variable array", substrs=["L\"Hey, I'm a super wchar_t string"]
46        )
47        self.expect("frame variable array", substrs=["[0]"], matching=False)
48
49        self.expect("frame variable wchar_zero", substrs=["L'\\0'"])
50        self.expect("expression wchar_zero", substrs=["L'\\0'"])
51