Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
e0a8a327
Commit
e0a8a327
authored
May 13, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add meta schema test (failing now)
parent
979088de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
schematest.cpp
test/unittest/schematest.cpp
+24
-6
No files found.
test/unittest/schematest.cpp
View file @
e0a8a327
...
...
@@ -837,7 +837,7 @@ TEST(SchemaValidator, AllOf_Nested) {
INVALIDATE
(
s
,
"123"
,
""
,
"allOf"
,
""
);
}
static
char
*
ReadFile
(
const
char
*
filename
,
size_t
&
length
)
{
static
char
*
ReadFile
(
const
char
*
filename
)
{
const
char
*
paths
[]
=
{
"%s"
,
"bin/%s"
,
...
...
@@ -858,7 +858,7 @@ static char* ReadFile(const char* filename, size_t& length) {
return
0
;
fseek
(
fp
,
0
,
SEEK_END
);
length
=
(
size_t
)
ftell
(
fp
);
size_t
length
=
(
size_t
)
ftell
(
fp
);
fseek
(
fp
,
0
,
SEEK_SET
);
char
*
json
=
(
char
*
)
malloc
(
length
+
1
);
size_t
readLength
=
fread
(
json
,
1
,
length
,
fp
);
...
...
@@ -867,6 +867,26 @@ static char* ReadFile(const char* filename, size_t& length) {
return
json
;
}
TEST
(
SchemaValidator
,
ValidateMetaSchema
)
{
char
*
json
=
ReadFile
(
"draft-04/schema"
);
Document
d
;
d
.
Parse
(
json
);
ASSERT_FALSE
(
d
.
HasParseError
());
SchemaDocument
sd
(
d
);
SchemaValidator
validator
(
sd
);
if
(
!
d
.
Accept
(
validator
))
{
StringBuffer
sb
;
validator
.
GetInvalidSchemaPointer
().
StringifyUriFragment
(
sb
);
printf
(
"Invalid schema: %s
\n
"
,
sb
.
GetString
());
printf
(
"Invalid keyword: %s
\n
"
,
validator
.
GetInvalidSchemaKeyword
());
sb
.
Clear
();
validator
.
GetInvalidDocumentPointer
().
StringifyUriFragment
(
sb
);
printf
(
"Invalid document: %s
\n
"
,
sb
.
GetString
());
//ADD_FAILURE();
}
free
(
json
);
}
class
RemoteSchemaDocumentProvider
:
public
IRemoteSchemaDocumentProvider
{
public
:
RemoteSchemaDocumentProvider
()
:
documentAllocator_
(),
schemaAllocator_
()
{
...
...
@@ -880,8 +900,7 @@ public:
for
(
size_t
i
=
0
;
i
<
kCount
;
i
++
)
{
sd_
[
i
]
=
0
;
size_t
length
;
char
*
json
=
ReadFile
(
filenames
[
i
],
length
);
char
*
json
=
ReadFile
(
filenames
[
i
]);
if
(
!
json
)
{
printf
(
"json remote file %s not found"
,
filenames
[
i
]);
ADD_FAILURE
();
...
...
@@ -972,8 +991,7 @@ TEST(SchemaValidator, TestSuite) {
for
(
size_t
i
=
0
;
i
<
sizeof
(
filenames
)
/
sizeof
(
filenames
[
0
]);
i
++
)
{
char
filename
[
FILENAME_MAX
];
sprintf
(
filename
,
"jsonschema/tests/draft4/%s"
,
filenames
[
i
]);
size_t
length
;
char
*
json
=
ReadFile
(
filename
,
length
);
char
*
json
=
ReadFile
(
filename
);
if
(
!
json
)
{
printf
(
"json test suite file %s not found"
,
filename
);
ADD_FAILURE
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment