Add test for detect()

This commit is contained in:
Sassa NF
2024-09-22 09:57:34 +01:00
parent c5ac3896fb
commit 718ea40859

View File

@@ -47,11 +47,32 @@ void test_rssi(void)
TEST_ASSERT_EQUAL_INT16_ARRAY(expect, samples, test_sz);
}
void test_detect()
{
uint16_t samples[test_sz] = {20, 50, 55, 60, 0, 70, 75, 80, 0, 90, 0, 100, 110};
bool result[test_sz];
size_t r = Scan::detect(samples, result, test_sz, 1);
bool expect[test_sz] = {1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1};
TEST_ASSERT_EQUAL_INT16(0, r);
TEST_ASSERT_EQUAL_INT8_ARRAY(expect, result, test_sz);
r = Scan::detect(samples, result, test_sz, 2);
bool expect2[test_sz] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0};
TEST_ASSERT_EQUAL_INT16(1, r);
TEST_ASSERT_EQUAL_INT8_ARRAY(expect2, result, test_sz);
}
int main(int argc, char **argv)
{
UNITY_BEGIN();
RUN_TEST(test_rssi);
RUN_TEST(test_detect);
UNITY_END();
}