Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurZucker committed Aug 6, 2024
1 parent a010f6b commit 021eec2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tokenizers/src/decoders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,11 @@ mod tests {
let json = r#"{"type":"Sequence","decoders":[{},{"type":"Metaspace","replacement":"▁","prepend_scheme":"always"}]}"#;
assert!(serde_json::from_str::<DecoderWrapper>(json).is_err());
}


#[test]
fn decoder_deserialization_no_type() {
let json = r#"{"replacement":"▁","prepend_scheme":"always"}"#;
assert!(serde_json::from_str::<DecoderWrapper>(json).is_err());
}
}
6 changes: 6 additions & 0 deletions tokenizers/src/pre_tokenizers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,10 @@ mod tests {
PreTokenizerWrapper::WhitespaceSplit(WhitespaceSplit {})
);
}

#[test]
fn pre_tokenizer_deserialization_no_type() {
let json = r#"{"replacement":"▁","add_prefix_space":true, "prepend_scheme":"always"}}"#;
assert!(serde_json::from_str::<PreTokenizerWrapper>(json).is_err());
}
}
6 changes: 6 additions & 0 deletions tokenizers/src/processors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,10 @@ mod tests {
PostProcessorWrapper::Bert(bert)
);
}

#[test]
fn post_processor_deserialization_no_type() {
let json = r#"{"sep":["[SEP]",102],"cls":["[CLS]",101]}}"#;
assert!(serde_json::from_str::<PostProcessorWrapper>(json).is_err());
}
}

0 comments on commit 021eec2

Please sign in to comment.