Fix chunk tests to match encoder run logic fixes
This commit is contained in:
parent
a75e7fe445
commit
49b4b5b69c
1 changed files with 22 additions and 32 deletions
|
@ -42,20 +42,8 @@ fn test_encode_rgba() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "reference")]
|
fn test_encode_run_start_len1to62_3ch() {
|
||||||
fn test_encode_run_start_len1_3ch_ref() {
|
for n in 1..=62 {
|
||||||
test_chunk([[0, 0, 0], [11, 22, 33]], [QOI_OP_RUN | 0, QOI_OP_RGB]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(not(feature = "reference"))]
|
|
||||||
fn test_encode_run_start_len1_3ch_non_ref() {
|
|
||||||
test_chunk([[0, 0, 0], [11, 22, 33]], [QOI_OP_INDEX | hash([0, 0, 0]), QOI_OP_RGB]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_encode_run_start_len2to62_3ch() {
|
|
||||||
for n in 2..=62 {
|
|
||||||
let mut v = vec![[0, 0, 0]; n];
|
let mut v = vec![[0, 0, 0]; n];
|
||||||
v.push([11, 22, 33]);
|
v.push([11, 22, 33]);
|
||||||
test_chunk(v, [QOI_OP_RUN | (n as u8 - 1), QOI_OP_RGB]);
|
test_chunk(v, [QOI_OP_RUN | (n as u8 - 1), QOI_OP_RGB]);
|
||||||
|
@ -72,24 +60,8 @@ fn test_encode_run_start_len1to62_4ch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "reference")]
|
fn test_encode_run_start_63to124_3ch() {
|
||||||
fn test_encode_run_start_len63_3ch_ref() {
|
for n in 63..=124 {
|
||||||
let mut v = vec![[0, 0, 0]; 63];
|
|
||||||
v.push([11, 22, 33]);
|
|
||||||
test_chunk(v, [QOI_OP_RUN | 61, QOI_OP_RUN | 0, QOI_OP_RGB]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(not(feature = "reference"))]
|
|
||||||
fn test_encode_run_start_len63_3ch_non_ref() {
|
|
||||||
let mut v = vec![[0, 0, 0]; 63];
|
|
||||||
v.push([11, 22, 33]);
|
|
||||||
test_chunk(v, [QOI_OP_RUN | 61, QOI_OP_INDEX | hash([0, 0, 0]), QOI_OP_RGB]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_encode_run_start_64to124_3ch() {
|
|
||||||
for n in 64..=124 {
|
|
||||||
let mut v = vec![[0, 0, 0]; n];
|
let mut v = vec![[0, 0, 0]; n];
|
||||||
v.push([11, 22, 33]);
|
v.push([11, 22, 33]);
|
||||||
test_chunk(v, [QOI_OP_RUN | 61, QOI_OP_RUN | (n as u8 - 63), QOI_OP_RGB]);
|
test_chunk(v, [QOI_OP_RUN | 61, QOI_OP_RUN | (n as u8 - 63), QOI_OP_RGB]);
|
||||||
|
@ -123,6 +95,24 @@ fn test_encode_run_end_4ch() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_encode_run_mid_3ch() {
|
||||||
|
let px = [11, 33, 55];
|
||||||
|
test_chunk(
|
||||||
|
[[1, 99, 2], px, px, px, [1, 2, 3]],
|
||||||
|
[QOI_OP_RGB, 1, 99, 2, QOI_OP_RGB, px[0], px[1], px[2], QOI_OP_RUN | 1],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_encode_run_mid_4ch() {
|
||||||
|
let px = [11, 33, 55, 77];
|
||||||
|
test_chunk(
|
||||||
|
[[1, 99, 2, 3], px, px, px, [1, 2, 3, 4]],
|
||||||
|
[QOI_OP_RGBA, 1, 99, 2, 3, QOI_OP_RGBA, px[0], px[1], px[2], px[3], QOI_OP_RUN | 1],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encode_index_3ch() {
|
fn test_encode_index_3ch() {
|
||||||
let px = [101, 102, 103];
|
let px = [101, 102, 103];
|
||||||
|
|
Loading…
Reference in a new issue