Files

42 lines
1.1 KiB
C

/* Public API / session tests (no-libusb build path). */
#include "mag160c/mag160c.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
int main(void) {
assert(mag160c_init(NULL) == MAG160C_ERR_INVALID_ARGUMENT);
mag160c_ctx_t *ctx = NULL;
assert(mag160c_init(&ctx) == MAG160C_OK);
assert(ctx != NULL);
mag160c_ir_t *ir = NULL;
mag160c_error_t rc = mag160c_ir_open(ctx, &ir);
#if !MAG160C_HAS_LIBUSB
assert(rc == MAG160C_ERR_NOT_SUPPORTED);
assert(strstr(mag160c_last_error(), "libusb") != NULL);
#else
if (rc == MAG160C_OK) {
assert(ir != NULL);
mag160c_ir_info_t info;
assert(mag160c_ir_get_info(ir, &info) == MAG160C_OK);
assert(info.width == 160 || info.width != 0);
mag160c_ir_close(ir);
}
#endif
mag160c_shutdown(ctx);
/* pure helpers must work regardless of transport */
uint8_t out[64];
size_t size = 0;
assert(mag160c_tcm_rotate(5, out, sizeof(out), &size) == MAG160C_OK);
assert(size == 11);
printf("test_api: all passed\n");
return 0;
}