SubGhz: Unit_test and bugfixes (#1104)

* SubGhz: CLI add "subghz decode_raw"
* SubGhz: unit_test
* SubGhz: add Hormann_hsm_raw unit_test
* SubGhz: fix duration raw
* Unit_test: fix total test timer
* SubGHz: fix name display scher_khan
* SubGhz: fix deviation protocol kia
* SubGhz: return max name length to previous value
* FuriHal: correctly handle mute in speaker
* UnitTests: fix grammar in subghz

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2022-04-14 16:49:29 +04:00
committed by GitHub
parent 917be9c6d3
commit 8cc3fd579c
57 changed files with 879 additions and 39 deletions

View File

@@ -0,0 +1,337 @@
#include <furi.h>
#include <flipper_format/flipper_format.h>
#include <flipper_format/flipper_format_i.h>
#include <toolbox/stream/stream.h>
#include <storage/storage.h>
#include "../minunit.h"
static const char* test_filetype = "Flipper Format test";
static const uint32_t test_version = 666;
static const char* test_string_key = "String data";
static const char* test_string_data = "String";
static const char* test_string_updated_data = "New string";
static const char* test_string_updated_2_data = "And some more";
static const char* test_int_key = "Int32 data";
static const int32_t test_int_data[] = {1234, -6345, 7813, 0};
static const int32_t test_int_updated_data[] = {-1337, 69};
static const int32_t test_int_updated_2_data[] = {-3, -2, -1, 0, 1, 2, 3};
static const char* test_uint_key = "Uint32 data";
static const uint32_t test_uint_data[] = {1234, 0, 5678, 9098, 7654321};
static const uint32_t test_uint_updated_data[] = {8, 800, 555, 35, 35};
static const uint32_t test_uint_updated_2_data[] = {20, 21};
static const char* test_float_key = "Float data";
static const float test_float_data[] = {1.5f, 1000.0f};
static const float test_float_updated_data[] = {1.2f};
static const float test_float_updated_2_data[] = {0.01f, 0.0f, -51.6f};
static const char* test_hex_key = "Hex data";
static const uint8_t test_hex_data[] = {0xDE, 0xAD, 0xBE};
static const uint8_t test_hex_updated_data[] = {0xFE, 0xCA};
static const uint8_t test_hex_updated_2_data[] = {0xCA, 0xCA, 0x05};
static const char* test_hex_new_key = "New Hex data";
static const uint8_t test_hex_new_data[] = {0xFF, 0x6A, 0x91};
static const char* test_data_nix = "Filetype: Flipper Format test\n"
"Version: 666\n"
"# This is comment\n"
"String data: String\n"
"Int32 data: 1234 -6345 7813 0\n"
"Uint32 data: 1234 0 5678 9098 7654321\n"
"Float data: 1.5 1000.0\n"
"Hex data: DE AD BE";
static const char* test_data_win = "Filetype: Flipper Format test\r\n"
"Version: 666\r\n"
"# This is comment\r\n"
"String data: String\r\n"
"Int32 data: 1234 -6345 7813 0\r\n"
"Uint32 data: 1234 0 5678 9098 7654321\r\n"
"Float data: 1.5 1000.0\r\n"
"Hex data: DE AD BE";
#define ARRAY_W_COUNT(x) (x), (COUNT_OF(x))
#define ARRAY_W_BSIZE(x) (x), (sizeof(x))
MU_TEST_1(flipper_format_read_and_update_test, FlipperFormat* flipper_format) {
string_t tmpstr;
uint32_t version;
uint32_t uint32_data[COUNT_OF(test_uint_data)];
int32_t int32_data[COUNT_OF(test_int_data)];
float float_data[COUNT_OF(test_float_data)];
uint8_t hex_data[COUNT_OF(test_hex_data)];
uint32_t count;
// key exist test
size_t position_before = stream_tell(flipper_format_get_raw_stream(flipper_format));
mu_check(flipper_format_key_exist(flipper_format, test_hex_key));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
mu_check(!flipper_format_key_exist(flipper_format, "invalid key"));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
// stream seek to end test
mu_check(flipper_format_seek_to_end(flipper_format));
mu_assert_int_eq(
stream_size(flipper_format_get_raw_stream(flipper_format)),
stream_tell(flipper_format_get_raw_stream(flipper_format)));
// key exist test
position_before = stream_tell(flipper_format_get_raw_stream(flipper_format));
mu_check(flipper_format_key_exist(flipper_format, test_hex_key));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
mu_check(!flipper_format_key_exist(flipper_format, "invalid key"));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
// rewind
mu_check(flipper_format_rewind(flipper_format));
// key exist test
position_before = stream_tell(flipper_format_get_raw_stream(flipper_format));
mu_check(flipper_format_key_exist(flipper_format, test_hex_key));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
mu_check(!flipper_format_key_exist(flipper_format, "invalid key"));
mu_assert_int_eq(position_before, stream_tell(flipper_format_get_raw_stream(flipper_format)));
// read test
string_init(tmpstr);
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
mu_assert_string_eq(test_string_data, string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_data), count);
mu_check(flipper_format_read_int32(flipper_format, test_int_key, ARRAY_W_COUNT(int32_data)));
mu_check(memcmp(test_int_data, ARRAY_W_BSIZE(int32_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_uint_key, &count));
mu_assert_int_eq(COUNT_OF(test_uint_data), count);
mu_check(
flipper_format_read_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_data)));
mu_check(memcmp(test_uint_data, ARRAY_W_BSIZE(uint32_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_float_key, &count));
mu_assert_int_eq(COUNT_OF(test_float_data), count);
mu_check(flipper_format_read_float(flipper_format, test_float_key, ARRAY_W_COUNT(float_data)));
mu_check(memcmp(test_float_data, ARRAY_W_BSIZE(float_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_hex_key, &count));
mu_assert_int_eq(COUNT_OF(test_hex_data), count);
mu_check(flipper_format_read_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(hex_data)));
mu_check(memcmp(test_hex_data, ARRAY_W_BSIZE(hex_data)) == 0);
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
string_clear(tmpstr);
// update data
mu_check(flipper_format_rewind(flipper_format));
mu_check(flipper_format_update_string_cstr(
flipper_format, test_string_key, test_string_updated_data));
mu_check(flipper_format_update_int32(
flipper_format, test_int_key, ARRAY_W_COUNT(test_int_updated_data)));
mu_check(flipper_format_update_uint32(
flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_updated_data)));
mu_check(flipper_format_update_float(
flipper_format, test_float_key, ARRAY_W_COUNT(test_float_updated_data)));
mu_check(flipper_format_update_hex(
flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_updated_data)));
// read updated data test
uint32_t uint32_updated_data[COUNT_OF(test_uint_updated_data)];
int32_t int32_updated_data[COUNT_OF(test_int_updated_data)];
float float_updated_data[COUNT_OF(test_float_updated_data)];
uint8_t hex_updated_data[COUNT_OF(test_hex_updated_data)];
mu_check(flipper_format_rewind(flipper_format));
string_init(tmpstr);
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
mu_assert_string_eq(test_string_updated_data, string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_updated_data), count);
mu_check(flipper_format_read_int32(
flipper_format, test_int_key, ARRAY_W_COUNT(int32_updated_data)));
mu_check(memcmp(test_int_updated_data, ARRAY_W_BSIZE(int32_updated_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_uint_key, &count));
mu_assert_int_eq(COUNT_OF(test_uint_updated_data), count);
mu_check(flipper_format_read_uint32(
flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_updated_data)));
mu_check(memcmp(test_uint_updated_data, ARRAY_W_BSIZE(uint32_updated_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_float_key, &count));
mu_assert_int_eq(COUNT_OF(test_float_updated_data), count);
mu_check(flipper_format_read_float(
flipper_format, test_float_key, ARRAY_W_COUNT(float_updated_data)));
mu_check(memcmp(test_float_updated_data, ARRAY_W_BSIZE(float_updated_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_hex_key, &count));
mu_assert_int_eq(COUNT_OF(test_hex_updated_data), count);
mu_check(
flipper_format_read_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(hex_updated_data)));
mu_check(memcmp(test_hex_updated_data, ARRAY_W_BSIZE(hex_updated_data)) == 0);
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
string_clear(tmpstr);
// update data
mu_check(flipper_format_rewind(flipper_format));
mu_check(flipper_format_insert_or_update_string_cstr(
flipper_format, test_string_key, test_string_updated_2_data));
mu_check(flipper_format_insert_or_update_int32(
flipper_format, test_int_key, ARRAY_W_COUNT(test_int_updated_2_data)));
mu_check(flipper_format_insert_or_update_uint32(
flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_updated_2_data)));
mu_check(flipper_format_insert_or_update_float(
flipper_format, test_float_key, ARRAY_W_COUNT(test_float_updated_2_data)));
mu_check(flipper_format_insert_or_update_hex(
flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_updated_2_data)));
mu_check(flipper_format_insert_or_update_hex(
flipper_format, test_hex_new_key, ARRAY_W_COUNT(test_hex_new_data)));
uint32_t uint32_updated_2_data[COUNT_OF(test_uint_updated_2_data)];
int32_t int32_updated_2_data[COUNT_OF(test_int_updated_2_data)];
float float_updated_2_data[COUNT_OF(test_float_updated_2_data)];
uint8_t hex_updated_2_data[COUNT_OF(test_hex_updated_2_data)];
uint8_t hex_new_data[COUNT_OF(test_hex_new_data)];
mu_check(flipper_format_rewind(flipper_format));
string_init(tmpstr);
mu_check(flipper_format_read_header(flipper_format, tmpstr, &version));
mu_assert_string_eq(test_filetype, string_get_cstr(tmpstr));
mu_assert_int_eq(test_version, version);
mu_check(flipper_format_read_string(flipper_format, test_string_key, tmpstr));
mu_assert_string_eq(test_string_updated_2_data, string_get_cstr(tmpstr));
mu_check(flipper_format_get_value_count(flipper_format, test_int_key, &count));
mu_assert_int_eq(COUNT_OF(test_int_updated_2_data), count);
mu_check(flipper_format_read_int32(
flipper_format, test_int_key, ARRAY_W_COUNT(int32_updated_2_data)));
mu_check(memcmp(test_int_updated_2_data, ARRAY_W_BSIZE(int32_updated_2_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_uint_key, &count));
mu_assert_int_eq(COUNT_OF(test_uint_updated_2_data), count);
mu_check(flipper_format_read_uint32(
flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_updated_2_data)));
mu_check(memcmp(test_uint_updated_2_data, ARRAY_W_BSIZE(uint32_updated_2_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_float_key, &count));
mu_assert_int_eq(COUNT_OF(test_float_updated_2_data), count);
mu_check(flipper_format_read_float(
flipper_format, test_float_key, ARRAY_W_COUNT(float_updated_2_data)));
mu_check(memcmp(test_float_updated_2_data, ARRAY_W_BSIZE(float_updated_2_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_hex_key, &count));
mu_assert_int_eq(COUNT_OF(test_hex_updated_2_data), count);
mu_check(
flipper_format_read_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(hex_updated_2_data)));
mu_check(memcmp(test_hex_updated_2_data, ARRAY_W_BSIZE(hex_updated_2_data)) == 0);
mu_check(flipper_format_get_value_count(flipper_format, test_hex_new_key, &count));
mu_assert_int_eq(COUNT_OF(test_hex_new_data), count);
mu_check(
flipper_format_read_hex(flipper_format, test_hex_new_key, ARRAY_W_COUNT(hex_new_data)));
mu_check(memcmp(test_hex_new_data, ARRAY_W_BSIZE(hex_new_data)) == 0);
mu_check(!flipper_format_read_string(flipper_format, "Key that doesn't exist", tmpstr));
string_clear(tmpstr);
// delete key test
mu_check(flipper_format_rewind(flipper_format));
mu_check(flipper_format_delete_key(flipper_format, test_uint_key));
// deleted key read test
mu_check(flipper_format_rewind(flipper_format));
mu_check(!flipper_format_read_uint32(
flipper_format, test_uint_key, ARRAY_W_COUNT(uint32_updated_data)));
}
MU_TEST(flipper_format_string_test) {
FlipperFormat* flipper_format = flipper_format_string_alloc();
Stream* stream = flipper_format_get_raw_stream(flipper_format);
mu_check(flipper_format_write_header_cstr(flipper_format, test_filetype, test_version));
mu_check(flipper_format_write_comment_cstr(flipper_format, "This is comment"));
mu_check(flipper_format_write_string_cstr(flipper_format, test_string_key, test_string_data));
mu_check(
flipper_format_write_int32(flipper_format, test_int_key, ARRAY_W_COUNT(test_int_data)));
mu_check(
flipper_format_write_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_data)));
mu_check(flipper_format_write_float(
flipper_format, test_float_key, ARRAY_W_COUNT(test_float_data)));
mu_check(flipper_format_write_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_data)));
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
stream_clean(stream);
stream_write_cstring(stream, test_data_nix);
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
stream_clean(stream);
stream_write_cstring(stream, test_data_win);
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
flipper_format_free(flipper_format);
}
MU_TEST(flipper_format_file_test) {
Storage* storage = furi_record_open("storage");
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
mu_check(flipper_format_file_open_always(flipper_format, "/ext/flipper.fff"));
Stream* stream = flipper_format_get_raw_stream(flipper_format);
mu_check(flipper_format_write_header_cstr(flipper_format, test_filetype, test_version));
mu_check(flipper_format_write_comment_cstr(flipper_format, "This is comment"));
mu_check(flipper_format_write_string_cstr(flipper_format, test_string_key, test_string_data));
mu_check(
flipper_format_write_int32(flipper_format, test_int_key, ARRAY_W_COUNT(test_int_data)));
mu_check(
flipper_format_write_uint32(flipper_format, test_uint_key, ARRAY_W_COUNT(test_uint_data)));
mu_check(flipper_format_write_float(
flipper_format, test_float_key, ARRAY_W_COUNT(test_float_data)));
mu_check(flipper_format_write_hex(flipper_format, test_hex_key, ARRAY_W_COUNT(test_hex_data)));
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
stream_clean(stream);
stream_write_cstring(stream, test_data_nix);
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
stream_clean(stream);
stream_write_cstring(stream, test_data_win);
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
flipper_format_free(flipper_format);
furi_record_close("storage");
}
MU_TEST_SUITE(flipper_format_string_suite) {
MU_RUN_TEST(flipper_format_string_test);
MU_RUN_TEST(flipper_format_file_test);
}
int run_minunit_test_flipper_format_string() {
MU_RUN_SUITE(flipper_format_string_suite);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,525 @@
#include <furi.h>
#include <flipper_format/flipper_format.h>
#include <flipper_format/flipper_format_i.h>
#include <toolbox/stream/stream.h>
#include "../minunit.h"
#define TEST_DIR TEST_DIR_NAME "/"
#define TEST_DIR_NAME "/ext/unit_tests_tmp"
static const char* test_filetype = "Flipper File test";
static const uint32_t test_version = 666;
static const char* test_string_key = "String data";
static const char* test_string_data = "String";
static const char* test_string_updated_data = "New string";
static const char* test_int_key = "Int32 data";
static const int32_t test_int_data[] = {1234, -6345, 7813, 0};
static const int32_t test_int_updated_data[] = {-1337, 69};
static const char* test_uint_key = "Uint32 data";
static const uint32_t test_uint_data[] = {1234, 0, 5678, 9098, 7654321};
static const uint32_t test_uint_updated_data[] = {8, 800, 555, 35, 35};
static const char* test_float_key = "Float data";
static const float test_float_data[] = {1.5f, 1000.0f};
static const float test_float_updated_data[] = {1.2f};
static const char* test_bool_key = "Bool data";
static const bool test_bool_data[] = {true, false};
static const bool test_bool_updated_data[] = {false, true, true};
static const char* test_hex_key = "Hex data";
static const uint8_t test_hex_data[] = {0xDE, 0xAD, 0xBE};
static const uint8_t test_hex_updated_data[] = {0xFE, 0xCA};
#define READ_TEST_NIX "ff_nix.test"
static const char* test_data_nix = "Filetype: Flipper File test\n"
"Version: 666\n"
"# This is comment\n"
"String data: String\n"
"Int32 data: 1234 -6345 7813 0\n"
"Uint32 data: 1234 0 5678 9098 7654321\n"
"Float data: 1.5 1000.0\n"
"Bool data: true false\n"
"Hex data: DE AD BE";
#define READ_TEST_WIN "ff_win.test"
static const char* test_data_win = "Filetype: Flipper File test\r\n"
"Version: 666\r\n"
"# This is comment\r\n"
"String data: String\r\n"
"Int32 data: 1234 -6345 7813 0\r\n"
"Uint32 data: 1234 0 5678 9098 7654321\r\n"
"Float data: 1.5 1000.0\r\n"
"Bool data: true false\r\n"
"Hex data: DE AD BE";
#define READ_TEST_FLP "ff_flp.test"
// data created by user on linux machine
static const char* test_file_linux = TEST_DIR READ_TEST_NIX;
// data created by user on windows machine
static const char* test_file_windows = TEST_DIR READ_TEST_WIN;
// data created by flipper itself
static const char* test_file_flipper = TEST_DIR READ_TEST_FLP;
static bool storage_write_string(const char* path, const char* data) {
Storage* storage = furi_record_open("storage");
File* file = storage_file_alloc(storage);
bool result = false;
do {
if(!storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) break;
if(storage_file_write(file, data, strlen(data)) != strlen(data)) break;
result = true;
} while(false);
storage_file_close(file);
storage_file_free(file);
furi_record_close("storage");
return result;
}
static void tests_setup() {
Storage* storage = furi_record_open("storage");
mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data");
mu_assert(storage_simply_mkdir(storage, TEST_DIR_NAME), "Cannot create dir");
furi_record_close("storage");
}
static void tests_teardown() {
Storage* storage = furi_record_open("storage");
mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data");
furi_record_close("storage");
}
static bool test_read(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
void* scratchpad = malloc(512);
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
if(!flipper_format_read_string(file, test_string_key, string_value)) break;
if(string_cmp_str(string_value, test_string_data) != 0) break;
if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_data)) break;
if(!flipper_format_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_int_data, sizeof(int32_t) * COUNT_OF(test_int_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_uint_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_uint_data)) break;
if(!flipper_format_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_uint_data, sizeof(uint32_t) * COUNT_OF(test_uint_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_float_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_float_data)) break;
if(!flipper_format_read_float(file, test_float_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_float_data, sizeof(float) * COUNT_OF(test_float_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_bool_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_bool_data)) break;
if(!flipper_format_read_bool(file, test_bool_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_bool_data, sizeof(bool) * COUNT_OF(test_bool_data)) != 0) break;
if(!flipper_format_get_value_count(file, test_hex_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_hex_data)) break;
if(!flipper_format_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
if(memcmp(scratchpad, test_hex_data, sizeof(uint8_t) * COUNT_OF(test_hex_data)) != 0)
break;
result = true;
} while(false);
free(scratchpad);
string_clear(string_value);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_read_updated(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
void* scratchpad = malloc(512);
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
if(!flipper_format_read_string(file, test_string_key, string_value)) break;
if(string_cmp_str(string_value, test_string_updated_data) != 0) break;
if(!flipper_format_get_value_count(file, test_int_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_int_updated_data)) break;
if(!flipper_format_read_int32(file, test_int_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_int_updated_data,
sizeof(int32_t) * COUNT_OF(test_int_updated_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_uint_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_uint_updated_data)) break;
if(!flipper_format_read_uint32(file, test_uint_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_uint_updated_data,
sizeof(uint32_t) * COUNT_OF(test_uint_updated_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_float_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_float_updated_data)) break;
if(!flipper_format_read_float(file, test_float_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_float_updated_data,
sizeof(float) * COUNT_OF(test_float_updated_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_bool_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_bool_updated_data)) break;
if(!flipper_format_read_bool(file, test_bool_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_bool_updated_data,
sizeof(bool) * COUNT_OF(test_bool_updated_data)) != 0)
break;
if(!flipper_format_get_value_count(file, test_hex_key, &uint32_value)) break;
if(uint32_value != COUNT_OF(test_hex_updated_data)) break;
if(!flipper_format_read_hex(file, test_hex_key, scratchpad, uint32_value)) break;
if(memcmp(
scratchpad,
test_hex_updated_data,
sizeof(uint8_t) * COUNT_OF(test_hex_updated_data)) != 0)
break;
result = true;
} while(false);
free(scratchpad);
string_clear(string_value);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_write(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_always(file, file_name)) break;
if(!flipper_format_write_header_cstr(file, test_filetype, test_version)) break;
if(!flipper_format_write_comment_cstr(file, "This is comment")) break;
if(!flipper_format_write_string_cstr(file, test_string_key, test_string_data)) break;
if(!flipper_format_write_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
break;
if(!flipper_format_write_uint32(
file, test_uint_key, test_uint_data, COUNT_OF(test_uint_data)))
break;
if(!flipper_format_write_float(
file, test_float_key, test_float_data, COUNT_OF(test_float_data)))
break;
if(!flipper_format_write_bool(
file, test_bool_key, test_bool_data, COUNT_OF(test_bool_data)))
break;
if(!flipper_format_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_delete_last_key(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_delete_key(file, test_hex_key)) break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_append_key(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_append(file, file_name)) break;
if(!flipper_format_write_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_update(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_update_string_cstr(file, test_string_key, test_string_updated_data))
break;
if(!flipper_format_update_int32(
file, test_int_key, test_int_updated_data, COUNT_OF(test_int_updated_data)))
break;
if(!flipper_format_update_uint32(
file, test_uint_key, test_uint_updated_data, COUNT_OF(test_uint_updated_data)))
break;
if(!flipper_format_update_float(
file, test_float_key, test_float_updated_data, COUNT_OF(test_float_updated_data)))
break;
if(!flipper_format_update_bool(
file, test_bool_key, test_bool_updated_data, COUNT_OF(test_bool_updated_data)))
break;
if(!flipper_format_update_hex(
file, test_hex_key, test_hex_updated_data, COUNT_OF(test_hex_updated_data)))
break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_update_backward(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_update_string_cstr(file, test_string_key, test_string_data)) break;
if(!flipper_format_update_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
break;
if(!flipper_format_update_uint32(
file, test_uint_key, test_uint_data, COUNT_OF(test_uint_data)))
break;
if(!flipper_format_update_float(
file, test_float_key, test_float_data, COUNT_OF(test_float_data)))
break;
if(!flipper_format_update_bool(
file, test_bool_key, test_bool_data, COUNT_OF(test_bool_data)))
break;
if(!flipper_format_update_hex(file, test_hex_key, test_hex_data, COUNT_OF(test_hex_data)))
break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_write_multikey(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_always(file, file_name)) break;
if(!flipper_format_write_header_cstr(file, test_filetype, test_version)) break;
bool error = false;
for(uint8_t index = 0; index < 100; index++) {
if(!flipper_format_write_hex(file, test_hex_key, &index, 1)) {
error = true;
break;
}
}
if(error) break;
result = true;
} while(false);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
static bool test_read_multikey(const char* file_name) {
Storage* storage = furi_record_open("storage");
bool result = false;
FlipperFormat* file = flipper_format_file_alloc(storage);
string_t string_value;
string_init(string_value);
uint32_t uint32_value;
do {
if(!flipper_format_file_open_existing(file, file_name)) break;
if(!flipper_format_read_header(file, string_value, &uint32_value)) break;
if(string_cmp_str(string_value, test_filetype) != 0) break;
if(uint32_value != test_version) break;
bool error = false;
uint8_t uint8_value;
for(uint8_t index = 0; index < 100; index++) {
if(!flipper_format_read_hex(file, test_hex_key, &uint8_value, 1)) {
error = true;
break;
}
if(uint8_value != index) {
error = true;
break;
}
}
if(error) break;
result = true;
} while(false);
string_clear(string_value);
flipper_format_free(file);
furi_record_close("storage");
return result;
}
MU_TEST(flipper_format_write_test) {
mu_assert(storage_write_string(test_file_linux, test_data_nix), "Write test error [Linux]");
mu_assert(
storage_write_string(test_file_windows, test_data_win), "Write test error [Windows]");
mu_assert(test_write(test_file_flipper), "Write test error [Flipper]");
}
MU_TEST(flipper_format_read_test) {
mu_assert(test_read(test_file_linux), "Read test error [Linux]");
mu_assert(test_read(test_file_windows), "Read test error [Windows]");
mu_assert(test_read(test_file_flipper), "Read test error [Flipper]");
}
MU_TEST(flipper_format_delete_test) {
mu_assert(test_delete_last_key(test_file_linux), "Cannot delete key [Linux]");
mu_assert(test_delete_last_key(test_file_windows), "Cannot delete key [Windows]");
mu_assert(test_delete_last_key(test_file_flipper), "Cannot delete key [Flipper]");
}
MU_TEST(flipper_format_delete_result_test) {
mu_assert(!test_read(test_file_linux), "Key deleted incorrectly [Linux]");
mu_assert(!test_read(test_file_windows), "Key deleted incorrectly [Windows]");
mu_assert(!test_read(test_file_flipper), "Key deleted incorrectly [Flipper]");
}
MU_TEST(flipper_format_append_test) {
mu_assert(test_append_key(test_file_linux), "Cannot append data [Linux]");
mu_assert(test_append_key(test_file_windows), "Cannot append data [Windows]");
mu_assert(test_append_key(test_file_flipper), "Cannot append data [Flipper]");
}
MU_TEST(flipper_format_append_result_test) {
mu_assert(test_read(test_file_linux), "Data appended incorrectly [Linux]");
mu_assert(test_read(test_file_windows), "Data appended incorrectly [Windows]");
mu_assert(test_read(test_file_flipper), "Data appended incorrectly [Flipper]");
}
MU_TEST(flipper_format_update_1_test) {
mu_assert(test_update(test_file_linux), "Cannot update data #1 [Linux]");
mu_assert(test_update(test_file_windows), "Cannot update data #1 [Windows]");
mu_assert(test_update(test_file_flipper), "Cannot update data #1 [Flipper]");
}
MU_TEST(flipper_format_update_1_result_test) {
mu_assert(test_read_updated(test_file_linux), "Data #1 updated incorrectly [Linux]");
mu_assert(test_read_updated(test_file_windows), "Data #1 updated incorrectly [Windows]");
mu_assert(test_read_updated(test_file_flipper), "Data #1 updated incorrectly [Flipper]");
}
MU_TEST(flipper_format_update_2_test) {
mu_assert(test_update_backward(test_file_linux), "Cannot update data #2 [Linux]");
mu_assert(test_update_backward(test_file_windows), "Cannot update data #2 [Windows]");
mu_assert(test_update_backward(test_file_flipper), "Cannot update data #2 [Flipper]");
}
MU_TEST(flipper_format_update_2_result_test) {
mu_assert(test_read(test_file_linux), "Data #2 updated incorrectly [Linux]");
mu_assert(test_read(test_file_windows), "Data #2 updated incorrectly [Windows]");
mu_assert(test_read(test_file_flipper), "Data #2 updated incorrectly [Flipper]");
}
MU_TEST(flipper_format_multikey_test) {
mu_assert(test_write_multikey(TEST_DIR "ff_multiline.test"), "Multikey write test error");
mu_assert(test_read_multikey(TEST_DIR "ff_multiline.test"), "Multikey read test error");
}
MU_TEST_SUITE(flipper_format) {
tests_setup();
MU_RUN_TEST(flipper_format_write_test);
MU_RUN_TEST(flipper_format_read_test);
MU_RUN_TEST(flipper_format_delete_test);
MU_RUN_TEST(flipper_format_delete_result_test);
MU_RUN_TEST(flipper_format_append_test);
MU_RUN_TEST(flipper_format_append_result_test);
MU_RUN_TEST(flipper_format_update_1_test);
MU_RUN_TEST(flipper_format_update_1_result_test);
MU_RUN_TEST(flipper_format_update_2_test);
MU_RUN_TEST(flipper_format_update_2_result_test);
MU_RUN_TEST(flipper_format_multikey_test);
tests_teardown();
}
int run_minunit_test_flipper_format() {
MU_RUN_SUITE(flipper_format);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,100 @@
#include "minunit.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
// this test is not accurate, but gives a basic understanding
// that memory management is working fine
// do not include memmgr.h here
// we also test that we are linking against stdlib
extern size_t memmgr_get_free_heap(void);
extern size_t memmgr_get_minimum_free_heap(void);
// current heap managment realization consume:
// X bytes after allocate and 0 bytes after allocate and free,
// where X = sizeof(void*) + sizeof(size_t), look to BlockLink_t
const size_t heap_overhead_max_size = sizeof(void*) + sizeof(size_t);
bool heap_equal(size_t heap_size, size_t heap_size_old) {
// heap borders with overhead
const size_t heap_low = heap_size_old - heap_overhead_max_size;
const size_t heap_high = heap_size_old + heap_overhead_max_size;
// not extact, so we must test it against bigger numbers than "overhead size"
const bool result = ((heap_size >= heap_low) && (heap_size <= heap_high));
// debug allocation info
if(!result) {
printf("\n(hl: %zu) <= (p: %zu) <= (hh: %zu)\n", heap_low, heap_size, heap_high);
}
return result;
}
void test_furi_memmgr() {
size_t heap_size = 0;
size_t heap_size_old = 0;
const int alloc_size = 128;
void* ptr = NULL;
void* original_ptr = NULL;
// do not include furi memmgr.h case
#ifdef FURI_MEMMGR_GUARD
mu_fail("do not link against furi memmgr.h");
#endif
// allocate memory case
heap_size_old = memmgr_get_free_heap();
ptr = malloc(alloc_size);
heap_size = memmgr_get_free_heap();
mu_assert_pointers_not_eq(ptr, NULL);
mu_assert(heap_equal(heap_size, heap_size_old - alloc_size), "allocate failed");
// free memory case
heap_size_old = memmgr_get_free_heap();
free(ptr);
ptr = NULL;
heap_size = memmgr_get_free_heap();
mu_assert(heap_equal(heap_size, heap_size_old + alloc_size), "free failed");
// reallocate memory case
// get filled array with some data
original_ptr = malloc(alloc_size);
mu_assert_pointers_not_eq(original_ptr, NULL);
for(int i = 0; i < alloc_size; i++) {
*(unsigned char*)(original_ptr + i) = i;
}
// malloc array and copy data
ptr = malloc(alloc_size);
mu_assert_pointers_not_eq(ptr, NULL);
memcpy(ptr, original_ptr, alloc_size);
// reallocate array
heap_size_old = memmgr_get_free_heap();
ptr = realloc(ptr, alloc_size * 2);
heap_size = memmgr_get_free_heap();
mu_assert(heap_equal(heap_size, heap_size_old - alloc_size), "reallocate failed");
mu_assert_int_eq(memcmp(original_ptr, ptr, alloc_size), 0);
free(original_ptr);
free(ptr);
// allocate and zero-initialize array (calloc)
original_ptr = malloc(alloc_size);
mu_assert_pointers_not_eq(original_ptr, NULL);
for(int i = 0; i < alloc_size; i++) {
*(unsigned char*)(original_ptr + i) = 0;
}
heap_size_old = memmgr_get_free_heap();
ptr = calloc(1, alloc_size);
heap_size = memmgr_get_free_heap();
mu_assert(heap_equal(heap_size, heap_size_old - alloc_size), "callocate failed");
mu_assert_int_eq(memcmp(original_ptr, ptr, alloc_size), 0);
free(original_ptr);
free(ptr);
}

View File

@@ -0,0 +1,45 @@
#include <stdio.h>
#include <string.h>
#include <furi.h>
#include "minunit.h"
const uint32_t context_value = 0xdeadbeef;
const uint32_t notify_value_0 = 0x12345678;
const uint32_t notify_value_1 = 0x11223344;
uint32_t pubsub_value = 0;
uint32_t pubsub_context_value = 0;
void test_pubsub_handler(const void* arg, void* ctx) {
pubsub_value = *(uint32_t*)arg;
pubsub_context_value = *(uint32_t*)ctx;
}
void test_furi_pubsub() {
FuriPubSub* test_pubsub = NULL;
FuriPubSubSubscription* test_pubsub_subscription = NULL;
// init pubsub case
test_pubsub = furi_pubsub_alloc();
mu_assert_pointers_not_eq(test_pubsub, NULL);
// subscribe pubsub case
test_pubsub_subscription =
furi_pubsub_subscribe(test_pubsub, test_pubsub_handler, (void*)&context_value);
mu_assert_pointers_not_eq(test_pubsub_subscription, NULL);
/// notify pubsub case
furi_pubsub_publish(test_pubsub, (void*)&notify_value_0);
mu_assert_int_eq(pubsub_value, notify_value_0);
mu_assert_int_eq(pubsub_context_value, context_value);
// unsubscribe pubsub case
furi_pubsub_unsubscribe(test_pubsub, test_pubsub_subscription);
/// notify unsubscribed pubsub case
furi_pubsub_publish(test_pubsub, (void*)&notify_value_1);
mu_assert_int_not_eq(pubsub_value, notify_value_1);
// delete pubsub case
furi_pubsub_free(test_pubsub);
}

View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include <string.h>
#include <furi.h>
#include "minunit.h"
void test_furi_create_open() {
// 1. Create record
uint8_t test_data = 0;
furi_record_create("test/holding", (void*)&test_data);
// 2. Open it
void* record = furi_record_open("test/holding");
mu_assert_pointers_eq(record, &test_data);
// 3. Close it
furi_record_close("test/holding");
// 4. Clean up
furi_record_destroy("test/holding");
}

View File

@@ -0,0 +1,130 @@
#include <stdio.h>
#include <string.h>
#include <furi.h>
#include "furi_hal_delay.h"
#include "minunit.h"
void test_furi_valuemutex() {
const int init_value = 0xdeadbeef;
const int changed_value = 0x12345678;
int value = init_value;
bool result;
ValueMutex valuemutex;
// init mutex case
result = init_mutex(&valuemutex, &value, sizeof(value));
mu_assert(result, "init mutex failed");
// acquire mutex case
int* value_pointer = acquire_mutex(&valuemutex, 100);
mu_assert_pointers_eq(value_pointer, &value);
// second acquire mutex case
int* value_pointer_second = acquire_mutex(&valuemutex, 100);
mu_assert_pointers_eq(value_pointer_second, NULL);
// change value case
*value_pointer = changed_value;
mu_assert_int_eq(value, changed_value);
// release mutex case
result = release_mutex(&valuemutex, &value);
mu_assert(result, "release mutex failed");
// TODO
//acquire mutex blocking case
//write mutex blocking case
//read mutex blocking case
mu_check(delete_mutex(&valuemutex));
}
/*
TEST: concurrent access
1. Create holding record
2. Open it twice
3. Change value simultaneously in two app and check integrity
*/
// TODO this test broke because mutex in furi is not implemented
typedef struct {
// a and b must be equal
uint8_t a;
uint8_t b;
} ConcurrentValue;
void furi_concurent_app(void* p) {
ValueMutex* mutex = (ValueMutex*)p;
if(mutex == NULL) {
printf("cannot open mutex\r\n");
osThreadExit();
}
for(size_t i = 0; i < 10; i++) {
ConcurrentValue* value = (ConcurrentValue*)acquire_mutex_block(mutex);
if(value == NULL) {
printf("cannot take record\r\n");
release_mutex(mutex, value);
osThreadExit();
}
// emulate read-modify-write broken by context switching
uint8_t a = value->a;
uint8_t b = value->b;
a++;
b++;
furi_hal_delay_ms(2);
value->a = a;
value->b = b;
release_mutex(mutex, value);
}
osThreadExit();
}
void test_furi_concurrent_access() {
// TODO: reimplement or delete test
return;
/*
// 1. Create holding record
ConcurrentValue value = {.a = 0, .b = 0};
ValueMutex mutex;
mu_check(init_mutex(&mutex, &value, sizeof(value)));
// 3. Create second app for interact with it
FuriApp* second_app = furiac_start(furi_concurent_app, "furi concurent app", (void*)&mutex);
// 4. multiply ConcurrentValue::a
for(size_t i = 0; i < 4; i++) {
ConcurrentValue* value = (ConcurrentValue*)acquire_mutex_block(&mutex);
if(value == NULL) {
release_mutex(&mutex, value);
mu_fail("cannot take record\r\n");
}
// emulate read-modify-write broken by context switching
uint8_t a = value->a;
uint8_t b = value->b;
a++;
b++;
value->a = a;
furi_hal_delay_ms(10); // this is only for test, do not add delay between take/give in prod!
value->b = b;
release_mutex(&mutex, value);
}
furi_hal_delay_ms(50);
mu_assert_pointers_eq(second_app->handler, NULL);
mu_assert_int_eq(value.a, value.b);
mu_check(delete_mutex(&mutex));
*/
}

View File

@@ -0,0 +1,331 @@
#include <furi.h>
#include "../minunit.h"
#include "infrared.h"
#include "common/infrared_common_i.h"
#include "test_data/infrared_nec_test_data.srcdata"
#include "test_data/infrared_necext_test_data.srcdata"
#include "test_data/infrared_samsung_test_data.srcdata"
#include "test_data/infrared_rc6_test_data.srcdata"
#include "test_data/infrared_rc5_test_data.srcdata"
#include "test_data/infrared_sirc_test_data.srcdata"
#define RUN_ENCODER(data, expected) \
run_encoder((data), COUNT_OF(data), (expected), COUNT_OF(expected))
#define RUN_DECODER(data, expected) \
run_decoder((data), COUNT_OF(data), (expected), COUNT_OF(expected))
#define RUN_ENCODER_DECODER(data) run_encoder_decoder((data), COUNT_OF(data))
static InfraredDecoderHandler* decoder_handler;
static InfraredEncoderHandler* encoder_handler;
static void test_setup(void) {
decoder_handler = infrared_alloc_decoder();
encoder_handler = infrared_alloc_encoder();
}
static void test_teardown(void) {
infrared_free_decoder(decoder_handler);
infrared_free_encoder(encoder_handler);
}
static void compare_message_results(
const InfraredMessage* message_decoded,
const InfraredMessage* message_expected) {
mu_check(message_decoded->protocol == message_expected->protocol);
mu_check(message_decoded->command == message_expected->command);
mu_check(message_decoded->address == message_expected->address);
if((message_expected->protocol == InfraredProtocolSIRC) ||
(message_expected->protocol == InfraredProtocolSIRC15) ||
(message_expected->protocol == InfraredProtocolSIRC20)) {
mu_check(message_decoded->repeat == false);
} else {
mu_check(message_decoded->repeat == message_expected->repeat);
}
}
/* Encodes signal and merges same levels (high+high, low+low) */
static void run_encoder_fill_array(
InfraredEncoderHandler* handler,
uint32_t* timings,
uint32_t* timings_len,
bool* start_level) {
uint32_t duration = 0;
bool level = false;
bool level_read;
InfraredStatus status = InfraredStatusError;
int i = 0;
bool first = true;
while(1) {
status = infrared_encode(handler, &duration, &level_read);
if(first) {
if(start_level) *start_level = level_read;
first = false;
timings[0] = 0;
} else if(level_read != level) {
++i;
furi_check(i < *timings_len);
timings[i] = 0;
}
level = level_read;
timings[i] += duration;
furi_check((status == InfraredStatusOk) || (status == InfraredStatusDone));
if(status == InfraredStatusDone) break;
}
*timings_len = i + 1;
}
// messages in input array for encoder should have one protocol
static void run_encoder(
const InfraredMessage input_messages[],
uint32_t input_messages_len,
const uint32_t expected_timings[],
uint32_t expected_timings_len) {
uint32_t* timings = 0;
uint32_t timings_len = 200;
uint32_t j = 0;
timings = malloc(sizeof(uint32_t) * timings_len);
for(uint32_t message_counter = 0; message_counter < input_messages_len; ++message_counter) {
const InfraredMessage* message = &input_messages[message_counter];
if(!message->repeat) {
infrared_reset_encoder(encoder_handler, message);
}
timings_len = 200;
run_encoder_fill_array(encoder_handler, timings, &timings_len, NULL);
furi_check(timings_len <= 200);
for(int i = 0; i < timings_len; ++i, ++j) {
mu_check(MATCH_TIMING(timings[i], expected_timings[j], 120));
mu_assert(j < expected_timings_len, "encoded more timings than expected");
}
}
free(timings);
mu_assert(j == expected_timings_len, "encoded less timings than expected");
}
static void
run_encoder_decoder(const InfraredMessage input_messages[], uint32_t input_messages_len) {
uint32_t* timings = 0;
uint32_t timings_len = 200;
bool level = false;
timings = malloc(sizeof(uint32_t) * timings_len);
for(uint32_t message_counter = 0; message_counter < input_messages_len; ++message_counter) {
const InfraredMessage* message_encoded = &input_messages[message_counter];
if(!message_encoded->repeat) {
infrared_reset_encoder(encoder_handler, message_encoded);
}
timings_len = 200;
run_encoder_fill_array(encoder_handler, timings, &timings_len, &level);
furi_check(timings_len <= 200);
const InfraredMessage* message_decoded = 0;
for(int i = 0; i < timings_len; ++i) {
message_decoded = infrared_decode(decoder_handler, level, timings[i]);
if((i == timings_len - 2) && level && message_decoded) {
/* In case we end with space timing - message can be decoded at last mark */
break;
} else if(i < timings_len - 1) {
mu_check(!message_decoded);
} else {
if(!message_decoded) {
message_decoded = infrared_check_decoder_ready(decoder_handler);
}
mu_check(message_decoded);
}
level = !level;
}
if(message_decoded) {
compare_message_results(message_decoded, message_encoded);
} else {
mu_check(0);
}
}
free(timings);
}
static void run_decoder(
const uint32_t* input_delays,
uint32_t input_delays_len,
const InfraredMessage* message_expected,
uint32_t message_expected_len) {
InfraredMessage message_decoded_check_local;
bool level = 0;
uint32_t message_counter = 0;
const InfraredMessage* message_decoded = 0;
for(uint32_t i = 0; i < input_delays_len; ++i) {
const InfraredMessage* message_decoded_check = 0;
if(input_delays[i] > INFRARED_RAW_RX_TIMING_DELAY_US) {
message_decoded_check = infrared_check_decoder_ready(decoder_handler);
if(message_decoded_check) {
/* infrared_decode() can reset message, but we have to call infrared_decode() to perform real
* simulation: infrared_check() by timeout, then infrared_decode() when meet edge */
message_decoded_check_local = *message_decoded_check;
message_decoded_check = &message_decoded_check_local;
}
}
message_decoded = infrared_decode(decoder_handler, level, input_delays[i]);
if(message_decoded_check || message_decoded) {
mu_assert(
!(message_decoded_check && message_decoded),
"both messages decoded: check_ready() and infrared_decode()");
if(message_decoded_check) {
message_decoded = message_decoded_check;
}
mu_assert(message_counter < message_expected_len, "decoded more than expected");
compare_message_results(message_decoded, &message_expected[message_counter]);
++message_counter;
}
level = !level;
}
message_decoded = infrared_check_decoder_ready(decoder_handler);
if(message_decoded) {
compare_message_results(message_decoded, &message_expected[message_counter]);
++message_counter;
}
mu_assert(message_counter == message_expected_len, "decoded less than expected");
}
MU_TEST(test_decoder_samsung32) {
RUN_DECODER(test_decoder_samsung32_input1, test_decoder_samsung32_expected1);
}
MU_TEST(test_mix) {
RUN_DECODER(test_decoder_rc5_input2, test_decoder_rc5_expected2);
RUN_DECODER(test_decoder_sirc_input1, test_decoder_sirc_expected1);
RUN_DECODER(test_decoder_necext_input1, test_decoder_necext_expected1);
// can use encoder data for decoding, but can't do opposite
RUN_DECODER(test_encoder_rc6_expected1, test_encoder_rc6_input1);
RUN_DECODER(test_decoder_samsung32_input1, test_decoder_samsung32_expected1);
RUN_DECODER(test_decoder_rc6_input1, test_decoder_rc6_expected1);
RUN_DECODER(test_decoder_samsung32_input1, test_decoder_samsung32_expected1);
RUN_DECODER(test_decoder_rc5_input1, test_decoder_rc5_expected1);
RUN_DECODER(test_decoder_sirc_input2, test_decoder_sirc_expected2);
RUN_DECODER(test_decoder_necext_input1, test_decoder_necext_expected1);
RUN_DECODER(test_decoder_sirc_input4, test_decoder_sirc_expected4);
RUN_DECODER(test_decoder_nec_input2, test_decoder_nec_expected2);
RUN_DECODER(test_decoder_rc6_input1, test_decoder_rc6_expected1);
RUN_DECODER(test_decoder_necext_input1, test_decoder_necext_expected1);
RUN_DECODER(test_decoder_sirc_input5, test_decoder_sirc_expected5);
RUN_DECODER(test_decoder_nec_input3, test_decoder_nec_expected3);
RUN_DECODER(test_decoder_rc5_input5, test_decoder_rc5_expected5);
RUN_DECODER(test_decoder_samsung32_input1, test_decoder_samsung32_expected1);
RUN_DECODER(test_decoder_sirc_input3, test_decoder_sirc_expected3);
}
MU_TEST(test_decoder_nec) {
RUN_DECODER(test_decoder_nec_input1, test_decoder_nec_expected1);
RUN_DECODER(test_decoder_nec_input2, test_decoder_nec_expected2);
RUN_DECODER(test_decoder_nec_input3, test_decoder_nec_expected3);
}
MU_TEST(test_decoder_unexpected_end_in_sequence) {
// test_decoder_nec_input1 and test_decoder_nec_input2 shuts unexpected
RUN_DECODER(test_decoder_nec_input1, test_decoder_nec_expected1);
RUN_DECODER(test_decoder_nec_input1, test_decoder_nec_expected1);
RUN_DECODER(test_decoder_nec_input2, test_decoder_nec_expected2);
RUN_DECODER(test_decoder_nec_input2, test_decoder_nec_expected2);
}
MU_TEST(test_decoder_necext1) {
RUN_DECODER(test_decoder_necext_input1, test_decoder_necext_expected1);
RUN_DECODER(test_decoder_necext_input1, test_decoder_necext_expected1);
}
MU_TEST(test_decoder_long_packets_with_nec_start) {
RUN_DECODER(test_decoder_nec42ext_input1, test_decoder_nec42ext_expected1);
RUN_DECODER(test_decoder_nec42ext_input2, test_decoder_nec42ext_expected2);
}
MU_TEST(test_encoder_sirc) {
RUN_ENCODER(test_encoder_sirc_input1, test_encoder_sirc_expected1);
RUN_ENCODER(test_encoder_sirc_input2, test_encoder_sirc_expected2);
}
MU_TEST(test_decoder_sirc) {
RUN_DECODER(test_decoder_sirc_input3, test_decoder_sirc_expected3);
RUN_DECODER(test_decoder_sirc_input1, test_decoder_sirc_expected1);
RUN_DECODER(test_decoder_sirc_input2, test_decoder_sirc_expected2);
RUN_DECODER(test_decoder_sirc_input4, test_decoder_sirc_expected4);
RUN_DECODER(test_decoder_sirc_input5, test_decoder_sirc_expected5);
RUN_ENCODER_DECODER(test_sirc);
}
MU_TEST(test_decoder_rc5) {
RUN_DECODER(test_decoder_rc5x_input1, test_decoder_rc5x_expected1);
RUN_DECODER(test_decoder_rc5_input1, test_decoder_rc5_expected1);
RUN_DECODER(test_decoder_rc5_input2, test_decoder_rc5_expected2);
RUN_DECODER(test_decoder_rc5_input3, test_decoder_rc5_expected3);
RUN_DECODER(test_decoder_rc5_input4, test_decoder_rc5_expected4);
RUN_DECODER(test_decoder_rc5_input5, test_decoder_rc5_expected5);
RUN_DECODER(test_decoder_rc5_input6, test_decoder_rc5_expected6);
RUN_DECODER(test_decoder_rc5_input_all_repeats, test_decoder_rc5_expected_all_repeats);
}
MU_TEST(test_encoder_rc5x) {
RUN_ENCODER(test_decoder_rc5x_expected1, test_decoder_rc5x_input1);
}
MU_TEST(test_encoder_rc5) {
RUN_ENCODER(test_decoder_rc5_expected_all_repeats, test_decoder_rc5_input_all_repeats);
}
MU_TEST(test_decoder_rc6) {
RUN_DECODER(test_decoder_rc6_input1, test_decoder_rc6_expected1);
}
MU_TEST(test_encoder_rc6) {
RUN_ENCODER(test_encoder_rc6_input1, test_encoder_rc6_expected1);
}
MU_TEST(test_encoder_decoder_all) {
RUN_ENCODER_DECODER(test_nec);
RUN_ENCODER_DECODER(test_necext);
RUN_ENCODER_DECODER(test_nec42);
RUN_ENCODER_DECODER(test_nec42ext);
RUN_ENCODER_DECODER(test_samsung32);
RUN_ENCODER_DECODER(test_rc6);
RUN_ENCODER_DECODER(test_rc5);
RUN_ENCODER_DECODER(test_sirc);
}
MU_TEST_SUITE(test_infrared_decoder_encoder) {
MU_SUITE_CONFIGURE(&test_setup, &test_teardown);
MU_RUN_TEST(test_encoder_sirc);
MU_RUN_TEST(test_decoder_sirc);
MU_RUN_TEST(test_encoder_rc5x);
MU_RUN_TEST(test_encoder_rc5);
MU_RUN_TEST(test_decoder_rc5);
MU_RUN_TEST(test_decoder_rc6);
MU_RUN_TEST(test_encoder_rc6);
MU_RUN_TEST(test_decoder_unexpected_end_in_sequence);
MU_RUN_TEST(test_decoder_long_packets_with_nec_start);
MU_RUN_TEST(test_decoder_nec);
MU_RUN_TEST(test_decoder_samsung32);
MU_RUN_TEST(test_decoder_necext1);
MU_RUN_TEST(test_mix);
MU_RUN_TEST(test_encoder_decoder_all);
}
int run_minunit_test_infrared_decoder_encoder() {
MU_RUN_SUITE(test_infrared_decoder_encoder);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,341 @@
const uint32_t test_decoder_nec_input1[] = {
/* message */
2640671, 9071, 4445, 601, 497, 578, 500, 604, 501, 603, 502, 581, 496, 615, 498, 606, 499, 584, 493, 610, 1630, 576, 1640, 601, 1615, 605, 1638, 581, 1634, 606, 1610, 610, 1633, 577, 1639, 601, 504, 580, 498, 604, 501, 603, 500, 582, 496, 607, 498, 606, 499, 585, 485, 610, 1633, 576, 1640, 596, 1615, 605, 1638, 582, 1634, 605, 1610, 609, 1634, 586, 1630, 600,
/* repeat */
40015, 9077, 2208, 593,
/* message */
1457713, 9076, 4440, 607, 508, 585, 493, 610, 494, 598, 506, 577, 501, 603, 502, 601, 504, 580, 498, 605, 1638, 582, 1634, 606, 1610, 610, 1633, 577, 1639, 600, 1616, 605, 1638, 582, 1634, 606, 499, 585, 493, 609, 495, 608, 496, 586, 502, 612, 493, 601, 504, 579, 498, 605, 1638, 582, 1633, 606, 1610, 610, 1633, 577, 1639, 602, 1614, 574, 1668, 582, 1634, 606,
/* message */
1415838, 9080, 4436, 611, 494, 600, 505, 578, 500, 608, 501, 602, 502, 580, 498, 606, 508, 605, 500, 583, 1633, 608, 1608, 611, 1631, 578, 1638, 602, 1614, 606, 1637, 583, 1633, 607, 1609, 611, 494, 600, 505, 570, 500, 604, 501, 602, 502, 581, 497, 606, 499, 605, 499, 583, 1633, 617, 1608, 611, 1631, 579, 1638, 602};
const InfraredMessage test_decoder_nec_expected1[] = {
{InfraredProtocolNEC, 0x00, 0, false},
{InfraredProtocolNEC, 0x00, 0, true},
{InfraredProtocolNEC, 0x00, 0, false},
};
const uint32_t test_decoder_nec_input2[] = {
18372093,9030,4495,559,524,585,526,613,496,560,522,595,524,605,504,553,530,578,524,608,1614,581,1668,557,1665,581,1641,585,1664,551,1671,605,1616,578,1670,555,528,581,1668,553,526,582,528,612,498,559,524,585,526,604,507,552,1670,597,504,553,1667,608,1613,582,1667,559,1663,613,1608,586,1662,552,
40067,9026,2219,579,
3060767,9079,4445,606,505,554,530,578,532,608,502,555,528,581,530,610,500,588,495,614,1635,580,1641,604,1617,618,1621,584,1637,608,1612,612,1636,589,1637,602,507,581,1641,605,505,582,501,609,502,607,503,585,498,611,499,609,1612,613,498,612,1610,615,1633,561,1661,606,1615,609,1639,585,1636,610,
40011,9072,2200,588,
96480,9075,2198,560,
96509,9047,2226,552,
96517,9049,2224,555,
96514,9042,2222,556,
96512,9053,2220,558,
96511,9045,2227,561,
96507,9048,2225,554,
96515,9061,2231,565,
96522,9053,2219,559,
96510,9044,2229,560,
96508,9046,2226,562,
96506,9027,2245,553,
96511,9030,2243,555,
96513,9031,2237,557,
96512,9054,2219,559,
570349,9027,4495,608,476,583,529,580,529,558,525,584,527,582,528,560,523,596,524,584,1636,578,1669,555,1667,578,1643,581,1666,558,1663,582,1639,586,1662,552,531,577,1670,554,1667,578,532,563,527,582,528,580,529,558,525,584,1665,561,523,586,525,584,1637,577,1670,554,1668,578,1642,582,1667,558,
40062,9021,2233,585,
172411,9020,4502,559,524,585,526,583,527,551,532,586,523,575,535,553,530,579,532,577,1643,581,1668,557,1664,581,1639,585,1664,552,1670,575,1637,579,1669,556,527,581,529,580,1642,584,536,581,528,560,523,585,524,584,526,552,1670,576,1645,579,530,578,1643,582,1667,558,1663,582,1639,586,1662,545,
40068,9026,2220,578,
226896,9054,4468,578,500,608,502,607,503,585,498,611,500,610,501,588,496,612,497,602,1610,615,1633,581,1640,606,1616,609,1639,585,1635,610,1612,614,1635,580,504,615,495,604,506,582,1639,606,503,585,499,610,501,609,502,587,1635,610,1610,614,1634,581,502,616,1632,582,1648,606,1615,610,1638,587,
40033,9050,2195,614,
249594,9020,4502,560,524,594,525,603,506,552,532,587,521,606,504,554,529,579,532,609,1612,582,1667,557,1654,612,1608,585,1663,552,1670,606,1615,579,1669,554,527,582,529,611,500,558,1663,612,497,560,523,585,524,598,505,552,1670,606,1614,580,1668,557,526,582,1665,558,1662,603,1618,587,1661,553,
40067,9058,2187,621,
97567,9054,4467,584,500,609,501,601,502,586,497,611,499,610,501,588,496,614,497,612,1609,615,1632,582,1640,606,1615,609,1639,586,1636,611,1611,614,1634,581,503,608,493,605,505,583,1639,607,503,586,498,611,500,609,501,588,1634,611,1609,615,1634,582,502,608,1641,553,1668,608,1613,581,1668,558,
112307,9078,4443,608,502,606,504,584,498,610,501,608,502,587,497,612,498,610,499,589,1633,603,1619,607,1642,583,1638,607,1614,611,1638,597,1634,611,1610,615,495,603,506,581,502,607,1642,584,500,609,501,607,503,585,498,611,1637,588,1634,611,1610,615,495,603,1618,607,1641,584,1638,607,1605,611,
112281,9076,4445,606,505,584,499,610,501,608,502,586,497,612,498,610,500,581,494,614,1635,581,1641,604,1617,608,1640,585,1637,609,1610,613,1636,589,1632,603,507,581,503,607,504,604,1617,608,502,607,503,585,498,611,500,609,1613,613,1636,590,1632,603,507,581,1641,605,1616,609,1640,585,1636,609,
94207,9075,4446,605,506,582,501,607,502,606,504,584,500,610,501,608,502,587,497,611,1636,588,1633,612,1610,616,1633,583,1639,604,1615,610,1638,587,1635,610,500,588,495,606,496,602,1619,616,495,605,506,583,501,609,502,606,1614,610,1638,587,1635,611,499,590,1632,603,1618,607,1641,583,1638,608,
103762,9076,4446,605,505,553,531,579,532,607,503,555,528,580,530,609,500,557,527,583,1666,559,1662,603,1609,587,1661,553,1669,608,1614,580,1659,557,1665,612,498,580,504,585,526,604,1617,607,503,606,504,584,499,610,500,609,1613,612,1636,588,1633,602,507,573,1641,605,1617,608,1640,585,1636,619,
76134,9056,4466,585,525,604,506,552,532,577,533,606,504,553,529,579,531,608,501,556,1665,611,1611,584,1665,561,1661,605,1616,578,1671,555,1667,609,1612,582,528,611,499,559,525,584,1664,551,533,586,524,605,505,553,530,578,1670,555,1667,610,1612,582,528,611,1610,584,1664,551,1671,606,1616,578,
112997,9073,4447,603,507,560,523,586,524,605,505,552,531,578,533,607,503,555,529,580,1668,548,1665,611,1611,584,1665,551,1671,615,1616,578,1670,555,1667,610,501,556,527,582,528,611,1609,584,518,604,506,551,533,586,524,606,1615,579,1669,555,1666,610,500,558,1664,612,1609,585,1663,551,1670,606,
84870,9053,4470,582,529,611,500,559,525,583,526,602,507,560,523,586,525,574,536,543,1669,608,1614,580,1668,556,1665,620,1610,585,1664,550,1671,605,1616,578,533,608,503,555,529,580,1677,557,526,582,528,612,498,559,525,585,1664,551,1671,605,1615,578,531,608,1614,581,1668,558,1664,611,1609,585,
76184,9025,4496,555,529,579,531,609,502,556,528,582,529,610,500,559,525,583,526,603,1619,586,1663,552,1669,606,1614,580,1668,556,1665,611,1610,584,1664,550,533,586,524,605,504,553,1669,608,503,555,529,580,530,609,501,557,1664,605,1609,585,1664,551,532,586,1661,553,1668,608,1614,581,1666,558,
96145,9073,4449,612,499,559,524,584,526,603,506,552,532,587,523,606,504,584,499,570,1669,556,1666,610,1611,614,1634,580,1641,605,1617,608,1640,584,1636,609,501,587,497,612,498,611,1611,615,496,602,508,580,503,595,535,614,1627,617,1650,594,1646,604,502,586,1635,611,1618,614,1634,581,1641,604,
86183,9080,4442,610,501,607,502,586,498,611,499,610,501,588,496,613,497,611,498,579,1642,604,1617,608,1641,583,1637,608,1613,611,1637,588,1634,611,1608,615,494,604,506,582,501,617,1641,584,499,610,493,608,502,586,497,612,1636,588,1633,602,1619,615,494,604,1617,608,1640,585,1637,608,1613,613,
234570,9078,4437,607,503,606,505,584,500,608,501,614,502,585,497,611,499,610,509,588,1634,612,1609,616,1633,582,1639,606,1616,610,1639,587,1635,610,1611,614,1634,581,503,606,504,604,1617,608,502,607,503,585,498,611,500,609,501,597,1634,611,1610,615,495,603,1618,607,1642,584,1638,607,1614,611,
112281,9076,4446,605,505,583,501,609,493,606,503,585,498,610,500,609,501,587,497,613,1636,579,1643,602,1618,606,1641,583,1639,607,1614,610,1638,554,1665,611,1611,584,526,603,507,551,1671,597,504,583,500,578,532,607,502,555,528,581,1668,556,1664,611,498,559,1663,604,1618,587,1662,553,1668,608,
130332,9076,4446,615,496,605,507,582,502,608,503,605,512,584,499,609,501,608,502,586,1636,610,1611,613,1635,579,1641,604,1617,608,1641,584,1637,608,1613,611,1636,588,495,614,497,613,1609,616,494,604,506,590,500,608,502,607,503,585,1635,609,1613,612,498,610,1610,614,1634,581,1641,604,1617,608,
886079,9020,4501,560,523,585,525,583,527,552,532,587,523,576,534,554,529,580,531,577,1644,582,1667,559,1663,582,1639,586,1663,553,1669,576,1645,581,1668,557,521,582,529,581,530,559,1663,582,527,551,532,587,523,575,535,553,1669,577,1644,581,1667,557,526,584,1665,560,1662,582,1637,588,1661,554,
76188,9053,4469,583,528,560,523,586,524,585,525,552,531,578,533,576,534,554,528,581,1668,557,1665,581,1631,585,1664,551,1670,575,1646,579,1678,555,1666,579,531,558,1664,581,528,559,1662,584,527,552,532,588,523,575,535,553,1668,578,532,556,1666,580,531,567,1663,582,1639,585,1662,552,1670,575,
76165,9054,4468,583,527,581,529,559,524,585,525,583,526,547,531,587,524,576,535,554,1668,577,1644,581,1667,558,1664,582,1640,586,1663,551,1670,576,1645,579,531,578,533,556,527,582,1666,559,525,583,526,582,528,560,523,586,1663,553,1669,576,1645,580,522,578,1642,582,1666,559,1663,582,1639,586,
40034,9049,2224,585,
114557,9051,4471,581,529,558,525,584,527,582,528,561,522,586,524,585,525,552,531,578,1670,555,1667,579,1643,577,1666,559,1662,583,1638,587,1662,563,1678,587,543,565,537,591,539,589,1651,592,537,591,539,569,533,595,535,593,1647,597,1670,563,1678,587,542,565,1675,589,1651,593,1675,569,1671,593,
40045,9047,2225,553,
114589,9029,4492,559,525,585,526,582,528,550,533,586,524,575,535,553,530,578,532,577,1645,581,1668,557,1664,581,1640,585,1664,552,1670,575,1646,579,1669,556,527,582,529,580,531,557,1663,582,528,560,523,586,524,585,525,552,1669,576,1645,580,1668,556,526,582,1667,559,1663,582,1639,593,1662,553,
40067,9026,4495,556,528,581,529,579,531,557,526,575,527,581,528,561,523,585,525,584,1638,588,1661,554,1667,578,1644,582,1667,559,1663,582,1639,586,1663,552,530,578,1671,555,529,581,1668,556,526,582,529,581,529,559,524,584,1664,550,533,587,1662,553,530,578,1669,555,1667,578,1642,582,1668,559,
58109,9049,4473,578,533,576,534,555,529,580,531,578,532,556,527,582,528,580,529,559,1663,583,1639,586,1662,553,1669,580,1644,581,1668,558,1664,581,1640,582,525,584,527,552,531,588,1670,554,529,579,531,578,532,556,527,582,1666,558,1663,582,1639,587,524,584,1636,578,1671,564,1676,588,1652,592,
263241,9028,4503,557,526,582,528,581,529,559,523,594,526,584,527,552,532,588,527,575,1646,579,1670,556,1666,579,1642,583,1665,560,1662,584,1638,578,1671,554,529,580,1669,559,527,582,1667,559,525,584,526,582,528,560,523,586,1662,552,530,578,1671,555,529,580,1668,556,1665,581,1640,584,1664,551,
40069,9025,2221,588
};
const InfraredMessage test_decoder_nec_expected2[] = {
{InfraredProtocolNEC, 0x00, 0x02, false},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, false},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x02, true},
{InfraredProtocolNEC, 0x00, 0x06, false},
{InfraredProtocolNEC, 0x00, 0x06, true},
{InfraredProtocolNEC, 0x00, 0x04, false},
{InfraredProtocolNEC, 0x00, 0x04, true},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, true},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, true},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x09, false},
{InfraredProtocolNEC, 0x00, 0x09, false},
{InfraredProtocolNEC, 0x00, 0x09, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x0A, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, true},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x08, true},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x0A, false},
{InfraredProtocolNEC, 0x00, 0x08, false},
{InfraredProtocolNEC, 0x00, 0x0A, false},
{InfraredProtocolNEC, 0x00, 0x0A, true},
};
const uint32_t test_decoder_nec_input3[] = {
200000, 8862, 4452, 562, 563, 559, 1681, 563, 1646, 567, 586, 556, 569, 563, 583, 559, 571, 561, 1675, 559, 565, 567, 1673, 561, 561, 561, 592, 561, 565, 567, 579, 563, 567, 565, 584, 558, 1652, 561, 592, 561, 561, 561, 1679, 565, 560, 562, 584, 558, 1659, 564, 585, 557, 566, 566, 1675, 559, 1649, 564, 589, 564, 1649, 564, 1668, 566, 565, 567, 1669, 565,
43470, 8896, 4432, 561, 561, 561, 1679, 565, 1648, 565, 581, 561, 568, 564, 586, 567, 558, 564, 1676, 558, 564, 558, 1681, 563, 563, 559, 587, 566, 565, 567, 582, 561, 564, 558, 595, 558, 1650, 563, 590, 563, 563, 559, 1674, 560, 570, 562, 587, 566, 1645, 568, 586, 556, 565, 567, 1672, 562, 1651, 562, 584, 558, 1658, 566, 1671, 563, 561, 561, 1679, 565,
200000, 8881, 4383, 569, 549, 573, 548, 574, 541, 571, 550, 572, 547, 575, 539, 573, 551, 571, 1651, 573, 545, 567, 554, 568, 548, 574, 1652, 572, 547, 575, 1645, 568, 1661, 573, 545, 567, 1657, 567, 554, 568, 547, 575, 1652, 572, 547, 575, 539, 573, 1657, 567, 550, 572, 545, 577, 1651, 573, 1648, 576, 545, 567, 1659, 575, 1645, 568, 555, 567, 1657, 567,
38995, 8883, 4369, 573, 543, 569, 552, 570, 549, 573, 541, 571, 553, 569, 548, 574, 543, 569, 1658, 566, 550, 572, 548, 574, 546, 566, 1653, 571, 553, 569, 1654, 570, 1654, 570, 551, 571, 1651, 573, 547, 575, 545, 567, 1653, 571, 552, 570, 547, 575, 1649, 564, 556, 566, 550, 572, 1655, 569, 1656, 568, 546, 566, 1664, 570, 1653, 571, 547, 565, 1663, 571,
200000, 8987, 4504, 561, 593, 539, 589, 533, 596, 515, 586, 536, 592, 540, 588, 534, 595, 517, 1713, 541, 1664, 570, 1686, 558, 596, 515, 587, 535, 593, 539, 1691, 543, 1689, 565, 588, 513, 1691, 563, 1668, 617, 1613, 641, 1615, 567, 587, 535, 593, 519, 610, 512, 590, 542, 1714, 510, 593, 539, 1691, 563, 591, 510, 1720, 535, 594, 518, 584, 538, 591, 541,
39546, 8990, 4501, 565, 590, 542, 586, 536, 593, 508, 593, 539, 589, 543, 585, 537, 592, 509, 1720, 545, 1660, 615, 1642, 561, 567, 534, 594, 538, 590, 542, 1688, 535, 1696, 558, 595, 517, 1687, 567, 1664, 621, 1635, 619, 1611, 561, 594, 538, 590, 511, 617, 515, 586, 536, 1721, 513, 589, 543, 1687, 568, 587, 514, 1691, 563, 590, 511, 591, 541, 587, 535,
200000, 8986, 4505, 560, 594, 538, 590, 542, 586, 515, 586, 536, 593, 539, 589, 533, 595, 517, 1714, 540, 587, 535, 594, 518, 1713, 542, 586, 515, 587, 535, 1722, 543, 1662, 562, 592, 540, 1664, 570, 585, 537, 591, 541, 1689, 545, 584, 538, 590, 542, 1688, 536, 593, 539, 589, 512, 590, 542, 586, 536, 1720, 514, 588, 544, 585, 537, 591, 541, 587, 514,
40671, 8986, 4505, 560, 594, 538, 590, 542, 586, 515, 587, 535, 593, 539, 589, 533, 595, 516, 1714, 541, 587, 535, 594, 518, 1712, 542, 586, 515, 587, 535, 1722, 543, 1662, 561, 592, 540, 1664, 570, 585, 537, 591, 541, 1689, 545, 584, 538, 590, 542, 1688, 536, 593, 539, 589, 512, 590, 542, 586, 536, 1720, 514, 588, 544, 585, 537, 591, 541, 587, 514,
200000, 8990, 4500, 566, 1692, 562, 1668, 566, 588, 534, 594, 518, 584, 538, 591, 541, 587, 535, 1669, 565, 589, 543, 1688, 536, 592, 540, 1691, 563, 1667, 567, 1664, 621, 1635, 568, 586, 515, 587, 535, 593, 539, 589, 543, 1662, 562, 592, 540, 588, 534, 594, 518, 585, 537, 591, 541, 587, 514, 587, 535, 594, 538, 590, 542, 586, 515, 586, 536, 593, 539,
39544, 8993, 4498, 567, 1690, 564, 1666, 568, 586, 536, 593, 508, 593, 539, 589, 543, 585, 537, 1668, 566, 588, 544, 1687, 537, 591, 541, 1690, 564, 1666, 568, 1663, 561, 1696, 569, 585, 516, 586, 536, 593, 539, 589, 543, 1661, 562, 592, 540, 588, 534, 594, 517, 584, 538, 591, 541, 587, 514, 587, 535, 593, 539, 589, 543, 585, 516, 586, 536, 592, 540,
200000, 8894, 4456, 589, 1676, 589, 571, 582, 574, 589, 571, 582, 1683, 582, 1677, 588, 1682, 583, 574, 589, 568, 585, 1682, 583, 1678, 587, 1680, 585, 574, 589, 565, 588, 575, 588, 1675, 590, 567, 586, 1681, 584, 571, 582, 1685, 590, 568, 585, 569, 584, 1685, 590, 567, 586, 1678, 587, 574, 589, 1672, 582, 578, 585, 1679, 586, 1674, 591, 572, 591, 1672, 582,
39632, 8912, 4464, 560, 1703, 562, 598, 565, 594, 559, 594, 559, 1711, 564, 1698, 567, 1697, 568, 593, 560, 595, 568, 1698, 567, 1698, 567, 1693, 561, 602, 561, 596, 567, 590, 563, 1704, 561, 594, 559, 1707, 568, 591, 562, 1697, 568, 596, 567, 590, 563, 1700, 565, 596, 567, 1693, 561, 599, 564, 1701, 564, 589, 564, 1706, 559, 1704, 561, 597, 566, 1700, 565,
200000, 9018, 4500, 565, 1666, 568, 1689, 565, 588, 513, 1691, 615, 1616, 618, 1639, 564, 1667, 567, 587, 535, 594, 538, 563, 538, 590, 542, 586, 536, 593, 508, 593, 539, 589, 543, 1688, 535, 592, 540, 588, 544, 585, 537, 591, 510, 1694, 560, 1670, 564, 1693, 562, 1669, 565, 1692, 542, 1689, 565, 588, 534, 595, 517, 585, 537, 591, 541, 587, 535, 568, 544, 584, 538, 591, 541, 1663, 560, 1696, 569, 1662, 562, 1695, 539, 1692, 614, 1616, 566, 1691, 563, 1667, 567,
23184, 9012, 4505, 560, 1697, 537, 1693, 561, 593, 508, 1696, 569, 1662, 562, 1695, 560, 1671, 563, 591, 541, 587, 535, 594, 518, 584, 538, 590, 542, 586, 515, 613, 509, 593, 539, 1692, 542, 585, 537, 592, 540, 588, 534, 594, 518, 1687, 567, 1663, 560, 1697, 568, 1662, 562, 1695, 539, 1692, 563, 591, 541, 587, 514, 588, 544, 584, 538, 590, 542, 586, 515, 587, 535, 593, 539, 1666, 568, 1689, 565, 1665, 569, 1688, 536, 1695, 570, 1661, 562, 1694, 561, 1670, 564,
200000, 8835, 4446, 537, 562, 539, 562, 539, 1663, 540, 1667, 536, 1669, 534, 560, 531, 573, 539, 559, 532, 1672, 531, 570, 531, 564, 537, 563, 538, 561, 540, 1660, 533, 1677, 536, 561, 540, 557, 534, 567, 534, 1668, 535, 1672, 531, 1675, 538, 555, 536, 1674, 539, 1665, 538, 1666, 537, 1671, 532, 563, 538, 1669, 534, 566, 535, 558, 533, 1677, 536, 562, 539, 558, 533, 568, 533, 1668, 535, 566, 535, 1670, 533, 1667, 536, 568, 533, 1671, 532, 1672, 531, 1676, 537,
22779, 8870, 4437, 535,
92592, 8861, 4414, 538,
};
const InfraredMessage test_decoder_nec_expected3[] = {
{InfraredProtocolNECext, 0x286, 0xB649, false},
{InfraredProtocolNECext, 0x286, 0xB649, false},
{InfraredProtocolNECext, 0x6880, 0xB649, false},
{InfraredProtocolNECext, 0x6880, 0xB649, false},
{InfraredProtocolNECext, 0x6380, 0x150F, false},
{InfraredProtocolNECext, 0x6380, 0x150F, false},
{InfraredProtocolNECext, 0x6480, 0x849, false},
{InfraredProtocolNECext, 0x6480, 0x849, false},
{InfraredProtocolNECext, 0x7A83, 0x8, false},
{InfraredProtocolNECext, 0x7A83, 0x8, false},
{InfraredProtocolNEC, 0x71, 0x4A, false},
{InfraredProtocolNEC, 0x71, 0x4A, false},
{InfraredProtocolNEC42, 0x7B, 0x0, false},
{InfraredProtocolNEC42, 0x7B, 0x0, false},
{InfraredProtocolNEC42, 0x11C, 0x12, false},
};
const InfraredMessage test_nec[] = {
{InfraredProtocolNEC, 0x00, 0x00, false},
{InfraredProtocolNEC, 0x01, 0x00, false},
{InfraredProtocolNEC, 0x01, 0x80, false},
{InfraredProtocolNEC, 0x00, 0x80, false},
{InfraredProtocolNEC, 0x00, 0x00, false},
{InfraredProtocolNEC, 0x00, 0x00, true},
{InfraredProtocolNEC, 0x00, 0x00, false},
{InfraredProtocolNEC, 0x00, 0x00, true},
{InfraredProtocolNEC, 0xFF, 0xFF, false},
{InfraredProtocolNEC, 0xFE, 0xFF, false},
{InfraredProtocolNEC, 0xFE, 0x7F, false},
{InfraredProtocolNEC, 0xFF, 0x7F, false},
{InfraredProtocolNEC, 0xFF, 0xFF, false},
{InfraredProtocolNEC, 0xFF, 0xFF, true},
{InfraredProtocolNEC, 0xAA, 0x55, false},
{InfraredProtocolNEC, 0x55, 0xAA, false},
{InfraredProtocolNEC, 0x55, 0x55, false},
{InfraredProtocolNEC, 0xAA, 0xAA, false},
{InfraredProtocolNEC, 0xAA, 0xAA, true},
{InfraredProtocolNEC, 0xAA, 0xAA, false},
{InfraredProtocolNEC, 0xAA, 0xAA, true},
{InfraredProtocolNEC, 0xAA, 0xAA, true},
{InfraredProtocolNEC, 0x55, 0x55, false},
{InfraredProtocolNEC, 0x55, 0x55, true},
{InfraredProtocolNEC, 0x55, 0x55, true},
{InfraredProtocolNEC, 0x55, 0x55, true},
};
const InfraredMessage test_nec42[] = {
{InfraredProtocolNEC42, 0x0000, 0x00, false},
{InfraredProtocolNEC42, 0x0001, 0x00, false},
{InfraredProtocolNEC42, 0x0001, 0x80, false},
{InfraredProtocolNEC42, 0x0000, 0x80, false},
{InfraredProtocolNEC42, 0x0000, 0x00, false},
{InfraredProtocolNEC42, 0x0000, 0x00, true},
{InfraredProtocolNEC42, 0x0000, 0x00, false},
{InfraredProtocolNEC42, 0x0000, 0x00, true},
{InfraredProtocolNEC42, 0x1FFF, 0xFF, false},
{InfraredProtocolNEC42, 0x1FFE, 0xFF, false},
{InfraredProtocolNEC42, 0x1FFE, 0x7F, false},
{InfraredProtocolNEC42, 0x1FFF, 0x7F, false},
{InfraredProtocolNEC42, 0x1FFF, 0xFF, false},
{InfraredProtocolNEC42, 0x1FFF, 0xFF, true},
{InfraredProtocolNEC42, 0x0AAA, 0x55, false},
{InfraredProtocolNEC42, 0x1555, 0xAA, false},
{InfraredProtocolNEC42, 0x1555, 0x55, false},
{InfraredProtocolNEC42, 0x0AAA, 0xAA, false},
{InfraredProtocolNEC42, 0x0AAA, 0xAA, true},
{InfraredProtocolNEC42, 0x0AAA, 0xAA, false},
{InfraredProtocolNEC42, 0x0AAA, 0xAA, true},
{InfraredProtocolNEC42, 0x0AAA, 0xAA, true},
{InfraredProtocolNEC42, 0x1555, 0x55, false},
{InfraredProtocolNEC42, 0x1555, 0x55, true},
{InfraredProtocolNEC42, 0x1555, 0x55, true},
{InfraredProtocolNEC42, 0x1555, 0x55, true},
};
const InfraredMessage test_nec42ext[] = {
{InfraredProtocolNEC42ext, 0x0000000, 0x0000, false},
{InfraredProtocolNEC42ext, 0x0000001, 0x0000, false},
{InfraredProtocolNEC42ext, 0x0000001, 0x8000, false},
{InfraredProtocolNEC42ext, 0x0000000, 0x8000, false},
{InfraredProtocolNEC42ext, 0x0000000, 0x0000, false},
{InfraredProtocolNEC42ext, 0x0000000, 0x0000, true},
{InfraredProtocolNEC42ext, 0x0000000, 0x0000, false},
{InfraredProtocolNEC42ext, 0x0000000, 0x0000, true},
{InfraredProtocolNEC42ext, 0x3F000FF, 0xF00F, false},
{InfraredProtocolNEC42ext, 0x3F000FE, 0xF00F, false},
{InfraredProtocolNEC42ext, 0x3F000FE, 0x700F, false},
{InfraredProtocolNEC42ext, 0x3F000FF, 0x700F, false},
{InfraredProtocolNEC42ext, 0x3F000FF, 0xF00F, false},
{InfraredProtocolNEC42ext, 0x3F000FF, 0xF00F, true},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0x5555, false},
{InfraredProtocolNEC42ext, 0x1555555, 0xAAAA, false},
{InfraredProtocolNEC42ext, 0x1555555, 0x5555, false},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0xAAAA, false},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0xAAAA, true},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0xAAAA, false},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0xAAAA, true},
{InfraredProtocolNEC42ext, 0x2AAAAAA, 0xAAAA, true},
{InfraredProtocolNEC42ext, 0x1555555, 0x5555, false},
{InfraredProtocolNEC42ext, 0x1555555, 0x5555, true},
{InfraredProtocolNEC42ext, 0x1555555, 0x5555, true},
{InfraredProtocolNEC42ext, 0x1555555, 0x5555, true},
};
const uint32_t test_decoder_nec42ext_input1[] = {
2000000, 9000, 4500, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 8
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 16
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 24
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 32
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 40
560, 560, 560, 560, 560, // 42
};
const uint32_t test_decoder_nec42ext_input2[] = {
2000000, 9000, 4500, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 8
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 16
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 24
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 32
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 40
560, 560, 560, 560, 560, 560, 560, // 43 - failed
2000000, 9000, 4500, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 8
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 16
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 24
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 32
560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // 40
560, 560, 560, 560, 560, 10000, 560, // 42 OK + 1 failed
};
const InfraredMessage test_decoder_nec42ext_expected1[] = {
{InfraredProtocolNEC42ext, 0x00, 0, false},
};
const InfraredMessage test_decoder_nec42ext_expected2[] = {
{InfraredProtocolNEC42ext, 0x00, 0, false},
};

