Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SE: ComputeBoolConstraint for numeric comparisons #7176

Merged
merged 10 commits into from
May 9, 2023

Conversation

pavel-mikula-sonarsource
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource commented May 5, 2023

Fixes #7142
Fixes #2528

I'm not going to fix the coverage, because we need #7143 first

Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just some minor comments and questions.

@sonarcloud
Copy link

sonarcloud bot commented May 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented May 8, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

84.6% 84.6% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Added a single test case.

NumberConstraint.From(1, 1).IsSingleValue.Should().BeTrue();
NumberConstraint.From(null, null).IsSingleValue.Should().BeFalse();
NumberConstraint.From(null, 42).IsSingleValue.Should().BeFalse();
NumberConstraint.From(42, null).IsSingleValue.Should().BeFalse();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know coverage is not a requirement for this PR, but this makes sense to test.

Suggested change
NumberConstraint.From(42, null).IsSingleValue.Should().BeFalse();
NumberConstraint.From(42, null).IsSingleValue.Should().BeFalse();
NumberConstraint.Empty.IsSingleValue.Should().BeFalse();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From(null, null) is already tested, so Empty will not change anything.

I don't really know what that line is not covered, we have
HasValue==true
HasValue==false
Min==Max
Min!=Max

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I think it's missing From(1, 42).
Additional note: I just changed the behavior of From(null, null) in #7174. You should change the test to use Empty instead.

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 6a9039e into master May 9, 2023
28 of 29 checks passed
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the Pavel/ComputeBool branch May 9, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants