-
Notifications
You must be signed in to change notification settings - Fork 15
/
capi_test.c
35 lines (28 loc) · 1.04 KB
/
capi_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "api.hpp"
void err(bool condition, const char* msg) {
if(condition) {
fprintf(stderr, "%s\n", msg);
exit(1);
}
}
int main(int argc, char** argv) {
mat_t* result = NULL;
const char* table = "test.biom";
const char* tree = "test.tre";
const char* method = "unweighted";
double exp[] = {0.2, 0.57142857, 0.6, 0.5, 0.2, 0.42857143, 0.66666667, 0.6, 0.33333333, 0.71428571, 0.85714286, 0.42857143, 0.33333333, 0.4, 0.6};
ComputeStatus status;
status = one_off(table, tree, method,
false, 1.0, 2, &result);
err(status != okay, "Compute failed");
err(result == NULL, "Empty result");
err(result->n_samples != 6, "Wrong number of samples");
err(result->cf_size != 15, "Wrong condensed form size");
err(!result->is_square, "Result is not squaure");
for(unsigned int i = 0; i < result->cf_size; i++)
err(fabs(exp[i] - result->condensed_form[i]) > 0.00001, "Result is wrong");
return 0;
}