[Scummvm-cvs-logs] scummvm master -> 3e246b3e67894b1b5d812d16a32a52198ecb9b6c

lordhoto lordhoto at gmail.com
Mon Jul 15 14:26:56 CEST 2013


This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4f7d92acb4 TEST: tests for common/huffman.h
4a18eab8a5 TEST: test cases for common/util.cpp
377789db77 TEST: tests for common/rendermode.h
2e4933dcd5 TEST: reorganize test/common/util.h
6245a68632 TEST: Thorough testing for common/hash-str.h
e9406fad24 TEST: removed fixed hashes in test/common/hash-str.h
d2c85e19eb TEST: Whitespaces in test/common/
3e246b3e67 Merge pull request #323 from tobiatesan/test_for_common


Commit: 4f7d92acb42e54b17e83fa855abcb3bb4e427c7f
    https://github.com/scummvm/scummvm/commit/4f7d92acb42e54b17e83fa855abcb3bb4e427c7f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:17:41-07:00

Commit Message:
TEST: tests for common/huffman.h

A few tests for the Huffman decoder.

The encoding is the example from Wikipedia.
This could be improved by someone more knowledgeable by
generating one at runtime or using multiple encodings
which would each contain one edge case.

Changed paths:
  A test/common/huffman.h



diff --git a/test/common/huffman.h b/test/common/huffman.h
new file mode 100644
index 0000000..52199a8
--- /dev/null
+++ b/test/common/huffman.h
@@ -0,0 +1,130 @@
+#include <cxxtest/TestSuite.h>
+#include "common/huffman.h"
+#include "common/bitstream.h"
+#include "common/memstream.h"
+
+class HuffmanTestSuite : public CxxTest::TestSuite
+{
+	public:
+	void test_get_with_full_symbols() {
+
+		/*
+		 * Testing the Huffman decoder.
+		 *
+		 * Encoding (arbitrary, for testing purpouses):
+		 * A=010
+		 * B=011
+		 * C=11
+		 * D=00
+		 * E=10
+		 */
+
+		uint32 codeCount = 5;
+		uint8 maxLength = 3;
+		const uint8 lengths[] = {3,3,2,2,2};
+		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
+		const uint32 symbols[]  = {0xA, 0xB, 0xC, 0xD, 0xE};
+
+		Common::Huffman h (maxLength, codeCount, codes, lengths, symbols);
+
+		byte input[] = {0x4F, 0x20};
+		// Provided input...
+		uint32 expected[] = {0xA, 0xB, 0xC, 0xD, 0xE, 0xD, 0xD};
+		// ..and expected output.
+
+		/*
+		 * What should be going on:
+		 * 010 011 11 00 10 00 00 = A B C D E D D
+		 *  = 0100 1111 0010 0000 = 0x4F20
+		 */
+
+		Common::MemoryReadStream ms(input, sizeof(input));
+		Common::BitStream8MSB bs(ms);
+
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[0]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[1]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[2]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[3]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[4]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[5]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[6]);
+	}
+
+	void test_get_without_symbols() {
+
+		/*
+		 * This is basically the same as above, but
+		 * I pass minimal arguments.
+		 * Specifically, I avoid passing the symbols table, so that
+		 * array indices are used instead.
+		 *
+		 * Encoding becomes:
+		 *
+		 * 0=010
+		 * 1=011
+		 * 2=11
+		 * 3=00
+		 * 4=10
+		 */
+
+		uint32 codeCount = 5;
+		const uint8 lengths[] = {3,3,2,2,2};
+		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
+
+		Common::Huffman h (0, codeCount, codes, lengths, 0);
+
+		byte input[] = {0x4F, 0x20};
+		uint32 expected[] = {0, 1, 2, 3, 4, 3 ,3};
+
+		Common::MemoryReadStream ms(input, sizeof(input));
+		Common::BitStream8MSB bs(ms);
+
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[0]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[1]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[2]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[3]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[4]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[5]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[6]);
+	}
+
+	void test_get_after_set_symbols() {
+
+		/*
+		 * Another variation of the above.
+		 * I use the setSymbols method to define, a posteriori,
+		 * an alphabet to be used in place of array indices
+		 */
+
+		uint32 codeCount = 5;
+		const uint8 lengths[] = {3,3,2,2,2};
+		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
+
+		Common::Huffman h (0, codeCount, codes, lengths, 0);
+
+		const uint32 symbols[]  = {0xA, 0xB, 0xC, 0xD, 0xE};
+		h.setSymbols(symbols);
+
+		byte input[] = {0x4F, 0x20};
+		uint32 expected[] = {0xA, 0xB, 0xC, 0xD, 0xE, 0xD, 0xD};
+
+		Common::MemoryReadStream ms(input, sizeof(input));
+		Common::BitStream8MSB bs(ms);
+
+		/* New symbols:
+		 * A=010
+		 * B=011
+		 * C=11
+		 * D=00
+		 * E=10
+		 */
+
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[0]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[1]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[2]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[3]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[4]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[5]);
+		TS_ASSERT_EQUALS(h.getSymbol(bs), expected[6]);
+	}
+};


Commit: 4a18eab8a55b70dc7d56aa943b9de080bffe7a9c
    https://github.com/scummvm/scummvm/commit/4a18eab8a55b70dc7d56aa943b9de080bffe7a9c
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:17:47-07:00

Commit Message:
TEST: test cases for common/util.cpp

Changed paths:
  A test/common/util.h



diff --git a/test/common/util.h b/test/common/util.h
new file mode 100644
index 0000000..c11ab74
--- /dev/null
+++ b/test/common/util.h
@@ -0,0 +1,200 @@
+#include <cxxtest/TestSuite.h>
+#include "common/util.h"
+
+class UtilTestSuite : public CxxTest::TestSuite {
+public:
+
+	void test_parsebool_good() {
+
+		// Test the parseBool function
+
+		bool valasbool;
+		bool success;
+
+		// 'Regular' cases that must work
+		// (note that the function must be case insensitive):
+
+		Common::String string_1 ("Yes");
+		success = Common::parseBool (string_1, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 1);
+
+		Common::String string_2 ("nO");
+		success = Common::parseBool (string_2, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 0);
+
+		Common::String string_3 ("tRuE");
+		success = Common::parseBool (string_3, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 1);
+
+		Common::String string_4 ("fAlSe");
+		success = Common::parseBool (string_4, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 0);
+
+		Common::String string_5 ("1");
+		success = Common::parseBool (string_5, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 1);
+
+		Common::String string_6 ("0");
+		success = Common::parseBool (string_6, valasbool);
+		TS_ASSERT_EQUALS(success, 1);
+		TS_ASSERT_EQUALS(valasbool, 0);
+
+	}
+
+	void test_parsebool_bad() {
+
+		bool valasbool;
+		bool success;
+
+		// Bad cases that should not return success #1:
+		// Random string
+		Common::String string_1 ("u_f1ght_l1k3_a_c0w");
+		success = Common::parseBool (string_1, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
+
+		// Bad cases that should not return success #2, #3:
+		// The function should NOT accept trailing whitespaces:
+		Common::String string_2 (" yes");
+		success = Common::parseBool (string_2, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
+
+		Common::String string_3 ("yes ");
+		success = Common::parseBool (string_3, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
+
+	}
+
+	void test_is_al_num() {
+
+		// Test the isAlnum function
+		// Should return true if and only if the input is an alphanumeric char
+
+		TS_ASSERT_EQUALS(Common::isAlnum('a'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('A'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('z'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('Z'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('1'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('0'), 1);
+		TS_ASSERT_EQUALS(Common::isAlnum('§'), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum('$'), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum(' '), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum('\n'), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum('\b'), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum(0), 0);
+		TS_ASSERT_EQUALS(Common::isAlnum(255), 0);
+
+	}
+
+	void test_is_alpha() {
+
+		// Test the isAlpha function
+		// Should return true if and only if the input is an alphanumeric char
+
+		TS_ASSERT_EQUALS(Common::isAlpha('a'), 1);
+		TS_ASSERT_EQUALS(Common::isAlpha('A'), 1);
+		TS_ASSERT_EQUALS(Common::isAlpha('z'), 1);
+		TS_ASSERT_EQUALS(Common::isAlpha('Z'), 1);
+		TS_ASSERT_EQUALS(Common::isAlpha('1'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha('0'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha('§'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha('$'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha(' '), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha('\n'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha('\b'), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha(0), 0);
+		TS_ASSERT_EQUALS(Common::isAlpha(255), 0);
+
+	}
+
+	void test_is_digit() {
+
+		// Test the isDigit function
+		// Should return true if and only if the input is a single digit
+
+		TS_ASSERT_EQUALS(Common::isDigit('a'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('A'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('z'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('Z'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('1'), 1);
+		TS_ASSERT_EQUALS(Common::isDigit('0'), 1);
+		TS_ASSERT_EQUALS(Common::isDigit('§'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('$'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit(' '), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('\n'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit('\b'), 0);
+		TS_ASSERT_EQUALS(Common::isDigit(0), 0);
+		TS_ASSERT_EQUALS(Common::isDigit(255), 0);
+
+	}
+
+	void test_is_lower() {
+
+		// Test the isLower function
+		// Should return true if and only if the input is a lowercase char
+
+		TS_ASSERT_EQUALS(Common::isLower('a'), 1);
+		TS_ASSERT_EQUALS(Common::isLower('A'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('z'), 1);
+		TS_ASSERT_EQUALS(Common::isLower('Z'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('1'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('0'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('§'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('$'), 0);
+		TS_ASSERT_EQUALS(Common::isLower(' '), 0);
+		TS_ASSERT_EQUALS(Common::isLower('\n'), 0);
+		TS_ASSERT_EQUALS(Common::isLower('\b'), 0);
+		TS_ASSERT_EQUALS(Common::isLower(0), 0);
+		TS_ASSERT_EQUALS(Common::isLower(255), 0);
+
+	}
+
+
+	void test_is_upper() {
+
+		// Test the isUpper function
+		// Should return true if and only if the input is an uppercase char
+
+		TS_ASSERT_EQUALS(Common::isUpper('a'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('A'), 1);
+		TS_ASSERT_EQUALS(Common::isUpper('z'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('Z'), 1);
+		TS_ASSERT_EQUALS(Common::isUpper('1'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('0'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('§'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('$'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper(' '), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('\n'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper('\b'), 0);
+		TS_ASSERT_EQUALS(Common::isUpper(0), 0);
+		TS_ASSERT_EQUALS(Common::isUpper(255), 0);
+
+	}
+	void test_is_space() {
+		// isSpace should return true iff the character is some kind of whitespace
+		// or tab character
+		for (int c=0; c<255; c++) {
+			 if (c==' ' || c=='\t' || c=='\r' || c=='\n' || c=='\v' || c=='\f') {
+				 TS_ASSERT_EQUALS(Common::isSpace(c), 1);
+			 } else {
+				 TS_ASSERT_EQUALS(Common::isSpace(c), 0);
+			 }
+		}
+	}
+
+	void test_is_print() {
+		// isPrint should return true iff the input is a printable ascii char.
+		// That is to say, 0x20 to 0x7E.
+		for (int c=0; c<255; c++) {
+			 if (c>=0x20 && c<=0x7E) {
+				 TS_ASSERT_EQUALS(Common::isPrint(c), 1);
+			 } else {
+				 TS_ASSERT_EQUALS(Common::isPrint(c), 0);
+			 }
+		}
+	}
+};


Commit: 377789db771d62c2c5aa30612e97caf8f3142016
    https://github.com/scummvm/scummvm/commit/377789db771d62c2c5aa30612e97caf8f3142016
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:17:52-07:00

Commit Message:
TEST: tests for common/rendermode.h

tests for parseRenderMode, renderMode2GUIO and getRenderModeCode.

Changed paths:
  A test/common/rendermode.h



diff --git a/test/common/rendermode.h b/test/common/rendermode.h
new file mode 100644
index 0000000..a25c098
--- /dev/null
+++ b/test/common/rendermode.h
@@ -0,0 +1,85 @@
+#include <cxxtest/TestSuite.h>
+#include "common/rendermode.h"
+#include "common/gui_options.h"
+#include "common/str.h"
+
+class RenderModeTestSuite : public CxxTest::TestSuite
+{
+	public:
+	void test_parse_render_mode_good() {
+		/*
+		 * Tests for parseRenderMode.
+		 * It takes a code (case-insensitive) and spits a RenderMode back at you.
+		 * These cases should work - the inputs are standard, there's just some
+		 * fun with caps being had in here.
+		 */
+		TS_ASSERT_EQUALS(Common::parseRenderMode("fMTOwNs"), Common::kRenderFMTowns);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("hercGrEen"), Common::kRenderHercG);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("hercAmbeR"), Common::kRenderHercA);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("CgA"), Common::kRenderCGA);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("ega"), Common::kRenderEGA);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("Vga"), Common::kRenderVGA);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("AmigA"), Common::kRenderAmiga);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("pc9821"), Common::kRenderPC9821);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("PC9801"), Common::kRenderPC9801);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("0"), Common::kRenderDefault);
+	}
+
+
+	void test_parse_render_mode_bad() {
+		/*
+		 * These cases, according to the specification, should return the default.
+		 * It is only mentioned that the function must be case insensitive.
+		 * Whitespaces, in particular, should not be automatically trimmed.
+		 */
+		TS_ASSERT_EQUALS(Common::parseRenderMode("fmtowns "), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("FM-TOWNS "), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode(" cga"), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("\tC g A"), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("\t"), Common::kRenderDefault);
+		// This is the only interesting bit: if the function was really, really
+		// broken it could be tempted to test for +-0x20.
+		TS_ASSERT_EQUALS(Common::parseRenderMode("pc Y8 21 "), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode(" PC\t9801 "), Common::kRenderDefault);
+		TS_ASSERT_EQUALS(Common::parseRenderMode("0"), Common::kRenderDefault);
+	}
+
+	void test_get_render_mode_code_back_and_forth() {
+		/*
+		 * What does getRenderModeCode return?
+		 * Notably, the output should not be in mixed case.
+		 */
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("FMTOWNS")), "fmtowns", 7);
+		TS_ASSERT_DIFFERS(Common::getRenderModeCode(Common::parseRenderMode("FMTOWNS")), "fmtowns");
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("CGA")), "cga", 3);
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("vga")), "vga", 3);
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("Ega")), "ega", 3);
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("AmiGa")), "amiga", 5);
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("PC9821")), "pc9821", 6);
+		TS_ASSERT_SAME_DATA(Common::getRenderModeCode(Common::parseRenderMode("PC9801")), "pc9801", 6);
+		// Slightly more interesting:
+		// Make sure that we get a null pointer for 0 (and not the "0" string or stuff)
+		char *null_p = 0;
+		TS_ASSERT_EQUALS(Common::getRenderModeCode(Common::kRenderDefault), null_p);
+	}
+
+	void test_render_2_guio () {
+		/*
+		 * Verify that a rendermode is taken and the corresponding
+		 * GUIO_xxxxx is returned.
+		 */
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderHercG), GUIO_RENDERHERCGREEN);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderHercA), GUIO_RENDERHERCAMBER);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderCGA), GUIO_RENDERCGA);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderEGA), GUIO_RENDEREGA);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderVGA), GUIO_RENDERVGA);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderAmiga), GUIO_RENDERAMIGA);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderFMTowns), GUIO_RENDERFMTOWNS);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderPC9821), GUIO_RENDERPC9821);
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderPC9801), GUIO_RENDERPC9801);
+		// renderMode2GUIO is supposed to return an empty string
+		// if given kRenderDefault as an argument
+		Common::String empty;
+		TS_ASSERT_EQUALS(Common::renderMode2GUIO(Common::kRenderDefault), empty);
+	}
+};


