]> git.draconx.ca Git - gob-dx.git/blobdiff - tests/general.at
Pull in dxcommon for library tests.
[gob-dx.git] / tests / general.at
diff --git a/tests/general.at b/tests/general.at
new file mode 100644 (file)
index 0000000..355f09e
--- /dev/null
@@ -0,0 +1,68 @@
+dnl Copyright © 2019 Nick Bowler
+dnl License GPLv2+: GNU General Public License version 2 or any later version.
+dnl This is free software: you are free to change and redistribute it.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([test.gob compilation])
+
+AT_CHECK([gob2 "$abs_top_srcdir/t/test.gob"])
+AT_CHECK([$HAVE_GTK2 || exit 77])
+TEST_COMPILE_GOBJECT([$GTK_CFLAGS test-object.c], [0], [], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([test.gob C++ compilation])
+
+AT_CHECK([gob2 --for-cpp "$abs_top_srcdir/t/test.gob"])
+AT_CHECK([$HAVE_GTK2 || exit 77])
+TEST_COMPILEXX_GOBJECT([$GTK_CFLAGS test-object.cc], [0], [], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([str.gob])
+
+AT_DATA([main.c],
+[[#include "str.h"
+
+int main(void)
+{
+  g_type_init ();
+
+  int the_answer = 42;
+  char *stupid_pointer = "ug";
+
+  /* This works fine. */
+  Str *test_good = (Str *) (str_new ("%d", the_answer));
+  test_good = test_good;
+
+  /* This gets a warning thanks to our function attribute. */
+  Str *test_bad = (Str *) (str_new ("%d", stupid_pointer));
+  test_bad = test_bad;
+
+  return 0;
+}
+]])
+
+str_gob=$abs_top_srcdir/t/str.gob
+AT_CHECK([gob2 "$str_gob"])
+TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr])
+mv stderr str_stderr
+
+# Check for correct diagnostic messages on the target lines...
+AT_CHECK([awk '/want a string/ { print NR }' "$str_gob" >str_lines])
+total=0
+exec 3<str_lines
+while read l <&3; do
+  AS_VAR_ARITH([total], [1 + $total])
+  AT_CHECK([awk -v line="$l" -v file="$str_gob" -NF : \
+    '$1 == file && $2 == line { exit 42 }' str_stderr], [42])
+done
+exec 3<&-
+AT_CHECK([test x"$total" = x"2"])
+
+TEST_COMPILE_GOBJECT([main.c], [0], [], [stderr])
+AT_CHECK([awk -NF : '$1 == "main.c" && $2 == "15" { exit 42 }' stderr], [42])
+
+AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main str.o main.o])
+
+AT_CLEANUP