From 7a3341179b9bb86774f10fd0891334c8c5e7c2d6 Mon Sep 17 00:00:00 2001 From: ch3 Date: Mon, 30 Nov 2015 21:51:53 +0000 Subject: -add tests for helpers "view" and "peers" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Bünger git-svn-id: https://gnunet.org/svn/gnunet@36700 140774ce-b5e7-0310-ab8b-a85725594a96 --- src/rps/test_service_rps_peers.c | 15 ++++++++++++--- src/rps/test_service_rps_view.c | 3 +++ 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))); -- cgit v1.2.3-18-g5258