Skip to content

Commit

Permalink
Merge pull request #226 from ZettaScaleLabs/fix-macos-build-warnings
Browse files Browse the repository at this point in the history
Fix MacOS build warnings
  • Loading branch information
milyin authored Dec 19, 2023
2 parents a2209b7 + c03def9 commit b154467
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
18 changes: 5 additions & 13 deletions tests/z_api_attachment_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>

#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

#include "z_int_helpers.h"
#include "zenoh.h"

#undef NDEBUG
Expand All @@ -30,14 +30,10 @@ void writting_through_map_by_alias_read_by_get() {

// Elements check
z_bytes_t a1 = z_attachment_get(attachment, z_bytes_new("k1"));
assert(a1.start != NULL);
assert(a1.len == 2);
assert(!strncmp(a1.start, "v1", a1.len));
ASSERT_STR_BYTES_EQUAL("v1", a1);

z_bytes_t a2 = z_attachment_get(attachment, z_bytes_new("k2"));
assert(a2.start != NULL);
assert(a2.len == 2);
assert(!strncmp(a2.start, "v2", a2.len));
ASSERT_STR_BYTES_EQUAL("v2", a2);

z_bytes_t a_non = z_attachment_get(attachment, z_bytes_new("k_non"));
assert(a_non.start == NULL);
Expand Down Expand Up @@ -86,14 +82,10 @@ void writting_no_map_read_by_get() {

// Elements check
z_bytes_t a1 = z_attachment_get(attachment, z_bytes_new("k1"));
assert(a1.start != NULL);
assert(a1.len == 2);
assert(!strncmp(a1.start, "v1", a1.len));
ASSERT_STR_BYTES_EQUAL("v1", a1);

z_bytes_t a2 = z_attachment_get(attachment, z_bytes_new("k2"));
assert(a2.start != NULL);
assert(a2.len == 2);
assert(!strncmp(a2.start, "v2", a2.len));
ASSERT_STR_BYTES_EQUAL("v2", a2);

z_bytes_t a_non = z_attachment_get(attachment, z_bytes_new("k_non"));
assert(a_non.start == NULL);
Expand Down
16 changes: 8 additions & 8 deletions tests/z_int_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ int run_timeouted_test(func_ptr_t functions[], int num_functions, int timeout_se
return result;
};

#define ASSERT_STR_BYTES_EQUAL(str, bytes) \
do { \
if (strlen(str) != bytes.len || strncmp(str, (const char *)bytes.start, (int)bytes.len)) { \
fprintf(stderr, "Check failed: '%s' != '%.*s'\n", str, (int)bytes.len, bytes.start); \
exit(-1); \
} \
} while (0)

#define SEM_INIT(sem, name) \
do { \
sem_unlink(name); \
Expand Down Expand Up @@ -162,3 +154,11 @@ int run_timeouted_test(func_ptr_t functions[], int num_functions, int timeout_se
} while (0)

#endif // def windows

#define ASSERT_STR_BYTES_EQUAL(str, bytes) \
do { \
if (strlen(str) != bytes.len || strncmp(str, (const char *)bytes.start, (int)bytes.len)) { \
fprintf(stderr, "Check failed: '%s' != '%.*s'\n", str, (int)bytes.len, bytes.start); \
exit(-1); \
} \
} while (0)
3 changes: 2 additions & 1 deletion tests/z_int_queryable_attachment_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void query_handler(const z_query_t *query, void *context) {
z_query_reply_options_t options = z_query_reply_options_default();
options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL);
options.attachment = z_bytes_map_as_attachment(&map);
z_query_reply(query, z_keyexpr((const char *)context), values[value_num], strlen(values[value_num]), &options);
z_query_reply(query, z_keyexpr((const char *)context), (const uint8_t *)values[value_num],
strlen(values[value_num]), &options);
z_drop(z_move(keystr));
z_drop(z_move(map));

Expand Down
3 changes: 2 additions & 1 deletion tests/z_int_queryable_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void query_handler(const z_query_t *query, void *context) {

z_query_reply_options_t options = z_query_reply_options_default();
options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL);
z_query_reply(query, z_keyexpr((const char *)context), values[value_num], strlen(values[value_num]), &options);
z_query_reply(query, z_keyexpr((const char *)context), (const uint8_t *)values[value_num],
strlen(values[value_num]), &options);
z_drop(z_move(keystr));

if (++value_num == values_count) {
Expand Down

0 comments on commit b154467

Please sign in to comment.