xref: /llvm-project/lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1# coding=utf8
2"""
3Test that the expression parser returns proper Unicode strings.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12# this test case fails because of rdar://12991846
13# the expression parser does not deal correctly with Unicode expressions
14# e.g.
15# (lldb) expr L"Hello"
16# (const wchar_t [6]) $0 = {
17#  [0] = \0\0\0\0
18#  [1] = \0\0\0\0
19#  [2] = \0\0\0\0
20#  [3] = \0\0\0\0
21#  [4] = H\0\0\0
22#  [5] = e\0\0\0
23# }
24
25
26class UnicodeLiteralsTestCase(TestBase):
27    def test_expr1(self):
28        """Test that the expression parser returns proper Unicode strings."""
29        self.rdar12991846(expr=1)
30
31    def test_expr2(self):
32        """Test that the expression parser returns proper Unicode strings."""
33        self.rdar12991846(expr=2)
34
35    def test_expr3(self):
36        """Test that the expression parser returns proper Unicode strings."""
37        self.rdar12991846(expr=3)
38
39    def rdar12991846(self, expr=None):
40        """Test that the expression parser returns proper Unicode strings."""
41        if self.getArchitecture() in ["i386"]:
42            self.skipTest("Skipping because this test is known to crash on i386")
43
44        self.build()
45        lldbutil.run_to_source_breakpoint(
46            self, "// Set break point at this line", lldb.SBFileSpec("main.cpp")
47        )
48
49        if expr == 1:
50            self.expect('expression L"hello"', substrs=["hello"])
51
52        if expr == 2:
53            self.expect('expression u"hello"', substrs=["hello"])
54
55        if expr == 3:
56            self.expect('expression U"hello"', substrs=["hello"])
57