[vala/0.44] tests: Add "typeof" tests for fundamental GLib.Type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.44] tests: Add "typeof" tests for fundamental GLib.Type
- Date: Thu, 7 Nov 2019 11:19:32 +0000 (UTC)
commit 12c2c861ed8d62c2f2dd768f40dec761a3818d7f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Oct 23 14:21:49 2019 +0200
tests: Add "typeof" tests for fundamental GLib.Type
tests/Makefile.am | 1 +
tests/basic-types/default-gtype.vala | 44 ++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b6ed4f931..51ee4d41d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,7 @@ TESTS = \
basic-types/escape-chars.vala \
basic-types/floats.vala \
basic-types/custom-types.vala \
+ basic-types/default-gtype.vala \
basic-types/strings.vala \
basic-types/arrays.vala \
basic-types/arrays-fixed-assignment.vala \
diff --git a/tests/basic-types/default-gtype.vala b/tests/basic-types/default-gtype.vala
new file mode 100644
index 000000000..26ee7f268
--- /dev/null
+++ b/tests/basic-types/default-gtype.vala
@@ -0,0 +1,44 @@
+//[CCode (cheader_filename = "glib-object.h", cname = "G_TYPE_STRV")]
+//extern GLib.Type G_TYPE_STRV;
+
+interface IFoo {
+}
+
+enum FooEnum {
+ FOO
+}
+
+[Flags]
+enum FooFlag {
+ FOO
+}
+
+struct FooStruct {
+ public int i;
+}
+
+void main () {
+ assert (typeof (bool) == GLib.Type.BOOLEAN);
+ assert (typeof (FooStruct).is_a (GLib.Type.BOXED));
+ assert (typeof (char) == GLib.Type.CHAR);
+ assert (typeof (double) == GLib.Type.DOUBLE);
+ assert (typeof (FooEnum).is_a (GLib.Type.ENUM));
+ assert (typeof (FooFlag).is_a (GLib.Type.FLAGS));
+ assert (typeof (float) == GLib.Type.FLOAT);
+ assert (typeof (int) == GLib.Type.INT);
+ assert (typeof (int64) == GLib.Type.INT64);
+ assert (typeof (IFoo).is_a (GLib.Type.INTERFACE));
+ assert (typeof (IFoo[]) == GLib.Type.INVALID);
+ assert (typeof (long) == GLib.Type.LONG);
+ assert (typeof (void) == GLib.Type.NONE);
+ assert (typeof (Object) == GLib.Type.OBJECT);
+ assert (typeof (ParamSpec) == GLib.Type.PARAM);
+ assert (typeof (void*) == GLib.Type.POINTER);
+ assert (typeof (string) == GLib.Type.STRING);
+ //assert (typeof (string[]) == G_TYPE_STRV);
+ assert (typeof (uchar) == GLib.Type.UCHAR);
+ assert (typeof (uint) == GLib.Type.UINT);
+ assert (typeof (uint64) == GLib.Type.UINT64);
+ assert (typeof (ulong) == GLib.Type.ULONG);
+ assert (typeof (Variant) == GLib.Type.VARIANT);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]