Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Schema Class Reference
Inheritance diagram for Schema:
Collaboration diagram for Schema:

Classes

struct  TestSuite
 

Public Member Functions

 Schema ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Protected Types

typedef std::vector< Document * > DocumentList
 
typedef std::vector< TestSuite * > TestSuiteList
 

Protected Attributes

TestSuiteList testSuites
 

Detailed Description

Definition at line 52 of file schematest.cpp.

Member Typedef Documentation

◆ DocumentList

std::vector<Document*> Schema::DocumentList
protected

Definition at line 181 of file schematest.cpp.

◆ TestSuiteList

std::vector<TestSuite* > Schema::TestSuiteList
protected

Definition at line 194 of file schematest.cpp.

Constructor & Destructor Documentation

◆ Schema()

Schema::Schema ( )
inline

Definition at line 54 of file schematest.cpp.

54{}

Member Function Documentation

◆ SetUp()

virtual void Schema::SetUp ( )
inlinevirtual

Definition at line 56 of file schematest.cpp.

56 {
57 PerfTest::SetUp();
58
59 const char* filenames[] = {
60 "additionalItems.json",
61 "additionalProperties.json",
62 "allOf.json",
63 "anyOf.json",
64 "default.json",
65 "definitions.json",
66 "dependencies.json",
67 "enum.json",
68 "items.json",
69 "maximum.json",
70 "maxItems.json",
71 "maxLength.json",
72 "maxProperties.json",
73 "minimum.json",
74 "minItems.json",
75 "minLength.json",
76 "minProperties.json",
77 "multipleOf.json",
78 "not.json",
79 "oneOf.json",
80 "pattern.json",
81 "patternProperties.json",
82 "properties.json",
83 "ref.json",
84 "refRemote.json",
85 "required.json",
86 "type.json",
87 "uniqueItems.json"
88 };
89
90 char jsonBuffer[65536];
91 MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));
92
93 for (size_t i = 0; i < ARRAY_SIZE(filenames); i++) {
94 char filename[FILENAME_MAX];
95 sprintf(filename, "jsonschema/tests/draft4/%s", filenames[i]);
96 char* json = ReadFile(filename, jsonAllocator);
97 if (!json) {
98 printf("json test suite file %s not found", filename);
99 return;
100 }
101
102 Document d;
103 d.Parse(json);
104 if (d.HasParseError()) {
105 printf("json test suite file %s has parse error", filename);
106 return;
107 }
108
109 for (Value::ConstValueIterator schemaItr = d.Begin(); schemaItr != d.End(); ++schemaItr) {
110 std::string schemaDescription = (*schemaItr)["description"].GetString();
111 if (IsExcludeTestSuite(schemaDescription))
112 continue;
113
114 TestSuite* ts = new TestSuite;
115 ts->schema = new SchemaDocument((*schemaItr)["schema"]);
116
117 const Value& tests = (*schemaItr)["tests"];
118 for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {
119 if (IsExcludeTest(schemaDescription + ", " + (*testItr)["description"].GetString()))
120 continue;
121
122 Document* d2 = new Document;
123 d2->CopyFrom((*testItr)["data"], d2->GetAllocator());
124 ts->tests.push_back(d2);
125 }
126 testSuites.push_back(ts);
127 }
128 }
129 }
Allocator & GetAllocator()
Get the allocator of this document.
Definition document.h:2412
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition document.h:578
Default memory allocator used by the parser and DOM.
Definition allocators.h:115
TestSuiteList testSuites
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition document.h:2506
GenericSchemaDocument< Value, CrtAllocator > SchemaDocument
Definition fwd.h:138
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
#define ARRAY_SIZE(a)
CK_ULONG d
Here is the call graph for this function:

◆ TearDown()

virtual void Schema::TearDown ( )
inlinevirtual

Definition at line 131 of file schematest.cpp.

131 {
132 PerfTest::TearDown();
133 for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr)
134 delete *itr;
135 testSuites.clear();
136 }

Member Data Documentation

◆ testSuites

TestSuiteList Schema::testSuites
protected

Definition at line 195 of file schematest.cpp.


The documentation for this class was generated from the following file: