mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 11:47:46 +00:00
Add a test to CFG, to see if it panics on clearly invalid garbage data
This commit is contained in:
parent
74940c0436
commit
170c61b556
2 changed files with 17 additions and 1 deletions
BIN
resources/tests/random
Normal file
BIN
resources/tests/random
Normal file
Binary file not shown.
16
src/cfg.rs
16
src/cfg.rs
|
@ -131,6 +131,14 @@ mod tests {
|
||||||
read(d).unwrap()
|
read(d).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn common_setup_invalid() -> ByteBuffer {
|
||||||
|
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
|
d.push("resources/tests");
|
||||||
|
d.push("random");
|
||||||
|
|
||||||
|
read(d).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_parsing() {
|
fn basic_parsing() {
|
||||||
let cfg = common_setup();
|
let cfg = common_setup();
|
||||||
|
@ -150,4 +158,12 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(modified_cfg, cfg_buffer);
|
assert_eq!(modified_cfg, cfg_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_invalid() {
|
||||||
|
let cfg = common_setup_invalid();
|
||||||
|
|
||||||
|
// Feeding it invalid data should not panic
|
||||||
|
ConfigFile::from_existing(&cfg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue