implements PLN-0171 variable glyph palette test coverage
This commit is contained in:
@@ -2184,6 +2184,29 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_decode_glyph_bank_rejects_mismatched_variable_serialized_size() {
|
||||
let mut entry = test_glyph_asset_entry_with_palette_count("glyphs", 16, 16, 3);
|
||||
entry.size += 1;
|
||||
|
||||
let err = match AssetManager::decode_glyph_bank_from_buffer(
|
||||
&entry,
|
||||
&test_glyph_asset_data_with_palette_count(3),
|
||||
) {
|
||||
Ok(_) => panic!("glyph decode should reject invalid serialized size"),
|
||||
Err(err) => err,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
err,
|
||||
format!(
|
||||
"Invalid GLYPHBANK serialized size: expected {}, got {}",
|
||||
expected_glyph_payload_size(16, 16, 3),
|
||||
expected_glyph_payload_size(16, 16, 3) + 1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_op_mode_for_glyphs_none_stages_in_memory() {
|
||||
let entry = test_glyph_asset_entry("glyphs", 16, 16);
|
||||
|
||||
@@ -14,7 +14,7 @@ use prometeu_hal::cartridge::{
|
||||
use prometeu_hal::color::Color;
|
||||
use prometeu_hal::glyph::Glyph;
|
||||
use prometeu_hal::glyph_bank::{
|
||||
TileSize, GLYPH_BANK_COLORS_PER_PALETTE, GLYPH_BANK_PALETTE_COUNT_V1,
|
||||
TileSize, GLYPH_BANK_COLORS_PER_PALETTE, GLYPH_BANK_MAX_PALETTE_COUNT_V1,
|
||||
};
|
||||
use prometeu_hal::scene_bank::SceneBank;
|
||||
use prometeu_hal::scene_layer::{ParallaxFactor, SceneLayer};
|
||||
@@ -275,15 +275,16 @@ fn build_glyph_asset() -> (AssetEntry, Vec<u8>) {
|
||||
bank_type: BankType::GLYPH,
|
||||
offset: 0,
|
||||
size: payload.len() as u64,
|
||||
decoded_size: (8 * 8 + GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4)
|
||||
decoded_size: (8 * 8
|
||||
+ GLYPH_BANK_MAX_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4)
|
||||
as u64,
|
||||
codec: AssetCodec::None,
|
||||
metadata: serde_json::json!({
|
||||
"tile_size": 8,
|
||||
"width": 8,
|
||||
"height": 8,
|
||||
"palette_count": GLYPH_BANK_PALETTE_COUNT_V1,
|
||||
"palette_authored": GLYPH_BANK_PALETTE_COUNT_V1
|
||||
"palette_count": GLYPH_BANK_MAX_PALETTE_COUNT_V1,
|
||||
"palette_authored": GLYPH_BANK_MAX_PALETTE_COUNT_V1
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -292,8 +293,8 @@ fn build_glyph_asset() -> (AssetEntry, Vec<u8>) {
|
||||
|
||||
fn build_palette_bytes() -> Vec<u8> {
|
||||
let mut bytes =
|
||||
Vec::with_capacity(GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4);
|
||||
for palette_id in 0..GLYPH_BANK_PALETTE_COUNT_V1 {
|
||||
Vec::with_capacity(GLYPH_BANK_MAX_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4);
|
||||
for palette_id in 0..GLYPH_BANK_MAX_PALETTE_COUNT_V1 {
|
||||
for color_index in 0..GLYPH_BANK_COLORS_PER_PALETTE {
|
||||
let color = if color_index == 1 { stress_color(palette_id) } else { Color::BLACK };
|
||||
bytes.extend_from_slice(&color.raw().to_be_bytes());
|
||||
|
||||
Reference in New Issue
Block a user