|
39 | 39 | #include "proton/types_fwd.hpp" |
40 | 40 | #include "proton/uuid.hpp" |
41 | 41 |
|
42 | | -#include <deque> |
| 42 | +#include <proton/codec.h> |
| 43 | +#include <proton/terminus.h> |
| 44 | + |
43 | 45 | #include <algorithm> |
| 46 | +#include <cstring> |
| 47 | +#include <deque> |
44 | 48 |
|
45 | 49 | namespace { |
46 | 50 |
|
@@ -466,6 +470,25 @@ void test_link_capability_filter() { |
466 | 470 | ASSERT_EQUAL(value("22"), f.get("2")); |
467 | 471 | } |
468 | 472 |
|
| 473 | +void test_terminus_capabilities_single_symbol() { |
| 474 | + // Test that capabilities() correctly handles a single symbol (not an array) |
| 475 | + // Capabilities can be encoded as either a single AMQP symbol or an array of symbols. |
| 476 | + record_handler ha, hb; |
| 477 | + driver_pair d(ha, hb); |
| 478 | + |
| 479 | + // Annoyingly, we have to use the C API to set capabilities as a single symbol |
| 480 | + // because the C++ API only supports setting arrays of symbols. |
| 481 | + auto s = d.a.connection().open_sender("test-address"); |
| 482 | + auto caps_data = pn_terminus_capabilities(unwrap(s.target())); |
| 483 | + auto cap_str = "single-capability"; |
| 484 | + pn_data_put_symbol(caps_data, pn_bytes(strlen(cap_str), cap_str)); |
| 485 | + |
| 486 | + // Verify that capabilities() returns a vector with the single symbol |
| 487 | + auto caps = s.target().capabilities(); |
| 488 | + ASSERT_EQUAL(1U, caps.size()); |
| 489 | + ASSERT_EQUAL(proton::symbol("single-capability"), caps[0]); |
| 490 | +} |
| 491 | + |
469 | 492 | void test_message() { |
470 | 493 | // Verify a message arrives intact |
471 | 494 | record_handler ha, hb; |
@@ -544,6 +567,7 @@ int main(int argc, char** argv) { |
544 | 567 | RUN_ARGV_TEST(failed, test_link_address()); |
545 | 568 | RUN_ARGV_TEST(failed, test_link_anonymous_dynamic()); |
546 | 569 | RUN_ARGV_TEST(failed, test_link_capability_filter()); |
| 570 | + RUN_ARGV_TEST(failed, test_terminus_capabilities_single_symbol()); |
547 | 571 | RUN_ARGV_TEST(failed, test_message()); |
548 | 572 | RUN_ARGV_TEST(failed, test_message_timeout_succeed()); |
549 | 573 | RUN_ARGV_TEST(failed, test_message_timeout_fail()); |
|
0 commit comments