1 //===-- SBStructuredDataTest.cpp ------------------------===----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===/
8 
9 #include "gtest/gtest.h"
10 
11 #include "lldb/API/SBStringList.h"
12 #include "lldb/API/SBStructuredData.h"
13 
14 #include <cstring>
15 #include <string>
16 
17 using namespace lldb;
18 
19 class SBStructuredDataTest : public testing::Test {};
20 
21 TEST_F(SBStructuredDataTest, NullImpl) {
22   SBStructuredData data(nullptr);
23   EXPECT_EQ(data.GetType(), eStructuredDataTypeInvalid);
24   EXPECT_EQ(data.GetSize(), 0ul);
25   SBStringList keys;
26   EXPECT_FALSE(data.GetKeys(keys));
27   EXPECT_EQ(data.GetValueForKey("key").GetType(), eStructuredDataTypeInvalid);
28   EXPECT_EQ(data.GetItemAtIndex(0).GetType(), eStructuredDataTypeInvalid);
29   EXPECT_EQ(data.GetIntegerValue(UINT64_MAX), UINT64_MAX);
30   EXPECT_EQ(data.GetFloatValue(DBL_MAX), DBL_MAX);
31   EXPECT_TRUE(data.GetBooleanValue(true));
32   EXPECT_FALSE(data.GetBooleanValue(false));
33   char dst[1];
34   EXPECT_EQ(data.GetStringValue(dst, sizeof(dst)), 0ul);
35 }
36