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
676f0712
Commit
676f0712
authored
Jul 14, 2016
by
Raman
Committed by
GitHub
Jul 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test.cpp
parent
db99c1aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
test.cpp
tests/test.cpp
+6
-6
No files found.
tests/test.cpp
View file @
676f0712
...
...
@@ -814,14 +814,14 @@ void ErrorTest() {
TestError
(
"table X { Y:byte; } root_type X; { Y:1, Y:2 }"
,
"more than once"
);
}
float
TestValue
(
const
char
*
json
)
{
template
<
typename
T
>
T
TestValue
(
const
char
*
json
)
{
flatbuffers
::
Parser
parser
;
// Simple schema.
TEST_EQ
(
parser
.
Parse
(
"table X { Y:float; } root_type X;"
),
true
);
TEST_EQ
(
parser
.
Parse
(
std
::
string
(
"table X { Y:"
+
std
::
string
(
typeid
(
T
).
name
())
+
"; } root_type X;"
).
c_str
()
),
true
);
TEST_EQ
(
parser
.
Parse
(
json
),
true
);
auto
root
=
flatbuffers
::
GetRoot
<
float
>
(
parser
.
builder_
.
GetBufferPointer
());
auto
root
=
flatbuffers
::
GetRoot
<
T
>
(
parser
.
builder_
.
GetBufferPointer
());
// root will point to the table, which is a 32bit vtable offset followed
// by a float:
TEST_EQ
(
sizeof
(
flatbuffers
::
soffset_t
),
4
);
// Test assumes 32bit offsets
...
...
@@ -833,13 +833,13 @@ bool FloatCompare(float a, float b) { return fabs(a - b) < 0.001; }
// Additional parser testing not covered elsewhere.
void
ValueTest
()
{
// Test scientific notation numbers.
TEST_EQ
(
FloatCompare
(
TestValue
(
"{ Y:0.0314159e+2 }"
),
3.14159
),
true
);
TEST_EQ
(
FloatCompare
(
TestValue
<
float
>
(
"{ Y:0.0314159e+2 }"
),
3.14159
),
true
);
// Test conversion functions.
TEST_EQ
(
FloatCompare
(
TestValue
(
"{ Y:cos(rad(180)) }"
),
-
1
),
true
);
TEST_EQ
(
FloatCompare
(
TestValue
<
float
>
(
"{ Y:cos(rad(180)) }"
),
-
1
),
true
);
// Test negative hex constant.
TEST_EQ
(
TestValue
(
"{ Y:-0x80 }"
)
==
-
128
,
true
);
TEST_EQ
(
TestValue
<
int
>
(
"{ Y:-0x80 }"
)
==
-
128
,
true
);
}
void
EnumStringsTest
()
{
...
...
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