summaryrefslogtreecommitdiffstats
path: root/test/rank.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/rank.c')
-rw-r--r--test/rank.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/rank.c b/test/rank.c
new file mode 100644
index 0000000..2c96247
--- /dev/null
+++ b/test/rank.c
@@ -0,0 +1,20 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_rank( void )
+{
+ /* k=3, data: 10, 20, 15, 25, 5, 30 */
+ /* i=2 (window [10,20,15]): current=15, <=: 10,15 => 2/3*100 = 66.667 */
+ /* i=3 (window [20,15,25]): current=25, <=: 20,15,25 => 3/3*100 = 100.0 */
+ /* i=4 (window [15,25,5]): current=5, <=: 5 => 1/3*100 = 33.333 */
+ /* i=5 (window [25,5,30]): current=30, <=: 25,5,30 => 3/3*100 = 100.0 */
+ fp_t const x[] = { 10, 20, 15, 25, 5, 30 };
+
+ fp_t const * const inp[1] = { x };
+ fp_t const e[] = { 66.66667, 100.0, 33.33333, 100.0 };
+ fp_t const * const exp[1] = { e };
+
+ uint_t k = 3;
+ return ts_test(ts_rank, ts_rank_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_rank_p);
+}