From 653b8103c8e146be8d5a3ae7cebc8deeca86c0cd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 13 Dec 2008 06:26:31 +0000 Subject: Test port lookup by symbol using new value constructors: 83.4% coverage. Replace warnings about ORDER BY being broken with fatal errors - it's catastropic anyway. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1864 a436a847-0d15-0410-975c-d299462d15a1 --- src/plugin.c | 14 +++----------- test/slv2_test.c | 7 ++++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/plugin.c b/src/plugin.c index ab8e4f8..0260a02 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -218,6 +218,9 @@ slv2_plugin_load(SLV2Plugin p) const int this_index = atoi(index); SLV2Port this_port = NULL; + // ORDER BY guarantees order + assert(this_index <= num_ports); + // Create a new SLV2Port, and add to template if (this_index == num_ports) { assert(this_index == last_index + 1); @@ -229,14 +232,6 @@ slv2_plugin_load(SLV2Plugin p) // More information about a port we already created } else if (this_index < num_ports) { this_port = slv2_plugin_get_port_by_index(p, this_index); - - // Got a port index out of whack; plugin or rasqal is broken - } else { - fprintf(stderr, "ERROR: Found port %d immediately after port %d\n", - this_index, num_ports-1); - fprintf(stderr, "Either the plugin %s or your version of rasqal is broken.\n", - slv2_value_as_uri(p->plugin_uri)); - fprintf(stderr, "Please report (with rasqal version): http://dev.drobilla.net/newticket?component=SLV2\n"); } if (this_port) { @@ -251,9 +246,6 @@ slv2_plugin_load(SLV2Plugin p) librdf_query_results_next(results); } - // Not necessary due to ORDER BY clause - //raptor_sequence_sort(p->ports, slv2_port_compare_by_index); - librdf_free_query_results(results); librdf_free_query(q); diff --git a/test/slv2_test.c b/test/slv2_test.c index af5cfef..41335ec 100644 --- a/test/slv2_test.c +++ b/test/slv2_test.c @@ -708,11 +708,12 @@ test_port() SLV2Plugin plug = slv2_plugins_get_by_uri(plugins, plugin_uri_value); TEST_ASSERT(plug); + SLV2Value psym = slv2_value_new_string(world, "foo"); SLV2Port p = slv2_plugin_get_port_by_index(plug, 0); - //SLV2Port p2 = slv2_plugin_get_port_by_symbol(plug, "foo"); + SLV2Port p2 = slv2_plugin_get_port_by_symbol(plug, psym); TEST_ASSERT(p != NULL); - //TEST_ASSERT(p2 != NULL); - //TEST_ASSERT(p == p2); + TEST_ASSERT(p2 != NULL); + TEST_ASSERT(p == p2); SLV2Value audio_class = slv2_value_new_uri(world, "http://lv2plug.in/ns/lv2core#AudioPort"); -- cgit v1.2.1