summaryrefslogtreecommitdiffstats
path: root/test/kvo.c
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-07-01 09:42:39 +0400
committerEthan Werner <mail@ethanwerner.com>2026-07-01 09:42:39 +0400
commit07e18043145f3d91c8ea7ec3ad41b3c905585277 (patch)
tree2bdeae46973f4bdfce263679a4008ac768011f28 /test/kvo.c
initial commit: ts time series analysis library v0.1.0
- 354 financial and mathematical time-series indicators - Uniform C11 API with consistent function signatures - 349 passing tests with -Werror - Static and shared library builds - pkg-config integration - Python bindings - Fuzzing and sanitizer support - Security hardening flags
Diffstat (limited to 'test/kvo.c')
-rw-r--r--test/kvo.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/kvo.c b/test/kvo.c
new file mode 100644
index 0000000..c0f489f
--- /dev/null
+++ b/test/kvo.c
@@ -0,0 +1,40 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_kvo( void )
+{
+ uint_t k1 = 3;
+ uint_t k2 = 3;
+
+ fp_t const o[] = { 10, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16 };
+ fp_t const h[] = { 12, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18 };
+ fp_t const l[] = { 8, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14 };
+ fp_t const c[] = { 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18 };
+ fp_t const v[] = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500 };
+
+ fp_t const * const x[] = { o, h, l, c, v };
+
+ fp_t e_kvo[5] = {
+ 1.0,
+ -0.044715,
+ 0.542893,
+ -0.323870,
+ 0.444411
+ };
+
+ fp_t e_sig[5] = {
+ 1.0,
+ 0.477642,
+ 0.510268,
+ 0.093199,
+ 0.268805
+ };
+
+ fp_t const * const exp[2] = { e_kvo, e_sig };
+
+ typedef struct { uint_t k1; fp_t k2; } c_t;
+ c_t cv = { .k1 = k1, .k2 = (fp_t)k2 };
+
+ return ts_test(ts_kvo, ts_kvo_offset, x, exp, 15, (ts_constant_t *)&cv, &ts_kvo_p);
+}