This repository has been archived on 2023-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
frostbite/snowlib_test/LmpFileTest.cpp
2020-02-06 00:23:46 +00:00

61 lines
1.7 KiB
C++

#include "LmpFile.h"
#define BOOST_TEST_MODULE LmpFileTest
#include "boost/test/included/unit_test.hpp"
const unsigned char lmpData[] = {
// Some initial data that should be skipped, 12 bytes
0xba, 0xdf, 0x00, 0x0d,
0xba, 0xdf, 0x00, 0x0d,
0xba, 0xdf, 0x00, 0x0d,
0x02, 0x00, 0x00,0x00, // Number of entries
// Entry 1
// Name of 56 bytes
'f', 'i', 'l', 'e', '1', '.', 'a', 'b',
'c', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// offset to entry data from start
64*2+4, 0, 0, 0,
// length of entry data
16, 0, 0, 0,
// Entry 2
// Name of 56 bytes
'f', 'i', 'l', 'e', '2', '.', 'a', 'b',
'd', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// offset to entry data from start
64*2+4+16, 0, 0, 0,
// length of entry data
16, 0, 0, 0,
// Entry 1 data, 16 bytes
1, 2, 3, 4, 5, 6, 7, 8,
9, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
// Entry 2 data, 16 bytes
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
};
BOOST_AUTO_TEST_CASE( lmp_test )
{
LmpFile* lmpFile = new LmpFile(DARK_ALLIANCE, lmpData, 12, sizeof(lmpData));
LmpEntry* entry = lmpFile->findEntry("file2.abd");
BOOST_CHECK(entry != NULL);
delete entry;
delete lmpFile;
}