[Scummvm-cvs-logs] scummvm master -> 65fc72e30a885f6adca99505ee869e010f94c1c3
fingolfin
max at quendi.de
Tue Apr 12 17:24:59 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f1471689cf COMMON: Let MKTAG always return an uint32
65fc72e30a COMMON: Add some testcases for common/endian.h
Commit: f1471689cf6b11412da0d8d09526a558ff33e9d0
https://github.com/scummvm/scummvm/commit/f1471689cf6b11412da0d8d09526a558ff33e9d0
Author: Max Horn (max at quendi.de)
Date: 2011-04-12T08:23:21-07:00
Commit Message:
COMMON: Let MKTAG always return an uint32
Changed paths:
common/endian.h
diff --git a/common/endian.h b/common/endian.h
index 4dbe8e0..e6c39d3 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -147,7 +147,7 @@
* be used for character constants. Hence if one uses multi-byte character
* constants, a potential portability problem opens up.
*/
-#define MKTAG(a0,a1,a2,a3) ((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24))
+#define MKTAG(a0,a1,a2,a3) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24)))
// Functions for reading/writing native Integers,
// this transparently handles the need for alignment
Commit: 65fc72e30a885f6adca99505ee869e010f94c1c3
https://github.com/scummvm/scummvm/commit/65fc72e30a885f6adca99505ee869e010f94c1c3
Author: Max Horn (max at quendi.de)
Date: 2011-04-12T08:23:32-07:00
Commit Message:
COMMON: Add some testcases for common/endian.h
Changed paths:
A test/common/endian.h
diff --git a/test/common/endian.h b/test/common/endian.h
new file mode 100644
index 0000000..cba7618
--- /dev/null
+++ b/test/common/endian.h
@@ -0,0 +1,36 @@
+#include <cxxtest/TestSuite.h>
+#include "common/endian.h"
+
+class EndianTestSuite : public CxxTest::TestSuite
+{
+ public:
+ void test_MKTAG() {
+ const char *str_tag = "ABCD";
+ uint32 tag = READ_BE_UINT32(str_tag);
+ TS_ASSERT_EQUALS(MKTAG('A','B','C','D'), tag);
+ }
+
+ void test_READ_BE_UINT32() {
+ const char data[4] = { 0x12, 0x34, 0x56, 0x78 };
+ uint32 value = READ_BE_UINT32(data);
+ TS_ASSERT_EQUALS(value, 0x12345678UL);
+ }
+
+ void test_READ_LE_UINT32() {
+ const char data[4] = { 0x12, 0x34, 0x56, 0x78 };
+ uint32 value = READ_LE_UINT32(data);
+ TS_ASSERT_EQUALS(value, 0x78563412UL);
+ }
+
+ void test_READ_BE_UINT16() {
+ const char data[4] = { 0x12, 0x34, 0x56, 0x78 };
+ uint32 value = READ_BE_UINT16(data);
+ TS_ASSERT_EQUALS(value, 0x1234UL);
+ }
+
+ void test_READ_LE_UINT16() {
+ const char data[4] = { 0x12, 0x34, 0x56, 0x78 };
+ uint32 value = READ_LE_UINT16(data);
+ TS_ASSERT_EQUALS(value, 0x3412UL);
+ }
+};
More information about the Scummvm-git-logs
mailing list