summaryrefslogtreecommitdiff
path: root/tests/basic-types/pointers.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2009-09-25 07:50:05 +0200
committerJürg Billeter <j@bitron.ch>2009-09-26 14:38:44 +0200
commit2706e671ff9600d252705913342d1890ca1eb43a (patch)
tree56249d07b992cf727775a246e7233d97ba3208ca /tests/basic-types/pointers.vala
parentffe25d65b4ac1ee955807fa1c1f395796feb34a9 (diff)
downloadvala-2706e671ff9600d252705913342d1890ca1eb43a.tar.gz
Speed up test infrastructure
The updated test runner builds all tests at once to speed up testing.
Diffstat (limited to 'tests/basic-types/pointers.vala')
-rw-r--r--tests/basic-types/pointers.vala42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/basic-types/pointers.vala b/tests/basic-types/pointers.vala
new file mode 100644
index 000000000..7517e71b0
--- /dev/null
+++ b/tests/basic-types/pointers.vala
@@ -0,0 +1,42 @@
+using GLib;
+
+struct SimpleStruct {
+ public int field;
+
+ public int test () {
+ return field;
+ }
+
+ public static void main () {
+ SimpleStruct* st = new SimpleStruct[1];
+ st->field = 1;
+ assert (st->field == st->test ());
+ delete st;
+
+ test_pointers_element_access ();
+ test_pointers_return_value ();
+ }
+
+ static void test_pointers_element_access () {
+ int* array = new int[42];
+ array[0] = 23;
+ assert (array[0] == 23);
+ delete array;
+ }
+
+ const int[] array = { 42 };
+
+ static int* return_pointer () {
+ return array;
+ }
+
+ static void test_pointers_return_value () {
+ int i = return_pointer ()[0];
+ assert (i == 42);
+ }
+}
+
+void main () {
+ SimpleStruct.main ();
+}
+