Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Bug: deserialization for enums with #[serde(flatten)] is not working #13

Closed
josecelano opened this issue Sep 25, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@josecelano
Copy link
Member

I think these two failing tests could be the same problem because they both use #[serde(flatten)] for an enum field.

  • cargo test ser_de_flattened_enum -- --nocapture
  • cargo test ser_de_flattened_adjacently_tagged_enum -- --nocapture

Failing test 1

$ cargo test ser_de_flattened_enum -- --nocapture
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/lib.rs (target/debug/deps/torrust_serde_bencode-61b7eea2ea5618bf)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/tests.rs (target/debug/deps/tests-b55451bec73c8180)

running 1 test
bytes: "d12:message_type8:Responsee"
bytes: "d12:message_type8:Responsee"
thread 'ser_de_flattened_enum' panicked at tests/tests.rs:34:41:
called `Result::unwrap()` on an `Err` value: InvalidType("Invalid Type: byte array (expected: `string or map`)")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test ser_de_flattened_enum ... FAILED

failures:

failures:
    ser_de_flattened_enum

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 42 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test tests`

Failing test 2

$ cargo test ser_de_flattened_adjacently_tagged_enum -- --nocapture
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/lib.rs (target/debug/deps/torrust_serde_bencode-61b7eea2ea5618bf)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/tests.rs (target/debug/deps/tests-b55451bec73c8180)

running 1 test
bytes: "d7:contentd5:tokeni456ee2:idi123e4:type7:Requeste"
thread 'ser_de_flattened_adjacently_tagged_enum' panicked at tests/tests.rs:34:41:
called `Result::unwrap()` on an `Err` value: InvalidType("Invalid Type: byte array (expected: `string or map`)")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test ser_de_flattened_adjacently_tagged_enum ... FAILED

failures:

failures:
    ser_de_flattened_adjacently_tagged_enum

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 42 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test tests`
@josecelano
Copy link
Member Author

@josecelano
Copy link
Member Author

Moved to upstream repo: toby#39

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant