[libgee] Add tests for GObject properties
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Add tests for GObject properties
- Date: Mon, 14 Sep 2009 17:16:42 +0000 (UTC)
commit ba4a80d5ec0f1a43eecd9ce5035ed31ddff5883c
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Mon Sep 14 18:55:58 2009 +0200
Add tests for GObject properties
tests/testarraylist.vala | 14 ++++++++++++++
tests/testcollection.vala | 22 ++++++++++++++++++++++
tests/testhashmap.vala | 24 ++++++++++++++++++++++++
tests/testlinkedlist.vala | 14 ++++++++++++++
tests/testmap.vala | 17 +++++++++++++++++
tests/testpriorityqueue.vala | 14 ++++++++++++++
tests/testqueue.vala | 24 ++++++++++++++++++++++++
tests/testtreemap.vala | 19 +++++++++++++++++++
8 files changed, 148 insertions(+), 0 deletions(-)
---
diff --git a/tests/testarraylist.vala b/tests/testarraylist.vala
index 9a3a9f3..888db97 100644
--- a/tests/testarraylist.vala
+++ b/tests/testarraylist.vala
@@ -30,6 +30,7 @@ public class ArrayListTests : ListTests {
public ArrayListTests () {
base ("ArrayList");
add_test ("[ArrayList] selected functions", test_selected_functions);
+ add_test ("[ArrayList] GObject properties", test_gobject_properties);
add_test ("[ArrayList] small sort (insertion)", test_small_sort);
add_test ("[ArrayList] big sort (timsort)", test_big_sort);
}
@@ -54,6 +55,19 @@ public class ArrayListTests : ListTests {
assert (test_list.equal_func == str_equal);
}
+ public new void test_gobject_properties() {
+ var test_list = test_collection as ArrayList<string>;
+
+ // Check the list exists
+ assert (test_list != null);
+ Value value;
+
+ value = Value (typeof (EqualFunc));
+ test_list.get_property ("equal-func", ref value);
+ assert (value.get_pointer () == (void*) test_list.equal_func);
+ value.unset ();
+ }
+
private void test_small_sort () {
var test_list = test_collection as ArrayList<string>;
diff --git a/tests/testcollection.vala b/tests/testcollection.vala
index ce18275..f37cd6d 100644
--- a/tests/testcollection.vala
+++ b/tests/testcollection.vala
@@ -39,6 +39,7 @@ public abstract class CollectionTests : Gee.TestCase {
add_test ("[Collection] remove_all", test_remove_all);
add_test ("[Collection] retain_all", test_retain_all);
add_test ("[Collection] to_array", test_to_array);
+ add_test ("[Collection] GObject properties", test_gobject_properties);
}
protected Collection<string> test_collection;
@@ -515,4 +516,25 @@ public abstract class CollectionTests : Gee.TestCase {
assert (element == array[index++]);
}
}
+
+ public void test_gobject_properties() {
+ // Check the collection exists
+ assert (test_collection != null);
+ Value value;
+
+ value = Value (typeof (Type));
+ test_collection.get_property ("element-type", ref value);
+ assert (value.get_gtype () == test_collection.element_type);
+ value.unset ();
+
+ value = Value (typeof (bool));
+ test_collection.get_property ("is-empty", ref value);
+ assert (value.get_boolean () == test_collection.is_empty);
+ value.unset ();
+
+ value = Value (typeof (int));
+ test_collection.get_property ("size", ref value);
+ assert (value.get_int () == test_collection.size);
+ value.unset ();
+ }
}
diff --git a/tests/testhashmap.vala b/tests/testhashmap.vala
index 599cba0..2c62950 100644
--- a/tests/testhashmap.vala
+++ b/tests/testhashmap.vala
@@ -28,6 +28,7 @@ public class HashMapTests : MapTests {
public HashMapTests () {
base ("HashMap");
add_test ("[HashMap] selected functions", test_selected_functions);
+ add_test ("[HashMap] GObject properties", test_gobject_properties);
}
public override void set_up () {
@@ -49,4 +50,27 @@ public class HashMapTests : MapTests {
assert (test_hash_map.key_equal_func == str_equal);
assert (test_hash_map.value_equal_func == str_equal);
}
+
+ public new void test_gobject_properties() {
+ var test_hash_map = test_map as HashMap<string,string>;
+
+ // Check the list exists
+ assert (test_hash_map != null);
+ Value value;
+
+ value = Value (typeof (HashFunc));
+ test_hash_map.get_property ("key-hash-func", ref value);
+ assert (value.get_pointer () == (void*) test_hash_map.key_hash_func);
+ value.unset ();
+
+ value = Value (typeof (EqualFunc));
+ test_hash_map.get_property ("key-equal-func", ref value);
+ assert (value.get_pointer () == (void*) test_hash_map.key_equal_func);
+ value.unset ();
+
+ value = Value (typeof (EqualFunc));
+ test_hash_map.get_property ("value-equal-func", ref value);
+ assert (value.get_pointer () == (void*) test_hash_map.value_equal_func);
+ value.unset ();
+ }
}
diff --git a/tests/testlinkedlist.vala b/tests/testlinkedlist.vala
index d10c3be..c30fd8c 100644
--- a/tests/testlinkedlist.vala
+++ b/tests/testlinkedlist.vala
@@ -29,6 +29,7 @@ public class LinkedListTests : ListTests {
public LinkedListTests () {
base ("LinkedList");
add_test ("[LinkedList] selected functions", test_selected_functions);
+ add_test ("[LinkedList] GObject properties", test_gobject_properties);
add_test ("[LinkedList] sort", test_sort);
}
@@ -50,6 +51,19 @@ public class LinkedListTests : ListTests {
assert (test_list.equal_func == str_equal);
}
+ public new void test_gobject_properties() {
+ var test_list = test_collection as LinkedList<string>;
+
+ // Check the list exists
+ assert (test_list != null);
+ Value value;
+
+ value = Value (typeof (EqualFunc));
+ test_list.get_property ("equal-func", ref value);
+ assert (value.get_pointer () == (void*) test_list.equal_func);
+ value.unset ();
+ }
+
private void test_sort () {
var test_list = test_collection as LinkedList<string>;
diff --git a/tests/testmap.vala b/tests/testmap.vala
index 5447ce5..739f1a9 100644
--- a/tests/testmap.vala
+++ b/tests/testmap.vala
@@ -36,6 +36,7 @@ public abstract class MapTests : Gee.TestCase {
add_test ("[Map] set all", test_set_all);
add_test ("[Map] remove all", test_remove_all);
add_test ("[Map] contains all", test_contains_all);
+ add_test ("[Map] GObject properties", test_gobject_properties);
}
protected Map<string, string> test_map;
@@ -419,4 +420,20 @@ public abstract class MapTests : Gee.TestCase {
assert (! test_map.contains_all (another_map));
}
+
+ public void test_gobject_properties() {
+ // Check the map exists
+ assert (test_map != null);
+ Value value;
+
+ value = Value (typeof (bool));
+ test_map.get_property ("is-empty", ref value);
+ assert (value.get_boolean () == test_map.is_empty);
+ value.unset ();
+
+ value = Value (typeof (int));
+ test_map.get_property ("size", ref value);
+ assert (value.get_int () == test_map.size);
+ value.unset ();
+ }
}
diff --git a/tests/testpriorityqueue.vala b/tests/testpriorityqueue.vala
index 9669069..cf345f8 100644
--- a/tests/testpriorityqueue.vala
+++ b/tests/testpriorityqueue.vala
@@ -27,6 +27,7 @@ public class PriorityQueueTests : QueueTests {
public PriorityQueueTests () {
base ("PriorityQueue");
add_test ("[PriorityQueue] selected functions", test_selected_functions);
+ add_test ("[PriorityQueue] GObject properties", test_gobject_properties);
add_test ("[PriorityQueue] poll gives minimum", test_poll_gives_minimum);
}
@@ -48,6 +49,19 @@ public class PriorityQueueTests : QueueTests {
assert (test_queue.compare_func == strcmp);
}
+ public new void test_gobject_properties() {
+ var test_queue = test_collection as PriorityQueue<string>;
+
+ // Check the list exists
+ assert (test_queue != null);
+ Value value;
+
+ value = Value (typeof (CompareFunc));
+ test_queue.get_property ("compare-func", ref value);
+ assert (value.get_pointer () == (void*) test_queue.compare_func);
+ value.unset ();
+ }
+
private void test_poll_gives_minimum () {
var test_queue = test_collection as Gee.Queue<string>;
diff --git a/tests/testqueue.vala b/tests/testqueue.vala
index 86833ae..c32f674 100644
--- a/tests/testqueue.vala
+++ b/tests/testqueue.vala
@@ -28,6 +28,7 @@ public abstract class QueueTests : CollectionTests {
base (name);
add_test ("[Queue] capacity bound", test_capacity_bound);
add_test ("[Queue] one element operation", test_one_element_operation);
+ add_test ("[Queue] GObject properties", test_gobject_properties);
}
public void test_capacity_bound () {
@@ -110,4 +111,27 @@ public abstract class QueueTests : CollectionTests {
assert (recipient.size == 1);
assert (recipient.get (0) == "one");
}
+
+ public new void test_gobject_properties() {
+ var test_queue = test_collection as Gee.Queue<string>;
+
+ // Check the list exists
+ assert (test_queue != null);
+ Value value;
+
+ value = Value (typeof (int));
+ test_queue.get_property ("capacity", ref value);
+ assert (value.get_int () == test_queue.capacity);
+ value.unset ();
+
+ value = Value (typeof (int));
+ test_queue.get_property ("remaining-capacity", ref value);
+ assert (value.get_int () == test_queue.remaining_capacity);
+ value.unset ();
+
+ value = Value (typeof (bool));
+ test_queue.get_property ("is-full", ref value);
+ assert (value.get_boolean () == test_queue.is_full);
+ value.unset ();
+ }
}
diff --git a/tests/testtreemap.vala b/tests/testtreemap.vala
index 92385f7..2de2da0 100644
--- a/tests/testtreemap.vala
+++ b/tests/testtreemap.vala
@@ -28,6 +28,7 @@ public class TreeMapTests : MapTests {
public TreeMapTests () {
base ("TreeMap");
add_test ("[TreeMap] selected functions", test_selected_functions);
+ add_test ("[TreeMap] GObject properties", test_gobject_properties);
add_test ("[TreeMap] key ordering", test_key_ordering);
}
@@ -50,6 +51,24 @@ public class TreeMapTests : MapTests {
assert (test_tree_map.value_equal_func == str_equal);
}
+ public new void test_gobject_properties() {
+ var test_tree_map = test_map as TreeMap<string,string>;
+
+ // Check the list exists
+ assert (test_tree_map != null);
+ Value value;
+
+ value = Value (typeof (CompareFunc));
+ test_tree_map.get_property ("key-compare-func", ref value);
+ assert (value.get_pointer () == (void*) test_tree_map.key_compare_func);
+ value.unset ();
+
+ value = Value (typeof (EqualFunc));
+ test_tree_map.get_property ("value-equal-func", ref value);
+ assert (value.get_pointer () == (void*) test_tree_map.value_equal_func);
+ value.unset ();
+ }
+
public void test_key_ordering () {
var test_tree_map = test_map as TreeMap<string,string>;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]