xref: /llvm-project/lldb/test/API/commands/expression/char/TestExprsChar.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6
7class ExprCharTestCase(TestBase):
8    def do_test(self, dictionary=None):
9        """These basic expression commands should work as expected."""
10        self.build(dictionary=dictionary)
11
12        lldbutil.run_to_source_breakpoint(
13            self, "// Break here", lldb.SBFileSpec("main.cpp")
14        )
15
16        self.expect_expr("foo(c)", result_value="1")
17        self.expect_expr("foo(sc)", result_value="2")
18        self.expect_expr("foo(uc)", result_value="3")
19        self.expect_expr("g", result_type="char")
20        self.expect_expr("gs", result_type="signed char")
21        self.expect_expr("gu", result_type="unsigned char")
22
23    def test_default_char(self):
24        self.do_test()
25
26    def test_signed_char(self):
27        self.do_test(dictionary={"CFLAGS_EXTRAS": "-fsigned-char"})
28
29    def test_unsigned_char(self):
30        self.do_test(dictionary={"CFLAGS_EXTRAS": "-funsigned-char"})
31