[Scummvm-cvs-logs] scummvm master -> 5a8eb1c9d699f69bfa0406a2d80f7576e7eb5136

sev- sev at scummvm.org
Mon May 23 19:06:50 CEST 2016


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

Summary:
1f8667c5d9 BUILD: Fix test compilation with event recorder enabled
3d89af272b COMMON: Fix SortedArray implementation for empty array
5a8eb1c9d6 TESTS: Implement SortedArray test


Commit: 1f8667c5d949070035390531e4f10c0f945d7352
    https://github.com/scummvm/scummvm/commit/1f8667c5d949070035390531e4f10c0f945d7352
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-05-23T16:36:26+02:00

Commit Message:
BUILD: Fix test compilation with event recorder enabled

Changed paths:
    common/recorderfile.cpp
    common/scummsys.h
    test/module.mk



diff --git a/common/recorderfile.cpp b/common/recorderfile.cpp
index 71f8272..04802aa 100644
--- a/common/recorderfile.cpp
+++ b/common/recorderfile.cpp
@@ -30,6 +30,8 @@
 #include "graphics/surface.h"
 #include "graphics/scaler.h"
 
+#ifdef ENABLE_EVENTRECORDER
+
 #define RECORD_VERSION 1
 
 namespace Common {
@@ -714,3 +716,5 @@ void PlaybackFile::checkRecordedMD5() {
 
 
 }
+
+#endif // ENABLE_EVENTRECORDER
diff --git a/common/scummsys.h b/common/scummsys.h
index 5e1069f..3513ee2 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -215,6 +215,10 @@
 #include "config.h"
 #endif
 
+// Now we need to adjust some settings when running tests
+#ifdef COMPILING_TESTS
+#undef ENABLE_EVENTRECORDER
+#endif
 
 // In the following we configure various targets, in particular those
 // which can't use our "configure" tool and hence don't use config.h.
diff --git a/test/module.mk b/test/module.mk
index 11ee6bd..e591854 100644
--- a/test/module.mk
+++ b/test/module.mk
@@ -26,6 +26,7 @@ endif
 #TEST_LDFLAGS += -L/usr/X11R6/lib -lX11
 
 
+test: CXXFLAGS +=  -DCOMPILING_TESTS=1
 test: test/runner
 	./test/runner
 test/runner: test/runner.cpp $(TEST_LIBS)


Commit: 3d89af272b718dd30a60f351149fde95958acfb0
    https://github.com/scummvm/scummvm/commit/3d89af272b718dd30a60f351149fde95958acfb0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-05-23T16:36:34+02:00

Commit Message:
COMMON: Fix SortedArray implementation for empty array

Changed paths:
    common/array.h



diff --git a/common/array.h b/common/array.h
index 869d79b..29a1ff8 100644
--- a/common/array.h
+++ b/common/array.h
@@ -378,6 +378,11 @@ public:
 	 * Inserts element at the sorted position.
 	 */
 	void insert(const T &element) {
+		if (!this->_size) {
+			this->insert_aux(this->_storage, &element, &element + 1);
+			return;
+		}
+
 		T *where = (T *)bsearchMin(element, this->front(), this->_size, sizeof(T), _comparator);
 		insert(where, element);
 	}


Commit: 5a8eb1c9d699f69bfa0406a2d80f7576e7eb5136
    https://github.com/scummvm/scummvm/commit/5a8eb1c9d699f69bfa0406a2d80f7576e7eb5136
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-05-23T16:36:34+02:00

Commit Message:
TESTS: Implement SortedArray test

Changed paths:
    test/common/array.h



diff --git a/test/common/array.h b/test/common/array.h
index 64354ab..7473398 100644
--- a/test/common/array.h
+++ b/test/common/array.h
@@ -354,3 +354,44 @@ class ArrayTestSuite : public CxxTest::TestSuite
 	}
 
 };
+
+struct ListElement {
+	int value;
+
+	ListElement(int v) : value(v) {}
+};
+
+static int compareInts(const void *a, const void *b) {
+	return ((ListElement *)a)->value - ((ListElement *)a)->value;
+}
+
+class SortedArrayTestSuite : public CxxTest::TestSuite {
+public:
+	void test_insert() {
+		Common::SortedArray<ListElement *> container(compareInts);
+		Common::SortedArray<ListElement *>::iterator iter;
+
+		// Fill the container with some random data
+		container.insert(new ListElement(1));
+		return;
+
+		container.insert(new ListElement(7));
+		container.insert(new ListElement(8));
+		container.insert(new ListElement(3));
+		container.insert(new ListElement(5));
+		container.insert(new ListElement(4));
+		container.insert(new ListElement(9));
+		container.insert(new ListElement(2));
+		container.insert(new ListElement(6));
+
+		// Verify contents are correct
+		iter = container.begin();
+
+		for (int i = 1; i < 10; i++) {
+			TS_ASSERT_EQUALS((*iter)->value, i);
+			++iter;
+			TS_ASSERT_DIFFERS(iter, container.end());
+		}
+	}
+
+};






More information about the Scummvm-git-logs mailing list