diff options
| author | Med Ismail Bennani <ismail@bennani.ma> | 2025-08-21 16:40:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-21 16:40:01 -0700 |
| commit | 05b1ec3724e1dbb88050ad2ae4c72e9832668ec9 (patch) | |
| tree | 319b41f7ebaf26f6b97259145ac01cd289afa16b /lldb/test/API/python_api | |
| parent | ff85dbdf6b399eac7bffa13e579f0f5e6edac3c0 (diff) | |
| download | llvm-05b1ec3724e1dbb88050ad2ae4c72e9832668ec9.zip llvm-05b1ec3724e1dbb88050ad2ae4c72e9832668ec9.tar.gz llvm-05b1ec3724e1dbb88050ad2ae4c72e9832668ec9.tar.bz2 | |
[lldb/API] Add setters to SBStructuredData (#154445)
This patch adds setters to the SBStruturedData class to be able to
initialize said object from the client side directly.
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py b/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py index 21256d6..99f88d3 100644 --- a/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py +++ b/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py @@ -10,7 +10,6 @@ from lldbsuite.test import lldbutil import json - class TestStructuredDataAPI(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -130,6 +129,52 @@ class TestStructuredDataAPI(TestBase): self.assertSuccess(example.SetFromJSON("null")) self.assertEqual(example.GetType(), lldb.eStructuredDataTypeNull) + example = lldb.SBStructuredData() + example.SetUnsignedIntegerValue(1) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeInteger) + self.assertEqual(example.GetIntegerValue(), 1) + + example.SetSignedIntegerValue(-42) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeSignedInteger) + self.assertEqual(example.GetSignedIntegerValue(), -42) + + example.SetFloatValue(4.19) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeFloat) + self.assertEqual(example.GetFloatValue(), 4.19) + + example.SetStringValue("Bonjour, 123!") + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeString) + self.assertEqual(example.GetStringValue(42), "Bonjour, 123!") + + value = lldb.SBStructuredData() + example.SetValueForKey("Hello", value) + self.assertEqual(example.GetSize(), 0) + + nested_obj = lldb.SBStructuredData() + nested_obj.SetStringValue("World") + example.SetValueForKey("Hello", nested_obj) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeDictionary) + nested_obj = None + nested_obj = example.GetValueForKey("Hello") + self.assertTrue(nested_obj.IsValid()) + self.assertEqual(nested_obj.GetType(), lldb.eStructuredDataTypeString) + self.assertEqual(nested_obj.GetStringValue(42), "World") + + example.SetBooleanValue(True) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeBoolean) + self.assertTrue(example.GetBooleanValue()) + + rnd_obj = MyRandomClass() + stp = lldb.SBScriptObject(rnd_obj, lldb.eScriptLanguagePython) + self.assertEqual(stp.ptr, rnd_obj) + + example.SetGenericValue(stp) + self.assertEqual(example.GetType(), lldb.eStructuredDataTypeGeneric) + + my_random_class = example.GetGenericValue() + self.assertTrue(my_random_class) + self.assertEqual(my_random_class.payload, MyRandomClass.payload) + example_arr = [1, 2.3, "4", {"5": False}] arr_str = json.dumps(example_arr) s.Clear() |
