ULTIMA8: Update unit tests for function renames

This commit is contained in:
Matthew Duggan 2020-04-04 17:45:36 +09:00
parent 426af9fe5e
commit 4161cab9ba
2 changed files with 40 additions and 40 deletions

View File

@ -12,9 +12,9 @@ class U8IDataSourceTestSuite : public CxxTest::TestSuite {
void test_empty_ibuffer_source() {
Ultima::Ultima8::IBufferDataSource source(NULL, 0, false, false);
TS_ASSERT_EQUALS(source.getSize(), 0);
TS_ASSERT_EQUALS(source.getPos(), 0);
TS_ASSERT(source.eof());
TS_ASSERT_EQUALS(source.size(), 0);
TS_ASSERT_EQUALS(source.pos(), 0);
TS_ASSERT(source.eos());
}
void test_ibuffer_source() {
@ -24,24 +24,24 @@ class U8IDataSourceTestSuite : public CxxTest::TestSuite {
}
Ultima::Ultima8::IBufferDataSource source(buf, 256, false, false);
TS_ASSERT_EQUALS(source.getSize(), 256);
TS_ASSERT_EQUALS(source.getPos(), 0);
TS_ASSERT(!source.eof());
TS_ASSERT_EQUALS(source.size(), 256);
TS_ASSERT_EQUALS(source.pos(), 0);
TS_ASSERT(!source.eos());
TS_ASSERT_EQUALS(source.read1(), 1);
TS_ASSERT_EQUALS(source.read2(), 0x0302);
TS_ASSERT_EQUALS(source.readByte(), 1);
TS_ASSERT_EQUALS(source.readUint16LE(), 0x0302);
TS_ASSERT_EQUALS(source.read3(), 0x060504);
TS_ASSERT_EQUALS(source.read4(), 0x0A090807);
TS_ASSERT_EQUALS(source.readUint32LE(), 0x0A090807);
source.skip(-2);
TS_ASSERT_EQUALS(source.read2(), 0x0A09);
TS_ASSERT_EQUALS(source.readUint16LE(), 0x0A09);
source.seek(16);
TS_ASSERT_EQUALS(source.read2(), 0x1211);
TS_ASSERT_EQUALS(source.readUint16LE(), 0x1211);
TS_ASSERT_EQUALS(source.readX(1), 0x13);
TS_ASSERT_EQUALS(source.readX(3), 0x161514);
TS_ASSERT_EQUALS(source.readXS(1), 0x17);
TS_ASSERT_EQUALS(source.readXS(3), 0x1A1918);
source.seek(256);
TS_ASSERT(source.eof());
TS_ASSERT(source.eos());
}
void test_ibuffer_str_source() {
@ -49,15 +49,15 @@ class U8IDataSourceTestSuite : public CxxTest::TestSuite {
const char *buf = "this is a \r\n dos string and a \n unix string.";
Ultima::Std::string str;
Ultima::Ultima8::IBufferDataSource source(buf, strlen(buf), true, false);
TS_ASSERT(!source.eof());
TS_ASSERT(!source.eos());
source.readline(str);
TS_ASSERT(!source.eof());
TS_ASSERT(!source.eos());
TS_ASSERT_EQUALS(str, "this is a ");
source.readline(str);
TS_ASSERT_EQUALS(str, " dos string and a ");
source.readline(str);
TS_ASSERT_EQUALS(str, " unix string.");
TS_ASSERT(source.eof());
TS_ASSERT(source.eos());
*/
}

View File

@ -11,35 +11,35 @@ class U8ODataSourceTestSuite : public CxxTest::TestSuite {
void test_autobuffer_source() {
Ultima::Ultima8::OAutoBufferDataSource source(12);
TS_ASSERT_EQUALS(source.getSize(), 0);
TS_ASSERT_EQUALS(source.getPos(), 0);
TS_ASSERT_EQUALS(source.size(), 0);
TS_ASSERT_EQUALS(source.pos(), 0);
source.write1(0xBEEF);
TS_ASSERT_EQUALS(source.getSize(), 1);
TS_ASSERT_EQUALS(source.getPos(), 1);
source.writeByte(0xBEEF);
TS_ASSERT_EQUALS(source.size(), 1);
TS_ASSERT_EQUALS(source.pos(), 1);
for (int i = 0; i < 10; i++) {
source.write4(0x8088C0DE);
source.writeUint32LE(0x8088C0DE);
}
TS_ASSERT_EQUALS(source.getSize(), 41);
TS_ASSERT_EQUALS(source.getPos(), 41);
TS_ASSERT_EQUALS(source.size(), 41);
TS_ASSERT_EQUALS(source.pos(), 41);
source.skip(0);
TS_ASSERT_EQUALS(source.getSize(), 41);
TS_ASSERT_EQUALS(source.getPos(), 41);
TS_ASSERT_EQUALS(source.size(), 41);
TS_ASSERT_EQUALS(source.pos(), 41);
// Check trying to skip past the end
source.skip(2);
TS_ASSERT_EQUALS(source.getSize(), 41);
TS_ASSERT_EQUALS(source.getPos(), 41);
TS_ASSERT_EQUALS(source.size(), 41);
TS_ASSERT_EQUALS(source.pos(), 41);
source.skip(-2);
TS_ASSERT_EQUALS(source.getPos(), 39);
source.write1(0x99);
TS_ASSERT_EQUALS(source.getSize(), 41);
TS_ASSERT_EQUALS(source.getPos(), 40);
TS_ASSERT_EQUALS(source.pos(), 39);
source.writeByte(0x99);
TS_ASSERT_EQUALS(source.size(), 41);
TS_ASSERT_EQUALS(source.pos(), 40);
source.seek(2);
TS_ASSERT_EQUALS(source.getSize(), 41);
TS_ASSERT_EQUALS(source.getPos(), 2);
TS_ASSERT_EQUALS(source.size(), 41);
TS_ASSERT_EQUALS(source.pos(), 2);
const uint8* buf = source.getBuf();
const uint8* buf = source.getData();
TS_ASSERT_EQUALS(buf[0], 0xEF);
TS_ASSERT_EQUALS(buf[1], 0xDE);
TS_ASSERT_EQUALS(buf[2], 0xC0);
@ -50,15 +50,15 @@ class U8ODataSourceTestSuite : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(buf[36], 0x80);
source.clear();
TS_ASSERT_EQUALS(source.getSize(), 0);
TS_ASSERT_EQUALS(source.getPos(), 0);
TS_ASSERT_EQUALS(source.size(), 0);
TS_ASSERT_EQUALS(source.pos(), 0);
source.write1(0x04030201);
source.write2(0x08070605);
source.writeByte(0x04030201);
source.writeUint16LE(0x08070605);
source.write3(0x0C0B0A09);
source.write4(0x100F0E0D);
source.writeUint32LE(0x100F0E0D);
buf = source.getBuf();
buf = source.getData();
TS_ASSERT_EQUALS(buf[0], 0x01);
TS_ASSERT_EQUALS(buf[1], 0x05);
TS_ASSERT_EQUALS(buf[2], 0x06);