Skip to content

Commit

Permalink
Fix tuple variant serialization with serde
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
  • Loading branch information
Licenser committed Oct 8, 2024
1 parent e1b8d7d commit c86fd8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 15 additions & 1 deletion src/serde/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ where
if self.first {
Ok(())
} else {
iomap!(self.s.write(b"}"))
iomap!(self.s.write(b"]}"))
}
}
}
Expand Down Expand Up @@ -815,6 +815,20 @@ mod test {
#[cfg(not(target_arch = "wasm32"))]
use proptest::prelude::*;

#[test]
fn enum_tuple() {
#[derive(serde::Serialize, Clone)]
enum ErrType {
Instruction(i64, i64),
}

let err = ErrType::Instruction(2, 68800);

assert_eq!(
crate::to_string(&err).expect("failed to serialize"),
"{\"Instruction\":[2,68800]}",
);
}
#[test]
fn print_serde() {
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
Expand Down
3 changes: 0 additions & 3 deletions src/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ fn map1() {
assert_eq!(to_value(d1), Ok(Value::from(h)));
}

#[cfg(feature = "serde_impl")]
#[test]
fn tpl1() {
let mut d = String::from("[-65.613616999999977, 43.420273000000009]");
Expand Down Expand Up @@ -701,7 +700,6 @@ fn crazy_string() {
assert_eq!(v_simd, v_serde);
}

#[cfg(feature = "serde_impl")]
#[test]
fn event() {
#[derive(Deserialize, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -825,7 +823,6 @@ fn arb_json() -> BoxedStrategy<String> {
.boxed()
}

#[cfg(feature = "serde_impl")]
#[test]
fn int_map_key() -> Result<(), crate::Error> {
use std::collections::BTreeMap;
Expand Down

0 comments on commit c86fd8e

Please sign in to comment.