Initial commit
This commit is contained in:
commit
3304b53c41
38 changed files with 6573 additions and 0 deletions
25
tests/Unit/Texture/PNamesParserTest.php
Normal file
25
tests/Unit/Texture/PNamesParserTest.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Doom\Texture\PNamesParser;
|
||||
|
||||
test('parses PNAMES lump names', function (): void {
|
||||
$data = pack('V', 3)
|
||||
. pack('a8', 'BROWN1')
|
||||
. pack('a8', 'STARTAN3')
|
||||
. pack('a8', 'BIGDOOR2');
|
||||
|
||||
$pNames = PNamesParser::parseBytes($data);
|
||||
|
||||
expect($pNames)->toHaveCount(3);
|
||||
expect($pNames)->toBe(['BROWN1', 'STARTAN3', 'BIGDOOR2']);
|
||||
expect($pNames[1] ?? null)->toBe('STARTAN3');
|
||||
expect($pNames[10] ?? null)->toBeNull();
|
||||
expect(array_search('BIGDOOR2', $pNames, true))->toBe(2);
|
||||
expect(array_search('MISSING', $pNames, true))->toBeFalse();
|
||||
});
|
||||
|
||||
test('throws on truncated PNAMES lump', function (): void {
|
||||
$data = pack('V', 2) . pack('a8', 'ONLYONE');
|
||||
|
||||
expect(fn () => PNamesParser::parseBytes($data))->toThrow(RuntimeException::class);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue