aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorch3 <ch3@140774ce-b5e7-0310-ab8b-a85725594a96>2015-11-30 21:51:53 +0000
committerch3 <ch3@140774ce-b5e7-0310-ab8b-a85725594a96>2015-11-30 21:51:53 +0000
commit7a3341179b9bb86774f10fd0891334c8c5e7c2d6 (patch)
tree3f6edc389be43d1f293321c2dc0939fd995eebfb
parent80d1fb3b59dfb1597076c77e6e435435ac1dec38 (diff)
-add tests for helpers "view" and "peers"
Signed-off-by: Julius Bünger <buenger@mytum.de> git-svn-id: https://gnunet.org/svn/gnunet@36700 140774ce-b5e7-0310-ab8b-a85725594a96
-rw-r--r--src/rps/test_service_rps_peers.c15
-rw-r--r--src/rps/test_service_rps_view.c3
2 files changed, 15 insertions, 3 deletions
diff --git a/src/rps/test_service_rps_peers.c b/src/rps/test_service_rps_peers.c
index b9f1307a9e..43d9362009 100644
--- a/src/rps/test_service_rps_peers.c
+++ b/src/rps/test_service_rps_peers.c
@@ -57,9 +57,6 @@ check ()
CHECK (GNUNET_OK == CustomPeerMap_put (c_m, &k1));
CHECK (1 == CustomPeerMap_size (c_m));
- /*ret = GNUNET_CONTAINER_multipeermap_get (m, &k1);
- GNUNET_assert (ret != NULL);
- CHECK (0 == strcmp ("v1", ret));*/
CHECK (GNUNET_NO == CustomPeerMap_put (c_m, &k1));
CHECK (1 == CustomPeerMap_size (c_m));
CHECK (GNUNET_YES == CustomPeerMap_contains_peer (c_m, &k1));
@@ -69,12 +66,14 @@ check ()
CHECK (GNUNET_NO == CustomPeerMap_contains_peer (c_m, &k2));
CHECK (GNUNET_OK == CustomPeerMap_put (c_m, &k1));
+ CHECK (1 == CustomPeerMap_size (c_m));
for (j = 0; j < 16; j++)
{
CHECK (GNUNET_NO == CustomPeerMap_put (c_m, &k1));
}
CHECK (1 == CustomPeerMap_size (c_m));
CHECK (GNUNET_OK == CustomPeerMap_put (c_m, &k2));
+ CHECK (2 == CustomPeerMap_size (c_m));
for (j = 0; j < 16; j++)
{
CHECK (GNUNET_NO == CustomPeerMap_put (c_m, &k2));
@@ -96,6 +95,16 @@ check ()
CHECK (GNUNET_YES == CustomPeerMap_contains_peer (c_m, &k2));
CHECK (NULL != CustomPeerMap_get_peer_by_index (c_m, 0));
+ CustomPeerMap_clear (c_m);
+ CHECK (0 == CustomPeerMap_size (c_m));
+
+ CHECK (GNUNET_OK == CustomPeerMap_put (c_m, &k1));
+ CHECK (1 == CustomPeerMap_size (c_m));
+ CHECK (GNUNET_OK == CustomPeerMap_put (c_m, &k2));
+ CHECK (2 == CustomPeerMap_size (c_m));
+ CustomPeerMap_clear (c_m);
+ CHECK (0 == CustomPeerMap_size (c_m));
+
CustomPeerMap_destroy (c_m);
return 0;
diff --git a/src/rps/test_service_rps_view.c b/src/rps/test_service_rps_view.c
index f6be298506..9d2d371cd9 100644
--- a/src/rps/test_service_rps_view.c
+++ b/src/rps/test_service_rps_view.c
@@ -87,14 +87,17 @@ check ()
CHECK (GNUNET_NO == View_contains_peer (&k1));
CHECK (GNUNET_YES == View_contains_peer (&k2));
CHECK (NULL != View_get_peer_by_index (0));
+ CHECK (NULL == View_get_peer_by_index (1));
View_clear ();
CHECK (0 == View_size ());
CHECK (GNUNET_OK == View_put (&k1));
CHECK (1 == View_size ());
+ CHECK (GNUNET_YES == View_contains_peer (&k1));
CHECK (GNUNET_OK == View_put (&k2));
CHECK (2 == View_size ());
+ CHECK (GNUNET_YES == View_contains_peer (&k2));
array = View_get_as_array ();
CHECK (0 == memcmp (&array[0], &k1, sizeof (k1)));
CHECK (0 == memcmp (&array[1], &k2, sizeof (k2)));