Skip to content

Commit

Permalink
assure test data is decoded successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Feb 20, 2021
1 parent c4a34c7 commit 85e9094
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ fs-err = "2.5"
tempdir = "0.3"
smush = "0.1.5"
env_logger = "0.8"
nlprule_030 = { package = "nlprule", version = "0.3.0" }
16 changes: 7 additions & 9 deletions build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ mod tests {
.join(Path::new(&tokenizer_filename("en")))
.with_extension("bin.gz");
assert!(tokenizer_path.exists());
smush::decode(&fs::read(tokenizer_path)?, smush::Codec::Gzip).unwrap();
let decoded = smush::decode(&fs::read(tokenizer_path)?, smush::Codec::Gzip).unwrap();

let _ = nlprule_030::Tokenizer::new_from(&mut decoded.as_slice()).unwrap();

Ok(())
}
Expand Down Expand Up @@ -704,6 +706,8 @@ mod tests {
let mut decoded = Vec::new();
decoder.read_to_end(&mut decoded).unwrap();

let _ = nlprule_030::Rules::new_from(&mut decoded.as_slice()).unwrap();

Ok(())
}

Expand Down Expand Up @@ -767,15 +771,9 @@ mod tests {
let rules_path = tempdir
.join(Path::new(&rules_filename("en")))
.with_extension("bin");
assert!(rules_path.exists());
assert!(rules_path.is_file());

// The following will always fail since the versions will mismatch and rebuilding does not make sense
// `get_build_dir` is tested separately
//
// ```rust,no_run
// let _ = nlprule::Rules::new(rules_path)
// .map_err(|e| Error::ValidationFailed("en".to_owned(), Binary::Rules, e))?;
// ```
let _ = nlprule_030::Rules::new(rules_path).unwrap();
Ok(())
}
}

0 comments on commit 85e9094

Please sign in to comment.