Files
MAG160C/analysis/legacy-cpp/tests/cpp/test_ir_skeleton.cpp
T

47 lines
1.5 KiB
C++

#include "mag160c/mag160c.h"
#include <cassert>
#include <cstring>
int main() {
assert(mag160c_ir_open_first(nullptr, nullptr) == MAG160C_ERR_INVALID_ARGUMENT);
assert(std::strstr(mag160c_last_error(), "ctx") != nullptr);
mag160c_ir_close(nullptr);
assert(mag160c_ir_get_info(nullptr, nullptr) == MAG160C_ERR_INVALID_ARGUMENT);
assert(std::strstr(mag160c_last_error(), "device") != nullptr);
mag160c_context_t* ctx = nullptr;
assert(mag160c_init(&ctx) == MAG160C_OK);
mag160c_ir_device_t* ir = nullptr;
assert(mag160c_ir_open_first(ctx, &ir) == MAG160C_OK);
assert(ir != nullptr);
mag160c_ir_info_t info{};
assert(mag160c_ir_get_info(ir, &info) == MAG160C_OK);
assert(info.width == 160);
assert(info.height == 120);
assert(info.output_width == 160);
assert(info.output_height == 120);
assert(info.max_fps == 25);
assert(info.current_fps == 0);
assert(std::strcmp(info.name, "MAG160C") == 0);
assert(std::strcmp(info.type, "vendor-bulk-ir") == 0);
assert(mag160c_ir_trigger_ffc(ir) == MAG160C_ERR_UNSUPPORTED);
assert(std::strstr(mag160c_last_error(), "0x6bb6b672") != nullptr);
assert(std::strstr(mag160c_last_error(), "0x03") != nullptr);
size_t raw_size = 123;
assert(mag160c_ir_read_raw_once(ir, nullptr, 0, &raw_size, 100) ==
MAG160C_ERR_UNSUPPORTED);
assert(raw_size == 0);
assert(std::strstr(mag160c_last_error(), "0x1bb1b11b") != nullptr);
mag160c_ir_close(ir);
mag160c_shutdown(ctx);
return 0;
}