ScalingSettings::MinPartiality: validate the argument, not the value it replaces
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit df5f2ae22f979a5569f4d569fe2a8cdd5999d242)
This commit is contained in:
1 parent
2dbb9d5951
commit
925701a1ce
2 files changed
+10
-1
No files matched your search
@@ -90,7 +90,7 @@ std::optional<double> ScalingSettings::GetRotationWedgeForScaling() const {
|
||||
}
|
||||
|
||||
ScalingSettings &ScalingSettings::MinPartiality(double input) {
|
||||
if (min_partiality < 0.0 || min_partiality > 1.0)
|
||||
if (!(input >= 0.0 && input <= 1.0))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Min partiality must be between 0 and 1");
|
||||
min_partiality = input;
|
||||
return *this;
|
||||
|
||||
@@ -1143,3 +1143,12 @@ TEST_CASE("MergeOnTheFly_CaptureTermDownweightsPartials") {
|
||||
CHECK(with < without);
|
||||
CHECK(with < 1.08f);
|
||||
}
|
||||
|
||||
// The setter checks the value it is given, not the one it replaces.
|
||||
TEST_CASE("ScalingSettings_MinPartialityRange") {
|
||||
ScalingSettings s;
|
||||
CHECK_THROWS(s.MinPartiality(1.5));
|
||||
CHECK_THROWS(s.MinPartiality(-0.1));
|
||||
CHECK_NOTHROW(s.MinPartiality(0.5));
|
||||
CHECK(s.GetMinPartiality() == 0.5);
|
||||
}
|
||||
Reference in new issue
Block a user