Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
8d5fe824
Commit
8d5fe824
authored
6 years ago
by
Tim Keil
Browse files
Options
Downloads
Patches
Plain Diff
[test.floatcmp] Add a better test for FloatCmp
parent
d05df96b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/xt/common/test/float_cmp.cc
+37
-0
37 additions, 0 deletions
dune/xt/common/test/float_cmp.cc
with
37 additions
and
0 deletions
dune/xt/common/test/float_cmp.cc
+
37
−
0
View file @
8d5fe824
...
@@ -97,6 +97,39 @@ typename std::enable_if<XT::Common::is_matrix<T>::value, T>::type make_type(cons
...
@@ -97,6 +97,39 @@ typename std::enable_if<XT::Common::is_matrix<T>::value, T>::type make_type(cons
return
Mat
::
create
(
VECSIZE
,
NUMCOLS
,
number
);
return
Mat
::
create
(
VECSIZE
,
NUMCOLS
,
number
);
}
}
template
<
class
T
,
bool
is_number
=
(
XT
::
Common
::
is_arithmetic
<
T
>
::
value
||
XT
::
Common
::
is_complex
<
T
>::
value
),
bool
is_vector
=
XT
::
Common
::
is_vector
<
T
>::
value
>
struct
suitable_entry
{
static
T
change_an_entry
(
const
T
&
input
,
const
int
value
)
{
DUNE_UNUSED_PARAMETER
(
value
);
return
input
;
}
};
template
<
class
T
>
struct
suitable_entry
<
T
,
false
,
true
>
{
static
T
change_an_entry
(
const
T
&
input
,
const
int
value
)
{
T
ret
=
input
;
ret
[
0
]
=
value
;
return
ret
;
}
};
template
<
class
T
>
struct
suitable_entry
<
T
,
false
,
false
>
{
static
T
change_an_entry
(
const
T
&
input
,
const
int
value
)
{
T
ret
=
input
;
ret
[
0
][
0
]
=
value
;
return
ret
;
}
};
template
<
class
T
>
template
<
class
T
>
struct
FloatCmpTest
:
public
testing
::
Test
struct
FloatCmpTest
:
public
testing
::
Test
...
@@ -115,6 +148,7 @@ struct FloatCmpTest : public testing::Test
...
@@ -115,6 +148,7 @@ struct FloatCmpTest : public testing::Test
FloatCmpTest
()
FloatCmpTest
()
:
zero
(
make_type
<
T
>
(
make_number
<
S
>
(
0
)))
:
zero
(
make_type
<
T
>
(
make_number
<
S
>
(
0
)))
,
one_with_one_zero_entry
(
suitable_entry
<
T
>::
change_an_entry
(
make_type
<
T
>
(
make_number
<
S
>
(
1
)),
0
))
,
one
(
make_type
<
T
>
(
make_number
<
S
>
(
1
)))
,
one
(
make_type
<
T
>
(
make_number
<
S
>
(
1
)))
,
neg_one
(
make_type
<
T
>
(
make_number
<
S
>
(
-
1
)))
,
neg_one
(
make_type
<
T
>
(
make_number
<
S
>
(
-
1
)))
,
epsilon
(
make_type
<
T
>
(
make_number
<
S
>
(
XT
::
Common
::
FloatCmp
::
DEFAULT_EPSILON
::
value
())))
,
epsilon
(
make_type
<
T
>
(
make_number
<
S
>
(
XT
::
Common
::
FloatCmp
::
DEFAULT_EPSILON
::
value
())))
...
@@ -130,6 +164,7 @@ struct FloatCmpTest : public testing::Test
...
@@ -130,6 +164,7 @@ struct FloatCmpTest : public testing::Test
}
}
const
T
zero
;
const
T
zero
;
const
T
one_with_one_zero_entry
;
const
T
one
;
const
T
one
;
const
T
neg_one
;
const
T
neg_one
;
const
T
epsilon
;
const
T
epsilon
;
...
@@ -240,6 +275,7 @@ struct FloatCmpTest : public testing::Test
...
@@ -240,6 +275,7 @@ struct FloatCmpTest : public testing::Test
TEST_DXTC_EXPECT_FLOAT_GE
(
one_plus_eps_minus_
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
one_plus_eps_minus_
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
one_plus_eps_plus_
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
one_plus_eps_plus_
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
two
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
two
,
one
);
TEST_DXTC_EXPECT_FLOAT_GE
(
one
,
one_with_one_zero_entry
);
}
}
void
check_le
()
void
check_le
()
...
@@ -251,6 +287,7 @@ struct FloatCmpTest : public testing::Test
...
@@ -251,6 +287,7 @@ struct FloatCmpTest : public testing::Test
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
one_plus_eps_minus_
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
one_plus_eps_minus_
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
one_plus_eps_plus_
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
one_plus_eps_plus_
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
two
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one
,
two
);
TEST_DXTC_EXPECT_FLOAT_LE
(
one_with_one_zero_entry
,
one
);
}
}
void
negative_numbers
()
void
negative_numbers
()
...
...
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