diff options
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/tests/test_buf.c')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/tests/test_buf.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/tests/test_buf.c b/src/others/mimesh/libg3d-0.0.8/tests/test_buf.c new file mode 100644 index 0000000..70551ba --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/tests/test_buf.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $Id:$ */ | ||
2 | |||
3 | /* | ||
4 | libg3d - 3D object loading library | ||
5 | |||
6 | Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de> | ||
7 | |||
8 | This library is free software; you can redistribute it and/or | ||
9 | modify it under the terms of the GNU Lesser General Public | ||
10 | License as published by the Free Software Foundation; either | ||
11 | version 2.1 of the License, or (at your option) any later version. | ||
12 | |||
13 | This library is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Lesser General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU Lesser General Public | ||
19 | License along with this library; if not, write to the Free Software | ||
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <glib.h> | ||
25 | #include <g3d/g3d.h> | ||
26 | #include <g3d/stream.h> | ||
27 | |||
28 | static guint8 test_buffer[] = { | ||
29 | 0x01, 0x23, 0x45, 0x67, /* 0x01234567 MSB */ | ||
30 | 0x67, 0x45, 0x23, 0x01, /* 0x01234567 LSB */ | ||
31 | 0x00 | ||
32 | }; | ||
33 | static gsize tbsize = sizeof(test_buffer); | ||
34 | |||
35 | int main(int argc, char *argv[]) | ||
36 | { | ||
37 | G3DStream *stream; | ||
38 | guint32 u; | ||
39 | |||
40 | stream = g3d_stream_from_buffer(test_buffer, tbsize, "testbuf", FALSE); | ||
41 | |||
42 | /* read 2 x 32-bit integer */ | ||
43 | u = g3d_stream_read_int32_be(stream); | ||
44 | g_print("MSB value: 0x%08x\n", u); | ||
45 | u = g3d_stream_read_int32_le(stream); | ||
46 | g_print("LSB value: 0x%08x\n", u); | ||
47 | /* seek back 4 bytes */ | ||
48 | g3d_stream_seek(stream, -4, G_SEEK_CUR); | ||
49 | u = g3d_stream_read_int32_le(stream); | ||
50 | g_print("LSB value: 0x%08x\n", u); | ||
51 | /* rewind stream */ | ||
52 | g3d_stream_seek(stream, 0, G_SEEK_SET); | ||
53 | u = g3d_stream_read_int32_be(stream); | ||
54 | g_print("MSB value: 0x%08x\n", u); | ||
55 | |||
56 | g3d_stream_close(stream); | ||
57 | |||
58 | return 0; | ||
59 | } | ||