-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
5 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
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
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
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ mod test_cursor; | |
mod test_file; | ||
mod test_guid; | ||
mod test_property; | ||
mod package_version_525; |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::fs::File; | ||
use std::io::{Cursor, Read}; | ||
use std::path::Path; | ||
use gvas::game_version::GameVersion; | ||
use gvas::GvasFile; | ||
use crate::common::PACKAGE_VERSION_525_PATH; | ||
|
||
#[test] | ||
fn package_version_525() { | ||
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join(PACKAGE_VERSION_525_PATH); | ||
let mut file = File::open(path).expect("Failed to open test asset"); | ||
|
||
// Read the file in to a Vec<u8> | ||
let mut data = Vec::new(); | ||
file.read_to_end(&mut data) | ||
.expect("Failed to read test asset"); | ||
|
||
// Convert the Vec<u8> to a GvasFile | ||
let mut cursor = Cursor::new(data); | ||
let file = | ||
GvasFile::read(&mut cursor, GameVersion::Default).expect("Failed to parse gvas file"); | ||
|
||
// Convert the GvasFile back to a Vec<u8> | ||
let mut writer = Cursor::new(Vec::new()); | ||
file.write(&mut writer) | ||
.expect("Failed to serialize gvas file"); | ||
|
||
// Compare the two Vec<u8>s | ||
assert_eq!(cursor.get_ref(), writer.get_ref()); | ||
|
||
// Read the file back in again | ||
let mut reader = Cursor::new(writer.get_ref().to_owned()); | ||
let read_back = GvasFile::read(&mut reader, GameVersion::Default) | ||
.expect("Failed to parse serialized save file"); | ||
|
||
// Compare the two GvasFiles | ||
assert_eq!(file, read_back); | ||
} |