This repository has been archived on 2026-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
molotov/crates/molotov-core/tests/asset_read_test.rs

24 lines
706 B
Rust

// SPDX-License-Identifier: GPL-3.0-or-later
use molotov_core::assets::asset::AssetFile;
#[test]
fn test_asset_read_and_seek_flow() {
let data = b"ROBLOX_ASSET_CONTENT_12345".to_vec();
let mut asset = AssetFile::new(data);
assert_eq!(asset.length(), 26);
assert_eq!(asset.remaining_length(), 26);
let mut buf = [0u8; 6];
assert_eq!(asset.read(&mut buf), 6);
assert_eq!(&buf, b"ROBLOX");
assert_eq!(asset.remaining_length(), 20);
// Seek to offset 7 (SEEK_SET = 0)
assert_eq!(asset.seek(7, 0), 7);
assert_eq!(asset.remaining_length(), 19);
let mut next_buf = [0u8; 5];
assert_eq!(asset.read(&mut next_buf), 5);
assert_eq!(&next_buf, b"ASSET");
}