diff options
Diffstat (limited to 'test')
32 files changed, 48 insertions, 44 deletions
diff --git a/test/README b/test/README index 479b290967..25c378374e 100644 --- a/test/README +++ b/test/README @@ -2,4 +2,4 @@ This directory contains some unit tests for ScummVM. They are based on CxxTest <http://cxxtest.com/>, which you can find in the cxxtest subdirectory, including its manual. -To run the unit tests, simply use "make test".
\ No newline at end of file +To run the unit tests, simply use "make test". diff --git a/test/audio/audiostream.h b/test/audio/audiostream.h index 1ffb2308ec..b94ee087d0 100644 --- a/test/audio/audiostream.h +++ b/test/audio/audiostream.h @@ -206,4 +206,3 @@ public: testSubLoopingAudioStreamFixedIter(22050, true, 2, 2); } }; - diff --git a/test/audio/helper.h b/test/audio/helper.h index e0d034aaea..5080c79eef 100644 --- a/test/audio/helper.h +++ b/test/audio/helper.h @@ -109,4 +109,3 @@ static Audio::SeekableAudioStream *createSineStream(const int sampleRate, const } #endif - diff --git a/test/common/algorithm.h b/test/common/algorithm.h index 4d7e9b2e20..6eecae3635 100644 --- a/test/common/algorithm.h +++ b/test/common/algorithm.h @@ -38,30 +38,30 @@ public: const int arraySorted[] = { 1, 2, 3, 3, 4, 5 }; const int arrayUnsorted[] = { 5, 3, 1, 2, 4, 3 }; - TS_ASSERT_EQUALS(checkSort(arraySorted, arraySorted + ARRAYSIZE(arraySorted), Common::Less<int>()), true); - TS_ASSERT_EQUALS(checkSort(arraySorted, arraySorted + ARRAYSIZE(arraySorted), Common::Greater<int>()), false); + TS_ASSERT_EQUALS(checkSort(arraySorted, ARRAYEND(arraySorted), Common::Less<int>()), true); + TS_ASSERT_EQUALS(checkSort(arraySorted, ARRAYEND(arraySorted), Common::Greater<int>()), false); - TS_ASSERT_EQUALS(checkSort(arrayUnsorted, arrayUnsorted + ARRAYSIZE(arrayUnsorted), Common::Less<int>()), false); - TS_ASSERT_EQUALS(checkSort(arrayUnsorted, arrayUnsorted + ARRAYSIZE(arrayUnsorted), Common::Greater<int>()), false); + TS_ASSERT_EQUALS(checkSort(arrayUnsorted, ARRAYEND(arrayUnsorted), Common::Less<int>()), false); + TS_ASSERT_EQUALS(checkSort(arrayUnsorted, ARRAYEND(arrayUnsorted), Common::Greater<int>()), false); } void test_pod_sort() { { int array[] = { 63, 11, 31, 72, 1, 48, 32, 69, 38, 31 }; - Common::sort(array, array + ARRAYSIZE(array)); - TS_ASSERT_EQUALS(checkSort(array, array + ARRAYSIZE(array), Common::Less<int>()), true); + Common::sort(array, ARRAYEND(array)); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less<int>()), true); // already sorted - Common::sort(array, array + ARRAYSIZE(array)); - TS_ASSERT_EQUALS(checkSort(array, array + ARRAYSIZE(array), Common::Less<int>()), true); + Common::sort(array, ARRAYEND(array)); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less<int>()), true); } { int array[] = { 90, 80, 70, 60, 50, 40, 30, 20, 10 }; - Common::sort(array, array + ARRAYSIZE(array)); - TS_ASSERT_EQUALS(checkSort(array, array + ARRAYSIZE(array), Common::Less<int>()), true); + Common::sort(array, ARRAYEND(array)); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Less<int>()), true); - Common::sort(array, array + ARRAYSIZE(array), Common::Greater<int>()); - TS_ASSERT_EQUALS(checkSort(array, array + ARRAYSIZE(array), Common::Greater<int>()), true); + Common::sort(array, ARRAYEND(array), Common::Greater<int>()); + TS_ASSERT_EQUALS(checkSort(array, ARRAYEND(array), Common::Greater<int>()), true); } } @@ -80,4 +80,3 @@ public: TS_ASSERT_EQUALS(checkSort(list.begin(), list.end(), Common::Less<Item>()), true); } }; - diff --git a/test/common/array.h b/test/common/array.h index c10270436f..f0027ec201 100644 --- a/test/common/array.h +++ b/test/common/array.h @@ -215,6 +215,11 @@ class ArrayTestSuite : public CxxTest::TestSuite Common::Array<int> array2(array1); + // Alter the original array + array1[0] = 7; + array1[1] = -5; + array1[2] = 2; + TS_ASSERT_EQUALS(array2[0], -3); TS_ASSERT_EQUALS(array2[1], 5); TS_ASSERT_EQUALS(array2[2], 9); diff --git a/test/common/fixedstack.h b/test/common/fixedstack.h index 62e536d5fa..9aa00b4680 100644 --- a/test/common/fixedstack.h +++ b/test/common/fixedstack.h @@ -79,4 +79,3 @@ public: TS_ASSERT(!q2.empty()); } }; - diff --git a/test/common/math.h b/test/common/math.h new file mode 100644 index 0000000000..5da0410e8e --- /dev/null +++ b/test/common/math.h @@ -0,0 +1,18 @@ +#include <cxxtest/TestSuite.h> + +#include "common/math.h" + +class MathTestSuite : public CxxTest::TestSuite +{ + public: + void test_intLog2() { + // Test special case for 0 + TS_ASSERT_EQUALS(Common::intLog2(0), -1); + + // intLog2 should round the result towards 0 + TS_ASSERT_EQUALS(Common::intLog2(7), 2); + + // Some simple test for 2^10 + TS_ASSERT_EQUALS(Common::intLog2(1024), 10); + } +}; diff --git a/test/common/queue.h b/test/common/queue.h index cadb3979d7..c11f7a31ca 100644 --- a/test/common/queue.h +++ b/test/common/queue.h @@ -80,4 +80,3 @@ public: TS_ASSERT(!q2.empty()); } }; - diff --git a/test/common/stack.h b/test/common/stack.h index 66ba5f5e2b..0b1bcee350 100644 --- a/test/common/stack.h +++ b/test/common/stack.h @@ -79,4 +79,3 @@ public: TS_ASSERT(!q2.empty()); } }; - diff --git a/test/common/tokenizer.h b/test/common/tokenizer.h index 9c14875b81..c6a73d77b7 100644 --- a/test/common/tokenizer.h +++ b/test/common/tokenizer.h @@ -55,4 +55,3 @@ public: } }; - diff --git a/test/cxxtest/COPYING b/test/cxxtest/COPYING index b1e3f5a263..cfe59bcadb 100644 --- a/test/cxxtest/COPYING +++ b/test/cxxtest/COPYING @@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names: Ty Coon, President of Vice That's all there is to it! - - diff --git a/test/cxxtest/TODO b/test/cxxtest/TODO index 7a7f926e50..63afa6896a 100644 --- a/test/cxxtest/TODO +++ b/test/cxxtest/TODO @@ -31,4 +31,3 @@ Seems logical, since they evolve separately. But then you'd want to download bo -fomit-frame-pointer ** TS_HEX - diff --git a/test/cxxtest/cxxtest.spec b/test/cxxtest/cxxtest.spec index 0f1ded6c53..c4d0017bb9 100644 --- a/test/cxxtest/cxxtest.spec +++ b/test/cxxtest/cxxtest.spec @@ -37,4 +37,3 @@ rm -rf $RPM_BUILD_ROOT %attr(-, root, root) /usr/include/cxxtest %attr(-, root, root) /usr/bin/cxxtestgen.pl %attr(-, root, root) /usr/bin/cxxtestgen.py - diff --git a/test/cxxtest/cxxtest/Descriptions.h b/test/cxxtest/cxxtest/Descriptions.h index c25b88dd99..f0e26cb942 100644 --- a/test/cxxtest/cxxtest/Descriptions.h +++ b/test/cxxtest/cxxtest/Descriptions.h @@ -71,4 +71,3 @@ namespace CxxTest } #endif // __cxxtest__Descriptions_h__ - diff --git a/test/cxxtest/cxxtest/DummyDescriptions.cpp b/test/cxxtest/cxxtest/DummyDescriptions.cpp index 04869bfc06..c8eca15827 100644 --- a/test/cxxtest/cxxtest/DummyDescriptions.cpp +++ b/test/cxxtest/cxxtest/DummyDescriptions.cpp @@ -46,4 +46,3 @@ namespace CxxTest bool DummyWorldDescription::setUp() { return true;} bool DummyWorldDescription::tearDown() { return true;} } - diff --git a/test/cxxtest/cxxtest/DummyDescriptions.h b/test/cxxtest/cxxtest/DummyDescriptions.h index 69d1116f84..e3aef921ca 100644 --- a/test/cxxtest/cxxtest/DummyDescriptions.h +++ b/test/cxxtest/cxxtest/DummyDescriptions.h @@ -73,4 +73,3 @@ namespace CxxTest } #endif // __cxxtest__DummyDescriptions_h__ - diff --git a/test/cxxtest/cxxtest/GlobalFixture.cpp b/test/cxxtest/cxxtest/GlobalFixture.cpp index edcaf1efe4..a5b2cf8340 100644 --- a/test/cxxtest/cxxtest/GlobalFixture.cpp +++ b/test/cxxtest/cxxtest/GlobalFixture.cpp @@ -20,4 +20,3 @@ namespace CxxTest } #endif // __cxxtest__GlobalFixture_cpp__ - diff --git a/test/cxxtest/cxxtest/GlobalFixture.h b/test/cxxtest/cxxtest/GlobalFixture.h index cbecb0daf8..3c4e12ec14 100644 --- a/test/cxxtest/cxxtest/GlobalFixture.h +++ b/test/cxxtest/cxxtest/GlobalFixture.h @@ -27,4 +27,3 @@ namespace CxxTest } #endif // __cxxtest__GlobalFixture_h__ - diff --git a/test/cxxtest/cxxtest/LinkedList.h b/test/cxxtest/cxxtest/LinkedList.h index bb5e842c97..0d134d2712 100644 --- a/test/cxxtest/cxxtest/LinkedList.h +++ b/test/cxxtest/cxxtest/LinkedList.h @@ -62,4 +62,3 @@ namespace CxxTest } #endif // __cxxtest__LinkedList_h__ - diff --git a/test/cxxtest/cxxtest/RealDescriptions.cpp b/test/cxxtest/cxxtest/RealDescriptions.cpp index 234622cbbf..079a9cf056 100644 --- a/test/cxxtest/cxxtest/RealDescriptions.cpp +++ b/test/cxxtest/cxxtest/RealDescriptions.cpp @@ -308,4 +308,3 @@ namespace CxxTest } #endif // __cxxtest__RealDescriptions_cpp__ - diff --git a/test/cxxtest/cxxtest/RealDescriptions.h b/test/cxxtest/cxxtest/RealDescriptions.h index ad455db0c2..76eee1a852 100644 --- a/test/cxxtest/cxxtest/RealDescriptions.h +++ b/test/cxxtest/cxxtest/RealDescriptions.h @@ -220,4 +220,3 @@ namespace CxxTest } #endif // __cxxtest__RealDescriptions_h__ - diff --git a/test/cxxtest/docs/guide.html b/test/cxxtest/docs/guide.html index fb435fb8f1..3e628ff742 100644 --- a/test/cxxtest/docs/guide.html +++ b/test/cxxtest/docs/guide.html @@ -1957,4 +1957,3 @@ no limit, or <code>CXXTEST_MAX_DUMP_SIZE</code> if you <code>#define</code> it. </body></html> - diff --git a/test/cxxtest/sample/Construct b/test/cxxtest/sample/Construct index b8019616a9..994daa4fa5 100644 --- a/test/cxxtest/sample/Construct +++ b/test/cxxtest/sample/Construct @@ -60,5 +60,3 @@ sub cons::CxxTestErrorPrinter($$@) { my ($env, $dst, @srcs) = @_; CxxTestRunner $env $dst, 'ErrorPrinter', @srcs; } - - diff --git a/test/cxxtest/sample/aborter.tpl b/test/cxxtest/sample/aborter.tpl index 14fc50d2c7..ec6e187c98 100644 --- a/test/cxxtest/sample/aborter.tpl +++ b/test/cxxtest/sample/aborter.tpl @@ -13,4 +13,3 @@ int main() // The CxxTest "world" <CxxTest world> - diff --git a/test/cxxtest/sample/file_printer.tpl b/test/cxxtest/sample/file_printer.tpl index a9627d6d0d..8bd11cada0 100644 --- a/test/cxxtest/sample/file_printer.tpl +++ b/test/cxxtest/sample/file_printer.tpl @@ -19,4 +19,3 @@ int main( int argc, char *argv[] ) // The CxxTest "world" <CxxTest world> - diff --git a/test/cxxtest/sample/mock/Dice.cpp b/test/cxxtest/sample/mock/Dice.cpp index 161b80fa2b..afd0641ac1 100644 --- a/test/cxxtest/sample/mock/Dice.cpp +++ b/test/cxxtest/sample/mock/Dice.cpp @@ -10,5 +10,3 @@ unsigned Dice::roll() { return (T::rand() % 6) + 1; } - - diff --git a/test/cxxtest/sample/mock/Dice.h b/test/cxxtest/sample/mock/Dice.h index 3a393ef262..2ffd2562c5 100644 --- a/test/cxxtest/sample/mock/Dice.h +++ b/test/cxxtest/sample/mock/Dice.h @@ -10,4 +10,3 @@ public: }; #endif // __DICE_H - diff --git a/test/cxxtest/sample/msvc/CxxTest_Workspace.dsw b/test/cxxtest/sample/msvc/CxxTest_Workspace.dsw index 9a88de6ef7..e59b75c11c 100644 --- a/test/cxxtest/sample/msvc/CxxTest_Workspace.dsw +++ b/test/cxxtest/sample/msvc/CxxTest_Workspace.dsw @@ -56,4 +56,3 @@ Package=<3> }}}
###############################################################################
-
diff --git a/test/cxxtest/sample/only.tpl b/test/cxxtest/sample/only.tpl index b2a7277cf6..12fde95224 100644 --- a/test/cxxtest/sample/only.tpl +++ b/test/cxxtest/sample/only.tpl @@ -30,4 +30,3 @@ int main( int argc, char *argv[] ) // The CxxTest "world" <CxxTest world> - diff --git a/test/cxxtest/sample/winddk/SOURCES b/test/cxxtest/sample/winddk/SOURCES index dae0148885..3129141d8a 100644 --- a/test/cxxtest/sample/winddk/SOURCES +++ b/test/cxxtest/sample/winddk/SOURCES @@ -43,4 +43,3 @@ SOURCES=RunTests.cpp # This line tells the build utility to process Makefile.inc # NTTARGETFILE0=RunTests.cpp - diff --git a/test/cxxtest_mingw.h b/test/cxxtest_mingw.h new file mode 100644 index 0000000000..f407105bfe --- /dev/null +++ b/test/cxxtest_mingw.h @@ -0,0 +1,11 @@ + +#ifndef CXXTEST_MINGW +#define CXXTEST_MINGW + +// HACK to allow building with the SDL backend on MinGW +// see bug #1800764 "TOOLS: MinGW tools building broken" +#ifdef main +#undef main +#endif // main + +#endif // CXXTEST_MINGW
\ No newline at end of file diff --git a/test/module.mk b/test/module.mk index 4e5cbf62e1..11ee6bd200 100644 --- a/test/module.mk +++ b/test/module.mk @@ -9,7 +9,7 @@ TESTS := $(srcdir)/test/common/*.h $(srcdir)/test/audio/*.h TEST_LIBS := audio/libaudio.a common/libcommon.a # -TEST_FLAGS := --runner=StdioPrinter --no-std --no-eh +TEST_FLAGS := --runner=StdioPrinter --no-std --no-eh --include=$(srcdir)/test/cxxtest_mingw.h TEST_CFLAGS := -I$(srcdir)/test/cxxtest TEST_LDFLAGS := $(LIBS) TEST_CXXFLAGS := $(filter-out -Wglobal-constructors,$(CXXFLAGS)) |