diff --git a/itf/tests/regression.rs b/itf/tests/regression.rs index f37bfe0..c991346 100644 --- a/itf/tests/regression.rs +++ b/itf/tests/regression.rs @@ -136,6 +136,34 @@ fn test_bigint_to_int() { assert!(itf::from_value::(itf).is_ok()); } +#[test] +fn test_enum_deserialization_failure() { + let itf = serde_json::json!({ + "_foo": {"#bigint": "1"}, + "typ": "Foo", + }); + + #[derive(Deserialize, Debug)] + #[serde(tag = "typ")] + enum FooBarInt { + // try to deserialize _foo as i64, instead of BigInt + Foo { _foo: i64 }, + Bar { _bar: String }, + } + + assert!(itf::from_value::(itf.clone()).is_err()); + + #[derive(Deserialize, Debug)] + #[serde(tag = "typ")] + enum FooBarBigInt { + // can deserialize _foo to BigInt + Foo { _foo: num_bigint::BigInt }, + Bar { _bar: String }, + } + + assert!(itf::from_value::(itf).is_ok()); +} + #[test] fn test_complete() { use std::collections::{BTreeSet, HashMap, HashSet};