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
d268d11c
Commit
d268d11c
authored
8 years ago
by
Michael Paulson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(test): Added mutation testing for scalar values.
This is a port of the tests found in test.cpp
parent
a351124c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
JavaScriptTest.js
tests/JavaScriptTest.js
+19
-1
No files found.
tests/JavaScriptTest.js
View file @
d268d11c
...
...
@@ -64,7 +64,10 @@ function main() {
fs
.
writeFileSync
(
'monsterdata_javascript_wire.mon'
,
new
Buffer
(
fbb
.
asUint8Array
()));
// Test it:
// Tests mutation first. This will verify that we did not trample any other
// part of the byte buffer.
testMutation
(
fbb
.
dataBuffer
());
testBuffer
(
fbb
.
dataBuffer
());
test64bit
();
...
...
@@ -74,6 +77,21 @@ function main() {
console
.
log
(
'FlatBuffers test: completed successfully'
);
}
function
testMutation
(
bb
)
{
var
monster
=
MyGame
.
Example
.
Monster
.
getRootAsMonster
(
bb
);
monster
.
mutate_hp
(
120
);
assert
.
strictEqual
(
monster
.
hp
(),
120
);
monster
.
mutate_hp
(
80
);
assert
.
strictEqual
(
monster
.
hp
(),
80
);
var
manaRes
=
monster
.
mutate_mana
(
10
);
assert
.
strictEqual
(
manaRes
,
false
);
// Field was NOT present, because default value.
// TODO: There is not the availability to mutate structs or vectors.
}
function
testBuffer
(
bb
)
{
assert
.
ok
(
MyGame
.
Example
.
Monster
.
bufferHasIdentifier
(
bb
));
...
...
This diff is collapsed.
Click to expand it.
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