MQTTSuite
Loading...
Searching...
No Matches
issue-105-verbose-combination-errors.cpp File Reference
#include "nlohmann/json-schema.hpp"
#include "nlohmann/json.hpp"
#include <iostream>
#include <regex>
#include <string>
#include <vector>
Include dependency graph for issue-105-verbose-combination-errors.cpp:

Go to the source code of this file.

Classes

class  anonymous_namespace{issue-105-verbose-combination-errors.cpp}::MyErrorHandler
struct  anonymous_namespace{issue-105-verbose-combination-errors.cpp}::MyErrorHandler::ErrorEntry

Namespaces

namespace  anonymous_namespace{issue-105-verbose-combination-errors.cpp}

Macros

#define LOG_ERROR(LOG_ERROR__ARGS)
#define EXPECT_THROW_WITH_MESSAGE(EXPRESSION, MESSAGE)
#define ASSERT_OR_EXPECT_EQ(FIRST_THING, SECOND_THING, RETURN_IN_CASE_OF_ERROR)
#define ASSERT_EQ(FIRST_THING, SECOND_THING)
#define EXPECT_EQ(FIRST_THING, SECOND_THING)
#define EXPECT_MATCH(STRING, REGEX)

Functions

auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::generateSchema (const std::string &first_combination, const std::string &second_combination) -> nlohmann::json
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::operator<< (std::string first, const std::string &second) -> std::string
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::rootError (const std::string &combination_type, std::size_t number_of_subschemas) -> std::string
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::combinationError (const std::string &combination_type, std::size_t test_case_number) -> std::string
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::validate (const nlohmann::json &schema, const nlohmann::json &instance, nlohmann::json_schema::error_handler *error_handler=nullptr) -> void
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::simpleTest (const std::string &first_combination, const std::string &second_combination) -> void
auto anonymous_namespace{issue-105-verbose-combination-errors.cpp}::verboseTest (const std::string &first_combination, const std::string &second_combination) -> void
auto main () -> int

Variables

int anonymous_namespace{issue-105-verbose-combination-errors.cpp}::g_error_count = 0
const std::string anonymous_namespace{issue-105-verbose-combination-errors.cpp}::g_schema_template

Macro Definition Documentation

◆ ASSERT_EQ

#define ASSERT_EQ ( FIRST_THING,
SECOND_THING )
Value:
ASSERT_OR_EXPECT_EQ(FIRST_THING, SECOND_THING, true)
#define ASSERT_OR_EXPECT_EQ(FIRST_THING, SECOND_THING, RETURN_IN_CASE_OF_ERROR)

Definition at line 40 of file issue-105-verbose-combination-errors.cpp.

◆ ASSERT_OR_EXPECT_EQ

#define ASSERT_OR_EXPECT_EQ ( FIRST_THING,
SECOND_THING,
RETURN_IN_CASE_OF_ERROR )
Value:
do { \
if ((FIRST_THING) != (SECOND_THING)) { \
LOG_ERROR("The two values of " << (FIRST_THING) << " (" #FIRST_THING << ") and " << (SECOND_THING) << " (" #SECOND_THING << ") should be equal"); \
if (RETURN_IN_CASE_OF_ERROR) { \
return; \
} \
} \
} while (false)

Definition at line 30 of file issue-105-verbose-combination-errors.cpp.

30#define ASSERT_OR_EXPECT_EQ(FIRST_THING, SECOND_THING, RETURN_IN_CASE_OF_ERROR) \
31 do { \
32 if ((FIRST_THING) != (SECOND_THING)) { \
33 LOG_ERROR("The two values of " << (FIRST_THING) << " (" #FIRST_THING << ") and " << (SECOND_THING) << " (" #SECOND_THING << ") should be equal"); \
34 if (RETURN_IN_CASE_OF_ERROR) { \
35 return; \
36 } \
37 } \
38 } while (false)

◆ EXPECT_EQ

#define EXPECT_EQ ( FIRST_THING,
SECOND_THING )
Value:
ASSERT_OR_EXPECT_EQ(FIRST_THING, SECOND_THING, true)

Definition at line 41 of file issue-105-verbose-combination-errors.cpp.

◆ EXPECT_MATCH

#define EXPECT_MATCH ( STRING,
REGEX )
Value:
do { \
if (!std::regex_search((STRING), std::regex{(REGEX)})) { \
LOG_ERROR("String \"" << (STRING) << "\" doesn't match with regex: \"" << (REGEX) << "\""); \
++g_error_count; \
} \
} while (false)

