From 4732e417d721d6fc1c4660faab0535696e51fb67 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 14 Sep 2017 16:11:50 +0200 Subject: [PATCH] feat(Variant): add getValueAsGeneric impl --- src/variant/variant.cpp | 7 ++++- tester/CMakeLists.txt | 1 + tester/liblinphone_tester.h | 1 + tester/property-container-tester.cpp | 44 ++++++++++++++++++++++++++++ tester/tester.c | 1 + 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tester/property-container-tester.cpp diff --git a/src/variant/variant.cpp b/src/variant/variant.cpp index 14bc77141..484e3fb9b 100644 --- a/src/variant/variant.cpp +++ b/src/variant/variant.cpp @@ -368,7 +368,12 @@ static inline float getValueAsString (const VariantPrivate &p, bool *soFarSoGood } static inline void *getValueAsGeneric (const VariantPrivate &p, bool *soFarSoGood) { - // TODO. + if (p.type == Variant::Generic) { + *soFarSoGood = true; + return p.value.g; + } + + *soFarSoGood = false; return nullptr; } diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index cb3c58fa1..2169fe567 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -199,6 +199,7 @@ set(SOURCE_FILES_CXX clonable-object-tester.cpp cpim-tester.cpp events-db-tester.cpp + property-container-tester.cpp ) set(SOURCE_FILES_OBJC ) diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 8bd915e62..ed764e09f 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -56,6 +56,7 @@ extern test_suite_t offeranswer_test_suite; extern test_suite_t player_test_suite; extern test_suite_t presence_server_test_suite; extern test_suite_t presence_test_suite; +extern test_suite_t property_container_test_suite; extern test_suite_t proxy_config_test_suite; extern test_suite_t quality_reporting_test_suite; extern test_suite_t register_test_suite; diff --git a/tester/property-container-tester.cpp b/tester/property-container-tester.cpp new file mode 100644 index 000000000..eb01e4fd1 --- /dev/null +++ b/tester/property-container-tester.cpp @@ -0,0 +1,44 @@ +/* + * property-container-tester.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "object/property-container.h" + +#include "liblinphone_tester.h" + +// ============================================================================= + +using namespace std; + +using namespace LinphonePrivate; + +// ----------------------------------------------------------------------------- + +static void set_integer_property () { + PropertyContainer properties; + properties.setProperty("integer", 42); + BC_ASSERT_EQUAL(properties.getProperty("integer").getValue(), 42, int, "%d"); +} + +test_t property_container_tests[] = { + TEST_NO_TAG("Set int property", set_integer_property) +}; + +test_suite_t property_container_test_suite = { + "PropertyContainer", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, + sizeof(property_container_tests) / sizeof(property_container_tests[0]), property_container_tests +}; diff --git a/tester/tester.c b/tester/tester.c index f2bae99df..1fb24d0f1 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -573,6 +573,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&cpim_test_suite); bc_tester_add_suite(&clonable_object_test_suite); bc_tester_add_suite(&events_db_test_suite); + bc_tester_add_suite(&property_container_test_suite); #if defined(VIDEO_ENABLED) && defined(HAVE_GTK) bc_tester_add_suite(&video_test_suite); #endif