Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
6a3327aa
Commit
6a3327aa
authored
7 years ago
by
Jacob Kegerreis
Browse files
Options
Downloads
Patches
Plain Diff
Add extra array slice test
parent
0a4406a5
No related branches found
No related tags found
1 merge request
!547
Add generic utility function to find a value in an array
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testUtilities.c
+15
-6
15 additions, 6 deletions
tests/testUtilities.c
with
15 additions
and
6 deletions
tests/testUtilities.c
100755 → 100644
+
15
−
6
View file @
6a3327aa
...
...
@@ -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
exampl
e
// Typical
valu
e
x
=
42
.
42
f
;
find_value_in_monotonic_array
(
x
,
arr
,
n
,
&
i
);
if
(
i
!=
42
)
{
printf
(
"Failed with a
norm
al value
\n
"
);
printf
(
"Failed with a
typic
al value
\n
"
);
return
1
;
}
//
O
n array element
//
Value o
n 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
;
}
//
B
elow array
//
Value b
elow array
x
=
-
123
.
f
;
find_value_in_monotonic_array
(
x
,
arr
,
n
,
&
i
);
if
(
i
!=
-
1
)
{
...
...
@@ -59,7 +59,7 @@ int main() {
return
1
;
}
//
A
bove array
//
Value a
bove 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
.
81
f
;
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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment