MQTTSuite
Loading...
Searching...
No Matches
issue-293.cpp File Reference
Include dependency graph for issue-293.cpp:

Go to the source code of this file.

Functions

template<typename T>
int should_throw (const nlohmann::json &schema, T value)
int main (void)

Function Documentation

◆ main()

int main ( void )

Definition at line 16 of file issue-293.cpp.

17{
18
19 json_validator({{"type", "number"}, {"multipleOf", 0.001}}).validate(0.3 - 0.2);
20 json_validator({{"type", "number"}, {"multipleOf", 3.3}}).validate(8.0 - 1.4);
21 json_validator({{"type", "number"}, {"multipleOf", 1000.01}}).validate((1000.03 - 0.02) * 15.0);
22 json_validator({{"type", "number"}, {"multipleOf", 0.001}}).validate(0.030999999999999993);
23 json_validator({{"type", "number"}, {"multipleOf", 0.100000}}).validate(1.9);
24 json_validator({{"type", "number"}, {"multipleOf", 100000.1}}).validate(9000009);
25
26 int exc_count = 0;
27 exc_count += should_throw({{"type", "number"}, {"multipleOf", 0.001}}, 0.3 - 0.2005);
28 exc_count += should_throw({{"type", "number"}, {"multipleOf", 1000.02}}, (1000.03 - 0.02) * 15.0);
29 exc_count += should_throw({{"type", "number"}, {"multipleOf", 100000.11}}, 9000009);
30
31 return exc_count;
32}
int should_throw(const nlohmann::json &schema, T value)
Definition issue-293.cpp:6
auto validate(const nlohmann::json &schema, const nlohmann::json &instance, nlohmann::json_schema::error_handler *error_handler=nullptr) -> void

References nlohmann::json_schema::json_validator::json_validator(), should_throw(), and nlohmann::json_schema::json_validator::validate().

Here is the call graph for this function:

◆ should_throw()

template<typename T>
int should_throw ( const nlohmann::json & schema,
T value )

Definition at line 6 of file issue-293.cpp.

7{
8 try {
10 } catch (const std::exception &ex) {
11 return 0;
12 }
13 return 1;
14}
auto schema
Definition id-ref.cpp:69

References nlohmann::json_schema::json_validator::json_validator().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: