From 5de968e80ade1c02d1907834dcff95e9fc9ad10a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 15 May 2014 23:11:54 +0200 Subject: SBUS: Return / if an object path getter returns NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Stef Walter Reviewed-by: Pavel Březina --- src/tests/sbus_codegen_tests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/tests/sbus_codegen_tests.c') diff --git a/src/tests/sbus_codegen_tests.c b/src/tests/sbus_codegen_tests.c index e92c5f784..c7da414fe 100644 --- a/src/tests/sbus_codegen_tests.c +++ b/src/tests/sbus_codegen_tests.c @@ -441,6 +441,13 @@ void pilot_get_null_string_handler(struct sbus_request *dbus_req, *string_val = NULL; } +void pilot_get_null_path_handler(struct sbus_request *dbus_req, + void *instance_data, + const char **path_val) +{ + *path_val = NULL; +} + #define array_getter_body(in, out, outlen) do { \ ck_assert(dbus_req != NULL); \ ck_assert(out != NULL); \ @@ -548,6 +555,7 @@ struct test_pilot pilot_iface = { .test_pilot_get_string = pilot_get_string_handler, .test_pilot_get_object_path = pilot_get_objpath_handler, .test_pilot_get_null_string = pilot_get_null_string_handler, + .test_pilot_get_null_path = pilot_get_null_path_handler, .test_pilot_get_byte_array = pilot_get_byte_array_handler, .test_pilot_get_int16_array = pilot_get_int16_array_handler, @@ -857,6 +865,12 @@ START_TEST(test_get_basic_types) call_get(client, "/test/leela", test_pilot_meta.name, "null_string", DBUS_TYPE_STRING, &string_val); ck_assert_str_eq(string_val, ""); + + /* If a string getter returns NULL, the caller should receive "/" */ + call_get(client, "/test/leela", test_pilot_meta.name, "null_path", + DBUS_TYPE_OBJECT_PATH, &path_val); + ck_assert_str_eq(path_val, "/"); + } END_TEST -- cgit