From 1d0c05a54af7ca2a18de0f17988f2f5bb0ab47b3 Mon Sep 17 00:00:00 2001 From: Heiko Strathmann Date: Tue, 23 Jan 2018 17:53:34 +0000 Subject: [PATCH] Disabled test that old parameter names and tag parameter names match Also fix available_objects namespace --- src/shogun/base/SGObject.h | 2 +- src/shogun/base/class_list.cpp.templ | 2 +- tests/unit/base/SGObject_unittest.cc | 43 +++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/shogun/base/SGObject.h b/src/shogun/base/SGObject.h index 495c30fc979..4df8f01aea0 100644 --- a/src/shogun/base/SGObject.h +++ b/src/shogun/base/SGObject.h @@ -23,8 +23,8 @@ #include #include -#include #include +#include /** \namespace shogun * @brief all of classes and functions are contained in the shogun namespace diff --git a/src/shogun/base/class_list.cpp.templ b/src/shogun/base/class_list.cpp.templ index b01b6c8c9cb..42e26c5083b 100644 --- a/src/shogun/base/class_list.cpp.templ +++ b/src/shogun/base/class_list.cpp.templ @@ -75,7 +75,7 @@ void shogun::delete_object(CSGObject* object) delete object; } -std::set available_objects() +std::set shogun::available_objects() { std::set result; for (class_list_entry_t* i=class_list; i->m_class_name != NULL; diff --git a/tests/unit/base/SGObject_unittest.cc b/tests/unit/base/SGObject_unittest.cc index 8d8855524b7..b853be78fd6 100644 --- a/tests/unit/base/SGObject_unittest.cc +++ b/tests/unit/base/SGObject_unittest.cc @@ -4,22 +4,25 @@ * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * Written (W) 2013 Heiko Strathmann + * Written (W) 2013-2018 Heiko Strathmann * Written (W) 2014 Thoralf Klein * Written (W) 2015 Wu Lin */ #include "MockObject.h" +#include #include #include #include #include #include +#include #include #include #include #include #include + #ifdef HAVE_PTHREAD #include #endif @@ -545,3 +548,41 @@ TEST(SGObject, watched_parameter_object) obj = nullptr; EXPECT_EQ(other_obj->ref_count(), 1); } + +// temporary test until old parameter framework is gone +// enable test to hunt for parameters not registered in tags +// see https://github.com/shogun-toolbox/shogun/issues/4117 +TEST(SGObjectAll, DISABLED_tag_coverage) +{ + auto class_names = available_objects(); + + for (auto class_name : class_names) + { + auto obj = create(class_name.c_str(), PT_NOT_GENERIC); + + // templated classes cannot be created in the above way + if (!obj) + { + // only test single generic type here: all types have the same + // parameter names + obj = create(class_name.c_str(), PT_FLOAT64); + } + + // whether templated or not + ASSERT_NE(obj, nullptr); + + // old parameter framework names + std::set old_names; + for (auto i : range(obj->m_parameters->get_num_parameters())) + old_names.insert(obj->m_parameters->get_parameter(i)->m_name); + auto tag_names = obj->parameter_names(); + + // hack to increase readability of error messages + old_names.insert("Class: " + class_name); + tag_names.insert("Class: " + class_name); + + EXPECT_EQ(tag_names, old_names); + + SG_UNREF(obj); + } +}