Skip to content
Snippets Groups Projects
Commit 6a3327aa authored by Jacob Kegerreis's avatar Jacob Kegerreis
Browse files

Add extra array slice test

parent 0a4406a5
No related branches found
No related tags found
1 merge request!547Add generic utility function to find a value in an array
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment