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

Add unit tests for CopyUtils #62

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add unit tests for CopyUtils #62

wants to merge 8 commits into from

Conversation

md5sha256
Copy link
Contributor

Resolves #61

@sonarcloud
Copy link

sonarcloud bot commented Aug 8, 2021

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
0.0% 0.0% Duplication

Comment on lines +29 to +41
private static <T> void assertHaveClonedElements(@Nonnull Collection<T> c1, @Nonnull Collection<T> c2) {
Assertions.assertEquals(c1.size(), c2.size());
for (T t1 : c1) {
for (T t2 : c2) {
// If they are the same, it did not clone and thus we fail.
Assertions.assertNotSame(t1, t2);
if (t1.equals(t2)) {
// If they are equal, the element has been cloned, thus, we break and check the next element.
break;
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Collections can be unordered, making this fail. This implementations only works for ordered/sorted collections, aka Lists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would this fail if it was unordered? Maybe I'm just very sleepy but I can't seem to think of why this would fail if it wasn't ordered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Unit Tests for CopyUtils.java
2 participants