1"""
2Test lldb data formatter subsystem.
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class TestDataFormatterLibcxxTuple(TestBase):
13    def setUp(self):
14        TestBase.setUp(self)
15        self.line = line_number("main.cpp", "// break here")
16        self.namespace = "std"
17
18    @add_test_categories(["libc++"])
19    def test(self):
20        """Test that std::tuple is displayed correctly"""
21        self.build()
22        lldbutil.run_to_source_breakpoint(
23            self, "// break here", lldb.SBFileSpec("main.cpp", False)
24        )
25
26        tuple_name = self.namespace + "::tuple"
27        self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"])
28
29        self.expect(
30            "frame variable one_elt",
31            substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
32        )
33
34        self.expect(
35            "frame variable three_elts",
36            substrs=[
37                tuple_name,
38                "size=3",
39                "{",
40                "[0] = 1",
41                "[1] = 47",
42                '[2] = "foo"',
43                "}",
44            ],
45        )
46