summaryrefslogtreecommitdiff
path: root/src/strings/astring.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-08-13 14:55:49 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-08-27 11:29:45 -0700
commit9951ad78c80e144c166a7d476cad7ffdf84332a9 (patch)
tree9f5498a9a3c23b62dc928288e72081e99f958f46 /src/strings/astring.py
parent749fec734c4583153fb2dbc80f1d21db2c2ab457 (diff)
downloadtmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.gz
tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.bz2
tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.xz
tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.zip
Debug debugging
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}}'),
+ ]