Skip to content

Commit

Permalink
rafiune the test
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurZucker committed Aug 6, 2024
1 parent f306795 commit 4ecd4d0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tokenizers/src/processors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod tests {

#[test]
fn post_processor_deserialization_no_type() {
let json = r#"{"sep":["[SEP]",102],"cls":["[CLS]",101]}}"#;
let json = r#"{"add_prefix_space": true, "trim_offsets": false, "use_regex": false}"#;
let reconstructed = serde_json::from_str::<PostProcessorWrapper>(json);
match reconstructed {
Err(err) => assert_eq!(
Expand All @@ -99,5 +99,19 @@ mod tests {
),
_ => panic!("Expected an error here"),
}

let json = r#"{"sep":["[SEP]",102],"cls":["[CLS]",101]}"#;
let reconstructed = serde_json::from_str::<PostProcessorWrapper>(json);
match reconstructed {
Ok(processor) => assert!(matches!(processor, PostProcessorWrapper::Bert(_))),
Err(err) => panic!("{:?}",err)
}

let json = r#"{"sep":["</s>",2], "cls":["<s>",0], "trim_offsets":true, "add_prefix_space":true}"#;
let reconstructed = serde_json::from_str::<PostProcessorWrapper>(json);
match reconstructed {
Ok(processor) => assert!(matches!(processor, PostProcessorWrapper::Roberta(_))),
Err(err) => panic!("{:?}",err)
}
}
}

0 comments on commit 4ecd4d0

Please sign in to comment.