OSDN Git Service

2010-07-29 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / type-stream-1.m
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
3 #include <objc/typedstream.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 int main (void)
8 {
9   FILE *f; TypedStream *ts;
10   struct T { int a, b; } x = { 1, 2 };
11   f = fopen ("foo", "w"); ts = objc_open_typed_stream (f, OBJC_WRITEONLY);
12   objc_write_type (ts, @encode(struct T), &x);
13   objc_close_typed_stream (ts); fclose (f);
14   f = fopen ("foo", "r"); ts = objc_open_typed_stream (f, OBJC_READONLY);
15   struct T y;
16   objc_read_type (ts, @encode(struct T), &y);
17   if (y.a != 1)
18    abort ();
19   if (y.b != 2)
20    abort ();
21   objc_close_typed_stream (ts); fclose (f);
22   remove ("foo");
23   return 0;
24 }
25