commit 7c517b4fcfa8915f5cdd6bc4af1ea9a3b3fd45a9
parent 553052a33740f2744221f9e23b29b8d0792bcd40
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 29 Dec 2022 16:24:28 -0800
unit: add invalid channels/freqs to test-band
Tests some channels and frequencies that are not in E-4 and
would pass the conversion without validation.
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/unit/test-band.c b/unit/test-band.c
@@ -650,6 +650,26 @@ static void test_6ghz_freqs(const void *data)
}
}
+static void test_conversions(const void *data)
+{
+ /*
+ * Test a few invalid channels/frequencies that appear valid but are
+ * not in the E-4 table. The checks in band.c seem to cover 2.4Ghz and
+ * 6Ghz very well since there are no gaps, but the 5GHz band has some
+ * segmentation.
+ */
+
+ /* Gap in 5GHz channels between 68 and 96 */
+ assert(!band_channel_to_freq(72, BAND_FREQ_5_GHZ));
+ assert(!band_freq_to_channel(5360, NULL));
+
+ /* Invalid channel using 4000mhz starting frequency */
+ assert(!band_channel_to_freq(183, BAND_FREQ_5_GHZ));
+ assert(!band_freq_to_channel(4915, NULL));
+
+ assert(!band_channel_to_freq(192, BAND_FREQ_5_GHZ));
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@@ -715,5 +735,7 @@ int main(int argc, char *argv[])
l_test_add("/band/6ghz/channels", test_6ghz_channels, NULL);
l_test_add("/band/6ghz/freq", test_6ghz_freqs, NULL);
+ l_test_add("/band/conversions", test_conversions, NULL);
+
return l_test_run();
}