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