Initial commit
This commit is contained in:
35
test/engines/ultima/ultima8/usecode/bit_set.h
Normal file
35
test/engines/ultima/ultima8/usecode/bit_set.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
#include "engines/ultima/ultima8/usecode/bit_set.h"
|
||||
/**
|
||||
* Test suite for the functions in engines/ultima/ultima8/usecode/bit_set.h
|
||||
*/
|
||||
|
||||
class U8BitSetTestSuite : public CxxTest::TestSuite {
|
||||
public:
|
||||
Ultima::Ultima8::BitSet bs;
|
||||
|
||||
U8BitSetTestSuite() {
|
||||
bs.setSize(0x1000);
|
||||
}
|
||||
|
||||
void test_set_get() {
|
||||
// Test with bit pattern in second byte of 01110100
|
||||
// (pos goes from low bit to high bit)
|
||||
bs.setEntries(10, 5, 0x1D);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(10, 5), 0x1D);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(10, 4), 0xD);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(8, 6), 0xD << 2);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(8, 7), 0x1D << 2);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(8, 8), 0x1D << 2);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(14, 2), 0x1);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(16, 32), 0);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(0, 10), 0);
|
||||
}
|
||||
|
||||
void test_clear() {
|
||||
bs.setEntries(10, 5, 0x15);
|
||||
bs.setSize(0x1000);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(10, 5), 0);
|
||||
TS_ASSERT_EQUALS(bs.getEntries(0, 32), 0);
|
||||
}
|
||||
};
|
||||
36
test/engines/ultima/ultima8/usecode/uc_list.h
Normal file
36
test/engines/ultima/ultima8/usecode/uc_list.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
#include "engines/ultima/ultima8/usecode/uc_list.h"
|
||||
/**
|
||||
* Test suite for the functions in engines/ultima/ultima8/usecode/uc_list.h
|
||||
*/
|
||||
|
||||
class U8UCListTestSuite : public CxxTest::TestSuite {
|
||||
public:
|
||||
U8UCListTestSuite() {
|
||||
}
|
||||
|
||||
void test_static_list() {
|
||||
Ultima::Ultima8::UCList l(2);
|
||||
|
||||
TS_ASSERT_EQUALS(l.getSize(), 0);
|
||||
TS_ASSERT_EQUALS(l.getElementSize(), 2);
|
||||
|
||||
uint16 test = 0xBEEF;
|
||||
l.append((uint8*)&test);
|
||||
TS_ASSERT_EQUALS(l.getSize(), 1);
|
||||
|
||||
uint16 test2 = 0xF00D;
|
||||
l.append((uint8*)&test2);
|
||||
TS_ASSERT_EQUALS(l.getSize(), 2);
|
||||
TS_ASSERT(l.inList((uint8*)&test));
|
||||
|
||||
l.remove((uint8*)&test);
|
||||
TS_ASSERT(!l.inList((uint8*)&test));
|
||||
TS_ASSERT(l.inList((uint8*)&test2));
|
||||
TS_ASSERT_EQUALS(l.getSize(), 1);
|
||||
|
||||
l.free();
|
||||
TS_ASSERT_EQUALS(l.getSize(), 0);
|
||||
}
|
||||
|
||||
};
|
||||
44
test/engines/ultima/ultima8/usecode/uc_stack.h
Normal file
44
test/engines/ultima/ultima8/usecode/uc_stack.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
#include "engines/ultima/ultima8/usecode/uc_stack.h"
|
||||
/**
|
||||
* Test suite for the functions in engines/ultima/ultima8/usecode/uc_stack.h
|
||||
*/
|
||||
|
||||
class U8UCStackTestSuite : public CxxTest::TestSuite {
|
||||
public:
|
||||
U8UCStackTestSuite() {
|
||||
}
|
||||
|
||||
void test_static_stack() {
|
||||
Ultima::Ultima8::UCStack stack;
|
||||
test_for_stack(stack);
|
||||
}
|
||||
|
||||
void test_dynamic_stack() {
|
||||
Ultima::Ultima8::DynamicUCStack stack;
|
||||
Ultima::Ultima8::DynamicUCStack stack2(32);
|
||||
TS_ASSERT_EQUALS(stack2.getSize(), 32);
|
||||
test_for_stack(stack);
|
||||
test_for_stack(stack2);
|
||||
}
|
||||
|
||||
private:
|
||||
void test_for_stack(Ultima::Ultima8::BaseUCStack &s) {
|
||||
TS_ASSERT_EQUALS(s.stacksize(), 0);
|
||||
s.push4(0xDEADBEEF);
|
||||
TS_ASSERT_EQUALS(s.stacksize(), 4);
|
||||
TS_ASSERT_EQUALS(s.pop2(), 0xBEEF);
|
||||
TS_ASSERT_EQUALS(s.pop2(), 0xDEAD);
|
||||
s.push1(0xFE);
|
||||
TS_ASSERT_EQUALS(s.stacksize(), 1);
|
||||
s.push1(0xED);
|
||||
s.push2(0xC0DE);
|
||||
TS_ASSERT_EQUALS(s.pop2(), 0xC0DE);
|
||||
TS_ASSERT_EQUALS(s.pop2(), 0xFEED);
|
||||
TS_ASSERT_EQUALS(s.stacksize(), 0);
|
||||
TS_ASSERT_EQUALS(s.getSP(), s.getSize());
|
||||
s.push4(0xCAFEF00D);
|
||||
TS_ASSERT_EQUALS(s.getSP(), s.getSize()-4);
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user