Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
cursorstreamwrappertest.cpp File Reference
Include dependency graph for cursorstreamwrappertest.cpp:

Go to the source code of this file.

Functions

bool testJson (const char *json, size_t &line, size_t &col)
 
 TEST (CursorStreamWrapper, MissingFirstBracket)
 
 TEST (CursorStreamWrapper, MissingQuotes)
 
 TEST (CursorStreamWrapper, MissingColon)
 
 TEST (CursorStreamWrapper, MissingSecondQuotes)
 
 TEST (CursorStreamWrapper, MissingComma)
 
 TEST (CursorStreamWrapper, MissingArrayBracket)
 
 TEST (CursorStreamWrapper, MissingArrayComma)
 
 TEST (CursorStreamWrapper, MissingLastArrayBracket)
 
 TEST (CursorStreamWrapper, MissingLastBracket)
 

Function Documentation

◆ TEST() [1/9]

TEST ( CursorStreamWrapper ,
MissingArrayBracket  )

Definition at line 81 of file cursorstreamwrappertest.cpp.

81 {
82 const char json[] = "{\"string\"\n\n:\"my string\",\"array\"\n:\"1\", \"2\", \"3\"]}";
83 size_t col, line;
84 bool ret = testJson(json, line, col);
86 EXPECT_EQ(line, 4u);
87 EXPECT_EQ(col, 9u);
88}
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
#define EXPECT_TRUE(condition)
Definition gtest.h:1895
CK_RV ret
Here is the call graph for this function:

◆ TEST() [2/9]

TEST ( CursorStreamWrapper ,
MissingArrayComma  )

Definition at line 90 of file cursorstreamwrappertest.cpp.

90 {
91 const char json[] = "{\"string\"\n\n:\"my string\",\"array\"\n:[\"1\" \"2\", \"3\"]}";
92 size_t col, line;
93 bool ret = testJson(json, line, col);
95 EXPECT_EQ(line, 4u);
96 EXPECT_EQ(col, 6u);
97}
Here is the call graph for this function:

◆ TEST() [3/9]

TEST ( CursorStreamWrapper ,
MissingColon  )

Definition at line 54 of file cursorstreamwrappertest.cpp.

54 {
55 const char json[] = "{\"string\"\n\n\"my string\",\"array\"\n:[\"1\", \"2\", \"3\"]}";
56 size_t col, line;
57 bool ret = testJson(json, line, col);
59 EXPECT_EQ(line, 3u);
60 EXPECT_EQ(col, 0u);
61}
Here is the call graph for this function:

◆ TEST() [4/9]

TEST ( CursorStreamWrapper ,
MissingComma  )

Definition at line 72 of file cursorstreamwrappertest.cpp.

72 {
73 const char json[] = "{\"string\"\n\n:\"my string\"\"array\"\n:[\"1\", \"2\", \"3\"]}";
74 size_t col, line;
75 bool ret = testJson(json, line, col);
77 EXPECT_EQ(line, 3u);
78 EXPECT_EQ(col, 12u);
79}
Here is the call graph for this function:

◆ TEST() [5/9]

TEST ( CursorStreamWrapper ,
MissingFirstBracket  )

Definition at line 36 of file cursorstreamwrappertest.cpp.

36 {
37 const char json[] = "\"string\"\n\n:\"my string\",\"array\"\n:[\"1\", \"2\", \"3\"]}";
38 size_t col, line;
39 bool ret = testJson(json, line, col);
41 EXPECT_EQ(line, 3u);
42 EXPECT_EQ(col, 0u);
43}
Here is the call graph for this function:

◆ TEST() [6/9]

TEST ( CursorStreamWrapper ,
MissingLastArrayBracket  )

Definition at line 99 of file cursorstreamwrappertest.cpp.

99 {
100 const char json8[] = "{\"string\"\n\n:\"my string\",\"array\"\n:[\"1\", \"2\", \"3\"}";
101 size_t col, line;
102 bool ret = testJson(json8, line, col);
104 EXPECT_EQ(line, 4u);
105 EXPECT_EQ(col, 15u);
106}
Here is the call graph for this function:

◆ TEST() [7/9]

TEST ( CursorStreamWrapper ,
MissingLastBracket  )

Definition at line 108 of file cursorstreamwrappertest.cpp.

108 {
109 const char json9[] = "{\"string\"\n\n:\"my string\",\"array\"\n:[\"1\", \"2\", \"3\"]";
110 size_t col, line;
111 bool ret = testJson(json9, line, col);
113 EXPECT_EQ(line, 4u);
114 EXPECT_EQ(col, 16u);
115}
Here is the call graph for this function:

◆ TEST() [8/9]

TEST ( CursorStreamWrapper ,
MissingQuotes  )

Definition at line 45 of file cursorstreamwrappertest.cpp.

45 {
46 const char json[] = "{\"string\n\n:\"my string\",\"array\"\n:[\"1\", \"2\", \"3\"]}";
47 size_t col, line;
48 bool ret = testJson(json, line, col);
50 EXPECT_EQ(line, 1u);
51 EXPECT_EQ(col, 8u);
52}
Here is the call graph for this function:

◆ TEST() [9/9]

TEST ( CursorStreamWrapper ,
MissingSecondQuotes  )

Definition at line 63 of file cursorstreamwrappertest.cpp.

63 {
64 const char json[] = "{\"string\"\n\n:my string\",\"array\"\n:[\"1\", \"2\", \"3\"]}";
65 size_t col, line;
66 bool ret = testJson(json, line, col);
68 EXPECT_EQ(line, 3u);
69 EXPECT_EQ(col, 1u);
70}
Here is the call graph for this function:

◆ testJson()

bool testJson ( const char * json,
size_t & line,
size_t & col )

Definition at line 23 of file cursorstreamwrappertest.cpp.

23 {
24 StringStream ss(json);
26 Document document;
27 document.ParseStream(csw);
28 bool ret = document.HasParseError();
29 if (ret) {
30 col = csw.GetColumn();
31 line = csw.GetLine();
32 }
33 return ret;
34}
Cursor stream wrapper for counting line and column number if error exists.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition document.h:2388
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition document.h:2259
static const Segment ss(Segment::ss)
Read-only string stream.
Definition stream.h:154
Here is the call graph for this function:
Here is the caller graph for this function: