diff options
author | Vincent Ambo <mail@tazj.in> | 2023-01-01T18·39+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-01-04T17·21+0000 |
commit | 0e88eb83efb194427329ccffd3b48671e1d72107 (patch) | |
tree | 86f5c4fd48ac9eca9956db40f8c1355ac0e06389 /tvix/serde/src/de_tests.rs | |
parent | 0c17718dd10f8b53b523eb8c54a525c7af166712 (diff) |
feat(tvix/serde): add newtype & tuple deserialisation r/5584
Only missing enums at this point, but they're a bit of a beast. Change-Id: I4ad47c034851f9a8794c81f39a5149a8ac1826e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7716 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/serde/src/de_tests.rs')
-rw-r--r-- | tvix/serde/src/de_tests.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tvix/serde/src/de_tests.rs b/tvix/serde/src/de_tests.rs index 1b9bc04d2362..1613b874d949 100644 --- a/tvix/serde/src/de_tests.rs +++ b/tvix/serde/src/de_tests.rs @@ -80,3 +80,18 @@ fn deserialize_struct() { } ); } + +#[test] +fn deserialize_newtype() { + #[derive(Debug, Deserialize, PartialEq)] + struct Number(usize); + + let result: Number = from_str("42").expect("should deserialize"); + assert_eq!(result, Number(42)); +} + +#[test] +fn deserialize_tuple() { + let result: (String, usize) = from_str(r#" [ "foo" 42 ] "#).expect("should deserialize"); + assert_eq!(result, ("foo".into(), 42)); +} |