Skip to content

Commit 1f01a8d

Browse files
committed
fixup! move test for invalid invariant index into separate test
1 parent 520c1f6 commit 1f01a8d

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CXX_SOURCES := main.cpp
2+
CXXFLAGS_EXTRAS := -std=c++17
3+
USE_LIBSTDCPP := 1
4+
5+
include Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
from lldbsuite.test.lldbtest import *
4+
from lldbsuite.test import lldbutil
5+
6+
7+
class InvalidStdVariantDataFormatterTestCase(TestBase):
8+
@add_test_categories(["libstdcxx"])
9+
def do_test(self):
10+
"""Test STL data formatters for std::variant with invalid index."""
11+
12+
(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
13+
self, "// break here", lldb.SBFileSpec("main.cpp", False)
14+
)
15+
16+
self.expect(
17+
"frame variable v1",
18+
substrs=["v1 = Active Type = char {", "Value = 'x'", "}"],
19+
)
20+
21+
var_v1 = thread.frames[0].FindVariable("v1")
22+
var_v1_raw_obj = var_v1.GetNonSyntheticValue()
23+
index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
24+
self.assertTrue(index_obj and index_obj.IsValid())
25+
26+
INVALID_INDEX = "100"
27+
index_obj.SetValueFromCString(INVALID_INDEX)
28+
29+
self.expect("frame variable v1", substrs=["v1 = <Invalid>"])
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <cstdio>
2+
#include <variant>
3+
4+
int main() {
5+
std::variant<int, double, char> v1;
6+
v1 = 'x';
7+
8+
std::puts("// break here");
9+
10+
return 0;
11+
}

0 commit comments

Comments
 (0)