Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
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
flatbuffers
Commits
53ce80ce
Commit
53ce80ce
authored
Oct 11, 2018
by
Frank Benkstein
Committed by
Wouter van Oortmerssen
Oct 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better output on TestError (#4979)
Print a slightly better error message when a TestError fails.
parent
233976c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
test.cpp
tests/test.cpp
+24
-5
No files found.
tests/test.cpp
View file @
53ce80ce
...
@@ -1166,16 +1166,35 @@ void FuzzTest2() {
...
@@ -1166,16 +1166,35 @@ void FuzzTest2() {
}
}
// Test that parser errors are actually generated.
// Test that parser errors are actually generated.
void
TestError
(
const
char
*
src
,
const
char
*
error_substr
,
void
TestError
_
(
const
char
*
src
,
const
char
*
error_substr
,
bool
strict_json
,
bool
strict_json
=
false
)
{
const
char
*
file
,
int
line
,
const
char
*
func
)
{
flatbuffers
::
IDLOptions
opts
;
flatbuffers
::
IDLOptions
opts
;
opts
.
strict_json
=
strict_json
;
opts
.
strict_json
=
strict_json
;
flatbuffers
::
Parser
parser
(
opts
);
flatbuffers
::
Parser
parser
(
opts
);
TEST_EQ
(
parser
.
Parse
(
src
),
false
);
// Must signal error
if
(
parser
.
Parse
(
src
))
{
// Must be the error we're expecting
TestFail
(
"true"
,
"false"
,
TEST_NOTNULL
(
strstr
(
parser
.
error_
.
c_str
(),
error_substr
));
(
"parser.Parse(
\"
"
+
std
::
string
(
src
)
+
"
\"
)"
).
c_str
(),
file
,
line
,
func
);
}
else
if
(
!
strstr
(
parser
.
error_
.
c_str
(),
error_substr
))
{
TestFail
(
parser
.
error_
.
c_str
(),
error_substr
,
(
"parser.Parse(
\"
"
+
std
::
string
(
src
)
+
"
\"
)"
).
c_str
(),
file
,
line
,
func
);
}
}
void
TestError_
(
const
char
*
src
,
const
char
*
error_substr
,
const
char
*
file
,
int
line
,
const
char
*
func
)
{
TestError_
(
src
,
error_substr
,
false
,
file
,
line
,
func
);
}
}
#ifdef WIN32
# define TestError(src, ...) \
TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__)
#else
# define TestError(src, ...) \
TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif
// Test that parsing errors occur as we'd expect.
// Test that parsing errors occur as we'd expect.
// Also useful for coverage, making sure these paths are run.
// Also useful for coverage, making sure these paths are run.
void
ErrorTest
()
{
void
ErrorTest
()
{
...
...
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