199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTests std::queue functionality. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 899451b44SJordan Rupprecht 9cabee89bSRaphael Isemann 1099451b44SJordan Rupprechtclass TestQueue(TestBase): 1199451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1299451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 13*74c5e474SMichael Buch @skipIf( 14*74c5e474SMichael Buch compiler="clang", 15*74c5e474SMichael Buch compiler_version=[">", "16.0"], 16*74c5e474SMichael Buch bugnumber="https://github.com/llvm/llvm-project/issues/68968", 17*74c5e474SMichael Buch ) 1899451b44SJordan Rupprecht def test(self): 1999451b44SJordan Rupprecht self.build() 2099451b44SJordan Rupprecht 212238dcc3SJonas Devlieghere lldbutil.run_to_source_breakpoint( 222238dcc3SJonas Devlieghere self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 232238dcc3SJonas Devlieghere ) 2499451b44SJordan Rupprecht 2599451b44SJordan Rupprecht self.runCmd("settings set target.import-std-module true") 2699451b44SJordan Rupprecht 272238dcc3SJonas Devlieghere if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( 282238dcc3SJonas Devlieghere [">", "16.0"] 292238dcc3SJonas Devlieghere ): 303f6c856bSRaphael Isemann queue_type = "std::queue<C>" 313c667298SMichael Buch else: 323c667298SMichael Buch queue_type = "std::queue<C, std::deque<C, std::allocator<C> > >" 333c667298SMichael Buch 3415f3cd6bSMatheus Izvekov size_type = "size_type" 3515f3cd6bSMatheus Izvekov value_type = "value_type" 36cabee89bSRaphael Isemann 3799451b44SJordan Rupprecht # Test std::queue functionality with a std::deque. 38cabee89bSRaphael Isemann self.expect_expr( 39cabee89bSRaphael Isemann "q_deque", 40cabee89bSRaphael Isemann result_type=queue_type, 412238dcc3SJonas Devlieghere result_children=[ValueCheck(children=[ValueCheck(value="1")])], 422238dcc3SJonas Devlieghere ) 4399451b44SJordan Rupprecht self.expect("expr q_deque.pop()") 4499451b44SJordan Rupprecht self.expect("expr q_deque.push({4})") 452238dcc3SJonas Devlieghere self.expect_expr("q_deque.size()", result_type=size_type, result_value="1") 46cabee89bSRaphael Isemann self.expect_expr("q_deque.front()", result_type=value_type) 47cabee89bSRaphael Isemann self.expect_expr("q_deque.back()", result_type=value_type) 482238dcc3SJonas Devlieghere self.expect_expr("q_deque.front().i", result_type="int", result_value="4") 492238dcc3SJonas Devlieghere self.expect_expr("q_deque.back().i", result_type="int", result_value="4") 502238dcc3SJonas Devlieghere self.expect_expr("q_deque.empty()", result_type="bool", result_value="false") 5199451b44SJordan Rupprecht self.expect("expr q_deque.pop()") 5299451b44SJordan Rupprecht self.expect("expr q_deque.emplace(5)") 532238dcc3SJonas Devlieghere self.expect_expr("q_deque.front().i", result_type="int", result_value="5") 5499451b44SJordan Rupprecht 5599451b44SJordan Rupprecht # Test std::queue functionality with a std::list. 562238dcc3SJonas Devlieghere if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( 572238dcc3SJonas Devlieghere [">", "16.0"] 582238dcc3SJonas Devlieghere ): 593f6c856bSRaphael Isemann queue_type = "std::queue<C, std::list<C> >" 603c667298SMichael Buch else: 613c667298SMichael Buch queue_type = "std::queue<C, std::list<C, std::allocator<C> > >" 623c667298SMichael Buch 63cabee89bSRaphael Isemann self.expect_expr( 64cabee89bSRaphael Isemann "q_list", 65cabee89bSRaphael Isemann result_type=queue_type, 662238dcc3SJonas Devlieghere result_children=[ValueCheck(children=[ValueCheck(value="1")])], 672238dcc3SJonas Devlieghere ) 68cabee89bSRaphael Isemann 6999451b44SJordan Rupprecht self.expect("expr q_list.pop()") 7099451b44SJordan Rupprecht self.expect("expr q_list.push({4})") 712238dcc3SJonas Devlieghere self.expect_expr("q_list.size()", result_type=size_type, result_value="1") 72cabee89bSRaphael Isemann self.expect_expr("q_list.front()", result_type=value_type) 73cabee89bSRaphael Isemann self.expect_expr("q_list.back()", result_type=value_type) 742238dcc3SJonas Devlieghere self.expect_expr("q_list.front().i", result_type="int", result_value="4") 752238dcc3SJonas Devlieghere self.expect_expr("q_list.back().i", result_type="int", result_value="4") 762238dcc3SJonas Devlieghere self.expect_expr("q_list.empty()", result_type="bool", result_value="false") 7799451b44SJordan Rupprecht self.expect("expr q_list.pop()") 7899451b44SJordan Rupprecht self.expect("expr q_list.emplace(5)") 792238dcc3SJonas Devlieghere self.expect_expr("q_list.front().i", result_type="int", result_value="5") 80