MQTTSuite
Loading...
Searching...
No Matches
json-patch.cpp File Reference
#include "../src/json-patch.hpp"
#include <iostream>
Include dependency graph for json-patch.cpp:

Go to the source code of this file.

Macros

#define OK(code)
#define KO(code)

Functions

int main (void)

Macro Definition Documentation

◆ KO

#define KO ( code)
Value:
do { \
try { \
code; \
std::cerr << "UNEXPECTED SUCCESS.\n"; \
return 1; \
} catch (const std::exception &e) { \
std::cerr << "EXPECTED FAIL: " << e.what() << "\n"; \
} \
} while (0)

Definition at line 17 of file json-patch.cpp.

17#define KO(code) \
18 do { \
19 try { \
20 code; \
21 std::cerr << "UNEXPECTED SUCCESS.\n"; \
22 return 1; \
23 } catch (const std::exception &e) { \
24 std::cerr << "EXPECTED FAIL: " << e.what() << "\n"; \
25 } \
26 } while (0)

◆ OK

#define OK ( code)
Value:
do { \
try { \
code; \
} catch (const std::exception &e) { \
std::cerr << "UNEXPECTED FAILED: " << e.what() << "\n"; \
return 1; \
} \
} while (0)

Definition at line 7 of file json-patch.cpp.

7#define OK(code) \
8 do { \
9 try { \
10 code; \
11 } catch (const std::exception &e) { \
12 std::cerr << "UNEXPECTED FAILED: " << e.what() << "\n"; \
13 return 1; \
14 } \
15 } while (0)

Function Documentation

◆ main()

int main ( void )

Definition at line 28 of file json-patch.cpp.

29{
30 OK(json_patch p1(R"([{"op":"add","path":"/0/renderable/bg","value":"Black"}])"_json));
31 OK(json_patch p1(R"([{"op":"replace","path":"/0/renderable/bg","value":"Black"}])"_json));
32 OK(json_patch p1(R"([{"op":"remove","path":"/0/renderable/bg"}])"_json));
33
34 // value not needed
35 KO(json_patch p1(R"([{"op":"remove","path":"/0/renderable/bg", "value":"Black"}])"_json));
36 // value missing
37 KO(json_patch p1(R"([{"op":"add","path":"/0/renderable/bg"}])"_json));
38 // value missing
39 KO(json_patch p1(R"([{"op":"replace","path":"/0/renderable/bg"}])"_json));
40
41 // wrong op
42 KO(json_patch p1(R"([{"op":"ad","path":"/0/renderable/bg","value":"Black"}])"_json));
43
44 // invalid json-pointer
45 KO(json_patch p1(R"([{"op":"add","path":"0/renderable/bg","value":"Black"}])"_json));
46
47 return 0;
48}
#define KO(code)
#define OK(code)
Definition json-patch.cpp:7

References nlohmann::json_patch::json_patch().

Here is the call graph for this function: