[Lldb-commits] [lldb] [lldb][test] Add a new test for char types (PR #208442)
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 9 05:08:43 PDT 2026
https://github.com/Teemperor created https://github.com/llvm/llvm-project/pull/208442
This is a new modern test for integer types that replaces the test logic from `API/types` test that is about to be deleted.
See also #208402
>From 4b00b54a85ca7be58e532d702912dee58424d075 Mon Sep 17 00:00:00 2001
From: Raphael Isemann <rise at apple.com>
Date: Thu, 9 Jul 2026 13:08:13 +0100
Subject: [PATCH] [lldb][test] Add a new test for char types
This is a new modern test for integer types that replaces the test
logic from `API/types` test that is about to be deleted.
See also #208402
---
.../API/lang/cpp/builtin_types/char/Makefile | 3 ++
.../cpp/builtin_types/char/TestCharTypes.py | 33 +++++++++++++++++++
.../API/lang/cpp/builtin_types/char/main.cpp | 19 +++++++++++
3 files changed, 55 insertions(+)
create mode 100644 lldb/test/API/lang/cpp/builtin_types/char/Makefile
create mode 100644 lldb/test/API/lang/cpp/builtin_types/char/TestCharTypes.py
create mode 100644 lldb/test/API/lang/cpp/builtin_types/char/main.cpp
diff --git a/lldb/test/API/lang/cpp/builtin_types/char/Makefile b/lldb/test/API/lang/cpp/builtin_types/char/Makefile
new file mode 100644
index 0000000000000..99998b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/builtin_types/char/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/builtin_types/char/TestCharTypes.py b/lldb/test/API/lang/cpp/builtin_types/char/TestCharTypes.py
new file mode 100644
index 0000000000000..d2c87df456b4e
--- /dev/null
+++ b/lldb/test/API/lang/cpp/builtin_types/char/TestCharTypes.py
@@ -0,0 +1,33 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+ def test(self):
+ self.build_and_run()
+
+ self.expect_var_path("the_char", type="char", value="'a'")
+ self.expect_expr("the_char", result_type="char", result_value="'a'")
+
+ self.expect_var_path("the_signed_char", type="signed char", value="'B'")
+ self.expect_expr(
+ "the_signed_char", result_type="signed char", result_value="'B'"
+ )
+
+ self.expect_var_path("the_unsigned_char", type="unsigned char", value="'Z'")
+ self.expect_expr(
+ "the_unsigned_char", result_type="unsigned char", result_value="'Z'"
+ )
+
+ # Check edge-case values: smallest, largest, zero and -1.
+ self.expect_var_path("char_zero", type="char", value="'\\0'")
+ self.expect_var_path("char_neg_one", type="char", value="'\\xff'")
+ self.expect_var_path("char_high_bit", type="char", value="'\\x80'")
+ self.expect_var_path("char_low_max", type="char", value="'\\x7f'")
+ self.expect_var_path("schar_neg_one", type="signed char", value="'\\xff'")
+ self.expect_var_path("schar_min", type="signed char", value="'\\x80'")
+ self.expect_var_path("schar_max", type="signed char", value="'\\x7f'")
+ self.expect_var_path("uchar_zero", type="unsigned char", value="'\\0'")
+ self.expect_var_path("uchar_max", type="unsigned char", value="'\\xff'")
\ No newline at end of file
diff --git a/lldb/test/API/lang/cpp/builtin_types/char/main.cpp b/lldb/test/API/lang/cpp/builtin_types/char/main.cpp
new file mode 100644
index 0000000000000..a24bbaac3b691
--- /dev/null
+++ b/lldb/test/API/lang/cpp/builtin_types/char/main.cpp
@@ -0,0 +1,19 @@
+int main() {
+ char the_char = 'a';
+ signed char the_signed_char = 'B';
+ unsigned char the_unsigned_char = 'Z';
+
+ // Edge-cases.
+ char char_zero = 0;
+ char char_neg_one = -1;
+ char char_high_bit = (char)0x80;
+ char char_low_max = (char)0x7f;
+
+ signed char schar_neg_one = -1;
+ signed char schar_min = -128;
+ signed char schar_max = 127;
+ unsigned char uchar_zero = 0;
+ unsigned char uchar_max = 255;
+
+ return 0; // break here
+}
More information about the lldb-commits
mailing list