summaryrefslogtreecommitdiffstats
path: root/lldb/test/functionalities
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-10-26 23:39:12 +0000
committerEnrico Granata <egranata@apple.com>2015-10-26 23:39:12 +0000
commit6ed1d75a9f491fe80a6226dce241def04ba5d667 (patch)
treeb73f2e65bddbf73e9b0817bdfbdd8422a4a5f686 /lldb/test/functionalities
parent45a9b282c2d9914ea11fb29e4cd053b53b991cdf (diff)
downloadbcm5719-llvm-6ed1d75a9f491fe80a6226dce241def04ba5d667.tar.gz
bcm5719-llvm-6ed1d75a9f491fe80a6226dce241def04ba5d667.zip
Change TestTypeCompletion to not rely on std::string
On some combination of platform and c++ library, this dependency was causing the test to fail for reasons tangential to its real objective llvm-svn: 251368
Diffstat (limited to 'lldb/test/functionalities')
-rw-r--r--lldb/test/functionalities/type_completion/TestTypeCompletion.py22
-rw-r--r--lldb/test/functionalities/type_completion/main.cpp43
2 files changed, 43 insertions, 22 deletions
diff --git a/lldb/test/functionalities/type_completion/TestTypeCompletion.py b/lldb/test/functionalities/type_completion/TestTypeCompletion.py
index f5e6e941b56..ea1c0119dd9 100644
--- a/lldb/test/functionalities/type_completion/TestTypeCompletion.py
+++ b/lldb/test/functionalities/type_completion/TestTypeCompletion.py
@@ -73,14 +73,10 @@ class TypeCompletionTestCase(TestBase):
self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid')
self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress should now be complete')
field0 = name_address_type.GetFieldAtIndex(0)
- if self.TraceOn():
- print('field0: ' + str(field0))
self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid')
string = field0.GetType().GetPointeeType()
- if self.TraceOn():
- print('string: ' + str(string))
- self.assertTrue(string.IsValid(), 'std::string should be valid')
- self.assertFalse(string.IsTypeComplete(), 'std::string complete but it should not be')
+ self.assertTrue(string.IsValid(), 'CustomString should be valid')
+ self.assertFalse(string.IsTypeComplete(), 'CustomString complete but it should not be')
self.runCmd("continue")
@@ -91,17 +87,13 @@ class TypeCompletionTestCase(TestBase):
self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be valid')
self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress should now be complete')
field0 = name_address_type.GetFieldAtIndex(0)
- if self.TraceOn():
- print('field0: ' + str(field0))
self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid')
string = field0.GetType().GetPointeeType()
- if self.TraceOn():
- print('string: ' + str(string))
- self.assertTrue(string.IsValid(), 'std::string should be valid')
- self.assertFalse(string.IsTypeComplete(), 'std::string complete but it should not be')
+ self.assertTrue(string.IsValid(), 'CustomString should be valid')
+ self.assertFalse(string.IsTypeComplete(), 'CustomString complete but it should not be')
self.runCmd('type category enable -l c++', check=False)
- self.runCmd('frame variable guy --show-types')
+ self.runCmd('frame variable guy --show-types --ptr-depth=1')
p_vector = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p')
p_type = p_vector.GetType()
@@ -112,5 +104,5 @@ class TypeCompletionTestCase(TestBase):
field0 = name_address_type.GetFieldAtIndex(0)
self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be valid')
string = field0.GetType().GetPointeeType()
- self.assertTrue(string.IsValid(), 'std::string should be valid')
- self.assertTrue(string.IsTypeComplete(), 'std::string should now be complete')
+ self.assertTrue(string.IsValid(), 'CustomString should be valid')
+ self.assertTrue(string.IsTypeComplete(), 'CustomString should now be complete')
diff --git a/lldb/test/functionalities/type_completion/main.cpp b/lldb/test/functionalities/type_completion/main.cpp
index c863ec5f9ed..80329737928 100644
--- a/lldb/test/functionalities/type_completion/main.cpp
+++ b/lldb/test/functionalities/type_completion/main.cpp
@@ -7,16 +7,45 @@
//
//===----------------------------------------------------------------------===//
-#include <string>
+#include <string.h>
#include <vector>
#include <iostream>
+class CustomString
+{
+public:
+ CustomString (const char* buffer) :
+ m_buffer(nullptr)
+ {
+ if (buffer)
+ {
+ auto l = strlen(buffer);
+ m_buffer = new char[1 + l];
+ strcpy(m_buffer, buffer);
+ }
+ }
+
+ ~CustomString ()
+ {
+ delete[] m_buffer;
+ }
+
+ const char*
+ GetBuffer ()
+ {
+ return m_buffer;
+ }
+
+private:
+ char *m_buffer;
+};
+
class NameAndAddress
{
public:
- std::string& GetName() { return *m_name; }
- std::string& GetAddress() { return *m_address; }
- NameAndAddress(const char* N, const char* A) : m_name(new std::string(N)), m_address(new std::string(A))
+ CustomString& GetName() { return *m_name; }
+ CustomString& GetAddress() { return *m_address; }
+ NameAndAddress(const char* N, const char* A) : m_name(new CustomString(N)), m_address(new CustomString(A))
{
}
~NameAndAddress()
@@ -24,8 +53,8 @@ class NameAndAddress
}
private:
- std::string* m_name;
- std::string* m_address;
+ CustomString* m_name;
+ CustomString* m_address;
};
typedef std::vector<NameAndAddress> People;
@@ -43,7 +72,7 @@ int main (int argc, const char * argv[])
for (int j = 0; j<p.size(); j++)
{
NameAndAddress guy = p[j];
- std::cout << "Person " << j << " is named " << guy.GetName() << " and lives at " << guy.GetAddress() << std::endl; // Set break point at this line.
+ std::cout << "Person " << j << " is named " << guy.GetName().GetBuffer() << " and lives at " << guy.GetAddress().GetBuffer() << std::endl; // Set break point at this line.
}
return 0;
OpenPOWER on IntegriCloud