1""" 2Tests std::queue functionality. 3""" 4 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9 10class TestQueue(TestBase): 11 12 @add_test_categories(["libc++"]) 13 @skipIf(compiler=no_match("clang")) 14 def test(self): 15 self.build() 16 17 lldbutil.run_to_source_breakpoint(self, 18 "// Set break point at this line.", 19 lldb.SBFileSpec("main.cpp")) 20 21 self.runCmd("settings set target.import-std-module true") 22 23 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']): 24 queue_type = "std::queue<C>" 25 else: 26 queue_type = "std::queue<C, std::deque<C, std::allocator<C> > >" 27 28 size_type = "size_type" 29 value_type = "value_type" 30 31 # Test std::queue functionality with a std::deque. 32 self.expect_expr( 33 "q_deque", 34 result_type=queue_type, 35 result_children=[ValueCheck(children=[ValueCheck(value="1")])]) 36 self.expect("expr q_deque.pop()") 37 self.expect("expr q_deque.push({4})") 38 self.expect_expr("q_deque.size()", 39 result_type=size_type, 40 result_value="1") 41 self.expect_expr("q_deque.front()", result_type=value_type) 42 self.expect_expr("q_deque.back()", result_type=value_type) 43 self.expect_expr("q_deque.front().i", 44 result_type="int", 45 result_value="4") 46 self.expect_expr("q_deque.back().i", 47 result_type="int", 48 result_value="4") 49 self.expect_expr("q_deque.empty()", 50 result_type="bool", 51 result_value="false") 52 self.expect("expr q_deque.pop()") 53 self.expect("expr q_deque.emplace(5)") 54 self.expect_expr("q_deque.front().i", 55 result_type="int", 56 result_value="5") 57 58 # Test std::queue functionality with a std::list. 59 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']): 60 queue_type = "std::queue<C, std::list<C> >" 61 else: 62 queue_type = "std::queue<C, std::list<C, std::allocator<C> > >" 63 64 self.expect_expr( 65 "q_list", 66 result_type=queue_type, 67 result_children=[ValueCheck(children=[ValueCheck(value="1")])]) 68 69 self.expect("expr q_list.pop()") 70 self.expect("expr q_list.push({4})") 71 self.expect_expr("q_list.size()", 72 result_type=size_type, 73 result_value="1") 74 self.expect_expr("q_list.front()", result_type=value_type) 75 self.expect_expr("q_list.back()", result_type=value_type) 76 self.expect_expr("q_list.front().i", 77 result_type="int", 78 result_value="4") 79 self.expect_expr("q_list.back().i", 80 result_type="int", 81 result_value="4") 82 self.expect_expr("q_list.empty()", 83 result_type="bool", 84 result_value="false") 85 self.expect("expr q_list.pop()") 86 self.expect("expr q_list.emplace(5)") 87 self.expect_expr("q_list.front().i", 88 result_type="int", 89 result_value="5") 90