Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow test failed #21

Open
db4 opened this issue Jul 25, 2018 · 1 comment
Open

Overflow test failed #21

db4 opened this issue Jul 25, 2018 · 1 comment

Comments

@db4
Copy link

db4 commented Jul 25, 2018

# Error: Test ppx_protobuf:0:Test wire format:2:test_overflow (in the log).
#
# File "src_test/test_wire.ml", line 92, characters 1-1:
# Error: Test ppx_protobuf:0:Test wire format:2:test_overflow (in the code).
#
# expected exception Protobuf.Decoder.Failure(Overflow("")), but no exception was raised.
# ------------------------------------------------------------------------------
# Ran: 31 tests in: 0.16 seconds.
# FAILED: Cases: 31 Tried: 31 Errors: 1 Failures: 1 Skip:  0 Todo: 0 Timeouts: 0.

Why

let test_overflow ctxt =
  if Sys.word_size = 32 then
    assert_raises Decoder.(Failure (Overflow ""))
                  (fun () -> Decoder.int_of_int32 "" 0xffffffffl)
  else

should overflow? 0xffffffffl = -1 on 32 bit systems - perfectly fits to int

@whitequark
Copy link
Collaborator

whitequark commented Jul 31, 2018

Oh, hm. Then the test is wrong. It should test for something like 0x7fffffff, an int32 value that doesn't fot into int. (Maybe Int32.max_int?) Can you please fix it and send a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants