Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91191739
vector_checker.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 8, 20:03
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Nov 10, 20:03 (2 d)
Engine
blob
Format
Raw Data
Handle
22216437
Attached To
rSPECMICP SpecMiCP / ReactMiCP
vector_checker.cpp
View Options
#include "specmicp_common/eigen/vector_checker.hpp"
#include <catch.hpp>
using
namespace
specmicp
;
using
namespace
specmicp
::
vector_checker
;
TEST_CASE
(
"Vector checker"
)
{
Vector
x
(
10
);
x
<<
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
;
Vector
null_vector
(
10
);
null_vector
.
setZero
();
Vector
notfinite
(
3
);
notfinite
<<
0
,
1
,
-
INFINITY
;
SECTION
(
"all"
)
{
CHECK
((
all
(
x
)
>=
0.0
));
CHECK_FALSE
((
all
(
x
)
>=
5.0
));
}
SECTION
(
"any"
)
{
CHECK
((
any
(
x
)
>=
0.0
));
CHECK
((
any
(
x
)
>=
5.0
));
}
SECTION
(
"is_finite"
)
{
CHECK
((
is_finite
(
x
)));
CHECK_FALSE
((
is_finite
(
notfinite
)));
}
SECTION
(
"is_bounded"
)
{
CHECK_FALSE
((
is_bounded
(
notfinite
,
0.0
,
1.0
)));
CHECK
((
is_bounded
(
x
,
0.0
,
10.0
)));
CHECK
((
is_bounded
(
x
,
0.0
,
10.0
)
&&
(
any
(
x
)
>
0.0
)));
CHECK
((
is_lower_bounded
(
x
,
0.0
)));
CHECK
((
is_upper_bounded
(
x
,
10.0
)));
CHECK_FALSE
((
is_lower_bounded
(
x
,
5.0
)));
CHECK_FALSE
((
is_upper_bounded
(
x
,
5.0
)));
}
SECTION
(
"And"
)
{
CHECK
((
is_finite
(
x
)
&&
all
(
x
)
>=
0.0
));
CHECK
(((
all
(
x
)
>=
0.0
)
&&
(
any
(
x
)
!=
0.0
)));
CHECK
(((
all
(
x
)
>=
0.0
)
&&
(
all
(
x
)
<
10.0
)));
CHECK_FALSE
(((
all
(
x
)
>=
1.0
)
&&
(
any
(
x
)
!=
0.0
)));
CHECK_FALSE
(((
any
(
x
)
!=
0.0
)
&&
(
all
(
x
)
>=
1.0
)));
CHECK_FALSE
(((
all
(
null_vector
)
>=
0.0
)
&&
(
any
(
null_vector
)
!=
0.0
)));
}
SECTION
(
"Or"
)
{
CHECK
(((
all
(
x
)
>=
10.0
)
||
(
all
(
x
)
<=
10.0
)));
CHECK
(((
all
(
x
)
<=
10.0
)
||
(
all
(
x
)
>=
10.0
)));
}
SECTION
(
"long combination"
)
{
CHECK
(((
all
(
x
)
>=
10.0
)
||
((
all
(
x
)
>=
0.0
)
&&
(
all
(
x
)
<
10.0
))));
CHECK
(((
all
(
x
)
>=
10.0
)
||
(
all
(
x
)
>=
0.0
)
&&
(
all
(
x
)
<
10.0
)));
CHECK
((
all
(
x
)
>=
10.0
||
all
(
x
)
>=
0.0
&&
all
(
x
)
<
10.0
));
CHECK
((
all
(
x
)
>=
10.0
||
(
all
(
x
)
>=
0.0
&&
all
(
x
)
<
10.0
)));
}
}
Event Timeline
Log In to Comment