summaryrefslogtreecommitdiffstats
path: root/src/sord.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-10-03 01:13:32 +0000
committerDavid Robillard <d@drobilla.net>2015-10-03 01:13:32 +0000
commit154437f46858502586d8e896bba3b4aac1a37cc7 (patch)
tree0cd6730af4fea96eaf41f9c3ae92c6102396e573 /src/sord.c
parent6cd2467a9b9033c75e98f65cffc18b6aa080921c (diff)
downloadsord-154437f46858502586d8e896bba3b4aac1a37cc7.tar.gz
sord-154437f46858502586d8e896bba3b4aac1a37cc7.tar.bz2
sord-154437f46858502586d8e896bba3b4aac1a37cc7.zip
Improve test coverage
git-svn-id: http://svn.drobilla.net/sord/trunk@331 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src/sord.c')
-rw-r--r--src/sord.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/sord.c b/src/sord.c
index 78ed919..ff89505 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -361,8 +361,7 @@ sord_iter_seek_match(SordIter* iter)
static inline bool
sord_iter_seek_match_range(SordIter* iter)
{
- if (iter->end)
- return true;
+ assert(!iter->end);
do {
const SordNode** key = (const SordNode**)zix_btree_get(iter->cur);
@@ -584,14 +583,10 @@ sord_best_index(SordModel* sord,
*n_prefix = 0;
switch (sig) {
case 0x000:
- if (graph_search) {
- *mode = RANGE;
- *n_prefix = 1;
- return DEFAULT_GRAPH_ORDER;
- } else {
- *mode = ALL;
- return DEFAULT_ORDER;
- }
+ assert(graph_search);
+ *mode = RANGE;
+ *n_prefix = 1;
+ return DEFAULT_GRAPH_ORDER;
case 0x111:
*mode = SINGLE;
return graph_search ? DEFAULT_GRAPH_ORDER : DEFAULT_ORDER;
@@ -1165,10 +1160,9 @@ sord_node_free(SordWorld* world, SordNode* node)
{
if (!node) {
return;
- }
-
- assert(node->refs > 0);
- if (--node->refs == 0) {
+ } else if (node->refs == 0) {
+ error(world, SERD_ERR_BAD_ARG, "attempt to free garbage node\n");
+ } else if (--node->refs == 0) {
sord_node_free_internal(world, node);
}
}
@@ -1252,6 +1246,7 @@ sord_erase(SordModel* sord, SordIter* iter)
{
if (sord->n_iters > 1) {
error(sord->world, SERD_ERR_BAD_ARG, "erased with many iterators\n");
+ return SERD_ERR_BAD_ARG;
}
SordQuad tup;