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

Commit

Permalink
Introduce failing test for flattened enums
Browse files Browse the repository at this point in the history
  • Loading branch information
nrempel authored and josecelano committed Sep 25, 2023
1 parent ecd700c commit 43ba81e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,35 @@ fn ser_de_field_vec_tuple() {

test_ser_de_eq(foo);
}

#[test]
fn ser_de_flattened_enum() {
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
struct KrpcMessage {
message_type: MessageType,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
enum MessageType {
Query,
Response,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
struct KrpcResponse {
#[serde(flatten)]
krpc: KrpcMessage,
}

// Passes
test_ser_de_eq(KrpcMessage {
message_type: MessageType::Response,
});

// Fails
test_ser_de_eq(KrpcResponse {
krpc: KrpcMessage {
message_type: MessageType::Response,
},
});
}

0 comments on commit 43ba81e

Please sign in to comment.