2 Test default template arguments.
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class TestDefaultTemplateArgs(TestBase
):
15 lldbutil
.run_to_source_breakpoint(
16 self
, "// break here", lldb
.SBFileSpec("main.cpp")
19 # Declare a template with a template argument that has a default argument.
21 "expr --top-level -- template<typename T = int> struct $X { int v; };"
24 # The type we display to the user should omit the argument with the default
26 result
= self
.expect_expr("$X<> x; x", result_type
="$X<>")
27 # The internal name should also always show all arguments (even if they
28 # have their default value).
29 self
.assertEqual(result
.GetTypeName(), "$X<int>")
31 # Test the template but this time specify a non-default value for the
33 # Both internal type name and the one we display to the user should
34 # show the non-default value in the type name.
35 result
= self
.expect_expr("$X<long> x; x", result_type
="$X<long>")
36 self
.assertEqual(result
.GetTypeName(), "$X<long>")
38 # Test that the formatters are using the internal type names that
39 # always include all template arguments.
40 self
.expect("type summary add '$X<int>' --summary-string 'summary1'")
41 self
.expect_expr("$X<> x; x", result_summary
="summary1")
42 self
.expect("type summary add '$X<long>' --summary-string 'summary2'")
43 self
.expect_expr("$X<long> x; x", result_summary
="summary2")