2 Tests std::stack functionality.
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
9 class TestStack(TestBase):
11 mydir = TestBase.compute_mydir(__file__)
13 @add_test_categories(["libc++"])
14 @skipIf(compiler=no_match("clang"))
18 lldbutil.run_to_source_breakpoint(self,
19 "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
21 self.runCmd("settings set target.import-std-module true")
23 # Test std::stack functionality with a std::deque.
24 self.expect("expr s_deque.pop()")
25 self.expect("expr s_deque.push({4})")
26 self.expect("expr (size_t)s_deque.size()", substrs=['(size_t) $0 = 3'])
27 self.expect("expr (int)s_deque.top().i", substrs=['(int) $1 = 4'])
28 self.expect("expr s_deque.emplace(5)")
29 self.expect("expr (int)s_deque.top().i", substrs=['(int) $2 = 5'])
31 # Test std::stack functionality with a std::vector.
32 self.expect("expr s_vector.pop()")
33 self.expect("expr s_vector.push({4})")
34 self.expect("expr (size_t)s_vector.size()", substrs=['(size_t) $3 = 3'])
35 self.expect("expr (int)s_vector.top().i", substrs=['(int) $4 = 4'])
36 self.expect("expr s_vector.emplace(5)")
37 self.expect("expr (int)s_vector.top().i", substrs=['(int) $5 = 5'])
39 # Test std::stack functionality with a std::list.
40 self.expect("expr s_list.pop()")
41 self.expect("expr s_list.push({4})")
42 self.expect("expr (size_t)s_list.size()", substrs=['(size_t) $6 = 3'])
43 self.expect("expr (int)s_list.top().i", substrs=['(int) $7 = 4'])
44 self.expect("expr s_list.emplace(5)")
45 self.expect("expr (int)s_list.top().i", substrs=['(int) $8 = 5'])