Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
557929a0
Commit
557929a0
authored
Jun 11, 2021
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Improve error messages and add bound violation tests
parent
fe78cc8e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/analysis/Polynomial1D.hpp
+2
-2
2 additions, 2 deletions
src/analysis/Polynomial1D.hpp
tests/test_Polynomial1D.cpp
+10
-1
10 additions, 1 deletion
tests/test_Polynomial1D.cpp
with
12 additions
and
3 deletions
src/analysis/Polynomial1D.hpp
+
2
−
2
View file @
557929a0
...
@@ -202,14 +202,14 @@ class [[nodiscard]] Polynomial1D
...
@@ -202,14 +202,14 @@ class [[nodiscard]] Polynomial1D
PUGS_INLINE
PUGS_INLINE
double
&
coefficient
(
const
size_t
i
)
double
&
coefficient
(
const
size_t
i
)
{
{
Assert
(
i
<
m_coefficients
.
size
());
Assert
(
i
<
m_coefficients
.
size
()
,
"invalid coefficient number"
);
return
m_coefficients
[
i
];
return
m_coefficients
[
i
];
}
}
PUGS_INLINE
PUGS_INLINE
const
double
&
coefficient
(
const
size_t
i
)
const
const
double
&
coefficient
(
const
size_t
i
)
const
{
{
Assert
(
i
<
m_coefficients
.
size
());
Assert
(
i
<
m_coefficients
.
size
()
,
"invalid coefficient number"
);
return
m_coefficients
[
i
];
return
m_coefficients
[
i
];
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_Polynomial1D.cpp
+
10
−
1
View file @
557929a0
...
@@ -254,6 +254,15 @@ TEST_CASE("Polynomial1D", "[analysis]")
...
@@ -254,6 +254,15 @@ TEST_CASE("Polynomial1D", "[analysis]")
}
}
#ifndef NDEBUG
#ifndef NDEBUG
SECTION
(
"checking for bounds validation"
)
{}
SECTION
(
"checking for bounds validation"
)
{
Polynomial1D
p
({
-
1
,
0
,
0
,
1
});
REQUIRE_THROWS_AS
(
p
.
coefficient
(
4
),
AssertError
);
const
Polynomial1D
q
({
-
1
,
0
,
0
,
1
});
REQUIRE_THROWS_AS
(
q
.
coefficient
(
4
),
AssertError
);
REQUIRE_THROWS_AS
(
Polynomial1D
{
std
::
vector
<
double
>
{}},
AssertError
);
}
#endif // NDEBUG
#endif // NDEBUG
}
}
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
sign in
to comment