-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9530a90
commit ec27522
Showing
5 changed files
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ categories = ["file-format", "audio", "games"] | |
[dependencies] | ||
paste = "1.0" | ||
byteorder = "1.4" | ||
diff = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
mod tests { | ||
use super::super::parser::read_nbs; | ||
use super::super::Song; | ||
const TEST_FILE_SOURCE: &str = "test_files/Megalovania.nbs"; | ||
const TEST_FILE_DEST: &str = "test_files/MegalovaniaTest.nbs"; | ||
use diff::chars; | ||
const TEST_FILES: [&str;2] = ["test_files/Megalovania.nbs", "test_files/DB.nbs"]; | ||
|
||
#[test] | ||
fn io() { | ||
let mut file_before_writing = read_nbs(TEST_FILE_SOURCE).expect("Some reading error occured before writing"); | ||
fn io() { for test_file in TEST_FILES { | ||
let mut file_before_writing = read_nbs(test_file).expect("Some reading error occured before writing"); | ||
|
||
let test_file_dest = (test_file.to_string() + "Test"); | ||
|
||
file_before_writing.save(TEST_FILE_DEST, 5).expect("Some writing error ocurred"); | ||
file_before_writing.save(test_file_dest.as_str(), file_before_writing.header.version.unwrap() as u8).expect("Some writing error ocurred"); | ||
|
||
let file_after_writing = read_nbs(TEST_FILE_DEST).expect("Some reading error occured after writing"); | ||
let file_after_writing = read_nbs(test_file_dest.as_str()).expect("Some reading error occured after writing"); | ||
|
||
assert_eq!(file_before_writing, file_after_writing); | ||
} | ||
if file_before_writing != file_after_writing { | ||
let dbg_before = format!("{:?}", file_before_writing); | ||
let dbg_after = format!("{:?}", file_after_writing); | ||
for diff in chars(dbg_before.as_str(), dbg_after.as_str()) { | ||
match diff { | ||
diff::Result::Left(l) => println!("\n\n- {}\n\n", l), | ||
diff::Result::Right(r) => println!("\n\n+ {}\n\n", r), | ||
diff::Result::Both(b, _) => print!("{}", b), | ||
} | ||
} panic!("{} failed!", test_file); | ||
} | ||
}} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.