Commit: 2e4933dcd5a07f42d130c3cff4d8ebf13c3953d6
    https://github.com/scummvm/scummvm/commit/2e4933dcd5a07f42d130c3cff4d8ebf13c3953d6
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:17:59-07:00

Commit Message:
TEST: reorganize test/common/util.h

Split a few test cases in two.
The resulting file is now better organized.

Changed paths:
    test/common/util.h



diff --git a/test/common/util.h b/test/common/util.h
index c11ab74..3bd997a 100644
--- a/test/common/util.h
+++ b/test/common/util.h
@@ -4,16 +4,16 @@
 class UtilTestSuite : public CxxTest::TestSuite {
 public:
 
-	void test_parsebool_good() {
+	// Test the parseBool function
 
-		// Test the parseBool function
+	// 'Regular' cases that must work
+	// (note that the function must be case insensitive):
+
+	void test_parsebool_yesno() {
 
 		bool valasbool;
 		bool success;
 
-		// 'Regular' cases that must work
-		// (note that the function must be case insensitive):
-
 		Common::String string_1 ("Yes");
 		success = Common::parseBool (string_1, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
@@ -23,6 +23,12 @@ public:
 		success = Common::parseBool (string_2, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 0);
+	}
+
+	void test_parsebool_truefalse() {
+
+		bool valasbool;
+		bool success;
 
 		Common::String string_3 ("tRuE");
 		success = Common::parseBool (string_3, valasbool);
@@ -33,6 +39,12 @@ public:
 		success = Common::parseBool (string_4, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 0);
+	}
+
+	void test_parsebool_onezero() {
+
+		bool valasbool;
+		bool success;
 
 		Common::String string_5 ("1");
 		success = Common::parseBool (string_5, valasbool);


Commit: 6245a68632875fb4a58eb5ca9fe2e321c171127b
    https://github.com/scummvm/scummvm/commit/6245a68632875fb4a58eb5ca9fe2e321c171127b
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:21:24-07:00

Commit Message:
TEST: Thorough testing for common/hash-str.h

We test the various equal_to and hash functions therein.

Changed paths:
  A test/common/hash-str.h
    test/common/huffman.h
    test/common/rendermode.h
    test/common/util.h



diff --git a/test/common/hash-str.h b/test/common/hash-str.h
new file mode 100644
index 0000000..b106f66
--- /dev/null
+++ b/test/common/hash-str.h
@@ -0,0 +1,183 @@
+#include <cxxtest/TestSuite.h>
+#include "common/hash-str.h"
+
+/**
+ * Test suite for common/hash-str.h
+ * We test a number of case sensitive/insensitive hash and compare functions
+ * using example strings and known hashes, trying to tackle
+ * as much edge cases as possible.
+ */
+class HashStrTestSuite : public CxxTest::TestSuite {
+
+	public:
+	void test_case_sensitive_string_equal_to() {
+
+		// Name says it all.
+		// This verifies that the function returns true
+		// for exactly the same string, false for the same
+		// string in mixed case and false for some edge cases
+		// with various spacings plus one character replaced
+		// by itself+128 (if there's some processing done after
+		// conversion to 7-bit ASCII this might yield funny results).
+
+		const Common::String lower("test");
+		const Common::String lower1("test");
+		const Common::String mixed("tESt");
+		const Common::String spaced("test ");
+		const Common::String doublespaced("test  ");
+		const Common::String tabbed("test\t");
+		const Common::String plus128("t\xE5est");
+		// 'e'+128 = 0xE5
+
+		Common::CaseSensitiveString_EqualTo css_et;
+		TS_ASSERT_EQUALS(css_et(lower, mixed), false);
+		TS_ASSERT_EQUALS(css_et(lower, lower1), true);
+		TS_ASSERT_EQUALS(css_et(lower, lower), true);
+
+		// Different sorts of whitespace are to be treated differently.
+		TS_ASSERT_EQUALS(css_et(lower, spaced), false);
+		TS_ASSERT_EQUALS(css_et(lower, tabbed), false);
+		TS_ASSERT_EQUALS(css_et(spaced, tabbed), false);
+		TS_ASSERT_EQUALS(css_et(spaced, doublespaced), false);
+		TS_ASSERT_EQUALS(css_et(lower, plus128), false);
+	}
+
+	void test_ignore_case_equal_to() {
+
+		// This should be probably called case_insensitive_string_equal_to
+		// or something,but it's basically the same thing as
+		// test_case_sensitive_string_equal_to, only it's case
+		// insensitive.
+
+		const Common::String lower("test");
+		const Common::String lower1("test");
+		const Common::String mixed("tESt");
+		const Common::String spaced("test ");
+		const Common::String mixedspaced("tESt ");
+		const Common::String doublespaced("test  ");
+		const Common::String tabbed("test\t");
+		const Common::String plus128("t\xE5est");
+
+		Common::IgnoreCase_EqualTo ic_et;
+		TS_ASSERT_EQUALS(ic_et(lower, mixed), true);
+		TS_ASSERT_EQUALS(ic_et(lower, lower1), true);
+		TS_ASSERT_EQUALS(ic_et(lower, lower), true);
+		// Edge case:
+		TS_ASSERT_EQUALS(ic_et(spaced, mixedspaced), true);
+
+		// Different sorts of whitespace are to be treated differently.
+		TS_ASSERT_EQUALS(ic_et(lower, spaced), false);
+		TS_ASSERT_EQUALS(ic_et(lower, tabbed), false);
+		TS_ASSERT_EQUALS(ic_et(spaced, tabbed), false);
+		TS_ASSERT_EQUALS(ic_et(spaced, doublespaced), false);
+		TS_ASSERT_EQUALS(ic_et(lower, plus128), false);
+	}
+
+	void test_case_sensitive_string_hash() {
+
+		// Here we compute string hashes for different
+		// strings and see that the functor is case sensitive
+		// and does not ignore spaces.
+		// The hashes come from Python's hash() function.
+
+		const Common::String lower("test");
+		const uint lower_hash = 1308370872;
+		const Common::String lower1("test");
+		const Common::String mixed("tESt");
+		const uint mixed_hash = -1217273608;
+		const Common::String spaced("test ");
+		const uint spaced_hash = -1086267887;
+		const Common::String mixedspaced("tESt ");
+		const Common::String doublespaced("test  ");
+		const Common::String tabbed("test\t");
+		const uint tabbed_hash = -1086267848;
+
+		Common::CaseSensitiveString_Hash css_h;
+		TS_ASSERT_EQUALS(css_h(lower), lower_hash);
+		TS_ASSERT_EQUALS(css_h(mixed), mixed_hash);
+		TS_ASSERT_EQUALS(css_h(spaced), spaced_hash);
+		TS_ASSERT_EQUALS(css_h(tabbed), tabbed_hash);
+		TS_ASSERT_DIFFERS(css_h(spaced), css_h(doublespaced));
+	}
+
+	void test_ignore_case_hash() {
+		// Same as test_case_sensitive_string_hash, but case insensitive.
+		const Common::String lower("test");
+		const uint lower_hash = 1308370872;
+		const Common::String lower1("test");
+		const Common::String mixed("tESt");
+		const Common::String spaced("test ");
+		const uint spaced_hash = -1086267887;
+		const Common::String mixedspaced("tESt ");
+		const Common::String doublespaced("test  ");
+		const Common::String tabbed("test\t");
+		const uint tabbed_hash = -1086267848;
+
+		Common::IgnoreCase_Hash ic_h;
+		TS_ASSERT_EQUALS(ic_h(lower), lower_hash);
+		TS_ASSERT_EQUALS(ic_h(mixed), lower_hash);
+		TS_ASSERT_EQUALS(ic_h(spaced), spaced_hash);
+		TS_ASSERT_EQUALS(ic_h(tabbed), tabbed_hash);
+		TS_ASSERT_EQUALS(ic_h(mixedspaced), spaced_hash);
+		TS_ASSERT_DIFFERS(ic_h(spaced), ic_h(doublespaced));
+	}
+
+	void test_cpp_string_hash ()
+	{
+		// We run the same tests with Hash<String>,
+		// a template specialization of Hash, also a functor.
+		// It is supposed to be case sensitive.
+		// Again, hashes come from Python's hash().
+
+		const Common::String lower("test");
+		const uint lower_hash = 1308370872;
+		const Common::String lower1("test");
+		const Common::String mixed("tESt");
+		const uint mixed_hash = -1217273608;
+		const Common::String spaced("test ");
+		const uint spaced_hash = -1086267887;
+		const Common::String mixedspaced("tESt ");
+		const Common::String doublespaced("test  ");
+		const Common::String tabbed("test\t");
+		const uint tabbed_hash = -1086267848;
+
+		Common::Hash<Common::String> h;
+		TS_ASSERT_EQUALS(h(lower), lower_hash);
+		TS_ASSERT_EQUALS(h(lower), h(lower1));
+		TS_ASSERT_EQUALS(h(mixed), mixed_hash);
+		TS_ASSERT_EQUALS(h(spaced), spaced_hash);
+		TS_ASSERT_EQUALS(h(tabbed), tabbed_hash);
+		TS_ASSERT_DIFFERS(h(spaced), h(doublespaced));
+	}
+
+	void test_c_style_string_hash ()
+	{
+		// Same as test_cpp_string_hash but with Hash<const char*>,
+		// a template specialization of Hash, also a functor,
+		// that works with C-Style strings.
+		// It is supposed to be case sensitive.
+
+		char lower[] = "test";
+		const uint lower_hash = 1308370872; // CPython told me so
+		char lower1[] = "test";
+		char mixed[] = "tESt";
+		const uint mixed_hash = -1217273608;
+		char spaced[] = "test ";
+		const uint spaced_hash = -1086267887;
+		char mixedspaced[] = "tESt ";
+		char doublespaced[] = "test  ";
+		char tabbed[] = "test\t";
+		const uint tabbed_hash = -1086267848;
+
+		Common::Hash<const char*> h;
+		TS_ASSERT_EQUALS(h(lower), lower_hash);
+		TS_ASSERT_EQUALS(h(lower), h(lower1));
+		TS_ASSERT_EQUALS(h(mixed), mixed_hash);
+		TS_ASSERT_EQUALS(h(spaced), spaced_hash);
+		TS_ASSERT_DIFFERS(h(spaced), h(mixedspaced));
+		TS_ASSERT_EQUALS(h(tabbed), tabbed_hash);
+		TS_ASSERT_DIFFERS(h(spaced), h(doublespaced));
+	}
+
+
+};
diff --git a/test/common/huffman.h b/test/common/huffman.h
index 52199a8..53353aa 100644
--- a/test/common/huffman.h
+++ b/test/common/huffman.h
@@ -3,20 +3,27 @@
 #include "common/bitstream.h"
 #include "common/memstream.h"
 
-class HuffmanTestSuite : public CxxTest::TestSuite
-{
+/**
+* A test suite for the Huffman decoder in common/huffman.h
+* The encoding used comes from the example on the Wikipedia page
+* for Huffman.
+* TODO: It could be improved by generating one at runtime.
+*/
+class HuffmanTestSuite : public CxxTest::TestSuite {
 	public:
 	void test_get_with_full_symbols() {
 
 		/*
-		 * Testing the Huffman decoder.
+		 * The class can be initialized with or without providing
+		 * a max_length and a symbol table.
+		 * We test with a table.
 		 *
 		 * Encoding (arbitrary, for testing purpouses):
-		 * A=010
-		 * B=011
-		 * C=11
-		 * D=00
-		 * E=10
+		 * 0xA=010
+		 * 0xB=011
+		 * 0xC=11
+		 * 0xD=00
+		 * 0xE=10
 		 */
 
 		uint32 codeCount = 5;
@@ -25,7 +32,7 @@ class HuffmanTestSuite : public CxxTest::TestSuite
 		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
 		const uint32 symbols[]  = {0xA, 0xB, 0xC, 0xD, 0xE};
 
-		Common::Huffman h (maxLength, codeCount, codes, lengths, symbols);
+		Common::Huffman h(maxLength, codeCount, codes, lengths, symbols);
 
 		byte input[] = {0x4F, 0x20};
 		// Provided input...
@@ -53,8 +60,8 @@ class HuffmanTestSuite : public CxxTest::TestSuite
 	void test_get_without_symbols() {
 
 		/*
-		 * This is basically the same as above, but
-		 * I pass minimal arguments.
+		 * This is basically the same as test_get_with_full_symbols, but
+		 * I only pass the minimal required arguments.
 		 * Specifically, I avoid passing the symbols table, so that
 		 * array indices are used instead.
 		 *
@@ -71,7 +78,7 @@ class HuffmanTestSuite : public CxxTest::TestSuite
 		const uint8 lengths[] = {3,3,2,2,2};
 		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
 
-		Common::Huffman h (0, codeCount, codes, lengths, 0);
+		Common::Huffman h(0, codeCount, codes, lengths, 0);
 
 		byte input[] = {0x4F, 0x20};
 		uint32 expected[] = {0, 1, 2, 3, 4, 3 ,3};
@@ -91,16 +98,23 @@ class HuffmanTestSuite : public CxxTest::TestSuite
 	void test_get_after_set_symbols() {
 
 		/*
-		 * Another variation of the above.
+		 * Another variation of test_get_with_full_symbols.
 		 * I use the setSymbols method to define, a posteriori,
-		 * an alphabet to be used in place of array indices
+		 * an alphabet to be used in place of array indices.
+		 * The encoding is, at first,
+		 * 0=010
+		 * 1=011
+		 * 2=11
+		 * 3=00
+		 * 4=10
+		 * (=array indices).
 		 */
 
 		uint32 codeCount = 5;
 		const uint8 lengths[] = {3,3,2,2,2};
 		const uint32 codes[]  = {0x2, 0x3, 0x3, 0x0, 0x2};
 
-		Common::Huffman h (0, codeCount, codes, lengths, 0);
+		Common::Huffman h(0, codeCount, codes, lengths, 0);
 
 		const uint32 symbols[]  = {0xA, 0xB, 0xC, 0xD, 0xE};
 		h.setSymbols(symbols);
diff --git a/test/common/rendermode.h b/test/common/rendermode.h
index a25c098..e5e277f 100644
--- a/test/common/rendermode.h
+++ b/test/common/rendermode.h
@@ -3,8 +3,7 @@
 #include "common/gui_options.h"
 #include "common/str.h"
 
-class RenderModeTestSuite : public CxxTest::TestSuite
-{
+class RenderModeTestSuite : public CxxTest::TestSuite {
 	public:
 	void test_parse_render_mode_good() {
 		/*
@@ -63,7 +62,7 @@ class RenderModeTestSuite : public CxxTest::TestSuite
 		TS_ASSERT_EQUALS(Common::getRenderModeCode(Common::kRenderDefault), null_p);
 	}
 
-	void test_render_2_guio () {
+	void test_render_2_guio() {
 		/*
 		 * Verify that a rendermode is taken and the corresponding
 		 * GUIO_xxxxx is returned.
diff --git a/test/common/util.h b/test/common/util.h
index 3bd997a..57688ff 100644
--- a/test/common/util.h
+++ b/test/common/util.h
@@ -1,16 +1,16 @@
 #include <cxxtest/TestSuite.h>
 #include "common/util.h"
 
+/**
+ * Test suite for the functions in common/util.h
+ */
 class UtilTestSuite : public CxxTest::TestSuite {
-public:
-
-	// Test the parseBool function
-
-	// 'Regular' cases that must work
-	// (note that the function must be case insensitive):
-
+	public:
 	void test_parsebool_yesno() {
 
+		// First test for the parseBool function.
+		// These are the mixed case yes/no cases that must work
+
 		bool valasbool;
 		bool success;
 
@@ -27,6 +27,9 @@ public:
 
 	void test_parsebool_truefalse() {
 
+		// First test for the parseBool function.
+		// These are the mixed case true/false cases that must work
+
 		bool valasbool;
 		bool success;
 
@@ -43,6 +46,12 @@ public:
 
 	void test_parsebool_onezero() {
 
+		// Third test for the parseBool function.
+		// These are the 1/0 cases that must work.
+		// Note that while 'a-z'+0x20 must work just fine,
+		// '0-1'+0x20 should NOT; this is addressed in
+		// parsebool_bad
+
 		bool valasbool;
 		bool success;
 
@@ -79,6 +88,20 @@ public:
 		success = Common::parseBool (string_3, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
+		// While 'a-z'+0x20 must work just fine,
+		// '0-1'+0x20 should NOT. '2' is not good either.
+
+		Common::String string_4 ("\x50");
+		success = Common::parseBool (string_4, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
+
+		Common::String string_5 ("\x51");
+		success = Common::parseBool (string_5, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
+
+		Common::String string_6 ("2");
+		success = Common::parseBool (string_6, valasbool);
+		TS_ASSERT_EQUALS(success, 0);
 	}
 
 	void test_is_al_num() {
@@ -189,8 +212,10 @@ public:
 	void test_is_space() {
 		// isSpace should return true iff the character is some kind of whitespace
 		// or tab character
-		for (int c=0; c<255; c++) {
-			 if (c==' ' || c=='\t' || c=='\r' || c=='\n' || c=='\v' || c=='\f') {
+		for (int c = 0; c < 255; c++) {
+			 if (c == ' '  || c == '\t' ||
+				 c == '\r' || c == '\n' ||
+				 c == '\v' || c == '\f') {
 				 TS_ASSERT_EQUALS(Common::isSpace(c), 1);
 			 } else {
 				 TS_ASSERT_EQUALS(Common::isSpace(c), 0);
@@ -201,8 +226,8 @@ public:
 	void test_is_print() {
 		// isPrint should return true iff the input is a printable ascii char.
 		// That is to say, 0x20 to 0x7E.
-		for (int c=0; c<255; c++) {
-			 if (c>=0x20 && c<=0x7E) {
+		for (int c = 0; c < 255; c++) {
+			 if (c >= 0x20 && c <= 0x7E) {
 				 TS_ASSERT_EQUALS(Common::isPrint(c), 1);
 			 } else {
 				 TS_ASSERT_EQUALS(Common::isPrint(c), 0);


Commit: e9406fad246efe975ce63dab207be76edf3e0998
    https://github.com/scummvm/scummvm/commit/e9406fad246efe975ce63dab207be76edf3e0998
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:22:01-07:00

Commit Message:
TEST: removed fixed hashes in test/common/hash-str.h

The hash function does not necessarily have to conform to one specific algorithm as long as equals/differs is respected.

Changed paths:
    test/common/hash-str.h
    test/common/util.h



diff --git a/test/common/hash-str.h b/test/common/hash-str.h
index b106f66..9eadea5 100644
--- a/test/common/hash-str.h
+++ b/test/common/hash-str.h
@@ -26,8 +26,8 @@ class HashStrTestSuite : public CxxTest::TestSuite {
 		const Common::String spaced("test ");
 		const Common::String doublespaced("test  ");
 		const Common::String tabbed("test\t");
-		const Common::String plus128("t\xE5est");
-		// 'e'+128 = 0xE5
+		const Common::String plus128("t\345est");
+		// 'e'+128 = 0xE5 = 0o345
 
 		Common::CaseSensitiveString_EqualTo css_et;
 		TS_ASSERT_EQUALS(css_et(lower, mixed), false);
@@ -56,7 +56,7 @@ class HashStrTestSuite : public CxxTest::TestSuite {
 		const Common::String mixedspaced("tESt ");
 		const Common::String doublespaced("test  ");
 		const Common::String tabbed("test\t");
-		const Common::String plus128("t\xE5est");
+		const Common::String plus128("t\345est");
 
 		Common::IgnoreCase_EqualTo ic_et;
 		TS_ASSERT_EQUALS(ic_et(lower, mixed), true);
@@ -78,79 +78,64 @@ class HashStrTestSuite : public CxxTest::TestSuite {
 		// Here we compute string hashes for different
 		// strings and see that the functor is case sensitive
 		// and does not ignore spaces.
-		// The hashes come from Python's hash() function.
 
 		const Common::String lower("test");
-		const uint lower_hash = 1308370872;
 		const Common::String lower1("test");
 		const Common::String mixed("tESt");
-		const uint mixed_hash = -1217273608;
 		const Common::String spaced("test ");
-		const uint spaced_hash = -1086267887;
 		const Common::String mixedspaced("tESt ");
 		const Common::String doublespaced("test  ");
 		const Common::String tabbed("test\t");
-		const uint tabbed_hash = -1086267848;
 
 		Common::CaseSensitiveString_Hash css_h;
-		TS_ASSERT_EQUALS(css_h(lower), lower_hash);
-		TS_ASSERT_EQUALS(css_h(mixed), mixed_hash);
-		TS_ASSERT_EQUALS(css_h(spaced), spaced_hash);
-		TS_ASSERT_EQUALS(css_h(tabbed), tabbed_hash);
+		TS_ASSERT_EQUALS(css_h(lower), css_h(lower1));
+		TS_ASSERT_DIFFERS(css_h(mixed), css_h(lower));
+		TS_ASSERT_DIFFERS(css_h(spaced), css_h(lower));
+		TS_ASSERT_DIFFERS(css_h(tabbed), css_h(spaced));
 		TS_ASSERT_DIFFERS(css_h(spaced), css_h(doublespaced));
 	}
 
 	void test_ignore_case_hash() {
 		// Same as test_case_sensitive_string_hash, but case insensitive.
 		const Common::String lower("test");
-		const uint lower_hash = 1308370872;
 		const Common::String lower1("test");
 		const Common::String mixed("tESt");
 		const Common::String spaced("test ");
-		const uint spaced_hash = -1086267887;
 		const Common::String mixedspaced("tESt ");
 		const Common::String doublespaced("test  ");
 		const Common::String tabbed("test\t");
-		const uint tabbed_hash = -1086267848;
 
 		Common::IgnoreCase_Hash ic_h;
-		TS_ASSERT_EQUALS(ic_h(lower), lower_hash);
-		TS_ASSERT_EQUALS(ic_h(mixed), lower_hash);
-		TS_ASSERT_EQUALS(ic_h(spaced), spaced_hash);
-		TS_ASSERT_EQUALS(ic_h(tabbed), tabbed_hash);
-		TS_ASSERT_EQUALS(ic_h(mixedspaced), spaced_hash);
+		TS_ASSERT_EQUALS(ic_h(lower), ic_h(lower1));
+		TS_ASSERT_EQUALS(ic_h(mixed), ic_h(lower));
+		TS_ASSERT_EQUALS(ic_h(spaced), ic_h(mixedspaced));
+		TS_ASSERT_DIFFERS(ic_h(tabbed), ic_h(lower));
 		TS_ASSERT_DIFFERS(ic_h(spaced), ic_h(doublespaced));
 	}
 
-	void test_cpp_string_hash ()
+	void test_cpp_string_hash()
 	{
 		// We run the same tests with Hash<String>,
 		// a template specialization of Hash, also a functor.
 		// It is supposed to be case sensitive.
-		// Again, hashes come from Python's hash().
 
 		const Common::String lower("test");
-		const uint lower_hash = 1308370872;
 		const Common::String lower1("test");
 		const Common::String mixed("tESt");
-		const uint mixed_hash = -1217273608;
 		const Common::String spaced("test ");
-		const uint spaced_hash = -1086267887;
 		const Common::String mixedspaced("tESt ");
 		const Common::String doublespaced("test  ");
 		const Common::String tabbed("test\t");
-		const uint tabbed_hash = -1086267848;
 
 		Common::Hash<Common::String> h;
-		TS_ASSERT_EQUALS(h(lower), lower_hash);
 		TS_ASSERT_EQUALS(h(lower), h(lower1));
-		TS_ASSERT_EQUALS(h(mixed), mixed_hash);
-		TS_ASSERT_EQUALS(h(spaced), spaced_hash);
-		TS_ASSERT_EQUALS(h(tabbed), tabbed_hash);
+		TS_ASSERT_DIFFERS(h(mixed), h(lower));
+		TS_ASSERT_DIFFERS(h(spaced), h(lower));
+		TS_ASSERT_DIFFERS(h(tabbed), h(spaced));
 		TS_ASSERT_DIFFERS(h(spaced), h(doublespaced));
 	}
 
-	void test_c_style_string_hash ()
+	void test_c_style_string_hash()
 	{
 		// Same as test_cpp_string_hash but with Hash<const char*>,
 		// a template specialization of Hash, also a functor,
@@ -158,25 +143,21 @@ class HashStrTestSuite : public CxxTest::TestSuite {
 		// It is supposed to be case sensitive.
 
 		char lower[] = "test";
-		const uint lower_hash = 1308370872; // CPython told me so
 		char lower1[] = "test";
 		char mixed[] = "tESt";
-		const uint mixed_hash = -1217273608;
 		char spaced[] = "test ";
-		const uint spaced_hash = -1086267887;
 		char mixedspaced[] = "tESt ";
 		char doublespaced[] = "test  ";
 		char tabbed[] = "test\t";
-		const uint tabbed_hash = -1086267848;
 
 		Common::Hash<const char*> h;
-		TS_ASSERT_EQUALS(h(lower), lower_hash);
 		TS_ASSERT_EQUALS(h(lower), h(lower1));
-		TS_ASSERT_EQUALS(h(mixed), mixed_hash);
-		TS_ASSERT_EQUALS(h(spaced), spaced_hash);
+		TS_ASSERT_DIFFERS(h(mixed), h(lower));
+		TS_ASSERT_DIFFERS(h(spaced), h(lower));
 		TS_ASSERT_DIFFERS(h(spaced), h(mixedspaced));
-		TS_ASSERT_EQUALS(h(tabbed), tabbed_hash);
+		TS_ASSERT_DIFFERS(h(tabbed), h(spaced));
 		TS_ASSERT_DIFFERS(h(spaced), h(doublespaced));
+
 	}
 
 
diff --git a/test/common/util.h b/test/common/util.h
index 57688ff..05e6243 100644
--- a/test/common/util.h
+++ b/test/common/util.h
@@ -14,13 +14,13 @@ class UtilTestSuite : public CxxTest::TestSuite {
 		bool valasbool;
 		bool success;
 
-		Common::String string_1 ("Yes");
-		success = Common::parseBool (string_1, valasbool);
+		Common::String string_1("Yes");
+		success = Common::parseBool(string_1, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 1);
 
-		Common::String string_2 ("nO");
-		success = Common::parseBool (string_2, valasbool);
+		Common::String string_2("nO");
+		success = Common::parseBool(string_2, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 0);
 	}
@@ -33,13 +33,13 @@ class UtilTestSuite : public CxxTest::TestSuite {
 		bool valasbool;
 		bool success;
 
-		Common::String string_3 ("tRuE");
-		success = Common::parseBool (string_3, valasbool);
+		Common::String string_3("tRuE");
+		success = Common::parseBool(string_3, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 1);
 
-		Common::String string_4 ("fAlSe");
-		success = Common::parseBool (string_4, valasbool);
+		Common::String string_4("fAlSe");
+		success = Common::parseBool(string_4, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 0);
 	}
@@ -56,12 +56,12 @@ class UtilTestSuite : public CxxTest::TestSuite {
 		bool success;
 
 		Common::String string_5 ("1");
-		success = Common::parseBool (string_5, valasbool);
+		success = Common::parseBool(string_5, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 1);
 
-		Common::String string_6 ("0");
-		success = Common::parseBool (string_6, valasbool);
+		Common::String string_6("0");
+		success = Common::parseBool(string_6, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 0);
 
@@ -74,33 +74,33 @@ class UtilTestSuite : public CxxTest::TestSuite {
 
 		// Bad cases that should not return success #1:
 		// Random string
-		Common::String string_1 ("u_f1ght_l1k3_a_c0w");
-		success = Common::parseBool (string_1, valasbool);
+		Common::String string_1("u_f1ght_l1k3_a_c0w");
+		success = Common::parseBool(string_1, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
 		// Bad cases that should not return success #2, #3:
 		// The function should NOT accept trailing whitespaces:
-		Common::String string_2 (" yes");
-		success = Common::parseBool (string_2, valasbool);
+		Common::String string_2(" yes");
+		success = Common::parseBool(string_2, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
-		Common::String string_3 ("yes ");
-		success = Common::parseBool (string_3, valasbool);
+		Common::String string_3("yes ");
+		success = Common::parseBool(string_3, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
 		// While 'a-z'+0x20 must work just fine,
 		// '0-1'+0x20 should NOT. '2' is not good either.
 
-		Common::String string_4 ("\x50");
-		success = Common::parseBool (string_4, valasbool);
+		Common::String string_4("\x50");
+		success = Common::parseBool(string_4, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
-		Common::String string_5 ("\x51");
-		success = Common::parseBool (string_5, valasbool);
+		Common::String string_5("\x51");
+		success = Common::parseBool(string_5, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 
-		Common::String string_6 ("2");
-		success = Common::parseBool (string_6, valasbool);
+		Common::String string_6("2");
+		success = Common::parseBool(string_6, valasbool);
 		TS_ASSERT_EQUALS(success, 0);
 	}
 


Commit: d2c85e19eb62f2e9a8ba3b1251ee42a1d68e92a5
    https://github.com/scummvm/scummvm/commit/d2c85e19eb62f2e9a8ba3b1251ee42a1d68e92a5
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-10T04:22:57-07:00

Commit Message:
TEST: Whitespaces in test/common/

Changed paths:
    test/common/hash-str.h
    test/common/util.h



diff --git a/test/common/hash-str.h b/test/common/hash-str.h
index 9eadea5..0391e71 100644
--- a/test/common/hash-str.h
+++ b/test/common/hash-str.h
@@ -150,7 +150,7 @@ class HashStrTestSuite : public CxxTest::TestSuite {
 		char doublespaced[] = "test  ";
 		char tabbed[] = "test\t";
 
-		Common::Hash<const char*> h;
+		Common::Hash<const char *> h;
 		TS_ASSERT_EQUALS(h(lower), h(lower1));
 		TS_ASSERT_DIFFERS(h(mixed), h(lower));
 		TS_ASSERT_DIFFERS(h(spaced), h(lower));
diff --git a/test/common/util.h b/test/common/util.h
index 05e6243..cd65307 100644
--- a/test/common/util.h
+++ b/test/common/util.h
@@ -55,7 +55,7 @@ class UtilTestSuite : public CxxTest::TestSuite {
 		bool valasbool;
 		bool success;
 
-		Common::String string_5 ("1");
+		Common::String string_5("1");
 		success = Common::parseBool(string_5, valasbool);
 		TS_ASSERT_EQUALS(success, 1);
 		TS_ASSERT_EQUALS(valasbool, 1);


Commit: 3e246b3e67894b1b5d812d16a32a52198ecb9b6c
    https://github.com/scummvm/scummvm/commit/3e246b3e67894b1b5d812d16a32a52198ecb9b6c
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2013-07-15T05:26:13-07:00

Commit Message:
Merge pull request #323 from tobiatesan/test_for_common

Test for common

Changed paths:
  A test/common/hash-str.h
  A test/common/huffman.h
  A test/common/rendermode.h
  A test/common/util.h









More information about the Scummvm-git-logs mailing list