-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix write_interleaved_bytes so that it actually writes interleaved (#287
) write_interleaved_bytes fails right now because it's just writing the bytes in their original sequence (see the results [here](https://github.com/rojo-rbx/rbx-dom/actions/runs/5296791237/jobs/9588138111))! This PR aims to close #286 by tweaking write_interleaved_bytes' implementation to interleave the bytes as it should.
- Loading branch information
1 parent
e99f37d
commit 5008074
Showing
3 changed files
with
77 additions
and
7 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
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,69 @@ | ||
use crate::core::{RbxReadExt, RbxWriteExt}; | ||
|
||
#[test] | ||
fn read_interleaved_bytes() { | ||
#[rustfmt::skip] | ||
let mut input: &[u8] = &[ | ||
0, 0, 0, | ||
1, 1, 1, | ||
2, 2, 2, | ||
3, 3, 3, | ||
4, 4, 4, | ||
5, 5, 5, | ||
6, 6, 6, | ||
7, 7, 7, | ||
8, 8, 8, | ||
9, 9, 9, | ||
10, 10, 10, | ||
11, 11, 11, | ||
12, 12, 12, | ||
13, 13, 13, | ||
14, 14, 14, | ||
15, 15, 15, | ||
]; | ||
|
||
let expected = &[ | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
]; | ||
|
||
let mut result = vec![[0; 16]; expected.len()]; | ||
input.read_interleaved_bytes::<16>(&mut result).unwrap(); | ||
|
||
assert_eq!(result, expected) | ||
} | ||
|
||
#[test] | ||
fn write_interleaved_bytes() { | ||
let input: &[[u8; 16]] = &[ | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], | ||
]; | ||
|
||
#[rustfmt::skip] | ||
let expected = &[ | ||
0, 0, 0, | ||
1, 1, 1, | ||
2, 2, 2, | ||
3, 3, 3, | ||
4, 4, 4, | ||
5, 5, 5, | ||
6, 6, 6, | ||
7, 7, 7, | ||
8, 8, 8, | ||
9, 9, 9, | ||
10, 10, 10, | ||
11, 11, 11, | ||
12, 12, 12, | ||
13, 13, 13, | ||
14, 14, 14, | ||
15, 15, 15, | ||
]; | ||
|
||
let mut result = Vec::new(); | ||
result.write_interleaved_bytes::<16>(input).unwrap(); | ||
|
||
assert_eq!(result, expected) | ||
} |
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,3 +1,4 @@ | ||
mod core_read_write; | ||
mod models; | ||
mod places; | ||
mod serializer; | ||
|