]> git.draconx.ca Git - gob-dx.git/blob - tests/general.at
Pull in dxcommon for library tests.
[gob-dx.git] / tests / general.at
1 dnl Copyright © 2019 Nick Bowler
2 dnl License GPLv2+: GNU General Public License version 2 or any later version.
3 dnl This is free software: you are free to change and redistribute it.
4 dnl There is NO WARRANTY, to the extent permitted by law.
5
6 AT_SETUP([test.gob compilation])
7
8 AT_CHECK([gob2 "$abs_top_srcdir/t/test.gob"])
9 AT_CHECK([$HAVE_GTK2 || exit 77])
10 TEST_COMPILE_GOBJECT([$GTK_CFLAGS test-object.c], [0], [], [ignore])
11
12 AT_CLEANUP
13
14 AT_SETUP([test.gob C++ compilation])
15
16 AT_CHECK([gob2 --for-cpp "$abs_top_srcdir/t/test.gob"])
17 AT_CHECK([$HAVE_GTK2 || exit 77])
18 TEST_COMPILEXX_GOBJECT([$GTK_CFLAGS test-object.cc], [0], [], [ignore])
19
20 AT_CLEANUP
21
22 AT_SETUP([str.gob])
23
24 AT_DATA([main.c],
25 [[#include "str.h"
26
27 int main(void)
28 {
29   g_type_init ();
30
31   int the_answer = 42;
32   char *stupid_pointer = "ug";
33
34   /* This works fine. */
35   Str *test_good = (Str *) (str_new ("%d", the_answer));
36   test_good = test_good;
37
38   /* This gets a warning thanks to our function attribute. */
39   Str *test_bad = (Str *) (str_new ("%d", stupid_pointer));
40   test_bad = test_bad;
41
42   return 0;
43 }
44 ]])
45
46 str_gob=$abs_top_srcdir/t/str.gob
47 AT_CHECK([gob2 "$str_gob"])
48 TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr])
49 mv stderr str_stderr
50
51 # Check for correct diagnostic messages on the target lines...
52 AT_CHECK([awk '/want a string/ { print NR }' "$str_gob" >str_lines])
53 total=0
54 exec 3<str_lines
55 while read l <&3; do
56   AS_VAR_ARITH([total], [1 + $total])
57   AT_CHECK([awk -v line="$l" -v file="$str_gob" -NF : \
58     '$1 == file && $2 == line { exit 42 }' str_stderr], [42])
59 done
60 exec 3<&-
61 AT_CHECK([test x"$total" = x"2"])
62
63 TEST_COMPILE_GOBJECT([main.c], [0], [], [stderr])
64 AT_CHECK([awk -NF : '$1 == "main.c" && $2 == "15" { exit 42 }' stderr], [42])
65
66 AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main str.o main.o])
67
68 AT_CLEANUP