Skip to content

Commit

Permalink
Adding a few tests for decoder deserialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Aug 6, 2024
1 parent adc82cb commit 2d27761
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tokenizers/src/decoders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ mod tests {
#[test]
fn decoder_serialization_no_decode() {
let json = r#"{"type":"Sequence","decoders":[{},{"type":"Metaspace","replacement":"▁","prepend_scheme":"always"}]}"#;
assert!(serde_json::from_str::<DecoderWrapper>(json).is_err());
let parse = serde_json::from_str::<DecoderWrapper>(json);
match parse {
Err(err) => assert_eq!(
format!("{err}"),
"data did not match any variant of untagged enum DecoderWrapper"
),
_ => panic!("Expected error"),
}

let json = r#"{"replacement":"▁","prepend_scheme":"always"}"#;
let parse = serde_json::from_str::<DecoderWrapper>(json);
match parse {
Err(err) => assert_eq!(
format!("{err}"),
"data did not match any variant of untagged enum DecoderWrapper"
),
_ => panic!("Expected error"),
}

let json = r#"{"type":"Sequence","prepend_scheme":"always"}"#;
let parse = serde_json::from_str::<DecoderWrapper>(json);
match parse {
Err(err) => assert_eq!(
format!("{err}"),
"data did not match any variant of untagged enum DecoderWrapper"
),
_ => panic!("Expected error"),
}
}
}

0 comments on commit 2d27761

Please sign in to comment.