blob: ec5f06445393bf48695cca6c94b3a9ff8092d7e1 [file] [log] [blame]
Lawrence Tangd34f2b12022-07-19 15:36:31 +01001#ifndef CPER_IR_TEST_UTILS_H
2#define CPER_IR_TEST_UTILS_H
3
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -08004#include <valijson/adapters/nlohmann_json_adapter.hpp>
5#include <valijson/schema.hpp>
6#include <valijson/schema_parser.hpp>
7#include <valijson/validator.hpp>
8#include <nlohmann/json.hpp>
9
Lawrence Tangd34f2b12022-07-19 15:36:31 +010010extern "C" {
Ed Tanousc97c0412025-02-04 11:31:31 -080011#include <stdio.h>
Thu Nguyene42fb482024-10-15 14:43:11 +000012#include <libcper/BaseTypes.h>
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -080013#include <libcper/generator/sections/gen-section.h>
Lawrence Tangd34f2b12022-07-19 15:36:31 +010014}
15
Ed Tanousd6b62632025-03-14 15:30:07 -070016// Controls whether required properties are added to the majority of property
17// definitions. This is useful for unit tests that are validating JSON where
18// all fields are valid
19enum class AddRequiredProps { YES, NO };
20
John Chungf8fc7052024-05-03 20:05:29 +080021FILE *generate_record_memstream(const char **types, UINT16 num_types,
22 char **buf, size_t *buf_size,
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -080023 int single_section,
24 GEN_VALID_BITS_TEST_TYPE validBitsType);
Ed Tanousd6b62632025-03-14 15:30:07 -070025
26std::unique_ptr<valijson::Schema>
27load_schema(AddRequiredProps add_required_props, int single_section);
28
29int schema_validate_from_file(const valijson::Schema &schema,
30 nlohmann::json &jsonData,
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -080031 std::string &error_message);
Ed Tanousd6b62632025-03-14 15:30:07 -070032
Aushim Nagarkattiae8f6d92025-01-29 17:34:44 -080033nlohmann::json loadJson(const char *filePath);
Lawrence Tangd34f2b12022-07-19 15:36:31 +010034
John Chungf8fc7052024-05-03 20:05:29 +080035#endif