Initial commit.
This commit is contained in:
commit
1d8f869b5b
39 changed files with 1671 additions and 0 deletions
43
tests/unit/test_core.c
Normal file
43
tests/unit/test_core.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include "xtlite/xtlite.h"
|
||||
#include "xtlite/xtlite_engine.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define CHECK(condition) do { \
|
||||
if (!(condition)) { \
|
||||
(void)fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #condition); \
|
||||
return 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
xt_app *app = NULL;
|
||||
xt_graph *graph = NULL;
|
||||
size_t node_a = 0U;
|
||||
size_t node_b = 0U;
|
||||
float input[4] = {1.0f, -1.0f, 0.5f, 0.0f};
|
||||
float output[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
CHECK(xt_app_create(&app) == XT_OK);
|
||||
CHECK(app != NULL);
|
||||
xt_app_destroy(app);
|
||||
|
||||
CHECK(xt_graph_create(4U, &graph) == XT_OK);
|
||||
CHECK(xt_graph_add_gain(graph, 0.5f, &node_a) == XT_OK);
|
||||
CHECK(xt_graph_add_gain(graph, 2.0f, &node_b) == XT_OK);
|
||||
CHECK(xt_graph_connect(graph, node_a, node_b) == XT_OK);
|
||||
CHECK(xt_graph_validate(graph) == XT_OK);
|
||||
CHECK(xt_graph_process_offline(graph, input, output, 4U, 1.0f) == XT_OK);
|
||||
CHECK(fabsf(output[0] - 1.0f) < 0.0001f);
|
||||
CHECK(fabsf(output[1] + 1.0f) < 0.0001f);
|
||||
CHECK(fabsf(output[2] - 0.5f) < 0.0001f);
|
||||
|
||||
CHECK(xt_graph_connect(graph, node_b, node_a) == XT_OK);
|
||||
CHECK(xt_graph_validate(graph) == XT_ERR_GRAPH_CYCLE);
|
||||
|
||||
xt_graph_destroy(graph);
|
||||
(void)puts("All xtlite core tests passed.");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue