Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
0d872f83
Commit
0d872f83
authored
Aug 28, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test of capnp encode/decode/eval.
parent
d5965282
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
188 additions
and
4 deletions
+188
-4
Makefile.am
c++/Makefile.am
+1
-1
capnp-test.ekam-rule
c++/src/capnp/compiler/capnp-test.ekam-rule
+50
-0
capnp-test.sh
c++/src/capnp/compiler/capnp-test.sh
+63
-0
evolution-test.c++
c++/src/capnp/compiler/evolution-test.c++
+2
-3
binary
c++/src/capnp/testdata/binary
+0
-0
flat
c++/src/capnp/testdata/flat
+0
-0
packed
c++/src/capnp/testdata/packed
+0
-0
pretty.txt
c++/src/capnp/testdata/pretty.txt
+71
-0
short.txt
c++/src/capnp/testdata/short.txt
+1
-0
No files found.
c++/Makefile.am
View file @
0d872f83
...
...
@@ -300,4 +300,4 @@ nodist_capnp_test_SOURCES = $(test_capnpc_outputs)
capnp_evolution_test_LDADD
=
libcapnpc.la libcapnp.la libkj.la
capnp_evolution_test_SOURCES
=
src/capnp/compiler/evolution-test.c++
TESTS
=
capnp-test capnp-evolution-test
TESTS
=
capnp-test capnp-evolution-test
src/capnp/compiler/capnp-test.sh
c++/src/capnp/compiler/capnp-test.ekam-rule
0 → 100755
View file @
0d872f83
#! /bin/sh
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This is a one-off test rule.
set
-eu
echo
findProvider file:capnp
read
CAPNP
export
CAPNP
echo
findProvider file:capnp/compiler/capnp-test.sh
read
CAPNP_TEST
# Register our interest in the testdata files.
echo
findProvider file:capnp/testdata/binary
;
read
JUNK
echo
findProvider file:capnp/testdata/flat
;
read
JUNK
echo
findProvider file:capnp/testdata/packed
;
read
JUNK
echo
findProvider file:capnp/testdata/pretty.txt
;
read
JUNK
echo
findProvider file:capnp/testdata/short.txt
;
read
JUNK
# Register our interest in the schema files.
echo
findProvider file:capnp/c++.capnp
echo
findProvider file:capnp/test.capnp
$CAPNP_TEST
>
&2
echo
passed
c++/src/capnp/compiler/capnp-test.sh
0 → 100755
View file @
0d872f83
#! /bin/sh
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Tests the `capnp` tool's various commands, other than `compile`.
set
-eu
fail
()
{
echo
"FAILED:
$@
"
>
&2
exit
1
}
if
test
-e
./capnp
;
then
CAPNP
=
${
CAPNP
:-
./capnp
}
else
CAPNP
=
${
CAPNP
:-
capnp
}
fi
SCHEMA
=
$(
dirname
"
$0
"
)
/../test.capnp
TESTDATA
=
$(
dirname
"
$0
"
)
/../testdata
$CAPNP
encode
$SCHEMA
TestAllTypes <
$TESTDATA
/short.txt | cmp
$TESTDATA
/binary
||
fail encode
$CAPNP
encode
--flat
$SCHEMA
TestAllTypes <
$TESTDATA
/short.txt | cmp
$TESTDATA
/flat
||
fail encode flat
$CAPNP
encode
--packed
$SCHEMA
TestAllTypes <
$TESTDATA
/short.txt | cmp
$TESTDATA
/packed
||
fail encode packed
$CAPNP
encode
$SCHEMA
TestAllTypes <
$TESTDATA
/pretty.txt | cmp
$TESTDATA
/binary
||
fail parse pretty
$CAPNP
decode
$SCHEMA
TestAllTypes <
$TESTDATA
/binary | cmp
$TESTDATA
/pretty.txt
||
fail decode
$CAPNP
decode
--flat
$SCHEMA
TestAllTypes <
$TESTDATA
/flat | cmp
$TESTDATA
/pretty.txt
||
fail decode flat
$CAPNP
decode
--packed
$SCHEMA
TestAllTypes <
$TESTDATA
/packed | cmp
$TESTDATA
/pretty.txt
||
fail decode packed
$CAPNP
decode
--short
$SCHEMA
TestAllTypes <
$TESTDATA
/binary | cmp
$TESTDATA
/short.txt
||
fail decode short
test_eval
()
{
test
"x
$(
$CAPNP
eval
$SCHEMA
$1
)
"
=
"x
$2
"
||
fail
eval
"
$1
==
$2
"
}
test_eval TestDefaults.uInt32Field 3456789012
test_eval TestDefaults.structField.textField
'"baz"'
test_eval TestDefaults.int8List
"[111, -111]"
test_eval
'TestDefaults.structList[1]'
'( textField = "structlist 2" )'
test_eval globalStruct
'(int32Field = 54321)'
test_eval TestConstants.enumConst corge
test_eval
'TestListDefaults.lists.int32ListList[2][0]'
12341234
c++/src/capnp/compiler/evolution-test.c++
View file @
0d872f83
...
...
@@ -265,7 +265,7 @@ static ChangeInfo structGroupifyFields(
groupNested
.
adoptWithCaveats
(
i
,
kj
::
mv
(
groupified
[
i
]));
}
newGroup
.
initName
().
setValue
(
kj
::
str
(
"g"
,
groupNested
[
0
].
getName
().
getValue
()));
newGroup
.
initName
().
setValue
(
kj
::
str
(
"g"
,
nextOrdinal
,
"x"
,
groupNested
[
0
].
getName
().
getValue
()));
newGroup
.
getId
().
setUnspecified
();
newGroup
.
setGroup
();
...
...
@@ -861,8 +861,7 @@ public:
{
kj
::
String
text
=
kj
::
str
(
"Randomly testing backwards-compatibility scenarios...
\n
"
"seed = "
,
seed
,
" <- PLEASE RECORD THIS NUMBER IF THE TEST FAILS
\n
"
);
"Randomly testing backwards-compatibility scenarios with seed: "
,
seed
,
"
\n
"
);
kj
::
FdOutputStream
(
STDOUT_FILENO
).
write
(
text
.
begin
(),
text
.
size
());
}
...
...
c++/src/capnp/testdata/binary
0 → 100644
View file @
0d872f83
File added
c++/src/capnp/testdata/flat
0 → 100644
View file @
0d872f83
File added
c++/src/capnp/testdata/packed
0 → 100644
View file @
0d872f83
File added
c++/src/capnp/testdata/pretty.txt
0 → 100644
View file @
0d872f83
( boolField = true,
int8Field = -123,
int16Field = -12345,
int32Field = -12345678,
int64Field = -123456789012345,
uInt8Field = 234,
uInt16Field = 45678,
uInt32Field = 3456789012,
uInt64Field = 12345678901234567890,
float32Field = 1234.5,
float64Field = -1.23e47,
textField = "foo",
dataField = "bar",
structField = (
boolField = true,
int8Field = -12,
int16Field = 3456,
int32Field = -78901234,
int64Field = 56789012345678,
uInt8Field = 90,
uInt16Field = 1234,
uInt32Field = 56789012,
uInt64Field = 345678901234567890,
float32Field = -1.25e-10,
float64Field = 345,
textField = "baz",
dataField = "qux",
structField = (
textField = "nested",
structField = (
textField = "really nested" ) ),
enumField = baz,
voidList = [void, void, void],
boolList = [false, true, false, true, true],
int8List = [12, -34, -128, 127],
int16List = [1234, -5678, -32768, 32767],
int32List = [12345678, -90123456, -2147483648, 2147483647],
int64List = [123456789012345, -678901234567890, -9223372036854775808, 9223372036854775807],
uInt8List = [12, 34, 0, 255],
uInt16List = [1234, 5678, 0, 65535],
uInt32List = [12345678, 90123456, 0, 4294967295],
uInt64List = [123456789012345, 678901234567890, 0, 18446744073709551615],
float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37],
float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306],
textList = ["quux", "corge", "grault"],
dataList = ["garply", "waldo", "fred"],
structList = [
( textField = "x structlist 1" ),
( textField = "x structlist 2" ),
( textField = "x structlist 3" ) ],
enumList = [qux, bar, grault] ),
enumField = corge,
voidList = [void, void, void, void, void, void],
boolList = [true, false, false, true],
int8List = [111, -111],
int16List = [11111, -11111],
int32List = [111111111, -111111111],
int64List = [1111111111111111111, -1111111111111111111],
uInt8List = [111, 222],
uInt16List = [33333, 44444],
uInt32List = [3333333333],
uInt64List = [11111111111111111111],
float32List = [5555.5, inf, -inf, nan],
float64List = [7777.75, inf, -inf, nan],
textList = ["plugh", "xyzzy", "thud"],
dataList = ["oops", "exhausted", "rfc3092"],
structList = [
( textField = "structlist 1" ),
( textField = "structlist 2" ),
( textField = "structlist 3" ) ],
enumList = [foo, garply] )
c++/src/capnp/testdata/short.txt
0 → 100644
View file @
0d872f83
(boolField = true, int8Field = -123, int16Field = -12345, int32Field = -12345678, int64Field = -123456789012345, uInt8Field = 234, uInt16Field = 45678, uInt32Field = 3456789012, uInt64Field = 12345678901234567890, float32Field = 1234.5, float64Field = -1.23e47, textField = "foo", dataField = "bar", structField = (boolField = true, int8Field = -12, int16Field = 3456, int32Field = -78901234, int64Field = 56789012345678, uInt8Field = 90, uInt16Field = 1234, uInt32Field = 56789012, uInt64Field = 345678901234567890, float32Field = -1.25e-10, float64Field = 345, textField = "baz", dataField = "qux", structField = (textField = "nested", structField = (textField = "really nested")), enumField = baz, voidList = [void, void, void], boolList = [false, true, false, true, true], int8List = [12, -34, -128, 127], int16List = [1234, -5678, -32768, 32767], int32List = [12345678, -90123456, -2147483648, 2147483647], int64List = [123456789012345, -678901234567890, -9223372036854775808, 9223372036854775807], uInt8List = [12, 34, 0, 255], uInt16List = [1234, 5678, 0, 65535], uInt32List = [12345678, 90123456, 0, 4294967295], uInt64List = [123456789012345, 678901234567890, 0, 18446744073709551615], float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], textList = ["quux", "corge", "grault"], dataList = ["garply", "waldo", "fred"], structList = [(textField = "x structlist 1"), (textField = "x structlist 2"), (textField = "x structlist 3")], enumList = [qux, bar, grault]), enumField = corge, voidList = [void, void, void, void, void, void], boolList = [true, false, false, true], int8List = [111, -111], int16List = [11111, -11111], int32List = [111111111, -111111111], int64List = [1111111111111111111, -1111111111111111111], uInt8List = [111, 222], uInt16List = [33333, 44444], uInt32List = [3333333333], uInt64List = [11111111111111111111], float32List = [5555.5, inf, -inf, nan], float64List = [7777.75, inf, -inf, nan], textList = ["plugh", "xyzzy", "thud"], dataList = ["oops", "exhausted", "rfc3092"], structList = [(textField = "structlist 1"), (textField = "structlist 2"), (textField = "structlist 3")], enumList = [foo, garply])
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