summaryrefslogtreecommitdiff
path: root/src/strings/astring.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/strings/astring.py')
-rw-r--r--src/strings/astring.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/strings/astring.py b/src/strings/astring.py
index 063e721..47e4e55 100644
--- a/src/strings/astring.py
+++ b/src/strings/astring.py
@@ -1,6 +1,4 @@
class AString(object):
- ''' print an AString
- '''
__slots__ = ('_value')
name = 'tmwa::strings::AString'
enabled = True
@@ -14,11 +12,40 @@ class AString(object):
def children(self):
b = self._value['data']
s = self._value['special']
+ b = b[0].address
if s == 255:
- b = b.cast(gdb.lookup_type('strings::RString').pointer())
+ b = b.cast(gdb.lookup_type('tmwa::strings::RString').pointer())
yield 'allocated', b.dereference()
else:
- b = b.cast(b.type.target().pointer())
n = 255
d = n - s
yield 'contained', b.lazy_string(length=d)
+
+ str256 = '0123456789abcdef' * 16
+
+ tests = [
+ ('tmwa::AString(""_s)', '{allocated = ""}'),
+ ('tmwa::AString(tmwa::ZString(""_s))', '{allocated = ""}'),
+ ('tmwa::AString(tmwa::RString(""_s))', '{allocated = ""}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString(""_s)))', '{allocated = ""}'),
+ ('tmwa::AString("Hello"_s)', '{allocated = "Hello"}'),
+ ('tmwa::AString(tmwa::ZString("Hello"_s))', '{contained = "Hello"}'),
+ ('tmwa::AString(tmwa::RString("Hello"_s))', '{allocated = "Hello"}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString("Hello"_s)))', '{allocated = "Hello" = {count = 0}}'),
+ ('tmwa::AString("' + str256[:-2] + '"_s)', '{allocated = "' + str256[:-2] + '"}'),
+ ('tmwa::AString(tmwa::ZString("' + str256[:-2] + '"_s))', '{contained = "' + str256[:-2] + '"}'),
+ ('tmwa::AString(tmwa::RString("' + str256[:-2] + '"_s))', '{allocated = "' + str256[:-2] + '"}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString("' + str256[:-2] + '"_s)))', '{allocated = "' + str256[:-2] + '" = {count = 0}}'),
+ ('tmwa::AString("' + str256[:-1] + '"_s)', '{allocated = "' + str256[:-1] + '"}'),
+ ('tmwa::AString(tmwa::ZString("' + str256[:-1] + '"_s))', '{contained = "' + str256[:-1] + '"}'),
+ ('tmwa::AString(tmwa::RString("' + str256[:-1] + '"_s))', '{allocated = "' + str256[:-1] + '"}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString("' + str256[:-1] + '"_s)))', '{allocated = "' + str256[:-1] + '" = {count = 0}}'),
+ ('tmwa::AString("' + str256 + '"_s)', '{allocated = "' + str256 + '"}'),
+ ('tmwa::AString(tmwa::ZString("' + str256 + '"_s))', '{allocated = "' + str256 + '" = {count = 0}}'),
+ ('tmwa::AString(tmwa::RString("' + str256 + '"_s))', '{allocated = "' + str256 + '"}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString("' + str256 + '"_s)))', '{allocated = "' + str256 + '" = {count = 0}}'),
+ ('tmwa::AString("' + str256 + 'x"_s)', '{allocated = "' + str256 + 'x"}'),
+ ('tmwa::AString(tmwa::ZString("' + str256 + 'x"_s))', '{allocated = "' + str256 + 'x" = {count = 0}}'),
+ ('tmwa::AString(tmwa::RString("' + str256 + 'x"_s))', '{allocated = "' + str256 + 'x"}'),
+ ('tmwa::AString(tmwa::RString(tmwa::ZString("' + str256 + 'x"_s)))', '{allocated = "' + str256 + 'x" = {count = 0}}'),
+ ]