View File

@@ -0,0 +1,255 @@
const uint32_t test_decoder_necext_input1[] = {
1915384, 8967, 4463, 587, 527, 590, 524, 584, 1647, 590, 524, 583, 531, 586, 527, 590, 524, 583, 1646, 589, 1640, 586, 527, 590, 524, 583, 1647, 590, 1640, 587, 1644, 582, 1647, 589, 524, 583, 531, 586, 1644, 593, 521, 586, 527, 589, 1641, 586, 528, 589, 525, 592, 521, 585, 1644, 592, 522, 585, 1645, 592, 1638, 589, 524, 592, 1637, 588, 1641, 585, 1645, 592,
41082, 8965, 2220, 591,
409594, 8972, 4458, 591, 523, 584, 530, 587, 1642, 584, 529, 588, 526, 591, 522, 583, 530, 587, 1643, 584, 1646, 590, 523, 584, 530, 587, 1643, 584, 1647, 590, 1640, 586, 1643, 583, 531, 586, 527, 589, 1641, 586, 528, 589, 524, 593, 1637, 589, 524, 593, 521, 586, 529, 589, 1641, 585, 528, 589, 1640, 586, 1644, 592, 521, 585, 1645, 592, 1638, 588, 1641, 585,
41088, 8968, 2218, 582,
95791, 8971, 2214, 587,
95787, 8965, 2220, 591,
95783, 8971, 2215, 585,
95787, 8964, 2221, 590,
95783, 8971, 2215, 586,
95788, 8965, 2220, 591,
95783, 8969, 2216, 585,
95789, 8965, 2220, 590,
95782, 8970, 2215, 586,
95788, 9047, 2139, 591,
95782, 8970, 2216, 585,
95788, 8966, 2220, 591,
95782, 8972, 2214, 588,
95786, 8964, 2222, 590,
95784, 8971, 2214, 586,
95787, 8967, 2218, 583,
95791, 8964, 2222, 588,
95785, 8969, 2217, 584,
333740, 8967, 4464, 586, 528, 590, 524, 592, 1637, 589, 525, 592, 521, 586, 528, 589, 525, 593, 1637, 588, 1640, 585, 528, 589, 525, 592, 1638, 589, 1641, 586, 1644, 592, 1638, 588, 525, 592, 522, 585, 1644, 592, 522, 585, 528, 588, 1642, 585, 529, 588, 526, 591, 522, 585, 1645, 591, 522, 584, 1646, 591, 1639, 587, 526, 591, 1639, 588, 1642, 583, 1646, 590,
41082, 8963, 2223, 588,
95785, 8967, 2219, 591,
95782, 8968, 2217, 584,
246369, 8972, 4459, 591, 523, 583, 530, 587, 1643, 583, 530, 587, 527, 590, 523, 584, 530, 586, 1643, 583, 1647, 590, 524, 583, 530, 586, 1643, 583, 1646, 589, 1641, 586, 1644, 583, 531, 586, 528, 589, 1640, 585, 528, 588, 525, 592, 1638, 588, 525, 592, 522, 585, 529, 589, 1641, 584, 529, 588, 1642, 585, 1645, 591, 522, 585, 1645, 590, 1639, 587, 1642, 584,
41090, 8966, 2220, 591,
95782, 8966, 2220, 592,
95782, 8967, 2218, 583,
165604, 9017, 4413, 586, 527, 590, 524, 583, 1647, 589, 523, 582, 531, 586, 528, 589, 525, 593, 1637, 589, 1640, 585, 527, 588, 525, 592, 1638, 589, 1641, 585, 1644, 592, 1638, 588, 525, 591, 523, 585, 1645, 591, 522, 584, 529, 588, 1642, 584, 530, 587, 527, 591, 523, 584, 1646, 591, 523, 584, 1646, 591, 1640, 586, 527, 590, 1640, 586, 1643, 583, 1646, 589,
41084, 8972, 2214, 587,
95787, 8967, 2219, 581,
95792, 8971, 2215, 586,
208929, 9016, 4414, 584, 529, 588, 526, 591, 1638, 588, 525, 591, 522, 584, 529, 587, 526, 591, 1639, 587, 1642, 584, 529, 588, 526, 591, 1638, 587, 1643, 584, 1646, 591, 1639, 587, 526, 590, 523, 584, 1646, 590, 524, 583, 530, 587, 1643, 583, 530, 587, 527, 590, 524, 583, 1647, 590, 524, 583, 1647, 590, 1640, 586, 527, 589, 1640, 586, 1644, 592, 1637, 589,
41085, 8972, 2214, 587,
95787, 8964, 2221, 590,
95784, 8965, 2221, 590,
167378, 8969, 4460, 589, 525, 582, 532, 586, 1644, 592, 521, 586, 528, 589, 524, 592, 522, 585, 1645, 592, 1638, 589, 525, 592, 522, 585, 1644, 591, 1639, 588, 1642, 585, 1645, 591, 522, 585, 529, 587, 1641, 584, 530, 587, 526, 591, 1639, 588, 526, 591, 522, 584, 530, 587, 1643, 584, 530, 587, 1642, 584, 1646, 591, 523, 584, 1647, 590, 1640, 587, 1643, 583,
41090, 9017, 2169, 591,
95781, 8969, 2216, 585,
95788, 8964, 2223, 588,
192781, 8969, 4461, 589, 525, 592, 522, 586, 1644, 592, 521, 586, 528, 589, 525, 592, 522, 585, 1644, 592, 1638, 589, 524, 592, 521, 586, 1645, 591, 1638, 588, 1642, 585, 1645, 590, 522, 584, 530, 587, 1642, 584, 530, 587, 526, 591, 1639, 588, 526, 590, 524, 583, 530, 587, 1643, 584, 530, 587, 1643, 584, 1646, 590, 524, 583, 1646, 590, 1640, 587, 1643, 583,
41090, 8967, 2219, 591,
95782, 8970, 2215, 586,
95788, 8963, 2222, 589,
179978, 8967, 4464, 586, 528, 589, 524, 593, 1637, 588, 525, 592, 522, 585, 529, 589, 525, 592, 1638, 589, 1641, 585, 529, 588, 526, 591, 1638, 588, 1641, 585, 1645, 590, 1639, 587, 527, 590, 523, 584, 1646, 591, 523, 584, 530, 587, 1643, 583, 530, 586, 527, 590, 524, 583, 1646, 590, 523, 584, 1646, 589, 1640, 586, 528, 589, 1640, 586, 1644, 593, 1638, 589,
41084, 8971, 2214, 587,
95787, 8964, 2221, 589,
95785, 8966, 2219, 592,
196616, 8967, 4463, 585, 527, 590, 525, 592, 1637, 589, 525, 592, 521, 586, 528, 589, 524, 592, 1638, 588, 1641, 585, 528, 589, 525, 592, 1637, 589, 1641, 585, 1645, 591, 1638, 588, 526, 591, 522, 585, 1645, 591, 522, 584, 530, 587, 1642, 584, 529, 588, 526, 591, 523, 583, 1645, 590, 523, 584, 1646, 590, 1639, 587, 527, 590, 1639, 586, 1644, 583, 1647, 589,
41084, 8971, 2214, 587,
95787, 8964, 2222, 589,
2112164, 8969, 4462, 588, 525, 592, 522, 585, 1645, 591, 523, 584, 529, 588, 526, 591, 523, 584, 1645, 591, 1639, 587, 527, 590, 524, 583, 1646, 590, 1639, 587, 1643, 584, 1673, 563, 524, 583, 531, 586, 1643, 593, 521, 586, 528, 589, 1641, 585, 528, 589, 525, 592, 521, 585, 1644, 592, 522, 584, 1645, 591, 1639, 588, 526, 591, 1639, 588, 1642, 583, 1646, 590,
41082, 8962, 2223, 588,
95785, 8965, 2220, 591,
95783, 8968, 2217, 583,
164778, 8969, 4462, 588, 525, 591, 522, 585, 1645, 591, 522, 585, 530, 587, 527, 591, 523, 584, 1646, 591, 1639, 588, 526, 591, 523, 583, 1646, 590, 1639, 587, 1643, 584, 1672, 564, 523, 584, 531, 586, 1643, 583, 530, 587, 527, 590, 1639, 587, 527, 589, 524, 583, 531, 586, 1644, 583, 531, 586, 1643, 583, 1647, 590, 525, 582, 1647, 589, 1639, 586, 1644, 593,
41081, 8965, 2220, 590,
95784, 8968, 2217, 583,
95790, 8970, 2215, 586,
161053, 8963, 4468, 592, 521, 586, 528, 589, 1641, 585, 529, 588, 526, 591, 522, 585, 529, 588, 1642, 585, 1645, 591, 523, 584, 530, 587, 1642, 584, 1646, 591, 1639, 586, 1669, 557, 531, 586, 527, 590, 1640, 586, 527, 590, 525, 592, 1638, 589, 525, 592, 522, 585, 528, 588, 1641, 585, 528, 588, 1642, 584, 1645, 591, 523, 584, 1645, 591, 1639, 587, 1643, 583,
41090, 8964, 2221, 590,
95784, 8963, 2222, 589,
95785, 8965, 2220, 590,
139334, 8968, 4463, 587, 527, 590, 523, 584, 1646, 590, 523, 583, 531, 586, 527, 589, 524, 583, 1647, 590, 1640, 586, 527, 590, 525, 592, 1637, 589, 1641, 585, 1644, 592, 1665, 562, 524, 591, 522, 584, 1645, 591, 523, 584, 529, 588, 1642, 584, 529, 587, 527, 590, 523, 584, 1646, 590, 523, 584, 1646, 590, 1639, 587, 527, 589, 1640, 586, 1644, 592, 1637, 589,
41085, 8970, 2217, 584,
95789, 8972, 2213, 586,
95787, 8965, 2221, 590,
141444, 8969, 4461, 589, 525, 592, 522, 584, 1644, 591, 522, 585, 529, 588, 526, 591, 522, 585, 1645, 592, 1638, 587, 526, 591, 523, 584, 1646, 591, 1639, 588, 1642, 583, 1672, 564, 523, 584, 530, 587, 1643, 584, 530, 587, 527, 590, 1640, 587, 527, 590, 524, 584, 530, 587, 1643, 584, 530, 586, 1644, 583, 1647, 589, 524, 583, 1647, 590, 1640, 586, 1645, 592,
41081, 8964, 2222, 589,
95784, 8968, 2218, 583,
95790, 8971, 2214, 586,
154119, 8969, 4462, 588, 526, 591, 522, 585, 1645, 592, 522, 585, 529, 589, 526, 591, 522, 584, 1646, 591, 1639, 588, 526, 591, 523, 583, 1645, 590, 1639, 587, 1642, 584, 1671, 564, 523, 584, 529, 587, 1643, 583, 530, 587, 527, 590, 1639, 587, 526, 590, 523, 583, 530, 586, 1643, 583, 529, 586, 1643, 583, 1646, 590, 524, 583, 1648, 589, 1641, 586, 1644, 592,
41081, 8965, 2220, 590,
95784, 8969, 2216, 585,
95790, 8964, 2221, 590,
147134, 8966, 4464, 586, 528, 589, 525, 593, 1637, 589, 524, 593, 522, 585, 529, 589, 525, 592, 1638, 589, 1641, 586, 528, 589, 525, 591, 1638, 588, 1641, 585, 1645, 592, 1664, 561, 525, 592, 523, 584, 1646, 591, 523, 584, 530, 588, 1642, 585, 526, 587, 527, 590, 523, 584, 1646, 591, 523, 584, 1646, 591, 1639, 586, 526, 590, 1640, 587, 1643, 583, 1646, 590,
41083, 8963, 2223, 587,
95786, 8965, 2221, 590,
95784, 8968, 2217, 584,
158330, 8965, 4465, 585, 529, 588, 526, 590, 1639, 587, 526, 590, 523, 584, 530, 586, 526, 590, 1639, 587, 1643, 583, 530, 587, 527, 590, 1639, 587, 1643, 584, 1647, 590, 1666, 561, 527, 589, 523, 583, 1646, 590, 523, 583, 531, 586, 1643, 583, 530, 586, 527, 590, 524, 582, 1646, 590, 525, 582, 1647, 589, 1640, 586, 528, 589, 1640, 586, 1644, 592, 1638, 589,
41085, 8971, 2214, 586,
95787, 8962, 2223, 588,
95786, 8965, 2222, 589,
206063, 8962, 4467, 591, 521, 585, 529, 588, 1642, 585, 529, 588, 525, 591, 522, 584, 530, 587, 1642, 584, 1646, 591, 523, 584, 529, 588, 1642, 583, 1646, 590, 1640, 587, 1668, 558, 530, 587, 526, 589, 1639, 586, 528, 589, 524, 583, 1647, 589, 524, 593, 521, 585, 528, 589, 1641, 585, 529, 589, 1641, 585, 1645, 592, 522, 585, 1644, 591, 1639, 587, 1642, 584,
41090, 8965, 2221, 590,
95784, 8963, 2223, 588,
95785, 8964, 2222, 589,
183026, 8970, 4460, 590, 524, 583, 531, 586, 1643, 583, 530, 587, 528, 589, 525, 592, 522, 586, 1644, 592, 1637, 588, 525, 591, 522, 585, 1645, 592, 1638, 588, 1641, 585, 1672, 565, 522, 584, 530, 588, 1642, 584, 529, 588, 526, 591, 1639, 587, 527, 590, 523, 584, 530, 587, 1642, 584, 530, 587, 1642, 583, 1647, 590, 524, 583, 1647, 590, 1640, 587, 1643, 582,
41090, 8965, 2221, 590,
95783, 8970, 2216, 584,
95789, 8962, 2223, 587,
184104, 8964, 4467, 583, 530, 587, 527, 590, 1640, 587, 527, 590, 523, 582, 531, 586, 528, 589, 1640, 586, 1644, 593, 521, 586, 528, 589, 1640, 585, 1644, 592, 1638, 589, 1667, 558, 528, 589, 526, 591, 1638, 588, 526, 591, 522, 585, 1645, 591, 522, 585, 530, 587, 527, 591, 1639, 587, 526, 591, 1639, 587, 1642, 584, 530, 587, 1643, 583, 1646, 590, 1639, 587,
41087, 9020, 2166, 584,
95790, 8972, 2213, 587,
95787, 8963, 2222, 589,
169833, 8964, 4465, 583, 529, 587, 527, 590, 1639, 587, 527, 591, 523, 584, 530, 586, 527, 590, 1640, 587, 1643, 583, 531, 587, 527, 590, 1640, 586, 1644, 583, 1647, 590, 1666, 560, 527, 590, 524, 582, 1647, 589, 525, 592, 521, 586, 1644, 592, 521, 586, 528, 589, 526, 592, 1638, 588, 525, 592, 1638, 589, 1641, 585, 528, 589, 1641, 585, 1645, 591, 1638, 588,
41086, 8971, 2215, 585,
95789, 8964, 2222, 588,
95785, 8967, 2218, 583,
185701, 8971, 4460, 590, 523, 584, 530, 587, 1642, 584, 530, 587, 527, 590, 524, 583, 531, 586, 1644, 583, 1647, 590, 524, 592, 521, 585, 1644, 592, 1638, 589, 1641, 585, 1671, 565, 522, 586, 529, 588, 1642, 585, 529, 588, 526, 591, 1638, 588, 525, 590, 523, 584, 530, 587, 1642, 584, 530, 587, 1642, 584, 1646, 590, 524, 583, 1646, 590, 1640, 586, 1643, 583,
41091, 8965, 2222, 589,
95784, 8965, 2221, 589,
95784, 8968, 2217, 583,
146332, 8969, 4461, 669, 445, 591, 522, 584, 1644, 591, 523, 584, 529, 588, 526, 591, 522, 585, 1645, 591, 1638, 587, 527, 590, 524, 584, 1646, 590, 1639, 587, 1642, 583, 1673, 564, 524, 583, 531, 586, 1643, 583, 531, 586, 528, 589, 1641, 585, 528, 589, 525, 592, 522, 585, 1644, 591, 521, 585, 1645, 592, 1638, 588, 525, 592, 1638, 588, 1641, 584, 1646, 591,
41083, 8963, 2222, 589,
95785, 8966, 2220, 592,
261924, 8965, 4465, 585, 529, 588, 525, 592, 1638, 588, 525, 592, 523, 584, 530, 587, 526, 591, 1639, 587, 1642, 583, 529, 587, 527, 590, 1639, 587, 1643, 584, 1646, 590,
};
const InfraredMessage test_decoder_necext_expected1[] = {
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, false},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
{InfraredProtocolNECext, 0x7984, 0xed12, true},
};
const InfraredMessage test_necext[] = {
{InfraredProtocolNECext, 0x0000, 0x0000, false},
{InfraredProtocolNECext, 0x0001, 0x0000, false},
{InfraredProtocolNECext, 0x0001, 0x8000, false},
{InfraredProtocolNECext, 0x0000, 0x8000, false},
{InfraredProtocolNECext, 0x0000, 0x0000, false},
{InfraredProtocolNECext, 0x0000, 0x0000, true},
{InfraredProtocolNECext, 0x0000, 0x0000, false},
{InfraredProtocolNECext, 0x0000, 0x0000, true},
{InfraredProtocolNECext, 0xFFFF, 0xFFFF, false},
{InfraredProtocolNECext, 0xFFFE, 0xFFFF, false},
{InfraredProtocolNECext, 0xFFFE, 0x7FFF, false},
{InfraredProtocolNECext, 0xFFFF, 0x7FFF, false},
{InfraredProtocolNECext, 0xFFFF, 0xFFFF, false},
{InfraredProtocolNECext, 0xFFFF, 0xFFFF, true},
{InfraredProtocolNECext, 0xAAAA, 0x5555, false},
{InfraredProtocolNECext, 0x5555, 0xAAAA, false},
{InfraredProtocolNECext, 0x5555, 0x5555, false},
{InfraredProtocolNECext, 0xAAAA, 0xAAAA, false},
{InfraredProtocolNECext, 0xAAAA, 0xAAAA, true},
{InfraredProtocolNECext, 0xAAAA, 0xAAAA, false},
{InfraredProtocolNECext, 0xAAAA, 0xAAAA, true},
{InfraredProtocolNECext, 0xAAAA, 0xAAAA, true},
{InfraredProtocolNECext, 0x5555, 0x5555, false},
{InfraredProtocolNECext, 0x5555, 0x5555, true},
{InfraredProtocolNECext, 0x5555, 0x5555, true},
{InfraredProtocolNECext, 0x5555, 0x5555, true},
};

