Skip to content

Commit 1a8c720

Browse files
committed
README on tests
1 parent 78952a5 commit 1a8c720

File tree

13 files changed

+80
-65
lines changed

13 files changed

+80
-65
lines changed

dist/protobuf.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

0 Bytes
Binary file not shown.

dist/protobuf.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codegen/verify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ function genVerifyValue(gen, field, fieldIndex, ref) {
190190
for (var j = 0; j < values.length; ++j) gen
191191
("case %d:", values[j]);
192192
gen
193+
("break")
193194
("}");
194195
} else if (field.resolvedType instanceof Type) { gen
195196
("var r;")

tests/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This folder contains all the tests, one per file.
2+
3+
It is essential that tests only use the cross-platform API that is also available in browsers:
4+
5+
* Use `load`, not `loadSync`
6+
* Use `Reader.create`, not `BufferReader`
7+
* Use `Writer.create`, not `BufferWriter`

tests/bench.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ tape.test("bench.proto and bench.json", function(test) {
99
return test.fail(err.message);
1010

1111
var Test = root.lookup("Test");
12+
1213
var data = require("../bench/bench.json");
1314

1415
test.equal(Test.verify(data), null, "should verify our test data");
15-
var writer = Test.encode(data);
16-
var decoded = Test.decode(writer.finish());
16+
17+
var decoded = Test.decode(Test.encode(data).finish());
1718
test.deepEqual(decoded, data, "should reproduce the original data when encoded and decoded again");
1819

1920
test.deepEqual(decoded.asJSON(), data, "should reproduce the original data asJSON");

tests/empty.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ tape.test("empty messages", function(test) {
1010
});
1111

1212
var Test = root.lookup("Test");
13+
1314
var buf = Test.encodeDelimited({}).finish();
15+
1416
test.equal(buf.length, 1, "should encodeDelimited to a buffer of length 1");
1517
test.equal(buf[0], 0, "should encodeDelimited a length of 0");
18+
1619
test.end();
1720
});

tests/oneof.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ tape.test("oneofs", function(test) {
99
return test.fail(err.message);
1010

1111
var Message = root.lookup("Message");
12+
1213
var message = Message.create({
1314
str: "a",
1415
num: 1
1516
});
17+
1618
test.equal(message.num, 1, "should initialize the last value");
1719
test.equal(message.getKind(), "num", "should reference the last value");
20+
1821
message.setKind('num');
1922
test.notOk(message.hasOwnProperty('str'), "should delete other values");
2023

0 commit comments

Comments
 (0)