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
3675b33a
Commit
3675b33a
authored
Apr 14, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search more paths for different build situations
parent
3f7a3bcc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
33 deletions
+64
-33
documenttest.cpp
test/unittest/documenttest.cpp
+13
-6
encodedstreamtest.cpp
test/unittest/encodedstreamtest.cpp
+13
-6
filestreamtest.cpp
test/unittest/filestreamtest.cpp
+15
-3
jsoncheckertest.cpp
test/unittest/jsoncheckertest.cpp
+23
-18
No files found.
test/unittest/documenttest.cpp
View file @
3675b33a
...
...
@@ -101,14 +101,21 @@ TEST(Document, Parse) {
}
static
FILE
*
OpenEncodedFile
(
const
char
*
filename
)
{
const
char
*
paths
[]
=
{
"encodings/%s"
,
"bin/encodings/%s"
,
"../bin/encodings/%s"
,
"../../bin/encodings/%s"
,
"../../../bin/encodings/%s"
};
char
buffer
[
1024
];
sprintf
(
buffer
,
"encodings/%s"
,
filename
);
FILE
*
fp
=
fopen
(
buffer
,
"rb"
);
if
(
!
fp
)
{
sprintf
(
buffer
,
"../../bin/encodings/%s"
,
filename
);
fp
=
fopen
(
buffer
,
"rb"
)
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
paths
)
/
sizeof
(
paths
[
0
]);
i
++
)
{
sprintf
(
buffer
,
paths
[
i
],
filename
);
FILE
*
fp
=
fopen
(
buffer
,
"rb"
);
if
(
fp
)
return
fp
;
}
return
fp
;
return
0
;
}
TEST
(
Document
,
ParseStream_EncodedInputStream
)
{
...
...
test/unittest/encodedstreamtest.cpp
View file @
3675b33a
...
...
@@ -47,14 +47,21 @@ private:
protected
:
static
FILE
*
Open
(
const
char
*
filename
)
{
const
char
*
paths
[]
=
{
"encodings/%s"
,
"bin/encodings/%s"
,
"../bin/encodings/%s"
,
"../../bin/encodings/%s"
,
"../../../bin/encodings/%s"
};
char
buffer
[
1024
];
sprintf
(
buffer
,
"encodings/%s"
,
filename
);
FILE
*
fp
=
fopen
(
buffer
,
"rb"
);
if
(
!
fp
)
{
sprintf
(
buffer
,
"../../bin/encodings/%s"
,
filename
);
fp
=
fopen
(
buffer
,
"rb"
)
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
paths
)
/
sizeof
(
paths
[
0
]);
i
++
)
{
sprintf
(
buffer
,
paths
[
i
],
filename
);
FILE
*
fp
=
fopen
(
buffer
,
"rb"
);
if
(
fp
)
return
fp
;
}
return
fp
;
return
0
;
}
static
char
*
ReadFile
(
const
char
*
filename
,
bool
appendPath
,
size_t
*
outLength
)
{
...
...
test/unittest/filestreamtest.cpp
View file @
3675b33a
...
...
@@ -31,9 +31,21 @@ public:
FileStreamTest
()
:
filename_
(),
json_
(),
length_
()
{}
virtual
void
SetUp
()
{
FILE
*
fp
=
fopen
(
filename_
=
"data/sample.json"
,
"rb"
);
if
(
!
fp
)
fp
=
fopen
(
filename_
=
"../../bin/data/sample.json"
,
"rb"
);
const
char
*
paths
[]
=
{
"data/sample.json"
,
"bin/data/sample.json"
,
"../bin/data/sample.json"
,
"../../bin/data/sample.json"
,
"../../../bin/data/sample.json"
};
FILE
*
fp
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
paths
)
/
sizeof
(
paths
[
0
]);
i
++
)
{
fp
=
fopen
(
paths
[
i
],
"rb"
);
if
(
fp
)
{
filename_
=
paths
[
i
];
break
;
}
}
ASSERT_TRUE
(
fp
!=
0
);
fseek
(
fp
,
0
,
SEEK_END
);
...
...
test/unittest/jsoncheckertest.cpp
View file @
3675b33a
...
...
@@ -25,9 +25,22 @@
using
namespace
rapidjson
;
static
char
*
ReadFile
(
const
char
*
filename
,
size_t
&
length
)
{
FILE
*
fp
=
fopen
(
filename
,
"rb"
);
if
(
!
fp
)
fp
=
fopen
(
filename
,
"rb"
);
const
char
*
paths
[]
=
{
"jsonchecker/%s"
,
"bin/jsonchecker/%s"
,
"../bin/jsonchecker/%s"
,
"../../bin/jsonchecker/%s"
,
"../../../bin/jsonchecker/%s"
};
char
buffer
[
1024
];
FILE
*
fp
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
paths
)
/
sizeof
(
paths
[
0
]);
i
++
)
{
sprintf
(
buffer
,
paths
[
i
],
filename
);
fp
=
fopen
(
buffer
,
"rb"
);
if
(
fp
)
break
;
}
if
(
!
fp
)
return
0
;
...
...
@@ -51,17 +64,13 @@ TEST(JsonChecker, Reader) {
if
(
i
==
18
)
// fail18.json is valid in rapidjson, which has no limitation on depth of nesting.
continue
;
sprintf
(
filename
,
"
jsonchecker/
fail%d.json"
,
i
);
sprintf
(
filename
,
"fail%d.json"
,
i
);
size_t
length
;
char
*
json
=
ReadFile
(
filename
,
length
);
if
(
!
json
)
{
sprintf
(
filename
,
"../../bin/jsonchecker/fail%d.json"
,
i
);
json
=
ReadFile
(
filename
,
length
);
if
(
!
json
)
{
printf
(
"jsonchecker file %s not found"
,
filename
);
ADD_FAILURE
();
continue
;
}
printf
(
"jsonchecker file %s not found"
,
filename
);
ADD_FAILURE
();
continue
;
}
GenericDocument
<
UTF8
<>
,
CrtAllocator
>
document
;
// Use Crt allocator to check exception-safety (no memory leak)
...
...
@@ -76,16 +85,12 @@ TEST(JsonChecker, Reader) {
// passX.json
for
(
int
i
=
1
;
i
<=
3
;
i
++
)
{
sprintf
(
filename
,
"
jsonchecker/
pass%d.json"
,
i
);
sprintf
(
filename
,
"pass%d.json"
,
i
);
size_t
length
;
char
*
json
=
ReadFile
(
filename
,
length
);
if
(
!
json
)
{
sprintf
(
filename
,
"../../bin/jsonchecker/pass%d.json"
,
i
);
json
=
ReadFile
(
filename
,
length
);
if
(
!
json
)
{
printf
(
"jsonchecker file %s not found"
,
filename
);
continue
;
}
printf
(
"jsonchecker file %s not found"
,
filename
);
continue
;
}
GenericDocument
<
UTF8
<>
,
CrtAllocator
>
document
;
// Use Crt allocator to check exception-safety (no memory leak)
...
...
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