View File

@@ -0,0 +1,160 @@
/*
_______----__--____----__--____--__----____----__--__--__--__
| 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5x_input1[] = {
27000 + 888, 1776, 888, 888, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5x_expected1[] = {
{InfraredProtocolRC5X, 0x13, 0x10, false}, // toggle 0
};
/*
_______--__----____----__--____--__----____----__--__--__--__
| 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input1[] = {
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5_expected1[] = {
{InfraredProtocolRC5, 0x13, 0x10, false}, // toggle 0
};
/*
_______--__--__--__----__--____--__----____----__--__--__--__
| 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input2[] = {
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5_expected2[] = {
{InfraredProtocolRC5, 0x13, 0x10, false}, // toggle 1
};
/*
_______--__----____----__--____--__----____----__--__--____--
| 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input3[] = {
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
};
const InfraredMessage test_decoder_rc5_expected3[] = {
{InfraredProtocolRC5, 0x13, 0x11, false}, // toggle 0
};
/*
_______--__--__--__----__--____--__----____----__--__--____--
| 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input4[] = {
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
};
const InfraredMessage test_decoder_rc5_expected4[] = {
{InfraredProtocolRC5, 0x13, 0x11, false}, // toggle 1
};
/*
_______--__----____--__--__--__--__--__--__--__--__--__--__--
| 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input5[] = {
27000 + 888, 888, 888, 1776, 1776, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5_expected5[] = {
{InfraredProtocolRC5, 0x1F, 0x3F, false}, // toggle 0
};
/*
_______--__--__--__--__--__--__--__--__--__--__--__--__--__--
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
s1 s2 t | address | command |
*/
const uint32_t test_decoder_rc5_input6[] = {
27000 + 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5_expected6[] = {
{InfraredProtocolRC5, 0x1F, 0x3F, false}, // toggle 1
};
const uint32_t test_decoder_rc5_input_all_repeats[] = {
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 1776, 888,
27000 + 888, 888, 888, 888, 888, 888, 888, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
27000 + 888, 888, 888, 1776, 1776, 1776, 888, 888, 1776, 888, 888, 1776, 1776, 1776, 888, 888, 888, 888, 888, 888,
27000 + 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888,
27000 + 888, 888, 888, 1776, 1776, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888,
27000 + 888, 888, 888, 1776, 1776, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888,
};
const InfraredMessage test_decoder_rc5_expected_all_repeats[] = {
{InfraredProtocolRC5, 0x13, 0x11, false}, // toggle 0
{InfraredProtocolRC5, 0x13, 0x11, false}, // toggle 1
{InfraredProtocolRC5, 0x13, 0x11, true}, // toggle 1
{InfraredProtocolRC5, 0x13, 0x11, true}, // toggle 1
{InfraredProtocolRC5, 0x13, 0x11, false}, // toggle 0
{InfraredProtocolRC5, 0x13, 0x10, false}, // toggle 1
{InfraredProtocolRC5, 0x13, 0x10, false}, // toggle 0
{InfraredProtocolRC5, 0x13, 0x10, true}, // toggle 0
{InfraredProtocolRC5, 0x1F, 0x3F, false}, // toggle 1
{InfraredProtocolRC5, 0x1F, 0x3F, false}, // toggle 0
{InfraredProtocolRC5, 0x1F, 0x3F, true}, // toggle 0
};
const InfraredMessage test_rc5[] = {
{InfraredProtocolRC5, 0x1F, 0x3F, false},
{InfraredProtocolRC5, 0x00, 0x00, false},
{InfraredProtocolRC5, 0x10, 0x01, false},
{InfraredProtocolRC5, 0x01, 0x20, false},
{InfraredProtocolRC5, 0x01, 0x20, false},
{InfraredProtocolRC5, 0x01, 0x20, true},
{InfraredProtocolRC5, 0x01, 0x20, true},
{InfraredProtocolRC5, 0x01, 0x20, true},
{InfraredProtocolRC5, 0x01, 0x20, true},
{InfraredProtocolRC5, 0x1F, 0x3F, false},
{InfraredProtocolRC5, 0x0A, 0x2A, false},
{InfraredProtocolRC5, 0x15, 0x15, false},
{InfraredProtocolRC5, 0x15, 0x15, true},
{InfraredProtocolRC5X, 0x1F, 0x3F, false},
{InfraredProtocolRC5X, 0x00, 0x00, false},
{InfraredProtocolRC5X, 0x10, 0x01, false},
{InfraredProtocolRC5X, 0x01, 0x20, false},
{InfraredProtocolRC5X, 0x01, 0x20, false},
{InfraredProtocolRC5X, 0x01, 0x20, true},
{InfraredProtocolRC5X, 0x01, 0x20, true},
{InfraredProtocolRC5X, 0x01, 0x20, true},
{InfraredProtocolRC5X, 0x01, 0x20, true},
{InfraredProtocolRC5X, 0x1F, 0x3F, false},
{InfraredProtocolRC5X, 0x0A, 0x2A, false},
{InfraredProtocolRC5X, 0x15, 0x15, false},
{InfraredProtocolRC5X, 0x15, 0x15, true},
};

View File

@@ -0,0 +1,162 @@
/*
_____---------______--____--__--__--____------____--__----____--__----__--__--____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 93 A0 0
s m2 m1 m0 T | address | command |
// 93 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888,
// --__----__--__--
// 0 | 0 | 1 | 1 | 1
//444, 444, 888, 444, 444, 444, 444,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
_____---------______--____--__--__------____--____--__----____--__----__--__--____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 93 A0 1
// 93 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888,
//444, 444, 888, 444, 444, 444, 444,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
_____---------______--____--__--__--____------____--__----____----____--__----____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 94 A0 0
// 94 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 888, 888, 444, 444, 888, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888,
//----____--__----
//0 | 1 | 0 | 0 | 1
//888, 888, 444, 444, 888,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
_____---------______--____--__--__------____--____--__----____----____--__----____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 94 A0 1
// 94 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 888, 888, 444, 444, 888, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888,
//888, 888, 444, 444, 888,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
_____---------______--____--__--__--____------____--__----____----____----__--____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 95 A0 0
// 95 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 888, 888, 888, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888,
//----____----__--
//0 | 1 | 0 | 1 | 1
//888, 888, 888, 444, 444,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
_____---------______--____--__--__------____--____--__----____----____----__--____----____--__--__--__--__--___________
| 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 95 A0 1
// 95 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 888, 888, 888, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
//27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888,
//888, 888, 888, 444, 444,
//888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
*/
const uint32_t test_decoder_rc6_input1[] = {
// 94 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 888, 888, 444, 444, 888, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// 93 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// failed 95
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 888, 888, 888, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 888,
// 93 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// 94 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 888, 888, 444, 444, 888, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// 95 A0 0
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 444 + 444, 888 + 444, 888, 444, 444, 888, 888, 888, 888, 888, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// failed 93 + 1 sample
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, 444,
// failed 93
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 888, 444, 444,
// failed 93
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 888,
// 95 A0 1
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444 + 888, 888, 444, 888, 444, 444, 888, 888, 888, 888, 888, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
};
const InfraredMessage test_decoder_rc6_expected1[] = {
{InfraredProtocolRC6, 0x94, 0xA0, false}, // toggle 0
{InfraredProtocolRC6, 0x93, 0xA0, false}, // toggle 1
// {InfraredProtocolRC6, 0x95, 0xA0, false}, failed
{InfraredProtocolRC6, 0x93, 0xA0, false}, // toggle 0
{InfraredProtocolRC6, 0x94, 0xA0, false}, // toggle 1
{InfraredProtocolRC6, 0x95, 0xA0, false}, // toggle 0
// {InfraredProtocolRC6, 0x93, 0xA0, false}, failed
// {InfraredProtocolRC6, 0x93, 0xA0, false}, failed
// {InfraredProtocolRC6, 0x93, 0xA0, false}, failed
{InfraredProtocolRC6, 0x95, 0xA0, false}, // toggle 1
};
const InfraredMessage test_encoder_rc6_input1[] = {
{InfraredProtocolRC6, 0x93, 0xA0, false}, // Toggle 0
{InfraredProtocolRC6, 0x93, 0xA0, true}, // Toggle 0
{InfraredProtocolRC6, 0x93, 0xA1, false}, // Toggle 1
{InfraredProtocolRC6, 0x93, 0xA1, true}, // Toggle 1
{InfraredProtocolRC6, 0x93, 0xA1, true}, // Toggle 1
{InfraredProtocolRC6, 0x93, 0xA0, false}, // Toggle 0
{InfraredProtocolRC6, 0x93, 0xA0, false}, // Toggle 1
{InfraredProtocolRC6, 0x93, 0xA0, true}, // Toggle 1
};
const uint32_t test_encoder_rc6_expected1[] = {
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 888, 888+444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 888, 888+444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444+888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 888,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444+888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 888,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444+888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 888,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444, 888, 888+444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444+888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
27000, 2666, 889, 444, 888, 444, 444, 444, 444, 444+888, 888, 444, 888, 444, 444, 888, 888, 444, 444, 888, 444, 444, 444, 444, 888, 888, 888, 444, 444, 444, 444, 444, 444, 444, 444, 444,
};
const InfraredMessage test_rc6[] = {
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 0
{InfraredProtocolRC6, 0x80, 0x00, false}, // t 1
{InfraredProtocolRC6, 0x80, 0x01, false}, // t 0
{InfraredProtocolRC6, 0x00, 0x01, false}, // t 1
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 0
{InfraredProtocolRC6, 0x00, 0x00, true}, // t 0
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 1
{InfraredProtocolRC6, 0x00, 0x00, true}, // t 1
{InfraredProtocolRC6, 0xFF, 0xFF, false}, // t 0
{InfraredProtocolRC6, 0x7F, 0xFF, false}, // t 1
{InfraredProtocolRC6, 0x7F, 0xFE, false}, // t 0
{InfraredProtocolRC6, 0xFF, 0xFE, false}, // t 1
{InfraredProtocolRC6, 0xFF, 0xFF, false}, // t 0
{InfraredProtocolRC6, 0xFF, 0xFF, true}, // t 0
{InfraredProtocolRC6, 0xAA, 0x55, false}, // t 1
{InfraredProtocolRC6, 0x55, 0xAA, false}, // t 0
{InfraredProtocolRC6, 0x55, 0x55, false}, // t 1
{InfraredProtocolRC6, 0xAA, 0xAA, false}, // t 0
{InfraredProtocolRC6, 0xAA, 0xAA, true}, // t 0
// same with inverted toggle bit
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 1
{InfraredProtocolRC6, 0x80, 0x00, false}, // t 0
{InfraredProtocolRC6, 0x80, 0x01, false}, // t 1
{InfraredProtocolRC6, 0x00, 0x01, false}, // t 0
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 1
{InfraredProtocolRC6, 0x00, 0x00, true}, // t 1
{InfraredProtocolRC6, 0x00, 0x00, false}, // t 0
{InfraredProtocolRC6, 0x00, 0x00, true}, // t 0
{InfraredProtocolRC6, 0xFF, 0xFF, false}, // t 1
{InfraredProtocolRC6, 0x7F, 0xFF, false}, // t 0
{InfraredProtocolRC6, 0x7F, 0xFE, false}, // t 1
{InfraredProtocolRC6, 0xFF, 0xFE, false}, // t 0
{InfraredProtocolRC6, 0xFF, 0xFF, false}, // t 1
{InfraredProtocolRC6, 0xFF, 0xFF, true}, // t 1
{InfraredProtocolRC6, 0xAA, 0x55, false}, // t 0
{InfraredProtocolRC6, 0x55, 0xAA, false}, // t 1
{InfraredProtocolRC6, 0x55, 0x55, false}, // t 0
{InfraredProtocolRC6, 0xAA, 0xAA, false}, // t 1
{InfraredProtocolRC6, 0xAA, 0xAA, true}, // t 1
{InfraredProtocolRC6, 0x93, 0xA0, false}, // t 0
{InfraredProtocolRC6, 0x93, 0xA1, false}, // t 1
};

View File

@@ -0,0 +1,254 @@
const uint32_t test_decoder_samsung32_input1[] = {
3129767, 4513, 4483, 565, 530, 586, 1670, 563, 1664, 588, 1666, 566, 530, 586,
535, 560, 535, 591, 531, 565, 531, 585, 1669, 563, 1666, 587, 1640, 593,
531, 566, 530, 587, 536, 559, 562, 564, 531, 585, 537, 558, 1670, 562,
1665, 587, 534, 561, 534, 592, 530, 566, 529, 587, 1668, 564, 1664, 589,
533, 563, 533, 594, 1661, 560, 1667, 565, 1661, 591, 1664, 558, 46325, 4517,
4480, 558, 1668, 595,
679127, 4511, 4485, 562, 532, 584, 1671, 561, 1666, 587, 1668, 564, 532, 585,
537, 559, 537, 589, 533, 562, 533, 593, 1661, 561, 1667, 586, 1642, 590,
532, 563, 531, 585, 537, 559, 564, 563, 1666, 567, 528, 588, 535, 613,
483, 593, 530, 586, 536, 559, 536, 590, 1637, 584, 537, 558, 1669, 594,
1661, 561, 1667, 586, 1642, 591, 1664, 559, 1670, 583, 534, 567, 46429, 4515,
4480, 558, 1671, 593,
618571, 4508, 4488, 560, 561, 566, 1663, 559, 1667, 583, 1670, 562, 534, 582,
540, 565, 531, 587, 536, 560, 536, 590, 1664, 558, 1670, 583, 1644, 588,
535, 561, 534, 592, 530, 566, 557, 610, 1616, 616, 479, 585, 537, 558,
537, 589, 534, 584, 539, 567, 529, 587, 534, 561, 534, 592, 1663, 559,
1668, 564, 1664, 588, 1666, 566, 1661, 581, 1646, 585, 1669, 563, 46106, 4511,
4485, 563, 1664, 589,
514897, 4514, 4482, 556, 564, 614, 1616, 565, 1664, 589, 1666, 557, 538, 588,
534, 562, 534, 592, 529, 566, 529, 587, 1667, 565, 1663, 590, 1638, 584,
538, 568, 527, 590, 534, 562, 562, 566, 530, 587, 1642, 590, 532, 563,
530, 586, 537, 589, 533, 563, 533, 583, 539, 566, 1661, 561, 561, 566,
1663, 559, 1668, 584, 1671, 563, 1666, 556, 1671, 591, 1663, 559, 46210, 4508,
4488, 560, 1668, 585,
683922, 4509, 4487, 561, 560, 565, 1662, 559, 1669, 585, 1670, 562, 534, 583,
540, 566, 529, 586, 535, 560, 535, 591, 1663, 559, 1669, 584, 1644, 588,
534, 561, 533, 593, 529, 556, 567, 561, 1668, 564, 1664, 590, 534, 563,
532, 584, 538, 557, 537, 589, 534, 562, 534, 593, 530, 566, 555, 561,
1667, 564, 1662, 589, 1665, 557, 1671, 581, 1647, 586, 1669, 564, 46686, 4514,
4481, 556, 1672, 592,
1088255, 4514, 4481, 557, 564, 562, 1667, 565, 1663, 591, 1665, 558, 538, 590,
533, 564, 532, 583, 539, 567, 528, 588, 1666, 566, 1663, 580, 1648, 585,
537, 559, 537, 589, 533, 562, 560, 618, 478, 589, 535, 562, 1667, 565,
1662, 588, 531, 565, 531, 585, 537, 558, 536, 590, 1666, 566, 1661, 592,
530, 566, 530, 586, 1669, 564, 1664, 558, 1669, 594, 1662, 560, 46291, 4510,
4485, 563, 1663, 589, 97349, 4510, 4487, 561, 1666, 586, 97560, 4513, 4482, 566,
1662, 591, 97123, 4510, 4485, 563, 1664, 588, 97605, 4508, 4487, 561, 1666, 586,
97371, 4518, 4478, 560, 1668, 595, 97514, 4518, 4478, 560, 1667, 586, 97014, 4515,
4480, 568, 1660, 593, 96719, 4516, 4481, 567, 1660, 593, 97528, 4515, 4480, 568,
1659, 593, 97453, 4510, 4485, 563, 1665, 587, 97351, 4518, 4477, 561, 1668, 585,
97216, 4511, 4484, 564, 1664, 589, 97708, 4518, 4477, 561, 1667, 586, 96718, 4516,
4479, 559, 1669, 594, 97070, 4515, 4480, 568, 1660, 593, 97500, 4511, 4484, 564,
1662, 590, 97425, 4515, 4481, 567, 1660, 593, 97025, 4515, 4482, 566, 1660, 592,
96796, 4509, 4487, 561, 1666, 587, 97399, 4512, 4484, 565, 1662, 591, 97486, 4516,
4480, 567, 1658, 594, 97425, 4515, 4481, 567, 1659, 593, 97511, 4510, 4485, 563,
1664, 650, 96969, 4511, 4485, 562, 1665, 588, 97243, 4512, 4484, 564, 1663, 590,
97031, 4519, 4478, 560, 1666, 586, 97548, 4514, 4482, 566, 1661, 591, 97302, 4515,
4480, 568, 1659, 593, 97726, 4510, 4486, 562, 1665, 588, 97396, 4514, 4482, 566,
1661, 592, 97301, 4515, 4480, 568, 1661, 593, 97453, 4518, 4477, 560, 1667, 585,
97430, 4518, 4477, 561, 1665, 587, 97521, 4511, 4484, 564, 1664, 589, 97182, 4512,
4484, 564, 1663, 590, 97760, 4516, 4479, 559, 1668, 595, 97268, 4516, 4479, 559,
1668, 595, 97243, 4512, 4485, 563, 1663, 589, 97695, 4510, 4486, 562, 1664, 588,
374205, 4513, 4483, 565, 530, 586, 1669, 564, 1665, 589, 1667, 567, 529, 587,
535, 560, 535, 591, 531, 565, 530, 585, 1669, 563, 1664, 588, 1639, 593,
529, 566, 529, 587, 536, 560, 563, 565, 532, 585, 537, 560, 1669, 563,
1664, 587, 534, 561, 534, 592, 529, 566, 529, 586, 1668, 564, 1663, 589,
532, 563, 534, 593, 1661, 562, 1666, 566, 1662, 591, 1664, 558,
149343, 4512, 4483, 565, 530, 586, 1669, 563, 1664, 588, 1667, 565, 530, 586,
536, 560, 536, 590, 532, 563, 531, 586, 1670, 563, 1666, 567, 1660, 592,
530, 565, 529, 586, 537, 558, 563, 563, 532, 584, 538, 568, 1661, 561,
1665, 587, 535, 560, 535, 592, 532, 565, 531, 587, 1669, 563, 1665, 587,
534, 561, 534, 592, 1663, 559, 1668, 564, 1662, 590, 1666, 566,
116399, 4514, 4482, 566, 531, 587, 1669, 564, 1664, 589, 1666, 566, 529, 587,
535, 561, 535, 592, 531, 565, 529, 587, 1668, 564, 1664, 558, 1670, 595,
529, 566, 528, 589, 535, 560, 562, 565, 531, 585, 536, 559, 1668, 564,
1664, 589, 534, 561, 533, 593, 530, 565, 528, 588, 1668, 564, 1665, 590,
533, 564, 532, 594, 1661, 561, 1666, 566, 1661, 592, 1663, 558,
121946, 4517, 4478, 559, 537, 590, 1664, 568, 1660, 593, 1661, 560, 536, 590,
531, 564, 531, 585, 537, 559, 536, 590, 1665, 568, 1661, 561, 1666, 587,
537, 559, 529, 591, 531, 564, 558, 558, 537, 588, 533, 562, 1665, 567,
1659, 593, 530, 565, 529, 587, 536, 561, 535, 592, 1664, 559, 1671, 593,
530, 566, 528, 587, 1667, 565, 1662, 558, 1668, 595, 1660, 561, 46509, 4516,
4479, 558, 1668, 594,
88785, 4512, 4484, 564, 530, 585, 1669, 563, 1664, 588, 1666, 566, 530, 587,
536, 560, 535, 592, 532, 565, 531, 585, 1669, 563, 1665, 557, 1669, 594,
530, 566, 530, 586, 535, 560, 562, 564, 530, 585, 537, 558, 1669, 563,
1664, 589, 535, 561, 534, 593, 529, 566, 529, 586, 1668, 564, 1664, 589,
533, 562, 532, 594, 1661, 561, 1666, 565, 1662, 591, 1665, 558,
289651, 4512, 4483, 564, 531, 586, 1669, 563, 1665, 588, 1667, 565, 529, 587,
536, 560, 536, 590, 531, 563, 531, 584, 1670, 562, 1666, 556, 1671, 592,
529, 566, 531, 586, 536, 561, 562, 564, 532, 585, 537, 558, 1669, 563,
1665, 588, 535, 561, 536, 590, 530, 565, 531, 585, 1669, 563, 1664, 587,
534, 561, 533, 593, 1662, 561, 1669, 564, 1663, 590, 1665, 567, 46302, 4509,
4487, 561, 1667, 585,
97097, 4513, 4483, 565, 529, 587, 1668, 564, 1663, 589, 1666, 567, 529, 587,
536, 560, 535, 591, 530, 565, 529, 587, 1669, 563, 1664, 558, 1669, 594,
529, 566, 527, 587, 535, 561, 561, 563, 530, 586, 537, 560, 1669, 563,
1663, 589, 534, 561, 532, 594, 529, 566, 528, 587, 1668, 564, 1663, 589,
532, 563, 532, 594, 1660, 561, 1667, 566, 1661, 592, 1663, 558, 46311, 4510,
4485, 562, 1665, 589,
99001, 4514, 4481, 566, 528, 587, 1667, 565, 1662, 589, 1664, 568, 528, 588,
535, 561, 535, 593, 529, 567, 528, 589, 1668, 564, 1663, 559, 1668, 595,
528, 567, 527, 589, 534, 562, 561, 565, 530, 586, 536, 560, 1668, 564,
1663, 590, 533, 563, 532, 595, 524, 567, 527, 588, 1667, 565, 1662, 590,
532, 563, 531, 595, 1659, 562, 1666, 566, 1661, 593, 1664, 559,
300259, 4514, 4482, 556, 565, 561, 1668, 564, 1663, 589, 1664, 556, 539, 588,
535, 561, 535, 643, 478, 568, 530, 587, 1668, 564, 1664, 589, 1636, 594,
529, 567, 528, 588, 534, 561, 561, 565, 1662, 560, 536, 590, 532, 564,
531, 586, 537, 589, 532, 564, 533, 584, 538, 568, 528, 588, 1667, 565,
1662, 560, 1669, 584, 1670, 562, 1666, 587, 1641, 591, 1664, 559, 46271, 4561,
4435, 562, 1666, 586,
81421, 4514, 4482, 556, 565, 561, 1667, 565, 1662, 589, 1664, 558, 538, 588,
534, 562, 534, 593, 530, 567, 530, 587, 1669, 564, 1663, 589, 1637, 594,
529, 567, 528, 588, 534, 561, 560, 566, 1663, 559, 535, 591, 531, 565,
530, 587, 538, 589, 533, 563, 533, 583, 539, 567, 529, 587, 1667, 565,
1662, 560, 1669, 584, 1669, 563, 1666, 587, 1640, 592, 1663, 560, 46296, 4516,
4480, 558, 1669, 594,
80690, 4508, 4489, 560, 561, 565, 1663, 558, 1670, 593, 1660, 561, 534, 592,
530, 565, 530, 586, 537, 560, 536, 591, 1664, 558, 1670, 583, 1644, 587,
535, 560, 534, 592, 530, 566, 556, 559, 1669, 563, 532, 584, 538, 558,
537, 588, 534, 582, 540, 567, 530, 588, 535, 562, 535, 591, 1663, 559,
1669, 564, 1665, 588, 1666, 566, 1662, 560, 1668, 585, 1669, 563,
136483, 4511, 4485, 563, 531, 585, 1671, 561, 1666, 587, 1668, 564, 531, 585,
536, 559, 537, 589, 532, 563, 532, 584, 1670, 562, 1666, 587, 1642, 591,
531, 566, 531, 585, 536, 559, 563, 563, 1665, 567, 528, 588, 535, 561,
534, 593, 529, 567, 556, 560, 535, 591, 530, 565, 531, 585, 1670, 563,
1665, 568, 1660, 593, 1662, 560, 1668, 564, 1663, 590, 1666, 566,
129038, 4511, 4484, 564, 533, 583, 1670, 562, 1666, 587, 1668, 565, 532, 586,
537, 559, 536, 591, 532, 564, 532, 594, 1660, 562, 1666, 566, 1660, 593,
531, 565, 530, 586, 537, 558, 563, 563, 1664, 568, 528, 589, 535, 562,
533, 595, 530, 567, 556, 560, 535, 591, 531, 565, 531, 584, 1669, 563,
1664, 567, 1661, 592, 1662, 559, 1668, 564, 1663, 590, 1666, 566, 46187, 4511,
4486, 562, 1665, 589,
110663, 4517, 4478, 558, 536, 590, 1665, 568, 1660, 593, 1661, 560, 536, 590,
531, 564, 531, 584, 537, 558, 536, 590, 1665, 567, 1661, 561, 1666, 587,
536, 560, 535, 591, 532, 564, 559, 557, 1670, 562, 532, 594, 529, 567,
528, 649, 473, 561, 561, 565, 531, 585, 536, 559, 536, 589, 1665, 567,
1660, 562, 1666, 587, 1668, 564, 1663, 558, 1669, 594, 1661, 561,
143736, 4517, 4479, 559, 536, 591, 1664, 558, 1670, 593, 1661, 559, 536, 590,
531, 564, 531, 585, 536, 559, 537, 589, 1665, 567, 1661, 561, 1666, 587,
536, 560, 536, 590, 530, 564, 557, 558, 1669, 562, 533, 593, 528, 568,
530, 586, 534, 561, 560, 566, 530, 586, 536, 560, 536, 591, 1664, 558,
1671, 562, 1666, 587, 1667, 565, 1663, 559, 1668, 594, 1660, 562, 46234, 4514,
4482, 566, 1661, 591,
120661, 4564, 4432, 565, 530, 586, 1669, 563, 1665, 587, 1666, 566, 531, 585,
536, 559, 536, 591, 532, 564, 532, 586, 1670, 563, 1666, 557, 1666, 592,
530, 565, 530, 586, 536, 560, 562, 563, 1664, 558, 538, 588, 533, 562,
533, 593, 528, 558, 565, 561, 534, 582, 541, 566, 530, 586, 1670, 563,
1664, 567, 1660, 593, 1662, 560, 1668, 564, 1663, 590, 1665, 567, 46472, 4513,
4484, 564, 1664, 588,
125301, 4511, 4484, 564, 532, 584, 1670, 562, 1666, 587, 1668, 565, 531, 586,
537, 560, 537, 591, 532, 565, 533, 584, 1671, 562, 1666, 566, 1661, 591,
530, 565, 532, 584, 536, 559, 562, 564, 1665, 567, 529, 587, 534, 563,
535, 593, 529, 568, 556, 561, 535, 592, 531, 565, 531, 585, 1669, 563,
1665, 567, 1660, 593, 1663, 559, 1668, 564, 1664, 589, 1666, 567,
200253, 4517, 4479, 558, 562, 615, 1613, 558, 1670, 592, 1661, 560, 536, 591,
531, 616, 480, 585, 537, 559, 537, 641, 1613, 568, 1661, 582, 1646, 586,
536, 559, 535, 591, 532, 564, 558, 558, 1670, 562, 533, 592, 530, 566,
529, 588, 536, 581, 542, 617, 479, 587, 537, 560, 536, 590, 1665, 557,
1670, 562, 1666, 587, 1668, 564, 1664, 558, 1669, 593, 1662, 561, 46230, 4570,
4426, 561, 1667, 586,
115418, 4514, 4483, 565, 557, 561, 1669, 563, 1664, 589, 1666, 566, 529, 587,
534, 561, 534, 592, 530, 566, 530, 586, 1668, 564, 1664, 589, 1639, 594,
529, 567, 528, 587, 534, 561, 561, 565, 1663, 559, 535, 590, 532, 563,
532, 584,
};
const InfraredMessage test_decoder_samsung32_expected1[] = {
{InfraredProtocolSamsung32, 0x0E, 0x0C, false}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x81, false}, {InfraredProtocolSamsung32, 0x0E, 0x81, true},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, true},
{InfraredProtocolSamsung32, 0x0E, 0x02, false}, {InfraredProtocolSamsung32, 0x0E, 0x02, true},
{InfraredProtocolSamsung32, 0x0E, 0x03, false}, {InfraredProtocolSamsung32, 0x0E, 0x03, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, false}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, false},
{InfraredProtocolSamsung32, 0x0E, 0x0C, false}, {InfraredProtocolSamsung32, 0x0E, 0x0C, false},
{InfraredProtocolSamsung32, 0x0E, 0x0C, false}, {InfraredProtocolSamsung32, 0x0E, 0x0C, true},
{InfraredProtocolSamsung32, 0x0E, 0x0C, false}, {InfraredProtocolSamsung32, 0x0E, 0x0C, false},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, false},
{InfraredProtocolSamsung32, 0x0E, 0x0C, true}, {InfraredProtocolSamsung32, 0x0E, 0x0C, false},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, true},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, true},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, false},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, true},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, false},
{InfraredProtocolSamsung32, 0x0E, 0x01, true}, {InfraredProtocolSamsung32, 0x0E, 0x01, false},
{InfraredProtocolSamsung32, 0x0E, 0x01, true}, {InfraredProtocolSamsung32, 0x0E, 0x01, false},
{InfraredProtocolSamsung32, 0x0E, 0x01, false}, {InfraredProtocolSamsung32, 0x0E, 0x01, true},
};
const InfraredMessage test_samsung32[] = {
{InfraredProtocolSamsung32, 0x00, 0x00, false},
{InfraredProtocolSamsung32, 0x01, 0x00, false},
{InfraredProtocolSamsung32, 0x01, 0x80, false},
{InfraredProtocolSamsung32, 0x00, 0x80, false},
{InfraredProtocolSamsung32, 0x00, 0x00, false},
{InfraredProtocolSamsung32, 0x00, 0x00, true},
{InfraredProtocolSamsung32, 0x00, 0x00, false},
{InfraredProtocolSamsung32, 0x00, 0x00, true},
{InfraredProtocolSamsung32, 0xFF, 0xFF, false},
{InfraredProtocolSamsung32, 0xFE, 0xFF, false},
{InfraredProtocolSamsung32, 0xFE, 0x7F, false},
{InfraredProtocolSamsung32, 0xFF, 0x7F, false},
{InfraredProtocolSamsung32, 0xFF, 0xFF, false},
{InfraredProtocolSamsung32, 0xFF, 0xFF, true},
{InfraredProtocolSamsung32, 0xAA, 0x55, false},
{InfraredProtocolSamsung32, 0x55, 0xAA, false},
{InfraredProtocolSamsung32, 0x55, 0x55, false},
{InfraredProtocolSamsung32, 0xAA, 0xAA, false},
{InfraredProtocolSamsung32, 0xAA, 0xAA, true},
{InfraredProtocolSamsung32, 0xAA, 0xAA, false},
{InfraredProtocolSamsung32, 0xAA, 0xAA, true},
{InfraredProtocolSamsung32, 0xAA, 0xAA, true},
{InfraredProtocolSamsung32, 0x55, 0x55, false},
{InfraredProtocolSamsung32, 0x55, 0x55, true},
{InfraredProtocolSamsung32, 0x55, 0x55, true},
{InfraredProtocolSamsung32, 0x55, 0x55, true},
};

