9
9
from lldbsuite .test .lldbtest import *
10
10
from lldbsuite .test import lldbutil
11
11
12
+ import json
12
13
13
14
class TestStructuredDataAPI (TestBase ):
14
15
NO_DEBUG_INFO_TESTCASE = True
@@ -19,8 +20,15 @@ def test(self):
19
20
def structured_data_api_test (self ):
20
21
error = lldb .SBError ()
21
22
s = lldb .SBStream ()
22
- s .Print (
23
- "{\" key_dict\" :{\" key_string\" :\" STRING\" ,\" key_int\" :3,\" key_float\" :2.99,\" key_bool\" :true,\" key_array\" :[\" 23\" ,\" arr\" ]}}" )
23
+
24
+ dict_str = json .dumps (
25
+ {"key_dict" :
26
+ {"key_string" :"STRING" ,
27
+ "key_uint" :0xffffffff00000000 ,
28
+ "key_float" :2.99 ,
29
+ "key_bool" :True ,
30
+ "key_array" :["23" ,"arr" ]}})
31
+ s .Print (dict_str )
24
32
example = lldb .SBStructuredData ()
25
33
26
34
# Check SetFromJSON API for dictionaries, integers, floating point
@@ -49,7 +57,7 @@ def structured_data_api_test(self):
49
57
self .string_struct_test (dict_struct )
50
58
51
59
# Tests for integer data type
52
- self .int_struct_test (dict_struct )
60
+ self .uint_struct_test (dict_struct )
53
61
54
62
# Tests for floating point data type
55
63
self .double_struct_test (dict_struct )
@@ -110,25 +118,27 @@ def string_struct_test(self, dict_struct):
110
118
str (output ) +
111
119
" returned for a string object" )
112
120
113
- def int_struct_test (self , dict_struct ):
114
- # Check a valid SBStructuredData containing an 'integer' by
115
- int_struct = lldb .SBStructuredData ()
116
- int_struct = dict_struct .GetValueForKey ("key_int" )
117
- if not int_struct .IsValid ():
121
+ def uint_struct_test (self , dict_struct ):
122
+ # Check a valid SBStructuredData containing an unsigned integer.
123
+ # We intentionally make this larger than what an int64_t can hold but
124
+ # still small enough to fit a uint64_t
125
+ uint_struct = lldb .SBStructuredData ()
126
+ uint_struct = dict_struct .GetValueForKey ("key_uint" )
127
+ if not uint_struct .IsValid ():
118
128
self .fail ("A valid object should have been returned" )
119
129
120
130
# Check Type API
121
- if not int_struct .GetType () == lldb .eStructuredDataTypeInteger :
122
- self .fail ("Wrong type returned: " + str (int_struct .GetType ()))
131
+ if not uint_struct .GetType () == lldb .eStructuredDataTypeInteger :
132
+ self .fail ("Wrong type returned: " + str (uint_struct .GetType ()))
123
133
124
134
# Check API returning 'integer' value
125
- output = int_struct .GetIntegerValue ()
126
- if not output == 3 :
135
+ output = uint_struct .GetIntegerValue ()
136
+ if not output == 0xffffffff00000000 :
127
137
self .fail ("wrong output: " + str (output ))
128
138
129
139
# Calling wrong API on a SBStructuredData
130
140
# (e.g. getting a string value from an integer type structure)
131
- output = int_struct .GetStringValue (25 )
141
+ output = uint_struct .GetStringValue (25 )
132
142
if output :
133
143
self .fail (
134
144
"Valid string " +
0 commit comments