Fix some json schema validation bugs
There were a couple of places where we would add null objects when
they were not allowed. Fix them.
Change-Id: I7c4c12ea1fa2913014e79603995267a9e560e288
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/tests/test-utils.hpp b/tests/test-utils.hpp
index 42e41bc..ec5f064 100644
--- a/tests/test-utils.hpp
+++ b/tests/test-utils.hpp
@@ -13,12 +13,23 @@
#include <libcper/generator/sections/gen-section.h>
}
+// Controls whether required properties are added to the majority of property
+// definitions. This is useful for unit tests that are validating JSON where
+// all fields are valid
+enum class AddRequiredProps { YES, NO };
+
FILE *generate_record_memstream(const char **types, UINT16 num_types,
char **buf, size_t *buf_size,
int single_section,
GEN_VALID_BITS_TEST_TYPE validBitsType);
-int schema_validate_from_file(const char *file_path, nlohmann::json &jsonData,
+
+std::unique_ptr<valijson::Schema>
+load_schema(AddRequiredProps add_required_props, int single_section);
+
+int schema_validate_from_file(const valijson::Schema &schema,
+ nlohmann::json &jsonData,
std::string &error_message);
+
nlohmann::json loadJson(const char *filePath);
#endif