View File

@@ -0,0 +1,479 @@
const uint32_t test_decoder_sirc_input1[] = { /* 121 timings */
1000000, 2420, 608, 1194, 608, 596, 604, 1198, 603, 591, 610, 1192, 609, 596, 605, 599, 601, 593, 607, 597, 604, 590, 610, 594, 606, 1196,
25957, 2426, 603, 1199, 603, 591, 610, 1192, 610, 594, 606, 1196, 606, 599, 603, 591, 609, 595, 606, 598, 602, 592, 609, 596, 605, 1197,
25960, 2423, 606, 1196, 606, 599, 602, 1200, 602, 592, 609, 1193, 609, 596, 606, 599, 602, 592, 609, 595, 605, 600, 601, 593, 608, 1194,
1000000, 2422, 607, 1195, 607, 598, 603, 1199, 604, 590, 610, 1192, 610, 594, 606, 598, 603, 591, 609, 595, 605, 600, 601, 593, 607, 1195,
25955, 2418, 610, 1192, 610, 594, 606, 1196, 606, 599, 602, 1200, 602, 592, 608, 596, 604, 590, 611, 594, 607, 597, 603, 591, 609, 1193,
25959, 2424, 604, 1198, 604, 590, 610, 1192, 610, 594, 606, 1196, 605, 600, 601, 593, 608, 597, 603, 591, 610, 595, 606, 598, 602, 1200,
1000000, 2424, 605, 599, 601, 593, 607, 597, 603, 591, 610, 594, 606, 1196, 606, 1196, 605, 600, 601, 593, 608, 597, 604, 590, 611, 1191,
26586, 2425, 604, 590, 611, 593, 607, 598, 603, 591, 610, 595, 606, 1196, 606, 1196, 606, 599, 602, 592, 608, 596, 604, 590, 611, 1191,
26586, 2424, 604, 590, 611, 593, 607, 598, 603, 591, 609, 595, 605, 1197, 605, 1197, 604, 590, 611, 593, 607, 597, 603, 591, 610, 1192,
1000000, 2424, 604, 1198, 604, 590, 611, 1191, 610, 594, 606, 598, 603, 1199, 602, 1200, 602, 592, 609, 595, 605, 600, 601, 593, 608, 1194,
25386, 2419, 610, 1192, 610, 594, 606, 1196, 607, 597, 603, 591, 610, 1192, 609, 1193, 610, 594, 606, 598, 602, 592, 609, 595, 605, 1197,
25385, 2421, 608, 1194, 608, 596, 605, 1197, 605, 599, 601, 593, 608, 1194, 608, 1194, 608, 596, 605, 589, 611, 594, 607, 597, 604, 1198,
1000000, 2426, 603, 1199, 602, 1200, 602, 1200, 602, 592, 608, 1194, 608, 596, 604, 590, 611, 594, 607, 597, 603, 591, 610, 594, 606, 1196, 605, 600, 601, 593, 608, 596, 604, 590, 610, 594, 607, 1195, 606, 598, 603, 591,
15078, 2419, 610, 1192, 610, 1192, 610, 1192, 610, 594, 606, 1196, 605, 600, 601, 593, 608, 597, 604, 590, 610, 595, 606, 598, 602, 1200, 602, 592, 608, 597, 604, 590, 611, 594, 607, 597, 603, 1199, 603, 591, 609, 595,
15075, 2422, 607, 1195, 607, 1195, 607, 1195, 607, 597, 604, 1198, 603, 591, 610, 594, 606, 598, 603, 591, 609, 595, 605, 600, 601, 1191, 611, 594, 607, 597, 603, 591, 610, 594, 606, 598, 602, 1200, 602, 592, 608, 596,
1000000, 2422, 607, 1195, 606, 599, 602, 592, 608, 596, 604, 590, 610, 1192, 610, 594, 606, 599, 602, 592, 608, 596, 604, 590, 610, 1192,
26585, 2426, 602, 1200, 602, 592, 608, 596, 604, 590, 611, 594, 607, 1195, 607, 598, 603, 591, 610, 594, 606, 598, 603, 591, 609, 1193,
26586, 2425, 604, 1198, 603, 591, 610, 594, 606, 598, 602, 592, 609, 1193, 608, 597, 605, 600, 601, 593, 607, 597, 604, 590, 610, 1192,
1000000, 2418, 610, 594, 606, 598, 603, 1199, 603, 1199, 603, 1199, 603, 1199, 603, 1199, 603, 591, 610, 1192, 610, 594, 606, 1196, 606, 1196, 606, 1196, 606, 598, 602, 592, 609, 1193, 609, 1193, 609, 1193, 609, 595, 605, 599,
11557, 2418, 611, 594, 607, 598, 603, 1199, 603, 1199, 603, 1199, 602, 1200, 602, 1200, 601, 593, 608, 1194, 607, 597, 604, 1198, 603, 1199, 603, 1199, 602, 592, 608, 596, 604, 1198, 603, 1199, 603, 1199, 603, 591, 609, 595,
11561, 2424, 604, 590, 610, 594, 607, 1195, 606, 1196, 606, 1196, 606, 1196, 606, 1196, 605, 600, 601, 1191, 611, 594, 607, 1195, 607, 1195, 607, 1195, 607, 597, 603, 591, 610, 1192, 610, 1192, 610, 1192, 610, 594, 606, 598,
1000000, 2424, 604, 590, 611, 594, 607, 1195, 607, 1195, 607, 1195, 607, 1195, 607, 1195, 606, 598, 603, 1199, 602, 592, 609, 1193, 608, 1194, 608, 1194, 608, 596, 604, 590, 611, 1191, 611, 1191, 611, 1191, 611, 594, 607, 598,
11559, 2427, 602, 592, 608, 596, 605, 1197, 604, 1198, 604, 1198, 604, 1198, 604, 1198, 604, 590, 610, 1192, 610, 595, 606, 1196, 606, 1196, 606, 1196, 606, 599, 603, 591, 609, 1193, 609, 1193, 609, 1193, 608, 597, 605, 589,
11567, 2418, 610, 595, 607, 597, 603, 1199, 603, 1199, 602, 1200, 602, 1200, 601, 1201, 601, 593, 608, 1194, 607, 598, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595, 605, 1197, 605, 1197, 605, 1197, 604, 590, 611, 594,
1000000, 2421, 608, 597, 604, 590, 610, 1192, 610, 1192, 609, 1193, 609, 1193, 609, 1193, 608, 596, 605, 1197, 604, 590, 610, 1192, 611, 1191, 610, 1192, 610, 594, 606, 598, 603, 1199, 603, 1199, 602, 1200, 602, 592, 608, 596,
11561, 2424, 604, 590, 610, 594, 606, 1196, 606, 1196, 606, 1196, 606, 1196, 605, 1197, 605, 600, 601, 1201, 601, 593, 607, 1195, 607, 1195, 606, 1196, 606, 598, 602, 592, 608, 1194, 608, 1194, 607, 1195, 607, 597, 603, 591,
11564, 2421, 607, 597, 604, 590, 610, 1192, 610, 1192, 610, 1192, 610, 1192, 610, 1192, 609, 595, 606, 1196, 606, 598, 602, 1200, 601, 1201, 601, 1201, 601, 593, 607, 598, 603, 1199, 603, 1199, 602, 1200, 602, 592, 608, 596,
1000000, 2420, 609, 595, 606, 598, 602, 1200, 602, 1200, 602, 1200, 602, 1200, 602, 1200, 602, 592, 608, 1194, 608, 596, 604, 1198, 603, 1199, 603, 1199, 603, 591, 610, 594, 606, 1196, 606, 1196, 606, 1196, 606, 598, 602, 592,
11565, 2420, 609, 595, 605, 600, 601, 1201, 601, 1201, 601, 1201, 601, 1201, 601, 1201, 601, 593, 607, 1195, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595, 605, 1197, 605, 1197, 605, 1197, 605, 599, 601, 593,
11563, 2422, 607, 597, 603, 591, 609, 1193, 609, 1193, 608, 1194, 608, 1194, 608, 1194, 582, 623, 603, 1199, 603, 591, 610, 1202, 599, 1203, 599, 1203, 599, 595, 581, 623, 577, 1225, 601, 1201, 601, 1201, 601, 593, 582, 623,
1000000, 2425, 602, 1200, 602, 1200, 602, 592, 608, 1194, 608, 1194, 607, 1195, 607, 1195, 607, 597, 603, 1199, 602, 592, 609, 1193, 608, 1194, 608, 1194, 607, 597, 603, 601, 575, 1227, 599, 1203, 599, 1203, 573, 621, 580, 625,
10931, 2426, 578, 1224, 578, 1224, 578, 616, 585, 1217, 585, 1217, 585, 1217, 585, 1217, 585, 620, 580, 1222, 580, 624, 577, 1225, 577, 1225, 577, 1225, 577, 617, 583, 622, 580, 1222, 580, 1222, 579, 1223, 579, 625, 576, 618,
10936, 2421, 583, 1219, 583, 1219, 582, 622, 579, 1223, 578, 1224, 578, 1224, 578, 1224, 578, 616, 584, 1218, 584, 621, 580, 1222, 579, 1223, 579, 1223, 579, 625, 576, 618, 583, 1219, 582, 1220, 582, 1220, 582, 622, 578, 616,
1000000, 2419, 584, 620, 580, 1222, 580, 624, 576, 1226, 576, 1226, 576, 1226, 576, 1226, 576, 618, 582, 1220, 582, 622, 579, 1223, 578, 1224, 579, 1223, 578, 616, 585, 619, 581, 1221, 581, 1221, 581, 1221, 580, 624, 576, 618,
11563, 2422, 582, 622, 579, 1223, 578, 616, 585, 1217, 585, 1217, 584, 1218, 584, 1218, 583, 622, 579, 1223, 579, 625, 575, 1216, 585, 1217, 585, 1217, 585, 619, 581, 623, 577, 1225, 577, 1225, 577, 1225, 576, 618, 583, 621,
11558, 2427, 577, 617, 584, 1218, 583, 621, 579, 1223, 579, 1223, 578, 1224, 578, 1224, 578, 647, 553, 1249, 553, 651, 549, 1253, 548, 1254, 549, 1253, 549, 645, 555, 649, 551, 1251, 551, 1251, 551, 1251, 550, 654, 546, 648,
1000000, 2456, 548, 646, 554, 650, 551, 653, 547, 1255, 547, 1255, 547, 1255, 547, 1255, 547, 647, 554, 1248, 554, 650, 551, 1251, 551, 1251, 551, 1251, 551, 653, 547, 647, 554, 1248, 554, 1248, 554, 1248, 553, 651, 550, 644,
12112, 2449, 555, 649, 551, 654, 547, 647, 554, 1248, 554, 1248, 553, 1249, 553, 1249, 553, 651, 549, 1253, 549, 645, 555, 1247, 555, 1247, 555, 1247, 554, 650, 550, 655, 547, 1244, 557, 1224, 578, 1224, 579, 615, 585, 619,
12139, 2423, 580, 624, 576, 618, 582, 622, 578, 1224, 578, 1224, 578, 1224, 578, 1224, 578, 616, 584, 1218, 584, 620, 580, 1222, 580, 1222, 581, 1221, 580, 624, 577, 617, 584, 1218, 584, 1218, 584, 1218, 584, 620, 581, 623,
1000000, 2422, 582, 1220, 581, 623, 578, 616, 584, 1218, 584, 1218, 584, 1218, 584, 1218, 584, 620, 580, 1222, 580, 624, 576, 1226, 577, 1225, 576, 1226, 576, 618, 583, 622, 579, 1223, 578, 1224, 577, 1225, 577, 617, 585, 619,
11559, 2426, 577, 1225, 577, 617, 583, 621, 579, 1223, 579, 1223, 578, 1224, 578, 1224, 578, 616, 584, 1218, 584, 620, 580, 1222, 580, 1222, 579, 1223, 579, 625, 575, 650, 550, 1252, 550, 1252, 549, 1253, 549, 645, 556, 648,
11531, 2453, 549, 1253, 548, 646, 555, 649, 551, 1251, 551, 1251, 550, 1252, 549, 1253, 549, 645, 556, 1246, 555, 649, 552, 1219, 582, 1220, 582, 1220, 582, 622, 578, 616, 585, 1217, 584, 1218, 584, 1218, 584, 620, 581, 623,
1000000, 2428, 576, 618, 582, 1220, 583, 622, 579, 1223, 578, 1224, 578, 1224, 578, 1224, 578, 616, 585, 1217, 585, 619, 582, 1220, 582, 1220, 582, 1220, 582, 622, 578, 616, 585, 1217, 585, 1217, 584, 1218, 584, 620, 581, 623,
11557, 2427, 577, 617, 584, 1218, 583, 621, 580, 1222, 580, 1222, 580, 1222, 580, 1222, 580, 624, 576, 1246, 555, 649, 552, 1250, 552, 1250, 551, 1251, 551, 653, 548, 646, 554, 1248, 555, 1247, 555, 1247, 555, 649, 551, 653,
11528, 2447, 556, 648, 552, 1250, 552, 653, 548, 1254, 548, 1254, 547, 1245, 557, 1245, 557, 647, 553, 1249, 552, 652, 549, 1253, 548, 1254, 548, 1254, 548, 646, 555, 649, 551, 1251, 551, 1251, 551, 1251, 551, 643, 557, 647,
1000000, 2418, 610, 594, 606, 598, 603, 1199, 603, 1199, 602, 1200, 602, 1200, 602, 1200, 602, 592, 608, 1194, 608, 596, 604, 1198, 604, 1198, 604, 1198, 603, 591, 610, 594, 606, 1196, 606, 1196, 605, 1197, 605, 599, 601, 593,
11563, 2422, 606, 598, 602, 592, 608, 1194, 608, 1194, 608, 1194, 607, 1195, 607, 1195, 607, 597, 603, 1199, 603, 591, 609, 1193, 609, 1193, 609, 1193, 608, 596, 605, 599, 601, 1201, 600, 1191, 611, 1191, 611, 593, 606, 598,
11558, 2427, 601, 593, 607, 597, 603, 1199, 603, 1199, 603, 1199, 602, 1200, 602, 1200, 601, 593, 607, 1195, 607, 597, 603, 1199, 603, 1199, 602, 1200, 602, 592, 608, 596, 604, 1198, 604, 1198, 604, 1198, 603, 591, 609, 595,
1000000, 2424, 605, 1197, 604, 600, 600, 1191, 610, 1192, 610, 1192, 610, 1192, 609, 1193, 609, 595, 605, 1197, 606, 598, 602, 1200, 602, 1200, 601, 1201, 601, 593, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595,
10937, 2420, 609, 1193, 609, 595, 605, 1197, 605, 1197, 605, 1197, 605, 1197, 605, 1197, 605, 600, 601, 1201, 601, 593, 608, 1194, 608, 1194, 608, 1194, 609, 595, 605, 599, 601, 1201, 601, 1201, 601, 1201, 601, 593, 608, 596,
10936, 2420, 608, 1194, 608, 596, 604, 1198, 605, 1197, 605, 1197, 605, 1197, 605, 1197, 605, 600, 601, 1201, 601, 593, 607, 1195, 608, 1194, 608, 1194, 608, 596, 604, 600, 600, 1202, 601, 1201, 601, 1201, 601, 593, 607, 597,
1000000, 2420, 609, 1193, 608, 1194, 608, 596, 579, 625, 600, 1202, 600, 1202, 600, 1202, 600, 594, 607, 1195, 607, 597, 603, 1199, 603, 1199, 602, 1200, 602, 592, 609, 595, 605, 1197, 605, 1197, 605, 1197, 604, 600, 600, 594,
11561, 2423, 605, 1197, 605, 1197, 605, 599, 601, 593, 607, 1195, 607, 1195, 607, 1195, 607, 597, 604, 1198, 603, 591, 610, 1192, 610, 1192, 610, 1192, 610, 594, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 610, 594,
11563, 2421, 608, 1194, 608, 1194, 608, 596, 605, 599, 601, 1201, 602, 1200, 602, 1200, 602, 592, 609, 1193, 609, 595, 605, 1197, 606, 1196, 606, 1196, 606, 598, 602, 592, 609, 1193, 609, 1193, 610, 1192, 610, 594, 607, 597,
1000000, 2428, 576, 1226, 600, 1192, 610, 594, 606, 598, 602, 1200, 602, 592, 609, 595, 605, 600, 601, 593, 607, 597, 603, 591, 609, 1193,
25955, 2427, 601, 1190, 610, 1192, 610, 594, 606, 598, 602, 1200, 601, 593, 607, 597, 603, 591, 610, 594, 606, 598, 602, 592, 608, 1194,
25957, 2425, 604, 1198, 603, 1199, 603, 591, 609, 595, 605, 1197, 605, 599, 601, 593, 607, 598, 603, 591, 610, 594, 606, 598, 602, 1200,
25952, 2420, 608, 1194, 608, 1194, 608, 596, 604, 601, 600, 1191, 610, 594, 606, 598, 603, 591, 609, 595, 605, 599, 601, 593, 608, 1194,
1000000, 2421, 607, 597, 603, 1199, 603, 591, 610, 594, 606, 1196, 605, 600, 576, 618, 583, 621, 604, 601, 575, 619, 606, 598, 603, 1199,
26576, 2424, 605, 600, 576, 1226, 601, 593, 608, 596, 604, 1198, 604, 600, 600, 594, 607, 597, 603, 591, 609, 595, 606, 598, 602, 1200,
26579, 2420, 583, 621, 605, 1197, 604, 600, 601, 593, 607, 1195, 607, 597, 604, 590, 610, 594, 607, 597, 603, 591, 610, 594, 606, 1196,
26584, 2426, 603, 591, 609, 1193, 609, 595, 605, 599, 601, 1201, 601, 593, 607, 597, 603, 591, 610, 594, 606, 598, 603, 591, 609, 1193,
1000000, 2418, 610, 594, 606, 598, 602, 592, 609, 595, 605, 1197, 605, 1197, 605, 600, 602, 592, 608, 1194, 608, 596, 605, 1197, 605, 1197, 604, 1198, 604, 600, 601, 593, 607, 1195, 607, 1195, 607, 1195, 607, 597, 603, 591,
13368, 2419, 610, 594, 606, 598, 602, 592, 608, 596, 605, 1197, 604, 1198, 604, 600, 601, 593, 607, 1195, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595, 605, 1197, 605, 1197, 605, 1197, 604, 601, 600, 594,
13362, 2425, 604, 601, 600, 594, 607, 597, 603, 591, 610, 1192, 610, 1192, 610, 594, 606, 598, 603, 1199, 602, 592, 609, 1193, 609, 1193, 608, 1194, 608, 596, 604, 601, 600, 1191, 610, 1192, 610, 1192, 610, 594, 607, 597,
1000000, 2427, 601, 1201, 601, 593, 582, 623, 603, 1199, 578, 1224, 603, 1199, 577, 617, 584, 620, 605, 1197, 605, 600, 601, 1201, 601, 1201, 601, 1201, 601, 593, 582, 622, 603, 1199, 603, 1199, 578, 1224, 603, 591, 610, 594,
12139, 2423, 605, 1197, 605, 600, 601, 593, 608, 1194, 608, 1194, 607, 1195, 607, 597, 604, 600, 601, 1201, 601, 593, 607, 1195, 608, 1194, 608, 1194, 583, 622, 604, 601, 600, 1202, 575, 1227, 601, 1201, 576, 618, 607, 597,
12137, 2424, 604, 1198, 604, 590, 610, 594, 607, 1195, 607, 1195, 607, 1195, 607, 597, 604, 601, 600, 1202, 600, 594, 607, 1195, 606, 1196, 581, 1221, 607, 597, 603, 591, 610, 1202, 600, 1202, 576, 1226, 602, 592, 609, 595,
1000000, 2422, 607, 1195, 607, 597, 603, 591, 585, 619, 606, 1196, 606, 1196, 581, 624, 577, 617, 609, 1193, 584, 621, 605, 1197, 604, 1198, 604, 1198, 604, 590, 610, 595, 581, 1221, 605, 1197, 605, 1197, 605, 599, 601, 593,
12763, 2427, 603, 1199, 603, 591, 609, 595, 605, 599, 577, 1225, 602, 1200, 601, 593, 583, 622, 604, 1198, 604, 590, 610, 1192, 610, 1192, 610, 1192, 610, 594, 606, 598, 603, 1199, 603, 1199, 603, 1199, 603, 591, 610, 594,
12763, 2427, 602, 1200, 601, 593, 608, 596, 604, 600, 600, 1202, 601, 1201, 601, 593, 607, 597, 604, 1198, 604, 590, 610, 1192, 610, 1192, 611, 1191, 610, 594, 607, 598, 578, 1224, 603, 1199, 603, 1199, 603, 591, 610, 594,
1000000, 2422, 607, 597, 603, 591, 610, 1192, 610, 594, 606, 1196, 580, 1222, 605, 600, 601, 593, 583, 1219, 608, 596, 579, 1223, 604, 1198, 604, 1198, 604, 590, 610, 594, 606, 1196, 606, 1196, 606, 1196, 606, 599, 602, 592,
12765, 2425, 603, 591, 610, 594, 606, 1196, 606, 598, 602, 1200, 601, 1201, 601, 593, 582, 623, 604, 1198, 604, 590, 610, 1192, 610, 1192, 609, 1193, 609, 596, 605, 599, 601, 1201, 601, 1201, 601, 1201, 600, 594, 607, 597,
12758, 2421, 607, 597, 603, 591, 609, 1193, 609, 595, 605, 1197, 605, 1197, 605, 599, 601, 593, 607, 1195, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595, 580, 1222, 605, 1197, 605, 1197, 605, 600, 600, 594,
1000000, 2422, 580, 625, 601, 1201, 601, 593, 608, 596, 604, 1198, 604, 1198, 604, 600, 600, 594, 607, 1195, 607, 597, 603, 1199, 603, 1199, 603, 1199, 578, 616, 609, 595, 606, 1196, 606, 1196, 606, 1196, 581, 624, 602, 592,
12766, 2424, 605, 599, 601, 1201, 601, 593, 608, 596, 604, 1198, 604, 1198, 579, 625, 601, 593, 608, 1194, 608, 596, 604, 1198, 580, 1222, 605, 1197, 605, 599, 602, 592, 608, 1194, 609, 1193, 609, 1193, 609, 596, 605, 599,
12759, 2420, 608, 597, 604, 1198, 604, 590, 610, 594, 606, 1196, 606, 1196, 606, 598, 602, 592, 608, 1194, 607, 597, 604, 1198, 603, 1199, 603, 1199, 602, 592, 609, 595, 605, 1197, 605, 1197, 605, 1197, 604, 600, 601, 593,
1000000, 2429, 600, 1202, 575, 1227, 599, 595, 606, 598, 602, 1200, 602, 1200, 602, 592, 609, 595, 605, 1197, 605, 599, 601, 1201, 601, 1201, 601, 1201, 601, 593, 607, 597, 603, 1199, 603, 1199, 603, 1199, 603, 591, 609, 595,
12136, 2425, 603, 1199, 603, 1199, 603, 591, 609, 595, 605, 1197, 605, 1197, 605, 599, 601, 593, 608, 1194, 608, 596, 604, 1198, 604, 1198, 603, 1199, 603, 591, 609, 595, 606, 1196, 606, 1196, 605, 1197, 605, 599, 601, 593,
12137, 2424, 604, 1198, 603, 1199, 603, 591, 609, 595, 606, 1196, 605, 1197, 605, 599, 601, 593, 607, 1195, 607, 597, 603, 1199, 603, 1199, 603, 1199, 602, 592, 609, 595, 605, 1197, 605, 1197, 604, 1198, 604, 600, 600, 594,
1000000, 2429, 574, 1228, 573, 1229, 573, 1229, 573, 1229, 573, 621, 581, 624, 577, 617, 583, 622, 580, 1222, 579, 625, 576, 1226, 577, 1225, 576, 1226, 577, 617, 584, 620, 581, 1221, 580, 1222, 579, 1223, 579, 625, 577, 617,
12142, 2419, 584, 1218, 584, 1218, 583, 1219, 583, 1219, 582, 623, 578, 616, 585, 619, 581, 623, 578, 1224, 577, 617, 584, 1218, 584, 1218, 584, 1218, 584, 620, 580, 624, 576, 1226, 575, 1227, 500, 1353, 523, 620, 582, 622, /* failed, noise pollution 500, 1353 timings */
12134, 2427, 576, 1226, 576, 1226, 576, 1226, 576, 1226, 576, 618, 583, 622, 579, 625, 576, 618, 583, 1219, 583, 673, 527, 1223, 579, 1223, 579, 1223, 579, 625, 576, 618, 582, 1220, 582, 1220, 582, 1220, 582, 622, 578, 616,
12140, 2421, 582, 1220, 581, 1221, 581, 1221, 580, 1222, 580, 624, 576, 618, 582, 622, 578, 616, 585, 1217, 584, 620, 581, 1221, 580, 1222, 580, 1222, 580, 624, 576, 618, 582, 1220, 582, 1220, 582, 1220, 582, 623, 578, 616,
1000000, 2419, 584, 672, 528, 625, 577, 617, 583, 1219, 582, 1220, 581, 1221, 582, 622, 578, 616, 585, 1217, 583, 621, 580, 1222, 580, 1222, 580, 1222, 580, 624, 576, 618, 583, 1219, 583, 1219, 582, 1220, 583, 621, 580, 624,
12732, 2427, 577, 617, 584, 672, 528, 676, 524, 1226, 576, 1226, 576, 1226, 576, 618, 583, 621, 579, 1223, 579, 625, 575, 1227, 575, 1227, 575, 1227, 575, 671, 529, 675, 526, 1224, 578, 1224, 578, 1224, 578, 616, 585, 619,
12738, 2421, 583, 621, 580, 624, 576, 618, 582, 1220, 582, 1220, 583, 1219, 583, 621, 579, 625, 576, 1226, 576, 670, 530, 1220, 582, 1220, 582, 1220, 581, 624, 577, 617, 584, 1218, 583, 1219, 583, 1219, 583, 622, 580, 624,
1000000, 2430, 599, 1192, 609, 595, 605, 1197, 580, 624, 601, 1201, 601, 593, 607, 597, 603, 591, 610, 594, 606, 598, 602, 592, 608, 1194,
25958, 2423, 605, 1197, 604, 600, 575, 1227, 600, 594, 606, 1196, 606, 598, 602, 592, 608, 596, 604, 601, 600, 594, 607, 597, 603, 1199,
25949, 2422, 607, 1195, 606, 598, 603, 1199, 602, 592, 608, 1194, 608, 596, 604, 600, 601, 593, 607, 597, 604, 600, 600, 594, 607, 1195,
25958, 2423, 606, 1196, 606, 598, 602, 1200, 602, 592, 608, 1194, 608, 596, 605, 600, 601, 593, 607, 597, 603, 591, 610, 594, 606, 1196,
25957, 2425, 604, 1198, 603, 591, 610, 1192, 610, 594, 606, 1196, 606, 598, 602, 592, 609, 595, 605, 599, 602, 592, 608, 596, 604, 1198,
25956, 2426, 604, 1198, 603, 591, 610, 1192, 610, 594, 606, 1196, 606, 598, 602, 592, 608, 597, 605, 599, 601, 593, 607, 597, 603, 1199,
25952, 2420, 609, 1193, 608, 596, 604, 1198, 604, 590, 610, 1192, 610, 594, 606, 598, 602, 592, 608, 596, 605, 599, 601, 593, 607, 1195,
1000000, 2422, 583, 1219, 608, 596, 605, 1197, 580, 624, 601, 1201, 601, 593, 608, 596, 604, 600, 601, 593, 607, 597, 604, 590, 610, 1202,
25955, 2427, 603, 1199, 603, 591, 609, 1193, 610, 594, 606, 1196, 607, 597, 603, 591, 609, 595, 606, 598, 602, 592, 609, 595, 605, 1197,
25957, 2425, 604, 1198, 604, 590, 610, 1192, 610, 594, 581, 1221, 606, 598, 602, 592, 608, 596, 605, 599, 601, 593, 607, 597, 604, 1198,
25954, 2418, 610, 1192, 610, 594, 606, 1196, 605, 599, 601, 1201, 601, 593, 608, 596, 604, 590, 610, 594, 606, 598, 603, 591, 609, 1193,
25958, 2424, 604, 1198, 604, 590, 610, 1192, 610, 594, 606, 1196, 606, 598, 602, 592, 609, 595, 605, 600, 601, 593, 607, 597, 603, 1199,
25953, 2419, 610, 1192, 609, 595, 605, 1197, 605, 600, 601, 1201, 600, 594, 607, 597, 603, 591, 609, 595, 605, 599, 601, 593, 608, 1194,
25954, 2418, 611, 1191, 610, 594, 606, 1196, 606, 598, 602, 1200, 602, 592, 608, 596, 604, 601, 600, 594, 607, 597, 603, 591, 609, 1193,
25958, 2424, 605, 1197, 605, 599, 601, 1201, 600, 594, 607, 1195, 607, 597, 603, 591, 609, 596, 605, 599, 602, 592, 608, 596, 605, 1197,
25954, 2428, 601, 1190, 610, 594, 607, 1195, 606, 598, 602, 1200, 602, 592, 608, 596, 604, 590, 610, 594, 606, 598, 603, 591, 609, 1193,
25960, 2422, 607, 1195, 606, 598, 602, 1200, 602, 592, 609, 1193, 609, 595, 605, 599, 601, 593, 607, 597, 604, 590, 610, 594, 606, 1196,
25957, 2424, 605, 1197, 604, 600, 600, 1202, 601, 593, 607, 1195, 607, 597, 603, 591, 610, 594, 606, 598, 603, 591, 609, 595, 606, 1196,
1000000, 2421, 608, 1194, 608, 596, 604, 1198, 604, 601, 575, 1227, 601, 593, 607, 598, 604, 600, 600, 594, 607, 598, 604, 601, 600, 1202,
25953, 2419, 609, 1193, 609, 596, 605, 1197, 605, 600, 601, 1201, 601, 593, 607, 597, 603, 591, 610, 594, 606, 599, 602, 592, 608, 1194,
25958, 2424, 605, 1197, 605, 600, 601, 1201, 600, 594, 607, 1195, 606, 598, 602, 592, 609, 595, 605, 600, 601, 593, 608, 596, 604, 1198,
1000000, 2423, 606, 1196, 606, 598, 602, 1200, 602, 592, 608, 1194, 608, 597, 604, 590, 610, 594, 607, 597, 603, 591, 610, 594, 606, 1196,
25958, 2424, 605, 1197, 604, 600, 601, 1201, 601, 593, 607, 1195, 607, 597, 604, 590, 610, 595, 607, 597, 603, 591, 610, 594, 607, 1195,
25961, 2421, 608, 1194, 608, 596, 605, 1197, 605, 600, 601, 1201, 601, 593, 607, 597, 603, 591, 610, 594, 606, 598, 602, 592, 609, 1193,
1000000, 2429, 601, 1201, 601, 593, 607, 1195, 608, 596, 604, 1198, 604, 600, 601, 593, 607, 597, 604, 590, 611, 593, 607, 597, 604, 1198,
25959, 2422, 607, 1195, 607, 597, 603, 1199, 603, 591, 609, 1193, 610, 594, 606, 598, 602, 592, 609, 595, 605, 599, 602, 592, 608, 1194,
25959, 2421, 608, 1194, 607, 597, 603, 1199, 603, 591, 610, 1192, 610, 594, 606, 598, 603, 591, 609, 595, 605, 599, 602, 592, 608, 1194,
25959, 2422, 608, 1194, 608, 596, 604, 1198, 604, 590, 611, 1201, 601, 593, 607, 597, 604, 590, 610, 594, 607, 597, 603, 591, 609, 1193,
25962, 2418, 610, 1192, 610, 594, 606, 1196, 607, 597, 603, 1199, 603, 591, 609, 595, 605, 599, 602, 592, 608, 596, 605, 599, 601, 1201,
1000000, 2357, 610, 1183, 592, 1191, 614, 1179, 595, 1188, 618, 584, 613, 1180, 593, 588, 613, 1190, 612, 590, 605, 587, 613, 589, 605, 587,
25398, 2355, 623, 1180, 591, 1181, 627, 1186, 589, 1183, 618, 584, 616, 1187, 587, 584, 614, 1189, 615, 587, 605, 587, 615, 587, 609, 593,
1000000, 2383, 609, 1214, 600, 612, 580, 1213, 608, 614, 583, 1210, 605, 607, 586, 616, 611, 1192, 599, 613, 608, 614, 579, 613, 615, 607,
26670, 2387, 601, 1212, 600, 612, 589, 1214, 603, 609, 586, 1217, 595, 607, 594, 618, 606, 1187, 602, 610, 609, 613, 588, 614, 610, 612,
1000000, 2445, 582, 1221, 603, 548, 602, 1191, 609, 572, 602, 1191, 609, 542, 607, 544, 631, 1172, 603, 568, 606, 545, 605, 566, 608, 543,
26263, 2414, 611, 1192, 607, 544, 606, 1197, 602, 569, 606, 1197, 602, 539, 611, 540, 635, 1168, 606, 565, 610, 541, 608, 563, 587, 564,
};
const InfraredMessage test_decoder_sirc_expected1[] = {
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x60, false},
{InfraredProtocolSIRC, 0x10, 0x60, false},
{InfraredProtocolSIRC, 0x10, 0x60, false},
{InfraredProtocolSIRC, 0x10, 0x65, false},
{InfraredProtocolSIRC, 0x10, 0x65, false},
{InfraredProtocolSIRC, 0x10, 0x65, false},
{InfraredProtocolSIRC20, 0x410, 0x17, false},
{InfraredProtocolSIRC20, 0x410, 0x17, false},
{InfraredProtocolSIRC20, 0x410, 0x17, false},
{InfraredProtocolSIRC, 0x10, 0x21, false},
{InfraredProtocolSIRC, 0x10, 0x21, false},
{InfraredProtocolSIRC, 0x10, 0x21, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7B, false},
{InfraredProtocolSIRC20, 0x73A, 0x7B, false},
{InfraredProtocolSIRC20, 0x73A, 0x7B, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x78, false},
{InfraredProtocolSIRC20, 0x73A, 0x78, false},
{InfraredProtocolSIRC20, 0x73A, 0x78, false},
{InfraredProtocolSIRC20, 0x73A, 0x79, false},
{InfraredProtocolSIRC20, 0x73A, 0x79, false},
{InfraredProtocolSIRC20, 0x73A, 0x79, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x7A, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7C, false},
{InfraredProtocolSIRC20, 0x73A, 0x7D, false},
{InfraredProtocolSIRC20, 0x73A, 0x7D, false},
{InfraredProtocolSIRC20, 0x73A, 0x7D, false},
{InfraredProtocolSIRC20, 0x73A, 0x73, false},
{InfraredProtocolSIRC20, 0x73A, 0x73, false},
{InfraredProtocolSIRC20, 0x73A, 0x73, false},
{InfraredProtocolSIRC, 0x10, 0x13, false},
{InfraredProtocolSIRC, 0x10, 0x13, false},
{InfraredProtocolSIRC, 0x10, 0x13, false},
{InfraredProtocolSIRC, 0x10, 0x13, false},
{InfraredProtocolSIRC, 0x10, 0x12, false},
{InfraredProtocolSIRC, 0x10, 0x12, false},
{InfraredProtocolSIRC, 0x10, 0x12, false},
{InfraredProtocolSIRC, 0x10, 0x12, false},
{InfraredProtocolSIRC20, 0x73A, 0x30, false},
{InfraredProtocolSIRC20, 0x73A, 0x30, false},
{InfraredProtocolSIRC20, 0x73A, 0x30, false},
{InfraredProtocolSIRC20, 0x73A, 0x39, false},
{InfraredProtocolSIRC20, 0x73A, 0x39, false},
{InfraredProtocolSIRC20, 0x73A, 0x39, false},
{InfraredProtocolSIRC20, 0x73A, 0x31, false},
{InfraredProtocolSIRC20, 0x73A, 0x31, false},
{InfraredProtocolSIRC20, 0x73A, 0x31, false},
{InfraredProtocolSIRC20, 0x73A, 0x34, false},
{InfraredProtocolSIRC20, 0x73A, 0x34, false},
{InfraredProtocolSIRC20, 0x73A, 0x34, false},
{InfraredProtocolSIRC20, 0x73A, 0x32, false},
{InfraredProtocolSIRC20, 0x73A, 0x32, false},
{InfraredProtocolSIRC20, 0x73A, 0x32, false},
{InfraredProtocolSIRC20, 0x73A, 0x33, false},
{InfraredProtocolSIRC20, 0x73A, 0x33, false},
{InfraredProtocolSIRC20, 0x73A, 0x33, false},
{InfraredProtocolSIRC20, 0x73A, 0x0F, false},
{InfraredProtocolSIRC20, 0x73A, 0x0F, false},
{InfraredProtocolSIRC20, 0x73A, 0x0F, false},
{InfraredProtocolSIRC20, 0x73A, 0x38, false},
{InfraredProtocolSIRC20, 0x73A, 0x38, false},
{InfraredProtocolSIRC20, 0x73A, 0x38, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x10, 0x15, false},
{InfraredProtocolSIRC, 0x01, 0x2F, false},
{InfraredProtocolSIRC, 0x01, 0x2F, false},
{InfraredProtocolSIRC, 0x01, 0x15, false},
{InfraredProtocolSIRC, 0x01, 0x15, false},
{InfraredProtocolSIRC, 0x01, 0x15, false},
{InfraredProtocolSIRC, 0x01, 0x15, false},
};
// command (0x55) address (0x0A) SIRC
// 1 0 1 0 1 0 1 0 1 0 1 0
// 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
//
// command (0x7F) address (0x1F) SIRC
// 1 1 1 1 1 1 1 1 1 1 1 1
// 2400, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
//
// command (0x00) address (0x00) SIRC
// 0 0 0 0 0 0 0 0 0 0 0 0
// 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
//
// command (0x53) address (0x0D) SIRC
// 1 1 0 0 1 0 1 1 0 1 1 0
// 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600,
const uint32_t test_decoder_sirc_input2[] = {
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, /* failed - should be skipped */
1000000, 2400, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
1000000, 2400, 600, 1200, 600, 600, /* failed - should be skipped */
1000000, 2400, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
1000000, 2400, 600, 1200, 600, /* failed - should be skipped */
2400, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
1000000, 2400, 600, 1200, 600, 600, /* failed - should be skipped */
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
1000000, 2400, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600,
};
const InfraredMessage test_decoder_sirc_expected2[] = {
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
/* failed - 13 data bits */
{InfraredProtocolSIRC, 0x1F, 0x7F, false},
/* failed - 2 data bits */
{InfraredProtocolSIRC, 0x1F, 0x7F, false},
/* failed - sudden end */
{InfraredProtocolSIRC, 0x1F, 0x7F, false},
/* failed */
{InfraredProtocolSIRC, 0x0A, 0x55, false},
{InfraredProtocolSIRC, 0x00, 0x00, false},
{InfraredProtocolSIRC, 0x0D, 0x53, false},
};
// command (0x13) address (0xFD) SIRC15
// 1 1 0 0 1 0 0 1 0 1 1 1 1 1 1
// 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
//
// command (0x53) address (0x7D) SIRC15
// 1 1 0 0 1 0 1 1 0 1 1 1 1 1 0
// 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
//
// command (0x53) address (0x0D) SIRC15
// 1 1 0 0 1 0 1 1 0 1 1 0 0 0 0
// 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
const uint32_t test_decoder_sirc_input3[] = {
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 600, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200,
};
const InfraredMessage test_decoder_sirc_expected3[] = {
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x0D, 0x53, false},
{InfraredProtocolSIRC15, 0x0D, 0x53, false},
{InfraredProtocolSIRC15, 0x0D, 0x53, false},
{InfraredProtocolSIRC15, 0x0D, 0x53, false},
{InfraredProtocolSIRC15, 0x0D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0xFD, 0x13, false},
};
const uint32_t test_decoder_sirc_input4[] = {
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
};
const InfraredMessage test_decoder_sirc_expected4[] = {
{InfraredProtocolSIRC20, 0xFB5, 0x53, false}, // {InfraredProtocolSIRC20, 0x15, 0x3ED3, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
};
const uint32_t test_decoder_sirc_input5[] = {
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
1000000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
};
const InfraredMessage test_decoder_sirc_expected5[] = {
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
{InfraredProtocolSIRC, 0xA, 0x55, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC20, 0xFB5, 0x53, false},
};
const InfraredMessage test_encoder_sirc_input1[] = {
{InfraredProtocolSIRC, 0xA, 0x55, false},
};
const uint32_t test_encoder_sirc_expected1[] = {
10000, 2400, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600,
};
const InfraredMessage test_encoder_sirc_input2[] = {
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, true},
{InfraredProtocolSIRC15, 0x7D, 0x53, true},
};
const uint32_t test_encoder_sirc_expected2[] = {
10000, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
18600, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
18600, 2400, 600, 1200, 600, 1200, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 600, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 1200, 600, 600,
};
const InfraredMessage test_sirc[] = {
{InfraredProtocolSIRC20, 0x1FFF, 0x7F, false},
{InfraredProtocolSIRC20, 0x1FFF, 0x7F, true},
{InfraredProtocolSIRC20, 0x1FFF, 0x7F, true},
{InfraredProtocolSIRC, 0x00, 0x00, false},
{InfraredProtocolSIRC, 0x00, 0x00, true},
{InfraredProtocolSIRC, 0x00, 0x00, true},
{InfraredProtocolSIRC, 0x1A, 0x22, false},
{InfraredProtocolSIRC, 0x1A, 0x22, true},
{InfraredProtocolSIRC, 0x1A, 0x22, true},
{InfraredProtocolSIRC, 0x17, 0x0A, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, false},
{InfraredProtocolSIRC15, 0x7D, 0x53, true},
{InfraredProtocolSIRC15, 0x7D, 0x53, true},
{InfraredProtocolSIRC15, 0x71, 0x0, false},
{InfraredProtocolSIRC15, 0x15, 0x01, false},
{InfraredProtocolSIRC15, 0x01, 0x15, false},
{InfraredProtocolSIRC20, 0xAA, 0x55, false},
{InfraredProtocolSIRC20, 0x331, 0x71, false},
{InfraredProtocolSIRC, 0x00, 0x00, false},
{InfraredProtocolSIRC, 0x1F, 0x7F, false},
{InfraredProtocolSIRC15, 0x00, 0x00, false},
{InfraredProtocolSIRC15, 0xFF, 0x7F, false},
{InfraredProtocolSIRC20, 0x00, 0x00, false},
{InfraredProtocolSIRC20, 0x1FFF, 0x7F, false},
};

