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

Introduce failing test for flattened enums #2

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
},
});
}