aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/rf_control_gain_profile_test.cpp
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2020-06-18 17:46:06 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2021-01-11 12:26:00 -0600
commit12673d9290319d2453fedd806ddf248d3d5586e3 (patch)
tree811016297552c5358129aecb5953a0c143229e86 /host/tests/rf_control_gain_profile_test.cpp
parentc9b35e3b7107ab82c0e3978b7cbfd76ba98e2407 (diff)
downloaduhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.gz
uhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.bz2
uhd-12673d9290319d2453fedd806ddf248d3d5586e3.zip
uhd: Split radio_control into rf_control interfaces
These rf_control interfaces allow easier implementation of radio controls as well as allowing easier sharing of code for implementing e.g. gain_profile.
Diffstat (limited to 'host/tests/rf_control_gain_profile_test.cpp')
-rw-r--r--host/tests/rf_control_gain_profile_test.cpp40
1 files changed, 40 insertions, 0 deletions
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);
+}