aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2018-04-08 16:13:00 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2018-04-08 16:13:00 +0300
commitd94b73731fb7da1f42f2bf0a6293070690bb9a5c (patch)
tree492c6d0f0a7ae5d77e2c3001296ccb695549c99d /tests
parentc065aed3140018bd2717566b21ec462c45ffe2a1 (diff)
downloadnimpb-d94b73731fb7da1f42f2bf0a6293070690bb9a5c.tar.gz
nimpb-d94b73731fb7da1f42f2bf0a6293070690bb9a5c.zip
Add initial message to JSON serialization support
Diffstat (limited to 'tests')
-rw-r--r--tests/conformance/conformance_nim.nim20
-rw-r--r--tests/conformance/failures.txt18
2 files changed, 33 insertions, 5 deletions
diff --git a/tests/conformance/conformance_nim.nim b/tests/conformance/conformance_nim.nim
index 9b30d26..461bc43 100644
--- a/tests/conformance/conformance_nim.nim
+++ b/tests/conformance/conformance_nim.nim
@@ -1,4 +1,5 @@
import endians
+import json
import streams
import strformat
@@ -27,7 +28,13 @@ proc myReadString(s: Stream, size: int): string =
raise newException(Exception, "failed to read data")
while true:
- var requestSize = readInt32Le(inputStream)
+ var requestSize = 0'i32
+
+ try:
+ requestSize = readInt32Le(inputStream)
+ except:
+ break
+
var requestData = myReadString(inputStream, requestSize)
let request = newConformance_ConformanceRequest(requestData)
@@ -36,19 +43,22 @@ while true:
if request.messageType == "protobuf_test_messages.proto2.TestAllTypesProto2":
response.skipped = "skipping proto2 tests"
- elif request.requestedOutputFormat == conformance_WireFormat.JSON:
- response.skipped = "dont know how to output json"
elif hasJsonPayload(request):
response.skipped = "dont know how to parse json"
else:
try:
let parsed = newprotobuf_test_messages_proto3_TestAllTypesProto3(string(request.protobufPayload))
- let ser = serialize(parsed)
- response.protobufPayload = bytes(ser)
+ if request.requestedOutputFormat == conformance_WireFormat.PROTOBUF:
+ let ser = serialize(parsed)
+ response.protobufPayload = bytes(ser)
+ elif request.requestedOutputFormat == conformance_WireFormat.JSON:
+ response.jsonPayload = $toJson(parsed)
except IOError as exc:
response.parse_error = exc.msg
except ParseError as exc:
response.parse_error = exc.msg
+ except ValueError as exc:
+ response.serializeError = exc.msg
except Exception as exc:
response.runtimeError = exc.msg
diff --git a/tests/conformance/failures.txt b/tests/conformance/failures.txt
new file mode 100644
index 0000000..5e8f520
--- /dev/null
+++ b/tests/conformance/failures.txt
@@ -0,0 +1,18 @@
+
+CONFORMANCE TEST BEGIN ====================================
+
+ERROR, test=Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.JsonOutput: Output was not equivalent to reference message: modified: optional_double: 2.2250738585072014e-308 -> 2.2250738585072009e-308
+. request=protobuf_payload: "a\232\231\231\231\231\231\271?a\377\377\377\377\377\377\357\177a\000\000\000\000\000\000\020\000" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3", response=json_payload: "{\"optionalDouble\":2.225073858507201e-308}"
+ERROR, test=Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.JsonOutput: JSON output we received from test was unparseable. request=protobuf_payload: "\321\002\232\231\231\231\231\231\271?\321\002\377\377\377\377\377\377\357\177\321\002\000\000\000\000\000\000\020\000" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3", response=json_payload: "{\"repeatedDouble\":[0.1,1.797693134862316e+308,2.225073858507201e-308]}"
+WARNING, test=Recommended.FieldMaskPathsDontRoundTrip.JsonOutput: Should have failed to serialize, but didn't. request=protobuf_payload: "\372\022\010\n\006fooBar" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3", response=json_payload: "{\"optionalFieldMask\":\"fooBar\"}"
+WARNING, test=Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput: Should have failed to serialize, but didn't. request=protobuf_payload: "\372\022\013\n\tfoo_3_bar" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3", response=json_payload: "{\"optionalFieldMask\":\"foo_3_bar\"}"
+WARNING, test=Recommended.FieldMaskTooManyUnderscore.JsonOutput: Should have failed to serialize, but didn't. request=protobuf_payload: "\372\022\n\n\010foo__bar" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3", response=json_payload: "{\"optionalFieldMask\":\"foo__bar\"}"
+
+These tests failed. If they can't be fixed right now, you can add them to the failure list so the overall suite can succeed. Add them to the failure list by running:
+ ./update_failure_list.py --add failing_tests.txt
+
+ Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.JsonOutput
+ Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.JsonOutput
+
+CONFORMANCE SUITE FAILED: 249 successes, 563 skipped, 0 expected failures, 2 unexpected failures.
+