Electroneum
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  ,
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);
40  EXPECT_TRUE(ret);
41  EXPECT_EQ(line, 3);
42  EXPECT_EQ(col, 0);
43 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [2/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);
49  EXPECT_TRUE(ret);
50  EXPECT_EQ(line, 1);
51  EXPECT_EQ(col, 8);
52 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
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);
58  EXPECT_TRUE(ret);
59  EXPECT_EQ(line, 3);
60  EXPECT_EQ(col, 0);
61 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [4/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);
67  EXPECT_TRUE(ret);
68  EXPECT_EQ(line, 3);
69  EXPECT_EQ(col, 1);
70 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [5/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);
76  EXPECT_TRUE(ret);
77  EXPECT_EQ(line, 3);
78  EXPECT_EQ(col, 12);
79 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [6/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);
85  EXPECT_TRUE(ret);
86  EXPECT_EQ(line, 4);
87  EXPECT_EQ(col, 9);
88 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [7/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);
94  EXPECT_TRUE(ret);
95  EXPECT_EQ(line, 4);
96  EXPECT_EQ(col, 6);
97 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
rapidjson::Document json
Definition: transport.cpp:49
Here is the call graph for this function:

◆ TEST() [8/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);
103  EXPECT_TRUE(ret);
104  EXPECT_EQ(line, 4);
105  EXPECT_EQ(col, 15);
106 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Here is the call graph for this function:

◆ TEST() [9/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);
112  EXPECT_TRUE(ret);
113  EXPECT_EQ(line, 4);
114  EXPECT_EQ(col, 16);
115 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool testJson(const char *json, size_t &line, size_t &col)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
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 }
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition: document.h:2394
Read-only string stream.
Definition: fwd.h:47
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
Definition: document.h:2265
rapidjson::Document json
Definition: transport.cpp:49
Cursor stream wrapper for counting line and column number if error exists.
Here is the call graph for this function:
Here is the caller graph for this function: