2 Test some expressions involving STL data types.
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
import lldbutil
12 class STLTestCase(TestBase
):
13 @expectedFailureAll(bugnumber
="llvm.org/PR36713")
15 """Test some expressions involving STL data types."""
17 lldbutil
.run_to_source_breakpoint(
18 self
, "// Set break point at this line", lldb
.SBFileSpec("main.cpp")
21 # Now try some expressions....
24 'expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }'
27 self
.expect("expr associative_array.size()", substrs
=[" = 3"])
28 self
.expect("expr associative_array.count(hello_world)", substrs
=[" = 1"])
29 self
.expect("expr associative_array[hello_world]", substrs
=[" = 1"])
30 self
.expect('expr associative_array["hello"]', substrs
=[" = 2"])
34 bugnumber
="ICC (13.1, 14-beta) do not emit DW_TAG_template_type_parameter.",
36 @add_test_categories(["pyapi"])
37 def test_SBType_template_aspects(self
):
38 """Test APIs for getting template arguments from an SBType."""
40 (_
, _
, thread
, _
) = lldbutil
.run_to_source_breakpoint(
41 self
, "// Set break point at this line", lldb
.SBFileSpec("main.cpp")
43 frame0
= thread
.GetFrameAtIndex(0)
45 # Get the type for variable 'associative_array'.
46 associative_array
= frame0
.FindVariable("associative_array")
47 self
.DebugSBValue(associative_array
)
48 self
.assertTrue(associative_array
, VALID_VARIABLE
)
49 map_type
= associative_array
.GetType()
50 self
.DebugSBType(map_type
)
51 self
.assertTrue(map_type
, VALID_TYPE
)
52 num_template_args
= map_type
.GetNumberOfTemplateArguments()
53 self
.assertGreater(num_template_args
, 0)
55 # We expect the template arguments to contain at least 'string' and
57 expected_types
= {"string": False, "int": False}
58 for i
in range(num_template_args
):
59 t
= map_type
.GetTemplateArgumentType(i
)
61 self
.assertTrue(t
, VALID_TYPE
)
64 expected_types
["string"] = True
66 expected_types
["int"] = True
68 # Check that both entries of the dictionary have 'True' as the value.
69 self
.assertTrue(all(expected_types
.values()))