Repository: qpid-dispatch Updated Branches: refs/heads/tross-DISPATCH-179-1 5139de6b3 -> 7e5d714a8
DISPATCH-179 - Added handling for the "/no-host/additional" form of address Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/deab357d Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/deab357d Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/deab357d Branch: refs/heads/tross-DISPATCH-179-1 Commit: deab357d89e54115c7c07e2df960fa30211a7805 Parents: 5139de6 Author: Ted Ross <[email protected]> Authored: Thu Feb 11 10:32:07 2016 -0500 Committer: Ted Ross <[email protected]> Committed: Thu Feb 11 10:32:07 2016 -0500 ---------------------------------------------------------------------- src/iterator.c | 9 ++++++--- tests/field_test.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/deab357d/src/iterator.c ---------------------------------------------------------------------- diff --git a/src/iterator.c b/src/iterator.c index 2fc49f6..cf4d67f 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -212,17 +212,20 @@ static void view_initialize(qd_field_iterator_t *iter) switch (state) { case STATE_START : - if (octet == '/') + if (octet == '/') { state = STATE_SLASH_LEFT; - else + save_pointer = iter->pointer; + } else state = STATE_SCANNING; break; case STATE_SLASH_LEFT : if (octet == '/') state = STATE_SKIPPING_TO_NEXT_SLASH; - else + else { state = STATE_AT_NODE_ID; + iter->pointer = save_pointer; + } break; case STATE_SKIPPING_TO_NEXT_SLASH : http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/deab357d/tests/field_test.c ---------------------------------------------------------------------- diff --git a/tests/field_test.c b/tests/field_test.c index e1ec6c6..414c84a 100644 --- a/tests/field_test.c +++ b/tests/field_test.c @@ -137,6 +137,34 @@ static char* test_view_global_no_host(void *context) } +static char* test_view_global_no_host_slash(void *context) +{ + qd_field_iterator_t *iter = qd_address_iterator_string("/global/sub", ITER_VIEW_ALL); + if (!qd_field_iterator_equal(iter, (unsigned char*) "/global/sub")) + return "ITER_VIEW_ALL failed"; + + qd_address_iterator_reset_view(iter, ITER_VIEW_NO_HOST); + if (!qd_field_iterator_equal(iter, (unsigned char*) "global/sub")) + return "ITER_VIEW_NO_HOST failed"; + + qd_address_iterator_reset_view(iter, ITER_VIEW_NODE_ID); + if (!qd_field_iterator_equal(iter, (unsigned char*) "global")) + return "ITER_VIEW_NODE_ID failed"; + + qd_address_iterator_reset_view(iter, ITER_VIEW_NODE_SPECIFIC); + if (!qd_field_iterator_equal(iter, (unsigned char*) "sub")) + return "ITER_VIEW_NODE_SPECIFIC failed"; + + qd_address_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH); + if (!qd_field_iterator_equal(iter, (unsigned char*) "M0global/sub")) + return "ITER_VIEW_ADDRESS_HASH failed"; + + qd_field_iterator_free(iter); + + return 0; +} + + static char* view_address_hash(void *context, qd_field_iterator_t *iter, const char *addr, const char *view) { @@ -167,6 +195,8 @@ static char* test_view_address_hash(void *context) {"_topo/my-area/my-router/my-addr", "Lmy-addr"}, {"_topo/my-area/router", "Rrouter"}, {"amqp:/mobile", "M1mobile"}, + {"mobile", "M1mobile"}, + {"/mobile", "M1mobile"}, // Re-run the above tests to make sure trailing dots are ignored. {"amqp:/_local/my-addr/sub.", "Lmy-addr/sub"}, @@ -626,6 +656,7 @@ int field_tests(void) TEST_CASE(test_view_global_dns, 0); TEST_CASE(test_view_global_non_dns, 0); TEST_CASE(test_view_global_no_host, 0); + TEST_CASE(test_view_global_no_host_slash, 0); TEST_CASE(test_view_address_hash, 0); TEST_CASE(test_view_address_hash_override, 0); TEST_CASE(test_view_node_hash, 0); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
