aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-04-05 14:09:50 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:23 +0100
commit28ddf4c3e52adc77d56b0c2e1c6ee00d95cb6f4f (patch)
tree4443016579473938f3e6545f7aa847c59d5360fb
parent40ec8624ccd76c574a136603f3dc2fc6683be969 (diff)
Add test for num_reflections() and fix it
-rw-r--r--src/reflist.c2
-rw-r--r--tests/list_check.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/reflist.c b/src/reflist.c
index 36753bd5..e420b736 100644
--- a/src/reflist.c
+++ b/src/reflist.c
@@ -775,7 +775,7 @@ static int recursive_count(Reflection *refl)
{
int count_left, count_right;
- if ( refl == NULL ) return 1;
+ if ( refl == NULL ) return 0;
count_left = recursive_count(refl->child[0]);
count_right = recursive_count(refl->child[1]);
diff --git a/tests/list_check.c b/tests/list_check.c
index 2b75ab72..180aeb6a 100644
--- a/tests/list_check.c
+++ b/tests/list_check.c
@@ -90,6 +90,7 @@ static int test_lists(int num_items)
optimise_reflist(list);
/* Iterate over the list and check we find everything */
+ int count = 0;
for ( refl = first_refl(list, &iter);
refl != NULL;
refl = next_refl(refl, iter) ) {
@@ -107,7 +108,15 @@ static int test_lists(int num_items)
}
}
+ count++;
+
+ }
+ if ( count != num_reflections(list) ) {
+ fprintf(stderr, "num_reflections gave %i, iteration gave %i\n",
+ num_reflections(list), count);
+ return 1;
}
+
for ( i=0; i<num_items; i++ ) {
if ( check[i].found == 0 ) {