From 264d65924b06ff9c57efa976d98046728447f77b Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Fri, 24 Sep 2010 21:52:37 +0000 Subject: [PATCH] Added comments about the usage of int(string, 0) and long(string, 0) which pass a base of 0 so that the radix of the string is determined based on the contents of string. llvm-svn: 114764 --- lldb/test/array_types/TestArrayTypes.py | 7 +++++-- lldb/test/bitfields/TestBitfields.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 38974a7649ac..ca08da182907 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -148,6 +148,9 @@ class ArrayTypesTestCase(TestBase): "Variable 'char_16' should have 16 children") # Lookup the "ushort_matrix" ushort[] array variable. + # Notice the pattern of int(child0_2.GetValue(frame), 0). We pass a + # base of 0 so that the proper radix is determined based on the contents + # of the string. Same applies to long(). variable = frame.LookupVar("ushort_matrix") self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 2, @@ -158,7 +161,7 @@ class ArrayTypesTestCase(TestBase): "Variable 'ushort_matrix[0]' should have 3 children") child0_2 = child0.GetChildAtIndex(2) self.DebugSBValue(frame, child0_2) - self.assertTrue(int(child0_2.GetValue(frame), 16) == 3, + self.assertTrue(int(child0_2.GetValue(frame), 0) == 3, "ushort_matrix[0][2] == 3") # Lookup the "long_6" char array variable. @@ -168,7 +171,7 @@ class ArrayTypesTestCase(TestBase): "Variable 'long_6' should have 6 children") child5 = variable.GetChildAtIndex(5) self.DebugSBValue(frame, child5) - self.assertTrue(long(child5.GetValue(frame)) == 6, + self.assertTrue(long(child5.GetValue(frame), 0) == 6, "long_6[5] == 6") diff --git a/lldb/test/bitfields/TestBitfields.py b/lldb/test/bitfields/TestBitfields.py index c25c7bc51f54..f3c71ee87a2a 100644 --- a/lldb/test/bitfields/TestBitfields.py +++ b/lldb/test/bitfields/TestBitfields.py @@ -108,6 +108,9 @@ class BitfieldsTestCase(TestBase): bits.GetByteSize() == 4, "(Bits)bits with byte size of 4 and 8 children") + # Notice the pattern of int(b1.GetValue(frame), 0). We pass a base of 0 + # so that the proper radix is determined based on the contents of the + # string. b1 = bits.GetChildAtIndex(0) self.DebugSBValue(frame, b1) self.assertTrue(b1.GetName() == "b1" and