summaryrefslogtreecommitdiffstats
path: root/test/missing_bar_count.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/missing_bar_count.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/missing_bar_count.c')
-rw-r--r--test/missing_bar_count.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/missing_bar_count.c b/test/missing_bar_count.c
new file mode 100644
index 0000000..e15e634
--- /dev/null
+++ b/test/missing_bar_count.c
@@ -0,0 +1,28 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_missing_bar_count( void )
+{
+ fp_t threshold = 0.5;
+
+ fp_t const x[] = { 10, 10.1, 10.2, 10.1, 11, 11.1, 11.2, 11.3, 12.5, 12.6 };
+
+ fp_t const * const inp[1] = { x };
+
+ /* i=0: 0
+ * i=1: |10.1-10|=0.1 < 0.5, count=1
+ * i=2: |10.2-10.1|=0.1 < 0.5, count=2
+ * i=3: |10.1-10.2|=0.1 < 0.5, count=3
+ * i=4: |11-10.1|=0.9 >= 0.5, count=0
+ * i=5: |11.1-11|=0.1 < 0.5, count=1
+ * i=6: |11.2-11.1|=0.1 < 0.5, count=2
+ * i=7: |11.3-11.2|=0.1 < 0.5, count=3
+ * i=8: |12.5-11.3|=1.2 >= 0.5, count=0
+ * i=9: |12.6-12.5|=0.1 < 0.5, count=1
+ */
+ fp_t const e[] = { 0, 1, 2, 3, 0, 1, 2, 3, 0, 1 };
+ fp_t const * const exp[1] = { e };
+
+ return ts_test(ts_missing_bar_count, ts_missing_bar_count_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&threshold, &ts_missing_bar_count_p);
+}