[Scummvm-cvs-logs] SF.net SVN: scummvm: [23570] scummvm/trunk/test/common/pack.h

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Jul 22 20:39:46 CEST 2006


Revision: 23570
Author:   fingolfin
Date:     2006-07-22 11:39:41 -0700 (Sat, 22 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23570&view=rev

Log Message:
-----------
Adding unit test for struct packing

Added Paths:
-----------
    scummvm/trunk/test/common/pack.h
Added: scummvm/trunk/test/common/pack.h
===================================================================
--- scummvm/trunk/test/common/pack.h	                        (rev 0)
+++ scummvm/trunk/test/common/pack.h	2006-07-22 18:39:41 UTC (rev 23570)
@@ -0,0 +1,36 @@
+#include <cxxtest/TestSuite.h>
+
+#include "common/stdafx.h"
+#include "common/scummsys.h"
+
+#include <common/pack-start.h>	// START STRUCT PACKING
+
+struct TestStruct {
+	uint32 x;
+	byte y;
+	uint16 z;
+	uint32 a;
+	byte b;
+};
+
+#include <common/pack-end.h>	// END STRUCT PACKING
+
+#define OFFS(type,item) (int)(&((type*)0)->type::item)
+
+class PackTestSuite : public CxxTest::TestSuite
+{
+	public:
+	void test_packing( void )
+	{
+		TS_ASSERT_EQUALS( sizeof(TestStruct), 4+1+2+4+1 );
+	}
+
+	void test_offsets( void )
+	{
+		TS_ASSERT_EQUALS( OFFS(TestStruct, x), 0 );
+		TS_ASSERT_EQUALS( OFFS(TestStruct, y), 4 );
+		TS_ASSERT_EQUALS( OFFS(TestStruct, z), 5 );
+		TS_ASSERT_EQUALS( OFFS(TestStruct, a), 7 );
+		TS_ASSERT_EQUALS( OFFS(TestStruct, b), 11 );
+	}
+};


Property changes on: scummvm/trunk/test/common/pack.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list