mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-27 06:27:45 +00:00
Add invalid data test to CharacterData
This commit is contained in:
parent
170c61b556
commit
363abc67da
1 changed files with 20 additions and 1 deletions
|
@ -6,6 +6,7 @@ use std::io::{BufWriter, Cursor};
|
|||
use binrw::{BinRead, BinWrite};
|
||||
use binrw::binrw;
|
||||
use crate::{ByteBuffer, ByteSpan};
|
||||
use crate::cfg::ConfigFile;
|
||||
use crate::common_file_operations::{read_bool_from, write_bool_as};
|
||||
|
||||
use crate::race::{Gender, Race, Subrace};
|
||||
|
@ -221,4 +222,22 @@ impl CharacterData {
|
|||
|
||||
Some(buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs::read;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_invalid() {
|
||||
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
d.push("resources/tests");
|
||||
d.push("random");
|
||||
|
||||
// Feeding it invalid data should not panic
|
||||
CharacterData::from_existing(&read(d).unwrap());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue