199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest basic std::list 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 TestBasicDeque(TestBase):
1199451b44SJordan Rupprecht
1299451b44SJordan Rupprecht    @add_test_categories(["libc++"])
1399451b44SJordan Rupprecht    @skipIf(compiler=no_match("clang"))
1499451b44SJordan Rupprecht    def test(self):
1599451b44SJordan Rupprecht        self.build()
1699451b44SJordan Rupprecht
1799451b44SJordan Rupprecht        lldbutil.run_to_source_breakpoint(self,
18cabee89bSRaphael Isemann                                          "// Set break point at this line.",
19cabee89bSRaphael Isemann                                          lldb.SBFileSpec("main.cpp"))
2099451b44SJordan Rupprecht
2199451b44SJordan Rupprecht        self.runCmd("settings set target.import-std-module true")
2299451b44SJordan Rupprecht
23*3f6c856bSRaphael Isemann        deque_type = "std::deque<int>"
24cabee89bSRaphael Isemann        size_type = deque_type + "::size_type"
25cabee89bSRaphael Isemann        value_type = "std::__deque_base<int, std::allocator<int> >::value_type"
26cabee89bSRaphael Isemann        iterator = deque_type + "::iterator"
27cabee89bSRaphael Isemann        iterator_children = [
28cabee89bSRaphael Isemann            ValueCheck(name="__m_iter_"),
29cabee89bSRaphael Isemann            ValueCheck(name="__ptr_")
30cabee89bSRaphael Isemann        ]
31cabee89bSRaphael Isemann        riterator = deque_type + "::reverse_iterator"
32cabee89bSRaphael Isemann        riterator_children = [
33cabee89bSRaphael Isemann            ValueCheck(name="__t"),
34cabee89bSRaphael Isemann            ValueCheck(name="current")
35cabee89bSRaphael Isemann        ]
36cabee89bSRaphael Isemann
37cabee89bSRaphael Isemann        self.expect_expr("a",
38cabee89bSRaphael Isemann                         result_type=deque_type,
39cabee89bSRaphael Isemann                         result_children=[
40cabee89bSRaphael Isemann                             ValueCheck(value='3'),
41cabee89bSRaphael Isemann                             ValueCheck(value='1'),
42cabee89bSRaphael Isemann                             ValueCheck(value='2'),
43cabee89bSRaphael Isemann                         ])
44cabee89bSRaphael Isemann
45cabee89bSRaphael Isemann        self.expect_expr("a.size()", result_type=size_type, result_value="3")
46cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="3")
47cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="2")
4899451b44SJordan Rupprecht
4999451b44SJordan Rupprecht        self.expect("expr std::sort(a.begin(), a.end())")
50cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="1")
51cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="3")
5299451b44SJordan Rupprecht
5399451b44SJordan Rupprecht        self.expect("expr std::reverse(a.begin(), a.end())")
54cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="3")
55cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="1")
5699451b44SJordan Rupprecht
57cabee89bSRaphael Isemann        self.expect_expr("*a.begin()", result_type="int", result_value="3")
58cabee89bSRaphael Isemann        self.expect_expr("*a.rbegin()", result_type="int", result_value="1")
59cabee89bSRaphael Isemann        self.expect_expr("a.begin()",
60cabee89bSRaphael Isemann                         result_type=iterator,
61cabee89bSRaphael Isemann                         result_children=iterator_children)
62cabee89bSRaphael Isemann        self.expect_expr("a.rbegin()",
63cabee89bSRaphael Isemann                         result_type=riterator,
64cabee89bSRaphael Isemann                         result_children=riterator_children)
65