summaryrefslogtreecommitdiff
path: root/tests/piece-table-internals.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/piece-table-internals.c')
-rw-r--r--tests/piece-table-internals.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/piece-table-internals.c b/tests/piece-table-internals.c
index 1108271..6cf5014 100644
--- a/tests/piece-table-internals.c
+++ b/tests/piece-table-internals.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -22,45 +23,44 @@ main ()
/** Inserting **/
/* Should add pieces... */
expected_count = 1;
- if (count_pieces (pt) != expected_count) return 10;
+ assert (count_pieces (pt) == expected_count);
piece_table_insert (pt, 10, "abcdefgh", 8);
expected_count++;
- if (count_pieces (pt) != expected_count) return 11;
+ assert (count_pieces (pt) == expected_count);
/* ... but not always **/
piece_table_insert (pt, 18, "abcdefgh", 8);
- if (count_pieces (pt) != expected_count) return 12;
+ assert (count_pieces (pt) == expected_count);
/** Deleting **/
piece_table_delete (pt, 23, 3);
- if (count_pieces (pt) != expected_count) return 20;
+ assert (count_pieces (pt) == expected_count);
piece_table_delete (pt, 13, 4);
expected_count++;
- if (count_pieces (pt) != expected_count) return 21;
+ assert (count_pieces (pt) == expected_count);
piece_table_delete (pt, 0, 10);
expected_count--;
- if (count_pieces (pt) != expected_count) return 22;
+ assert (count_pieces (pt) == expected_count);
/** Result **/
piece_table_to_string (pt, tmp, 99);
- if (strcmp (tmp, "abchabcde"))
- return 30;
+ assert (0 == strcmp (tmp, "abchabcde"));
/** Optimize **/
piece_table_optimize (pt);
expected_count = 1;
- if (count_pieces (pt) != expected_count) return 40;
+ assert (count_pieces (pt) == expected_count);
/** Result **/
piece_table_to_string (pt, tmp, 99);
- if (strcmp (tmp, "abchabcde"))
- return 50;
+ assert (0 == strcmp (tmp, "abchabcde"));
piece_table_destroy (pt);
+
return 0;
}