View File

@@ -0,0 +1,628 @@
/*
* Copyright (c) 2012 David Siñuela Pastor, siu.4coders@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef MINUNIT_MINUNIT_H
#define MINUNIT_MINUNIT_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
#include <Windows.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#define __func__ __FUNCTION__
#endif
#elif defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
/* Change POSIX C SOURCE version for pure c99 compilers */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
#include <unistd.h> /* POSIX flags */
#include <time.h> /* clock_gettime(), time() */
#include <sys/time.h> /* gethrtime(), gettimeofday() */
#include <sys/resource.h>
#include <sys/times.h>
#include <string.h>
#if defined(__MACH__) && defined(__APPLE__)
#include <mach/mach.h>
#include <mach/mach_time.h>
#endif
#if __GNUC__ >= 5 && !defined(__STDC_VERSION__)
#define __func__ __extension__ __FUNCTION__
#endif
#else
// #error "Unable to define timers for an unknown OS."
#endif
#include <stdio.h>
#include <math.h>
/* Maximum length of last message */
#define MINUNIT_MESSAGE_LEN 1024
/* Accuracy with which floats are compared */
#define MINUNIT_EPSILON 1E-12
#include "minunit_vars_ex.h"
/* Test setup and teardown function pointers */
__attribute__((unused)) static void (*minunit_setup)(void) = NULL;
__attribute__((unused)) static void (*minunit_teardown)(void) = NULL;
void minunit_print_progress(void);
void minunit_print_fail(const char* error);
/* Definitions */
#define MU_TEST(method_name) static void method_name(void)
#define MU_TEST_1(method_name, arg_1) static void method_name(arg_1)
#define MU_TEST_SUITE(suite_name) static void suite_name(void)
#define MU__SAFE_BLOCK(block) \
do { \
block \
} while(0)
/* Run test suite and unset setup and teardown functions */
#define MU_RUN_SUITE(suite_name) \
MU__SAFE_BLOCK(suite_name(); minunit_setup = NULL; minunit_teardown = NULL;)
/* Configure setup and teardown functions */
#define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) \
MU__SAFE_BLOCK(minunit_setup = setup_fun; minunit_teardown = teardown_fun;)
/* Test runner */
#define MU_RUN_TEST(test) \
MU__SAFE_BLOCK( \
if(minunit_real_timer == 0 && minunit_proc_timer == 0) { \
minunit_real_timer = mu_timer_real(); \
minunit_proc_timer = mu_timer_cpu(); \
} if(minunit_setup) (*minunit_setup)(); \
minunit_status = 0; \
printf(#test "()\r\n"); \
test(); \
minunit_run++; \
if(minunit_status) { \
minunit_fail++; \
minunit_print_fail(minunit_last_message); \
minunit_status = 0; \
} fflush(stdout); \
if(minunit_teardown)(*minunit_teardown)();)
#define MU_RUN_TEST_1(test, arg_1) \
MU__SAFE_BLOCK( \
if(minunit_real_timer == 0 && minunit_proc_timer == 0) { \
minunit_real_timer = mu_timer_real(); \
minunit_proc_timer = mu_timer_cpu(); \
} if(minunit_setup) (*minunit_setup)(); \
minunit_status = 0; \
printf(#test "(" #arg_1 ")\r\n"); \
test(arg_1); \
minunit_run++; \
if(minunit_status) { \
minunit_fail++; \
minunit_print_fail(minunit_last_message); \
minunit_status = 0; \
} fflush(stdout); \
if(minunit_teardown)(*minunit_teardown)();)
/* Report */
#define MU_REPORT() \
MU__SAFE_BLOCK(double minunit_end_real_timer; double minunit_end_proc_timer; printf( \
"\n\n%d tests, %d assertions, %d failures\n", \
minunit_run, \
minunit_assert, \
minunit_fail); \
minunit_end_real_timer = mu_timer_real(); \
minunit_end_proc_timer = mu_timer_cpu(); \
printf( \
"\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n", \
minunit_end_real_timer - minunit_real_timer, \
minunit_end_proc_timer - minunit_proc_timer);)
#define MU_EXIT_CODE minunit_fail
/* Assertions */
#define mu_check(test) \
MU__SAFE_BLOCK( \
minunit_assert++; if(!(test)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
#test); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_fail(message) \
MU__SAFE_BLOCK(minunit_assert++; snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
message); \
minunit_status = 1; \
return;)
#define mu_assert(test, message) \
MU__SAFE_BLOCK( \
minunit_assert++; if(!(test)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
message); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_eq(expected, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(minunit_tmp_e != minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d expected but was %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_not_eq(expected, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(minunit_tmp_e == minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: expected different results but both were %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_greater_than(val, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val >= minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d <= %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_less_than(val, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val <= minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d >= %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_between(expected_lower, expected_upper, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_m; int minunit_tmp_r; minunit_assert++; \
minunit_tmp_e = (expected_lower); \
minunit_tmp_m = (expected_upper); \
minunit_tmp_r = (result); \
if(result < minunit_tmp_e || result > minunit_tmp_m) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_int_in(expected, array_length, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_r; minunit_assert++; minunit_tmp_r = (result); int t = 0; int i; \
for(i = 0; i < array_length; i++) { \
if(expected[i] == minunit_tmp_r) t = 1; \
} if(t == 0) { \
char tmp[500] = {0}; \
tmp[0] = '['; \
for(i = 0; i < array_length; i++) { \
sprintf(tmp + strlen(tmp), "%d, ", expected[i]); \
} \
int len = strlen(tmp); \
tmp[len - 2] = ']'; \
tmp[len - 1] = '\0'; \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: expected to be one of %s but was %d", \
__func__, \
__FILE__, \
__LINE__, \
tmp, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_double_eq(expected, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(fabs(minunit_tmp_e - minunit_tmp_r) > MINUNIT_EPSILON) { \
int minunit_significant_figures = 1 - log10(MINUNIT_EPSILON); \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %.*g expected but was %.*g", \
__func__, \
__FILE__, \
__LINE__, \
minunit_significant_figures, \
minunit_tmp_e, \
minunit_significant_figures, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_double_greater_than(val, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val >= minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f <= %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_double_less_than(val, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val <= minunit_tmp_r) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f >= %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_double_between(expected_lower, expected_upper, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_m; double minunit_tmp_r; minunit_assert++; \
minunit_tmp_e = (expected_lower); \
minunit_tmp_m = (expected_upper); \
minunit_tmp_r = (result); \
if(result < minunit_tmp_e || result > minunit_tmp_m) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_string_eq(expected, result) \
MU__SAFE_BLOCK( \
const char* minunit_tmp_e = expected; const char* minunit_tmp_r = result; \
minunit_assert++; \
if(!minunit_tmp_e) { minunit_tmp_e = "<null pointer>"; } if(!minunit_tmp_r) { \
minunit_tmp_r = "<null pointer>"; \
} if(strcmp(minunit_tmp_e, minunit_tmp_r)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: '%s' expected but was '%s'", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { minunit_print_progress(); })
#define mu_assert_null(result) \
MU__SAFE_BLOCK( \
minunit_assert++; if(result == NULL) { minunit_print_progress(); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected result was not NULL", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_not_null(result) \
MU__SAFE_BLOCK( \
minunit_assert++; if(result != NULL) { minunit_print_progress(); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected result was not NULL", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_pointers_eq(pointer1, pointer2) \
MU__SAFE_BLOCK( \
minunit_assert++; if(pointer1 == pointer2) { minunit_print_progress(); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_pointers_not_eq(pointer1, pointer2) \
MU__SAFE_BLOCK( \
minunit_assert++; if(pointer1 != pointer2) { minunit_print_progress(); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
})
/*
* The following two functions were written by David Robert Nadeau
* from http://NadeauSoftware.com/ and distributed under the
* Creative Commons Attribution 3.0 Unported License
*/
/**
* Returns the real time, in seconds, or -1.0 if an error occurred.
*
* Time is measured since an arbitrary and OS-dependent start time.
* The returned real time is only useful for computing an elapsed time
* between two calls to this function.
*/
__attribute__((unused)) static double mu_timer_real(void) {
#if defined(_WIN32)
/* Windows 2000 and later. ---------------------------------- */
LARGE_INTEGER Time;
LARGE_INTEGER Frequency;
QueryPerformanceFrequency(&Frequency);
QueryPerformanceCounter(&Time);
Time.QuadPart *= 1000000;
Time.QuadPart /= Frequency.QuadPart;
return (double)Time.QuadPart / 1000000.0;
#elif(defined(__hpux) || defined(hpux)) || \
((defined(__sun__) || defined(__sun) || defined(sun)) && \
(defined(__SVR4) || defined(__svr4__)))
/* HP-UX, Solaris. ------------------------------------------ */
return (double)gethrtime() / 1000000000.0;
#elif defined(__MACH__) && defined(__APPLE__)
/* OSX. ----------------------------------------------------- */
static double timeConvert = 0.0;
if(timeConvert == 0.0) {
mach_timebase_info_data_t timeBase;
(void)mach_timebase_info(&timeBase);
timeConvert = (double)timeBase.numer / (double)timeBase.denom / 1000000000.0;
}
return (double)mach_absolute_time() * timeConvert;
#elif defined(_POSIX_VERSION)
/* POSIX. --------------------------------------------------- */
struct timeval tm;
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
{
struct timespec ts;
#if defined(CLOCK_MONOTONIC_PRECISE)
/* BSD. --------------------------------------------- */
const clockid_t id = CLOCK_MONOTONIC_PRECISE;
#elif defined(CLOCK_MONOTONIC_RAW)
/* Linux. ------------------------------------------- */
const clockid_t id = CLOCK_MONOTONIC_RAW;
#elif defined(CLOCK_HIGHRES)
/* Solaris. ----------------------------------------- */
const clockid_t id = CLOCK_HIGHRES;
#elif defined(CLOCK_MONOTONIC)
/* AIX, BSD, Linux, POSIX, Solaris. ----------------- */
const clockid_t id = CLOCK_MONOTONIC;
#elif defined(CLOCK_REALTIME)
/* AIX, BSD, HP-UX, Linux, POSIX. ------------------- */
const clockid_t id = CLOCK_REALTIME;
#else
const clockid_t id = (clockid_t)-1; /* Unknown. */
#endif /* CLOCK_* */
if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
/* Fall thru. */
}
#endif /* _POSIX_TIMERS */
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, POSIX, Solaris. ----- */
gettimeofday(&tm, NULL);
return (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0;
#else
return -1.0; /* Failed. */
#endif
}
/**
* Returns the amount of CPU time used by the current process,
* in seconds, or -1.0 if an error occurred.
*/
__attribute__((unused)) static double mu_timer_cpu(void) {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
FILETIME createTime;
FILETIME exitTime;
FILETIME kernelTime;
FILETIME userTime;
/* This approach has a resolution of 1/64 second. Unfortunately, Windows' API does not offer better */
if(GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime) != 0) {
ULARGE_INTEGER userSystemTime;
memcpy(&userSystemTime, &userTime, sizeof(ULARGE_INTEGER));
return (double)userSystemTime.QuadPart / 10000000.0;
}
#elif defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, and Solaris --------- */
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
/* Prefer high-res POSIX timers, when available. */
{
clockid_t id;
struct timespec ts;
#if _POSIX_CPUTIME > 0
/* Clock ids vary by OS. Query the id, if possible. */
if(clock_getcpuclockid(0, &id) == -1)
#endif
#if defined(CLOCK_PROCESS_CPUTIME_ID)
/* Use known clock id for AIX, Linux, or Solaris. */
id = CLOCK_PROCESS_CPUTIME_ID;
#elif defined(CLOCK_VIRTUAL)
/* Use known clock id for BSD or HP-UX. */
id = CLOCK_VIRTUAL;
#else
id = (clockid_t)-1;
#endif
if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
}
#endif
#if defined(RUSAGE_SELF)
{
struct rusage rusage;
if(getrusage(RUSAGE_SELF, &rusage) != -1)
return (double)rusage.ru_utime.tv_sec + (double)rusage.ru_utime.tv_usec / 1000000.0;
}
#endif
#if defined(_SC_CLK_TCK)
{
const double ticks = (double)sysconf(_SC_CLK_TCK);
struct tms tms;
if(times(&tms) != (clock_t)-1) return (double)tms.tms_utime / ticks;
}
#endif
#if defined(CLOCKS_PER_SEC)
{
clock_t cl = clock();
if(cl != (clock_t)-1) return (double)cl / (double)CLOCKS_PER_SEC;
}
#endif
#endif
return -1; /* Failed. */
}
#ifdef __cplusplus
}
#endif
#endif /* MINUNIT_MINUNIT_H */

View File

@@ -0,0 +1,67 @@
#include <stdio.h>
#include <furi.h>
#include "minunit.h"
// v2 tests
void test_furi_create_open();
void test_furi_valuemutex();
void test_furi_concurrent_access();
void test_furi_pubsub();
void test_furi_memmgr();
static int foo = 0;
void test_setup(void) {
foo = 7;
}
void test_teardown(void) {
/* Nothing */
}
MU_TEST(test_check) {
mu_check(foo != 6);
}
// v2 tests
MU_TEST(mu_test_furi_create_open) {
test_furi_create_open();
}
MU_TEST(mu_test_furi_valuemutex) {
test_furi_valuemutex();
}
MU_TEST(mu_test_furi_concurrent_access) {
test_furi_concurrent_access();
}
MU_TEST(mu_test_furi_pubsub) {
test_furi_pubsub();
}
MU_TEST(mu_test_furi_memmgr) {
// this test is not accurate, but gives a basic understanding
// that memory management is working fine
test_furi_memmgr();
}
MU_TEST_SUITE(test_suite) {
MU_SUITE_CONFIGURE(&test_setup, &test_teardown);
MU_RUN_TEST(test_check);
// v2 tests
MU_RUN_TEST(mu_test_furi_create_open);
MU_RUN_TEST(mu_test_furi_valuemutex);
MU_RUN_TEST(mu_test_furi_concurrent_access);
MU_RUN_TEST(mu_test_furi_pubsub);
MU_RUN_TEST(mu_test_furi_memmgr);
}
int run_minunit() {
MU_RUN_SUITE(test_suite);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "minunit.h"
/* Misc. counters */
int minunit_run = 0;
int minunit_assert = 0;
int minunit_fail = 0;
int minunit_status = 0;
/* Timers */
double minunit_real_timer = 0;
double minunit_proc_timer = 0;
/* Last message */
char minunit_last_message[MINUNIT_MESSAGE_LEN];

View File

@@ -0,0 +1,15 @@
#pragma once
#include "minunit.h"
/* Misc. counters */
extern int minunit_run;
extern int minunit_assert;
extern int minunit_fail;
extern int minunit_status;
/* Timers */
extern double minunit_real_timer;
extern double minunit_proc_timer;
/* Last message */
extern char minunit_last_message[MINUNIT_MESSAGE_LEN];

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
#include "../minunit.h"
#include <furi.h>
#include <furi_hal_delay.h>
#include <storage/storage.h>
#define STORAGE_LOCKED_FILE "/ext/locked_file.test"
#define STORAGE_LOCKED_DIR "/int"
static void storage_file_open_lock_setup() {
Storage* storage = furi_record_open("storage");
File* file = storage_file_alloc(storage);
storage_simply_remove(storage, STORAGE_LOCKED_FILE);
mu_check(storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_WRITE, FSOM_CREATE_NEW));
mu_check(storage_file_write(file, "0123", 4) == 4);
mu_check(storage_file_close(file));
storage_file_free(file);
furi_record_close("storage");
}
static void storage_file_open_lock_teardown() {
Storage* storage = furi_record_open("storage");
mu_check(storage_simply_remove(storage, STORAGE_LOCKED_FILE));
furi_record_close("storage");
}
static int32_t storage_file_locker(void* ctx) {
Storage* storage = furi_record_open("storage");
osSemaphoreId_t semaphore = ctx;
File* file = storage_file_alloc(storage);
furi_check(storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_READ_WRITE, FSOM_OPEN_EXISTING));
osSemaphoreRelease(semaphore);
furi_hal_delay_ms(1000);
furi_check(storage_file_close(file));
furi_record_close("storage");
storage_file_free(file);
return 0;
}
MU_TEST(storage_file_open_lock) {
Storage* storage = furi_record_open("storage");
bool result = false;
osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL);
File* file = storage_file_alloc(storage);
// file_locker thread start
FuriThread* locker_thread = furi_thread_alloc();
furi_thread_set_name(locker_thread, "StorageFileLocker");
furi_thread_set_stack_size(locker_thread, 2048);
furi_thread_set_context(locker_thread, semaphore);
furi_thread_set_callback(locker_thread, storage_file_locker);
mu_check(furi_thread_start(locker_thread));
// wait for file lock
osSemaphoreAcquire(semaphore, osWaitForever);
osSemaphoreDelete(semaphore);
result = storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_READ_WRITE, FSOM_OPEN_EXISTING);
storage_file_close(file);
// file_locker thread stop
mu_check(furi_thread_join(locker_thread) == osOK);
furi_thread_free(locker_thread);
// clean data
storage_file_free(file);
furi_record_close("storage");
mu_assert(result, "cannot open locked file");
}
MU_TEST(storage_file_open_close) {
Storage* storage = furi_record_open("storage");
File* file;
file = storage_file_alloc(storage);
mu_check(storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_READ_WRITE, FSOM_OPEN_EXISTING));
storage_file_close(file);
storage_file_free(file);
for(size_t i = 0; i < 10; i++) {
file = storage_file_alloc(storage);
mu_check(
storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_READ_WRITE, FSOM_OPEN_EXISTING));
storage_file_free(file);
}
furi_record_close("storage");
}
MU_TEST_SUITE(storage_file) {
storage_file_open_lock_setup();
MU_RUN_TEST(storage_file_open_close);
MU_RUN_TEST(storage_file_open_lock);
storage_file_open_lock_teardown();
}
MU_TEST(storage_dir_open_close) {
Storage* storage = furi_record_open("storage");
File* file;
file = storage_file_alloc(storage);
mu_check(storage_dir_open(file, STORAGE_LOCKED_DIR));
storage_dir_close(file);
storage_file_free(file);
for(size_t i = 0; i < 10; i++) {
file = storage_file_alloc(storage);
mu_check(storage_dir_open(file, STORAGE_LOCKED_DIR));
storage_file_free(file);
}
furi_record_close("storage");
}
static int32_t storage_dir_locker(void* ctx) {
Storage* storage = furi_record_open("storage");
osSemaphoreId_t semaphore = ctx;
File* file = storage_file_alloc(storage);
furi_check(storage_dir_open(file, STORAGE_LOCKED_DIR));
osSemaphoreRelease(semaphore);
furi_hal_delay_ms(1000);
furi_check(storage_dir_close(file));
furi_record_close("storage");
storage_file_free(file);
return 0;
}
MU_TEST(storage_dir_open_lock) {
Storage* storage = furi_record_open("storage");
bool result = false;
osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL);
File* file = storage_file_alloc(storage);
// file_locker thread start
FuriThread* locker_thread = furi_thread_alloc();
furi_thread_set_name(locker_thread, "StorageDirLocker");
furi_thread_set_stack_size(locker_thread, 2048);
furi_thread_set_context(locker_thread, semaphore);
furi_thread_set_callback(locker_thread, storage_dir_locker);
mu_check(furi_thread_start(locker_thread));
// wait for dir lock
osSemaphoreAcquire(semaphore, osWaitForever);
osSemaphoreDelete(semaphore);
result = storage_dir_open(file, STORAGE_LOCKED_DIR);
storage_dir_close(file);
// file_locker thread stop
mu_check(furi_thread_join(locker_thread) == osOK);
furi_thread_free(locker_thread);
// clean data
storage_file_free(file);
furi_record_close("storage");
mu_assert(result, "cannot open locked dir");
}
MU_TEST_SUITE(storage_dir) {
MU_RUN_TEST(storage_dir_open_close);
MU_RUN_TEST(storage_dir_open_lock);
}
int run_minunit_test_storage() {
MU_RUN_SUITE(storage_file);
MU_RUN_SUITE(storage_dir);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,381 @@
#include <furi.h>
#include <toolbox/stream/stream.h>
#include <toolbox/stream/string_stream.h>
#include <toolbox/stream/file_stream.h>
#include <storage/storage.h>
#include "../minunit.h"
static const char* stream_test_data = "I write differently from what I speak, "
"I speak differently from what I think, "
"I think differently from the way I ought to think, "
"and so it all proceeds into deepest darkness.";
static const char* stream_test_left_data = "There are two cardinal human sins ";
static const char* stream_test_right_data =
"from which all others derive: impatience and indolence.";
MU_TEST_1(stream_composite_subtest, Stream* stream) {
const size_t data_size = 128;
uint8_t data[data_size];
string_t string_lee;
string_init_set(string_lee, "lee");
// test that stream is empty
// "" -> ""
mu_check(stream_size(stream) == 0);
mu_check(stream_eof(stream));
mu_check(stream_tell(stream) == 0);
mu_check(stream_read(stream, data, data_size) == 0);
mu_check(stream_eof(stream));
mu_check(stream_tell(stream) == 0);
// write char
// "" -> "2"
mu_check(stream_write_char(stream, '2') == 1);
mu_check(stream_size(stream) == 1);
mu_check(stream_tell(stream) == 1);
mu_check(stream_eof(stream));
// test rewind and eof
stream_rewind(stream);
mu_check(stream_size(stream) == 1);
mu_check(stream_tell(stream) == 0);
mu_check(!stream_eof(stream));
// add another char with replacement
// "2" -> "1"
mu_check(stream_write_char(stream, '1') == 1);
mu_check(stream_size(stream) == 1);
mu_check(stream_tell(stream) == 1);
mu_check(stream_eof(stream));
// write string
// "1" -> "1337_69"
mu_check(stream_write_cstring(stream, "337_69") == 6);
mu_check(stream_size(stream) == 7);
mu_check(stream_tell(stream) == 7);
mu_check(stream_eof(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_check(stream_read(stream, data, data_size) == 7);
mu_check(strcmp((char*)data, "1337_69") == 0);
// test misc seeks
mu_check(stream_seek(stream, 2, StreamOffsetFromStart));
mu_check(stream_tell(stream) == 2);
mu_check(!stream_seek(stream, 9000, StreamOffsetFromStart));
mu_check(stream_tell(stream) == 7);
mu_check(stream_eof(stream));
mu_check(stream_seek(stream, -3, StreamOffsetFromEnd));
mu_check(stream_tell(stream) == 4);
// write string with replacemet
// "1337_69" -> "1337lee"
mu_check(stream_write_string(stream, string_lee) == 3);
mu_check(stream_size(stream) == 7);
mu_check(stream_tell(stream) == 7);
mu_check(stream_eof(stream));
// append char
// "1337lee" -> "1337leet"
mu_check(stream_write(stream, (uint8_t*)"t", 1) == 1);
mu_check(stream_size(stream) == 8);
mu_check(stream_tell(stream) == 8);
mu_check(stream_eof(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_check(stream_read(stream, data, data_size) == 8);
mu_check(strcmp((char*)data, "1337leet") == 0);
mu_check(stream_tell(stream) == 8);
mu_check(stream_eof(stream));
// negative seek from current position -> clamp to 0
mu_check(!stream_seek(stream, -9000, StreamOffsetFromCurrent));
mu_check(stream_tell(stream) == 0);
// negative seek from start position -> clamp to 0
stream_rewind(stream);
mu_check(!stream_seek(stream, -3, StreamOffsetFromStart));
mu_check(stream_tell(stream) == 0);
// zero seek from current position -> clamp to stream size
mu_check(stream_seek(stream, 0, StreamOffsetFromEnd));
mu_check(stream_tell(stream) == 8);
// negative seek from end position -> clamp to 0
mu_check(!stream_seek(stream, -9000, StreamOffsetFromEnd));
mu_check(stream_tell(stream) == 0);
// clean stream
stream_clean(stream);
mu_check(stream_size(stream) == 0);
mu_check(stream_eof(stream));
mu_check(stream_tell(stream) == 0);
// write format
// "" -> "dio666"
mu_check(stream_write_format(stream, "%s%d", "dio", 666) == 6);
mu_check(stream_size(stream) == 6);
mu_check(stream_eof(stream));
mu_check(stream_tell(stream) == 6);
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_check(stream_read(stream, data, data_size) == 6);
mu_check(strcmp((char*)data, "dio666") == 0);
// clean and write cstring
// "dio666" -> "" -> "1234567890"
stream_clean(stream);
mu_check(stream_write_cstring(stream, "1234567890") == 10);
// delete 4 bytes from 1 pos
// "1xxxx67890" -> "167890"
mu_check(stream_seek(stream, 1, StreamOffsetFromStart));
mu_check(stream_delete(stream, 4));
mu_assert_int_eq(6, stream_size(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_assert_int_eq(6, stream_read(stream, data, data_size));
mu_check(strcmp((char*)data, "167890") == 0);
// write cstring
// "167890" -> "167890It Was Me, Dio!"
mu_check(stream_write_cstring(stream, "It Was Me, Dio!") == 15);
// delete 1337 bytes from 1 pos
// and check that we can delete only 20 bytes
// "1xxxxxxxxxxxxxxxxxxxx" -> "1"
mu_check(stream_seek(stream, 1, StreamOffsetFromStart));
mu_check(stream_delete(stream, 1337));
mu_assert_int_eq(1, stream_size(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_check(stream_read(stream, data, data_size) == 1);
mu_check(strcmp((char*)data, "1") == 0);
// write cstring from 0 pos, replacing 1 byte
// "1" -> "Oh? You're roaching me?"
mu_check(stream_rewind(stream));
mu_assert_int_eq(23, stream_write_cstring(stream, "Oh? You're roaching me?"));
// insert 11 bytes to 0 pos
// "Oh? You're roaching me?" -> "Za Warudo! Oh? You're roaching me?"
mu_check(stream_rewind(stream));
mu_check(stream_insert(stream, (uint8_t*)"Za Warudo! ", 11));
mu_assert_int_eq(34, stream_size(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_assert_int_eq(34, stream_read(stream, data, data_size));
mu_assert_string_eq("Za Warudo! Oh? You're roaching me?", (char*)data);
// insert cstring to 22 pos
// "Za Warudo! Oh? You're roaching me?" -> "Za Warudo! Oh? You're approaching me?"
mu_check(stream_seek(stream, 22, StreamOffsetFromStart));
mu_check(stream_insert_cstring(stream, "app"));
mu_assert_int_eq(37, stream_size(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_assert_int_eq(37, stream_read(stream, data, data_size));
mu_assert_string_eq("Za Warudo! Oh? You're approaching me?", (char*)data);
// insert cstring to the end of the stream
// "Za Warudo! Oh? You're approaching me?" -> "Za Warudo! Oh? You're approaching me? It was me, Dio!"
mu_check(stream_seek(stream, 0, StreamOffsetFromEnd));
mu_check(stream_insert_cstring(stream, " It was me, Dio!"));
mu_assert_int_eq(53, stream_size(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_assert_int_eq(53, stream_read(stream, data, data_size));
mu_assert_string_eq("Za Warudo! Oh? You're approaching me? It was me, Dio!", (char*)data);
// delete 168430090 bytes from stream
// and test that we can delete only 53
mu_check(stream_rewind(stream));
mu_check(stream_delete(stream, 0x0A0A0A0A));
mu_assert_int_eq(0, stream_size(stream));
mu_check(stream_eof(stream));
mu_assert_int_eq(0, stream_tell(stream));
// clean stream
stream_clean(stream);
mu_assert_int_eq(0, stream_size(stream));
mu_check(stream_eof(stream));
mu_assert_int_eq(0, stream_tell(stream));
// insert formated string at the end of stream
// "" -> "dio666"
mu_check(stream_insert_format(stream, "%s%d", "dio", 666));
mu_assert_int_eq(6, stream_size(stream));
mu_check(stream_eof(stream));
mu_assert_int_eq(6, stream_tell(stream));
// insert formated string at the end of stream
// "dio666" -> "dio666zlo555"
mu_check(stream_insert_format(stream, "%s%d", "zlo", 555));
mu_assert_int_eq(12, stream_size(stream));
mu_check(stream_eof(stream));
mu_assert_int_eq(12, stream_tell(stream));
// insert formated string at the 6 pos
// "dio666" -> "dio666baba13zlo555"
mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
mu_check(stream_insert_format(stream, "%s%d", "baba", 13));
mu_assert_int_eq(18, stream_size(stream));
mu_assert_int_eq(12, stream_tell(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_assert_int_eq(18, stream_read(stream, data, data_size));
mu_assert_string_eq("dio666baba13zlo555", (char*)data);
// delete 6 chars from pos 6 and insert 1 chars
// "dio666baba13zlo555" -> "dio666xzlo555"
mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
mu_check(stream_delete_and_insert_char(stream, 6, 'x'));
mu_assert_int_eq(13, stream_size(stream));
mu_assert_int_eq(7, stream_tell(stream));
// read data
memset(data, 0, data_size);
stream_rewind(stream);
mu_check(stream_read(stream, data, data_size) == 13);
mu_assert_string_eq("dio666xzlo555", (char*)data);
// delete 9000 chars from pos 6 and insert 3 chars from string
// "dio666xzlo555" -> "dio666777"
mu_check(stream_seek(stream, 6, StreamOffsetFromStart));
mu_check(stream_delete_and_insert_cstring(stream, 9000, "777"));
mu_assert_int_eq(9, stream_size(stream));
mu_assert_int_eq(9, stream_tell(stream));
mu_check(stream_eof(stream));
string_clear(string_lee);
}
MU_TEST(stream_composite_test) {
// test string stream
Stream* stream;
stream = string_stream_alloc();
MU_RUN_TEST_1(stream_composite_subtest, stream);
stream_free(stream);
// test file stream
Storage* storage = furi_record_open("storage");
stream = file_stream_alloc(storage);
mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
MU_RUN_TEST_1(stream_composite_subtest, stream);
stream_free(stream);
furi_record_close("storage");
}
MU_TEST_1(stream_write_subtest, Stream* stream) {
mu_assert_int_eq(strlen(stream_test_data), stream_write_cstring(stream, stream_test_data));
}
MU_TEST_1(stream_read_subtest, Stream* stream) {
uint8_t data[256] = {0};
mu_check(stream_rewind(stream));
mu_assert_int_eq(strlen(stream_test_data), stream_read(stream, data, 256));
mu_assert_string_eq(stream_test_data, (const char*)data);
}
MU_TEST(stream_write_read_save_load_test) {
Stream* stream_orig = string_stream_alloc();
Stream* stream_copy = string_stream_alloc();
Storage* storage = furi_record_open("storage");
// write, read
MU_RUN_TEST_1(stream_write_subtest, stream_orig);
MU_RUN_TEST_1(stream_read_subtest, stream_orig);
// copy, read
mu_assert_int_eq(strlen(stream_test_data), stream_copy_full(stream_orig, stream_copy));
MU_RUN_TEST_1(stream_read_subtest, stream_orig);
// save to file
mu_check(stream_seek(stream_orig, 0, StreamOffsetFromStart));
mu_assert_int_eq(
strlen(stream_test_data),
stream_save_to_file(stream_orig, storage, "/ext/filestream.str", FSOM_CREATE_ALWAYS));
stream_free(stream_copy);
stream_free(stream_orig);
// load from file, read
Stream* stream_new = string_stream_alloc();
mu_assert_int_eq(
strlen(stream_test_data),
stream_load_from_file(stream_new, storage, "/ext/filestream.str"));
MU_RUN_TEST_1(stream_read_subtest, stream_new);
stream_free(stream_new);
furi_record_close("storage");
}
MU_TEST_1(stream_split_subtest, Stream* stream) {
stream_clean(stream);
stream_write_cstring(stream, stream_test_left_data);
stream_write_cstring(stream, stream_test_right_data);
Stream* stream_left = string_stream_alloc();
Stream* stream_right = string_stream_alloc();
mu_check(stream_seek(stream, strlen(stream_test_left_data), StreamOffsetFromStart));
mu_check(stream_split(stream, stream_left, stream_right));
uint8_t data[256] = {0};
mu_check(stream_rewind(stream_left));
mu_assert_int_eq(strlen(stream_test_left_data), stream_read(stream_left, data, 256));
mu_assert_string_eq(stream_test_left_data, (const char*)data);
mu_check(stream_rewind(stream_right));
mu_assert_int_eq(strlen(stream_test_right_data), stream_read(stream_right, data, 256));
mu_assert_string_eq(stream_test_right_data, (const char*)data);
stream_free(stream_right);
stream_free(stream_left);
}
MU_TEST(stream_split_test) {
// test string stream
Stream* stream;
stream = string_stream_alloc();
MU_RUN_TEST_1(stream_split_subtest, stream);
stream_free(stream);
// test file stream
Storage* storage = furi_record_open("storage");
stream = file_stream_alloc(storage);
mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
MU_RUN_TEST_1(stream_split_subtest, stream);
stream_free(stream);
furi_record_close("storage");
}
MU_TEST_SUITE(stream_suite) {
MU_RUN_TEST(stream_write_read_save_load_test);
MU_RUN_TEST(stream_composite_test);
MU_RUN_TEST(stream_split_test);
}
int run_minunit_test_stream() {
MU_RUN_SUITE(stream_suite);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,404 @@
#include <furi.h>
#include <furi_hal.h>
#include "../minunit.h"
#include <lib/subghz/receiver.h>
#include <lib/subghz/transmitter.h>
#include <lib/subghz/subghz_keystore.h>
#include <lib/subghz/subghz_file_encoder_worker.h>
#include <lib/subghz/protocols/registry.h>
#include <flipper_format/flipper_format_i.h>
#define TAG "SubGhz TEST"
#define KEYSTORE_DIR_NAME "/ext/subghz/assets/keeloq_mfcodes"
#define CAME_ATOMO_DIR_NAME "/ext/subghz/assets/came_atomo"
#define NICE_FLOR_S_DIR_NAME "/ext/subghz/assets/nice_flor_s"
#define TEST_RANDOM_DIR_NAME "/ext/unit_tests/subghz/test_random_raw.sub"
#define TEST_RANDOM_COUNT_PARSE 101
#define TEST_TIMEOUT 10000
static SubGhzEnvironment* environment_handler;
static SubGhzReceiver* receiver_handler;
//static SubGhzTransmitter* transmitter_handler;
static SubGhzFileEncoderWorker* file_worker_encoder_handler;
static uint16_t subghz_test_decoder_count = 0;
static void subghz_test_rx_callback(
SubGhzReceiver* receiver,
SubGhzProtocolDecoderBase* decoder_base,
void* context) {
string_t text;
string_init(text);
subghz_protocol_decoder_base_get_string(decoder_base, text);
FURI_LOG_I(TAG, "\r\n%s", string_get_cstr(text));
string_clear(text);
subghz_test_decoder_count++;
}
static void subghz_test_init(void) {
environment_handler = subghz_environment_alloc();
subghz_environment_set_came_atomo_rainbow_table_file_name(
environment_handler, CAME_ATOMO_DIR_NAME);
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment_handler, NICE_FLOR_S_DIR_NAME);
receiver_handler = subghz_receiver_alloc_init(environment_handler);
subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable);
subghz_receiver_set_rx_callback(receiver_handler, subghz_test_rx_callback, NULL);
}
static void subghz_test_deinit(void) {
subghz_receiver_free(receiver_handler);
subghz_environment_free(environment_handler);
}
static bool subghz_decode_test(const char* path, const char* name_decoder) {
subghz_test_decoder_count = 0;
uint32_t test_start = furi_hal_get_tick();
SubGhzProtocolDecoderBase* decoder =
subghz_receiver_search_decoder_base_by_name(receiver_handler, name_decoder);
if(decoder) {
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
//the worker needs a file in order to open and read part of the file
osDelay(100);
LevelDuration level_duration;
while(furi_hal_get_tick() - test_start < TEST_TIMEOUT) {
furi_hal_delay_us(
500); //you need to have time to read from the file from the SD card
level_duration =
subghz_file_encoder_worker_get_level_duration(file_worker_encoder_handler);
if(!level_duration_is_reset(level_duration)) {
bool level = level_duration_get_level(level_duration);
uint32_t duration = level_duration_get_duration(level_duration);
decoder->protocol->decoder->feed(decoder, level, duration);
} else {
break;
}
}
furi_hal_delay_ms(10);
}
if(subghz_file_encoder_worker_is_running(file_worker_encoder_handler)) {
subghz_file_encoder_worker_stop(file_worker_encoder_handler);
}
subghz_file_encoder_worker_free(file_worker_encoder_handler);
}
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT) {
printf("\033[0;31mTest decoder %s ERROR TimeOut\033[0m\r\n", name_decoder);
return false;
} else {
return subghz_test_decoder_count ? true : false;
}
}
static bool subghz_decode_ramdom_test(const char* path) {
subghz_test_decoder_count = 0;
subghz_receiver_reset(receiver_handler);
uint32_t test_start = furi_hal_get_tick();
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
//the worker needs a file in order to open and read part of the file
osDelay(100);
LevelDuration level_duration;
while(furi_hal_get_tick() - test_start < TEST_TIMEOUT * 10) {
furi_hal_delay_us(500); //you need to have time to read from the file from the SD card
level_duration =
subghz_file_encoder_worker_get_level_duration(file_worker_encoder_handler);
if(!level_duration_is_reset(level_duration)) {
bool level = level_duration_get_level(level_duration);
uint32_t duration = level_duration_get_duration(level_duration);
subghz_receiver_decode(receiver_handler, level, duration);
} else {
break;
}
}
furi_hal_delay_ms(10);
if(subghz_file_encoder_worker_is_running(file_worker_encoder_handler)) {
subghz_file_encoder_worker_stop(file_worker_encoder_handler);
}
subghz_file_encoder_worker_free(file_worker_encoder_handler);
}
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT * 10) {
printf("\033[0;31mRandom test ERROR TimeOut\033[0m\r\n");
return false;
} else if(subghz_test_decoder_count == TEST_RANDOM_COUNT_PARSE) {
return true;
} else {
return false;
}
}
static bool subghz_ecode_test(const char* path) {
subghz_test_decoder_count = 0;
uint32_t test_start = furi_hal_get_tick();
string_t temp_str;
string_init(temp_str);
bool file_load = false;
Storage* storage = furi_record_open("storage");
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
do {
if(!flipper_format_file_open_existing(fff_data_file, path)) {
FURI_LOG_E(TAG, "Error open file %s", path);
break;
}
if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) {
FURI_LOG_E(TAG, "Missing Preset");
break;
}
if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) {
FURI_LOG_E(TAG, "Missing Protocol");
break;
}
file_load = true;
} while(false);
if(file_load) {
SubGhzTransmitter* transmitter =
subghz_transmitter_alloc_init(environment_handler, string_get_cstr(temp_str));
subghz_transmitter_deserialize(transmitter, fff_data_file);
SubGhzProtocolDecoderBase* decoder = subghz_receiver_search_decoder_base_by_name(
receiver_handler, string_get_cstr(temp_str));
if(decoder) {
LevelDuration level_duration;
while(furi_hal_get_tick() - test_start < TEST_TIMEOUT) {
level_duration = subghz_transmitter_yield(transmitter);
if(!level_duration_is_reset(level_duration)) {
bool level = level_duration_get_level(level_duration);
uint32_t duration = level_duration_get_duration(level_duration);
decoder->protocol->decoder->feed(decoder, level, duration);
} else {
break;
}
}
furi_hal_delay_ms(10);
}
subghz_transmitter_free(transmitter);
}
flipper_format_free(fff_data_file);
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT) {
printf("\033[0;31mTest encoder %s ERROR TimeOut\033[0m\r\n", string_get_cstr(temp_str));
subghz_test_decoder_count = 0;
}
string_clear(temp_str);
return subghz_test_decoder_count ? true : false;
}
MU_TEST(subghz_keystore_test) {
mu_assert(
subghz_environment_load_keystore(environment_handler, KEYSTORE_DIR_NAME),
"Test keystore error");
}
MU_TEST(subghz_decoder_came_atomo_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/came_atomo_raw.sub", SUBGHZ_PROTOCOL_CAME_ATOMO_NAME),
"Test decoder " SUBGHZ_PROTOCOL_CAME_ATOMO_NAME " error\r\n");
}
MU_TEST(subghz_decoder_came_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/came_raw.sub", SUBGHZ_PROTOCOL_CAME_NAME),
"Test decoder " SUBGHZ_PROTOCOL_CAME_NAME " error\r\n");
}
MU_TEST(subghz_decoder_came_twee_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/came_twee_raw.sub", SUBGHZ_PROTOCOL_CAME_TWEE_NAME),
"Test decoder " SUBGHZ_PROTOCOL_CAME_TWEE_NAME " error\r\n");
}
MU_TEST(subghz_decoder_faac_slh_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/faac_slh_raw.sub", SUBGHZ_PROTOCOL_FAAC_SLH_NAME),
"Test decoder " SUBGHZ_PROTOCOL_FAAC_SLH_NAME " error\r\n");
}
MU_TEST(subghz_decoder_gate_tx_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/gate_tx_raw.sub", SUBGHZ_PROTOCOL_GATE_TX_NAME),
"Test decoder " SUBGHZ_PROTOCOL_GATE_TX_NAME " error\r\n");
}
MU_TEST(subghz_decoder_hormann_hsm_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/hormann_hsm_raw.sub", SUBGHZ_PROTOCOL_HORMANN_HSM_NAME),
"Test decoder " SUBGHZ_PROTOCOL_HORMANN_HSM_NAME " error\r\n");
}
MU_TEST(subghz_decoder_ido_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/ido_117_111_raw.sub", SUBGHZ_PROTOCOL_IDO_NAME),
"Test decoder " SUBGHZ_PROTOCOL_IDO_NAME " error\r\n");
}
MU_TEST(subghz_decoder_keelog_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/doorhan_raw.sub", SUBGHZ_PROTOCOL_KEELOQ_NAME),
"Test decoder " SUBGHZ_PROTOCOL_KEELOQ_NAME " error\r\n");
}
MU_TEST(subghz_decoder_kia_seed_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/kia_seed_raw.sub", SUBGHZ_PROTOCOL_KIA_NAME),
"Test decoder " SUBGHZ_PROTOCOL_KIA_NAME " error\r\n");
}
MU_TEST(subghz_decoder_nero_radio_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/nero_radio_raw.sub", SUBGHZ_PROTOCOL_NERO_RADIO_NAME),
"Test decoder " SUBGHZ_PROTOCOL_NERO_RADIO_NAME " error\r\n");
}
MU_TEST(subghz_decoder_nero_sketch_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/nero_sketch_raw.sub", SUBGHZ_PROTOCOL_NERO_SKETCH_NAME),
"Test decoder " SUBGHZ_PROTOCOL_NERO_SKETCH_NAME " error\r\n");
}
MU_TEST(subghz_decoder_nice_flo_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/nice_flo_raw.sub", SUBGHZ_PROTOCOL_NICE_FLO_NAME),
"Test decoder " SUBGHZ_PROTOCOL_NICE_FLO_NAME " error\r\n");
}
MU_TEST(subghz_decoder_nice_flor_s_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/nice_flor_s_raw.sub", SUBGHZ_PROTOCOL_NICE_FLOR_S_NAME),
"Test decoder " SUBGHZ_PROTOCOL_NICE_FLOR_S_NAME " error\r\n");
}
MU_TEST(subghz_decoder_princeton_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/Princeton_raw.sub", SUBGHZ_PROTOCOL_PRINCETON_NAME),
"Test decoder " SUBGHZ_PROTOCOL_PRINCETON_NAME " error\r\n");
}
MU_TEST(subghz_decoder_scher_khan_magic_code_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/scher_khan_magic_code.sub", SUBGHZ_PROTOCOL_SCHER_KHAN_NAME),
"Test decoder " SUBGHZ_PROTOCOL_SCHER_KHAN_NAME " error\r\n");
}
MU_TEST(subghz_decoder_somfy_keytis_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/Somfy_keytis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_KEYTIS_NAME),
"Test decoder " SUBGHZ_PROTOCOL_SOMFY_KEYTIS_NAME " error\r\n");
}
MU_TEST(subghz_decoder_somfy_telis_test) {
mu_assert(
subghz_decode_test(
"/ext/unit_tests/subghz/somfy_telis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_TELIS_NAME),
"Test decoder " SUBGHZ_PROTOCOL_SOMFY_TELIS_NAME " error\r\n");
}
MU_TEST(subghz_decoder_star_line_test) {
mu_assert(
subghz_decode_test("/ext/unit_tests/subghz/cenmax_raw.sub", SUBGHZ_PROTOCOL_STAR_LINE_NAME),
"Test decoder " SUBGHZ_PROTOCOL_STAR_LINE_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_princeton_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/princeton.sub"),
"Test encoder " SUBGHZ_PROTOCOL_PRINCETON_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_came_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/came.sub"),
"Test encoder " SUBGHZ_PROTOCOL_CAME_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_came_twee_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/came_twee.sub"),
"Test encoder " SUBGHZ_PROTOCOL_CAME_TWEE_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_gate_tx_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/gate_tx.sub"),
"Test encoder " SUBGHZ_PROTOCOL_GATE_TX_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_nice_flo_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/nice_flo.sub"),
"Test encoder " SUBGHZ_PROTOCOL_NICE_FLO_NAME " error\r\n");
}
MU_TEST(subghz_ecoder_keelog_test) {
mu_assert(
subghz_ecode_test("/ext/unit_tests/subghz/doorhan.sub"),
"Test encoder " SUBGHZ_PROTOCOL_KEELOQ_NAME " error\r\n");
}
MU_TEST(subghz_random_test) {
mu_assert(subghz_decode_ramdom_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n");
}
MU_TEST_SUITE(subghz) {
//MU_SUITE_CONFIGURE(&subghz_test_init, &subghz_test_deinit);
subghz_test_init();
MU_RUN_TEST(subghz_keystore_test);
MU_RUN_TEST(subghz_decoder_came_atomo_test);
MU_RUN_TEST(subghz_decoder_came_test);
MU_RUN_TEST(subghz_decoder_came_twee_test);
MU_RUN_TEST(subghz_decoder_faac_slh_test);
MU_RUN_TEST(subghz_decoder_gate_tx_test);
MU_RUN_TEST(subghz_decoder_hormann_hsm_test);
MU_RUN_TEST(subghz_decoder_ido_test);
MU_RUN_TEST(subghz_decoder_keelog_test);
MU_RUN_TEST(subghz_decoder_kia_seed_test);
MU_RUN_TEST(subghz_decoder_nero_radio_test);
MU_RUN_TEST(subghz_decoder_nero_sketch_test);
MU_RUN_TEST(subghz_decoder_nice_flo_test);
MU_RUN_TEST(subghz_decoder_nice_flor_s_test);
MU_RUN_TEST(subghz_decoder_princeton_test);
MU_RUN_TEST(subghz_decoder_scher_khan_magic_code_test);
MU_RUN_TEST(subghz_decoder_somfy_keytis_test);
MU_RUN_TEST(subghz_decoder_somfy_telis_test);
MU_RUN_TEST(subghz_decoder_star_line_test);
MU_RUN_TEST(subghz_ecoder_princeton_test);
MU_RUN_TEST(subghz_ecoder_came_test);
MU_RUN_TEST(subghz_ecoder_came_twee_test);
MU_RUN_TEST(subghz_ecoder_gate_tx_test);
MU_RUN_TEST(subghz_ecoder_nice_flo_test);
MU_RUN_TEST(subghz_ecoder_keelog_test);
MU_RUN_TEST(subghz_random_test);
subghz_test_deinit();
}
int run_minunit_test_subghz() {
MU_RUN_SUITE(subghz);
return MU_EXIT_CODE;
}

View File

@@ -0,0 +1,98 @@
#include "m-string.h"
#include <stdio.h>
#include <furi.h>
#include <furi_hal.h>
#include "minunit_vars.h"
#include <notification/notification_messages.h>
#include <cli/cli.h>
#include <loader/loader.h>
#define TAG "UnitTests"
int run_minunit();
int run_minunit_test_infrared_decoder_encoder();
int run_minunit_test_rpc();
int run_minunit_test_flipper_format();
int run_minunit_test_flipper_format_string();
int run_minunit_test_stream();
int run_minunit_test_storage();
int run_minunit_test_subghz();
void minunit_print_progress(void) {
static char progress[] = {'\\', '|', '/', '-'};
static uint8_t progress_counter = 0;
static TickType_t last_tick = 0;
TickType_t current_tick = xTaskGetTickCount();
if(current_tick - last_tick > 20) {
last_tick = current_tick;
printf("[%c]\033[3D", progress[++progress_counter % COUNT_OF(progress)]);
}
}
void minunit_print_fail(const char* str) {
printf(FURI_LOG_CLR_E "%s\n" FURI_LOG_CLR_RESET, str);
}
void unit_tests_cli(Cli* cli, string_t args, void* context) {
uint32_t test_result = 0;
minunit_run = 0;
minunit_assert = 0;
minunit_fail = 0;
minunit_status = 0;
Loader* loader = furi_record_open("loader");
NotificationApp* notification = furi_record_open("notification");
// TODO: lock device while test running
if(loader_is_locked(loader)) {
FURI_LOG_E(TAG, "RPC: stop all applications to run tests");
notification_message(notification, &sequence_blink_magenta_100);
} else {
notification_message_block(notification, &sequence_set_only_blue_255);
uint32_t heap_before = memmgr_get_free_heap();
uint32_t cycle_counter = furi_hal_get_tick();
test_result |= run_minunit();
test_result |= run_minunit_test_storage();
test_result |= run_minunit_test_stream();
test_result |= run_minunit_test_flipper_format();
test_result |= run_minunit_test_flipper_format_string();
test_result |= run_minunit_test_infrared_decoder_encoder();
test_result |= run_minunit_test_rpc();
test_result |= run_minunit_test_subghz();
cycle_counter = (furi_hal_get_tick() - cycle_counter);
FURI_LOG_I(TAG, "Consumed: %0.2fs", (float)cycle_counter / 1000);
if(test_result == 0) {
furi_hal_delay_ms(200); /* wait for tested services and apps to deallocate */
uint32_t heap_after = memmgr_get_free_heap();
notification_message(notification, &sequence_success);
if(heap_after != heap_before) {
FURI_LOG_E(TAG, "Leaked: %d", heap_before - heap_after);
} else {
FURI_LOG_I(TAG, "No leaks");
}
FURI_LOG_I(TAG, "PASSED");
} else {
notification_message(notification, &sequence_error);
FURI_LOG_E(TAG, "FAILED");
}
}
furi_record_close("notification");
furi_record_close("loader");
}
void unit_tests_on_system_start() {
#ifdef SRV_CLI
Cli* cli = furi_record_open("cli");
// We need to launch apps from tests, so we cannot lock loader
cli_add_command(cli, "unit_tests", CliCommandFlagParallelSafe, unit_tests_cli, NULL);
furi_record_close("cli");
#endif
}