diff options
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | host/tests/rf_control_gain_profile_test.cpp | 40 |
2 files changed, 46 insertions, 0 deletions
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index e2d192796..980f87d75 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -376,6 +376,12 @@ UHD_ADD_NONAPI_TEST( ${CMAKE_SOURCE_DIR}/lib/features/discoverable_feature_registry.cpp ) +UHD_ADD_NONAPI_TEST( + TARGET "rf_control_gain_profile_test.cpp" + EXTRA_SOURCES + ${CMAKE_SOURCE_DIR}/lib/rfnoc/rf_control/gain_profile.cpp +) + ######################################################################## # demo of a loadable module ######################################################################## diff --git a/host/tests/rf_control_gain_profile_test.cpp b/host/tests/rf_control_gain_profile_test.cpp new file mode 100644 index 000000000..d68f4b378 --- /dev/null +++ b/host/tests/rf_control_gain_profile_test.cpp @@ -0,0 +1,40 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhdlib/rfnoc/rf_control/gain_profile_iface.hpp> +#include <uhd/types/ranges.hpp> +#include <boost/test/unit_test.hpp> +#include <iostream> + +using namespace uhd::rfnoc::rf_control; + +static const double tolerance = 0.001; // % + +void test_profile_invariant(gain_profile_iface& gain_profile) +{ + BOOST_CHECK(gain_profile.get_gain_profile_names(0).size() > 0); + for (auto& profile : gain_profile.get_gain_profile_names(0)) + { + gain_profile.set_gain_profile(profile, 0); + BOOST_CHECK(gain_profile.get_gain_profile(0) == profile); + } +} + +BOOST_AUTO_TEST_CASE(test_default_profile_get_set) +{ + default_gain_profile gain_profile; + test_profile_invariant(gain_profile); +} + +BOOST_AUTO_TEST_CASE(test_enumerated_profile_get_set) +{ + enumerated_gain_profile gain_profile( + {"ProfileA", "ProfileB", "ProfileC", "ProfileD"}, + "ProfileD", + 1 + ); + test_profile_invariant(gain_profile); +} |