Skip to content

Conversation

@md5sha256
Copy link
Contributor

Resolves #61

@md5sha256 md5sha256 requested a review from TheBusyBiscuit July 29, 2021 00:21
@sonarqubecloud
Copy link

sonarqubecloud 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

3 participants