Definition at line 43 of file issue-105-verbose-combination-errors.cpp.

43#define EXPECT_MATCH(STRING, REGEX) \
44 do { \
45 if (!std::regex_search((STRING), std::regex{(REGEX)})) { \
46 LOG_ERROR("String \"" << (STRING) << "\" doesn't match with regex: \"" << (REGEX) << "\""); \
47 ++g_error_count; \
48 } \
49 } while (false)

◆ EXPECT_THROW_WITH_MESSAGE

#define EXPECT_THROW_WITH_MESSAGE ( EXPRESSION,
MESSAGE )
Value:
do { \
try { \
EXPRESSION; \
LOG_ERROR("Expected exception not thrown with matching regex: \"" << MESSAGE << "\""); \
++g_error_count; \
} catch (const std::exception &error) { \
const std::regex error_re{MESSAGE}; \
if (!std::regex_search(error.what(), error_re)) { \
LOG_ERROR("Expected exception with matching regex: \"" << MESSAGE << "\", but got this instead: " << error.what()); \
} \
} \
} while (false)

Definition at line 15 of file issue-105-verbose-combination-errors.cpp.

15#define EXPECT_THROW_WITH_MESSAGE(EXPRESSION, MESSAGE) \
16 do { \
17 try { \
18 EXPRESSION; \
19 LOG_ERROR("Expected exception not thrown with matching regex: \"" << MESSAGE << "\""); \
20 ++g_error_count; \
21 } catch (const std::exception &error) { \
22 const std::regex error_re{MESSAGE}; \
23 if (!std::regex_search(error.what(), error_re)) { \
24 LOG_ERROR("Expected exception with matching regex: \"" << MESSAGE << "\", but got this instead: " << error.what()); \
25 ++g_error_count; \
26 } \
27 } \
28 } while (false)

◆ LOG_ERROR

#define LOG_ERROR ( LOG_ERROR__ARGS)
Value:
std::cerr << __FILE__ << ":" << __LINE__ << ": " << LOG_ERROR__ARGS << std::endl

Definition at line 12 of file issue-105-verbose-combination-errors.cpp.

12#define LOG_ERROR(LOG_ERROR__ARGS) \
13 std::cerr << __FILE__ << ":" << __LINE__ << ": " << LOG_ERROR__ARGS << std::endl

Function Documentation

◆ main()

auto main ( void ) ->int

Definition at line 308 of file issue-105-verbose-combination-errors.cpp.

309{
310 simpleTest("anyOf", "anyOf");
311 simpleTest("anyOf", "oneOf");
312 simpleTest("oneOf", "anyOf");
313 simpleTest("oneOf", "oneOf");
314
315 verboseTest("anyOf", "anyOf");
316 verboseTest("anyOf", "oneOf");
317 verboseTest("oneOf", "anyOf");
318 verboseTest("oneOf", "oneOf");
319
320 return g_error_count;
321}
auto simpleTest(const std::string &first_combination, const std::string &second_combination) -> void
auto verboseTest(const std::string &first_combination, const std::string &second_combination) -> void

References anonymous_namespace{issue-105-verbose-combination-errors.cpp}::g_error_count, anonymous_namespace{issue-105-verbose-combination-errors.cpp}::simpleTest(), and anonymous_namespace{issue-105-verbose-combination-errors.cpp}::verboseTest().

Here is the call graph for this function: