looklook 0.9.0

Descriptive signal synthesiser.
// Copyright 2026 Gabriel Bjørnager Jensen.
//
// This file is part of LOOKLOOK.
//
// LOOKLOOK is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later ver-
// sion.
//
// LOOKLOOK is distributed in the hope that it will be useful, but WITHOUT ANY WAR-
// RANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along
// with LOOKLOOK. If not, see <https://www.gnu.org/licenses/>.

//! Tests for [`Mem`].

#![cfg(test)]

use crate::isa::Long;
use crate::vm::Mem;

use std::assert_matches;

#[test]
fn test_mem_map_addr() {
	assert_matches!(
		Mem::map_addr(Long::from_u32(0x000000)),
		Ok(0x000000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x100000)),
		Ok(0x100000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x200000)),
		Ok(0x200000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x300000)),
		Ok(0x300000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x400000)),
		Ok(0x400000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x500000)),
		Ok(0x500000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x600000)),
		Ok(0x600000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x700000)),
		Ok(0x700000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x800000)),
		Ok(0x800000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x87FFFF)),
		Ok(0x87FFFF),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x880000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0x900000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xA00000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xB00000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xC00000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xD00000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xE00000)),
		Err(_),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xF00000)),
		Ok(0x880000),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xF003FF)),
		Ok(0x8803FF),
	);

	assert_matches!(
		Mem::map_addr(Long::from_u32(0xF00400)),
		Err(_),
	);
}