aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Hoops2012-03-20 14:18:57 -0400
committerMatthew Hoops2012-03-20 14:49:16 -0400
commit71756bdf4eae5ba9cc3f329b85e894f04640aaef (patch)
tree40d464262da107ab5eed82f198685209161ebac1 /test
parent03eba05b09e5c9e5a351f8111185934b92a3fed3 (diff)
parent3c3576a224b92c703b4e8ea20008ac8a069980dd (diff)
downloadscummvm-rg350-71756bdf4eae5ba9cc3f329b85e894f04640aaef.tar.gz
scummvm-rg350-71756bdf4eae5ba9cc3f329b85e894f04640aaef.tar.bz2
scummvm-rg350-71756bdf4eae5ba9cc3f329b85e894f04640aaef.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'test')
-rw-r--r--test/common/fixedstack.h14
-rw-r--r--test/common/memoryreadstream.h16
-rw-r--r--test/common/pack.h2
-rw-r--r--test/common/stack.h12
-rw-r--r--test/common/subreadstream.h18
-rw-r--r--test/cxxtest/cxxtest/ValueTraits.h4
6 files changed, 52 insertions, 14 deletions
diff --git a/test/common/fixedstack.h b/test/common/fixedstack.h
index 9aa00b4680..9d4cceb2e6 100644
--- a/test/common/fixedstack.h
+++ b/test/common/fixedstack.h
@@ -18,18 +18,20 @@ public:
}
void test_size() {
- Common::FixedStack<int> stack;
- TS_ASSERT_EQUALS(stack.size(), 0);
+ typedef Common::FixedStack<int> Stack;
+
+ Stack stack;
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)0);
stack.push(5);
- TS_ASSERT_EQUALS(stack.size(), 1);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)1);
stack.push(9);
stack.push(0);
- TS_ASSERT_EQUALS(stack.size(), 3);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)3);
stack.pop();
- TS_ASSERT_EQUALS(stack.size(), 2);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)2);
}
void test_top_pop() {
@@ -44,7 +46,7 @@ public:
stack[0] = -23;
stack.top() = 42;
TS_ASSERT_EQUALS(stack[0], -23);
- TS_ASSERT_EQUALS(stack.top(), 42);
+ TS_ASSERT_EQUALS(stack.top(), 42);
stack.pop();
TS_ASSERT_EQUALS(stack[0], -23);
diff --git a/test/common/memoryreadstream.h b/test/common/memoryreadstream.h
index a476f12a2f..adef861a5e 100644
--- a/test/common/memoryreadstream.h
+++ b/test/common/memoryreadstream.h
@@ -84,4 +84,20 @@ class MemoryReadStreamTestSuite : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(ms.pos(), 7);
TS_ASSERT(!ms.eos());
}
+
+ void test_eos() {
+ byte contents[] = { 1, 2, 3, 4, 5, 6, 7 };
+ Common::MemoryReadStream ms(contents, sizeof(contents));
+
+ // Read after the end of the stream
+ for (int32 i = 0; i <= ms.size(); ++i)
+ ms.readByte();
+
+ // The eos flag should be set here
+ TS_ASSERT(ms.eos());
+
+ // Seeking should reset the eos flag
+ ms.seek(0, SEEK_SET);
+ TS_ASSERT(!ms.eos());
+ }
};
diff --git a/test/common/pack.h b/test/common/pack.h
index 724457f838..f62b31e9dc 100644
--- a/test/common/pack.h
+++ b/test/common/pack.h
@@ -15,7 +15,7 @@ struct TestStruct {
#include <common/pack-end.h> // END STRUCT PACKING
-#define OFFS(type,item) (((ptrdiff_t)(&((type*)42)->type::item))-42)
+#define OFFS(type,item) (((ptrdiff_t)(&((type *)42)->type::item))-42)
class PackTestSuite : public CxxTest::TestSuite
{
diff --git a/test/common/stack.h b/test/common/stack.h
index 0b1bcee350..ed32ec6496 100644
--- a/test/common/stack.h
+++ b/test/common/stack.h
@@ -18,18 +18,20 @@ public:
}
void test_size() {
- Common::Stack<int> stack;
- TS_ASSERT_EQUALS(stack.size(), 0);
+ typedef Common::Stack<int> Stack;
+
+ Stack stack;
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)0);
stack.push(5);
- TS_ASSERT_EQUALS(stack.size(), 1);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)1);
stack.push(9);
stack.push(0);
- TS_ASSERT_EQUALS(stack.size(), 3);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)3);
stack.pop();
- TS_ASSERT_EQUALS(stack.size(), 2);
+ TS_ASSERT_EQUALS(stack.size(), (Stack::size_type)2);
}
void test_top_pop() {
diff --git a/test/common/subreadstream.h b/test/common/subreadstream.h
index 463f49e929..32e6f938d2 100644
--- a/test/common/subreadstream.h
+++ b/test/common/subreadstream.h
@@ -26,4 +26,22 @@ class SubReadStreamTestSuite : public CxxTest::TestSuite {
b = srs.readByte();
TS_ASSERT(srs.eos());
}
+
+ void test_safe_eos() {
+ byte contents[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ Common::MemoryReadStream ms(contents, sizeof(contents));
+
+ Common::SafeSeekableSubReadStream ssrs1(&ms, 0, sizeof(contents));
+ Common::SafeSeekableSubReadStream ssrs2(&ms, 0, sizeof(contents));
+
+ // Read after the end of the stream of the first sub stream
+ for (int32 i = 0; i <= ssrs1.size(); ++i)
+ ssrs1.readByte();
+
+ // eos should be set for the first sub stream
+ TS_ASSERT(ssrs1.eos());
+
+ // eos should not be set for the second sub stream
+ TS_ASSERT(!ssrs2.eos());
+ }
};
diff --git a/test/cxxtest/cxxtest/ValueTraits.h b/test/cxxtest/cxxtest/ValueTraits.h
index 339a345029..45b2ea39c1 100644
--- a/test/cxxtest/cxxtest/ValueTraits.h
+++ b/test/cxxtest/cxxtest/ValueTraits.h
@@ -70,7 +70,7 @@ namespace CxxTest
//
// The default ValueTraits class dumps up to 8 bytes as hex values
//
- template <class T>
+ template<class T>
class ValueTraits
{
enum { MAX_BYTES = 8 };
@@ -85,7 +85,7 @@ namespace CxxTest
// traits( T t )
// Creates an object of type ValueTraits<T>
//
- template <class T>
+ template<class T>
inline ValueTraits<T> traits( T t )
{
return ValueTraits<T>( t );