forked from OSchip/llvm-project
[lldb][NFC] Modernize TestCPPStaticMethods
Now with LLVM code style and expect_expr for checking. Also some minor changes to be more similar to the structure we use in other tests.
This commit is contained in:
parent
aafdeeade8
commit
4bee2afcd7
|
@ -15,10 +15,7 @@ class CPPStaticMethodsTestCase(TestBase):
|
|||
def test_with_run_command(self):
|
||||
"""Test that static methods are properly distinguished from regular methods"""
|
||||
self.build()
|
||||
lldbutil.run_to_source_breakpoint(self, "// Break at this line", lldb.SBFileSpec("main.cpp"))
|
||||
lldbutil.run_to_source_breakpoint(self, "// Break here", lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
self.expect("expression -- A::getStaticValue()",
|
||||
startstr="(int) $0 = 5")
|
||||
|
||||
self.expect("expression -- my_a.getMemberValue()",
|
||||
startstr="(int) $1 = 3")
|
||||
self.expect_expr("A::getStaticValue()", result_type="int", result_value="5")
|
||||
self.expect_expr("a.getMemberValue()", result_type="int", result_value="3")
|
||||
|
|
|
@ -1,29 +1,13 @@
|
|||
#include <stdio.h>
|
||||
|
||||
class A
|
||||
{
|
||||
struct A {
|
||||
public:
|
||||
static int getStaticValue();
|
||||
int getMemberValue();
|
||||
static int getStaticValue() { return 5; }
|
||||
int getMemberValue() { return a; }
|
||||
int a;
|
||||
};
|
||||
|
||||
int A::getStaticValue()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
int A::getMemberValue()
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
A my_a;
|
||||
|
||||
my_a.a = 3;
|
||||
|
||||
printf("%d\n", A::getStaticValue()); // Break at this line
|
||||
printf("%d\n", my_a.getMemberValue());
|
||||
A a;
|
||||
a.a = 3;
|
||||
return A::getStaticValue() + a.getMemberValue(); // Break here
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue