aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-04-16 16:35:08 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-04-16 16:35:08 -0700
commitb48fb4d83121ee776cce12a7be43afed7332bd7d (patch)
tree7385ab05f2380e194ed0236624d20253c0fc20f5 /tests/runner.py
parent11420a30683911e32c14dcf8286d4b256462b351 (diff)
proper support for packed structs
Diffstat (limited to 'tests/runner.py')
-rw-r--r--tests/runner.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index d7a6409e..635a4d0f 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1228,6 +1228,37 @@ if 'benchmark' not in sys.argv:
'''
self.do_test(src, '*96,97,98,101,101*')
+ def test_pack(self):
+ src = '''
+ #include <stdio.h>
+ #include <string.h>
+
+ #pragma pack(push,1)
+ typedef struct header
+ {
+ unsigned char id;
+ unsigned short colour;
+ unsigned char desc;
+ } header;
+ #pragma pack(pop)
+
+ typedef struct fatheader
+ {
+ unsigned char id;
+ unsigned short colour;
+ unsigned char desc;
+ } fatheader;
+
+ int main( int argc, const char *argv[] ) {
+ header h, *ph = 0;
+ fatheader fh, *pfh = 0;
+ printf("*%d,%d,%d*\\n", sizeof(header), (int)((int)&h.desc - (int)&h.id), (int)(&ph[1])-(int)(&ph[0]));
+ printf("*%d,%d,%d*\\n", sizeof(fatheader), (int)((int)&fh.desc - (int)&fh.id), (int)(&pfh[1])-(int)(&pfh[0]));
+ return 0;
+ }
+ '''
+ self.do_test(src, '*4,3,4*\n*6,4,6*')
+
def test_varargs(self):
src = '''
#include <stdio.h>