diff --git a/meson.build b/meson.build index 3641eb5c..38eadf96 100644 --- a/meson.build +++ b/meson.build @@ -605,5 +605,10 @@ unit_test_opts = {'c_args': linux_c_args, 'link_args' : linux_l_args} unit_test_src = openrtx_src + minmea_src + linux_platform_src -dummy_test = executable('dummy', 'tests/unit/dummy.c') -test('Dummy Unit Test', dummy_test) +#dummy_test = executable('dummy', 'tests/unit/dummy.c') +#test('Dummy Unit Test', dummy_test) + +m17_golay_test = executable('m17_golay_test', + sources: unit_test_src + ['tests/unit/M17_golay.cpp'], + kwargs: unit_test_opts) +test('M17 Golay Unit Test', m17_golay_test) diff --git a/tests/unit/M17_golay.cpp b/tests/unit/M17_golay.cpp index b487291e..e089ead6 100644 --- a/tests/unit/M17_golay.cpp +++ b/tests/unit/M17_golay.cpp @@ -71,10 +71,17 @@ int main() // Less than four errors should be corrected. if(decoded == value) correcting_ok = true; - printf("Value %04x, emask %08x errs %d -> d %s, c %s\n", value, emask, - __builtin_popcount(emask), + int input_error_count = __builtin_popcount(emask); + + printf("Value %04x, emask %08x errs %d -> d %s, c %s\n", + value, + emask, + input_error_count, decoding_ok ? "OK" : "FAIL", correcting_ok ? "OK" : "FAIL"); + + if(input_error_count <= 4 && (!decoding_ok || !correcting_ok)) + return -1; } return 0;