From 6a3327aad62a991d990bb47ce00541b3b2d025a8 Mon Sep 17 00:00:00 2001 From: Jacob Kegerreis <jacob.kegerreis@durham.ac.uk> Date: Thu, 17 May 2018 08:50:41 +0100 Subject: [PATCH] Add extra array slice test --- tests/testUtilities.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) mode change 100755 => 100644 tests/testUtilities.c diff --git a/tests/testUtilities.c b/tests/testUtilities.c old mode 100755 new mode 100644 index 55109e7796..d0bd8258e6 --- a/tests/testUtilities.c +++ b/tests/testUtilities.c @@ -25,7 +25,7 @@ */ int main() { /// Test find_value_in_monotonic_array() - const int n = 100; + int n = 100; float arr[n]; int i; float x; @@ -35,15 +35,15 @@ int main() { arr[j] = j; } - // Typical example + // Typical value x = 42.42f; find_value_in_monotonic_array(x, arr, n, &i); if (i != 42) { - printf("Failed with a normal value \n"); + printf("Failed with a typical value \n"); return 1; } - // On array element + // Value on array element x = 33.f; find_value_in_monotonic_array(x, arr, n, &i); if (i != 33) { @@ -51,7 +51,7 @@ int main() { return 1; } - // Below array + // Value below array x = -123.f; find_value_in_monotonic_array(x, arr, n, &i); if (i != -1) { @@ -59,7 +59,7 @@ int main() { return 1; } - // Above array + // Value above array x = 123.f; find_value_in_monotonic_array(x, arr, n, &i); if (i != n) { @@ -67,5 +67,14 @@ int main() { return 1; } + // Array slice with typical value + x = 9.81f; + n = 10; + find_value_in_monotonic_array(x, arr + 5, n, &i); + if (i != 4) { + printf("Failed with an array slice \n"); + return 1; + } + return 0; } -- GitLab