1# coding=utf8
2"""
3Test that C++ supports char8_t correctly.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10import lldbsuite.test.lldbutil as lldbutil
11
12
13class CxxChar8_tTestCase(TestBase):
14
15    @skipIf(compiler="clang", compiler_version=['<', '7.0'])
16    @expectedFailureDarwin(archs=["arm64", "arm64e"]) # <rdar://problem/37773624>
17    def test_without_process(self):
18        """Test that C++ supports char8_t without a running process."""
19        self.build()
20        lldbutil.run_to_breakpoint_make_target(self)
21
22        self.expect("target variable a", substrs=["char8_t", "0x61 u8'a'"])
23        self.expect("target variable ab",
24                substrs=["const char8_t *", 'u8"你好"'])
25        self.expect("target variable abc", substrs=["char8_t[9]", 'u8"你好"'])
26
27        self.expect_expr("a", result_type="char8_t", result_summary="0x61 u8'a'")
28        self.expect_expr("ab", result_type="const char8_t *", result_summary='u8"你好"')
29
30        # FIXME: This should work too.
31        self.expect("expr abc", substrs=['u8"你好"'], matching=False)
32
33
34    @skipIf(compiler="clang", compiler_version=['<', '7.0'])
35    def test_with_process(self):
36        """Test that C++ supports char8_t with a running process."""
37        self.build()
38        lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp"))
39
40        # As well as with it
41        self.expect_expr("a", result_type="char8_t", result_summary="0x61 u8'a'")
42        self.expect_expr("ab", result_type="const char8_t *", result_summary='u8"你好"')
43        self.expect_expr("abc", result_type="char8_t[9]", result_summary='u8"你好"')
44