-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update equals() method to account for the type of T
Also reflects the equals() change to hashCode() and adds tests for both implementations.
- Loading branch information
1 parent
58da7a0
commit f477f44
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
async-profiler-context/src/test/java/io/pyroscope/labels/RefTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.pyroscope.labels; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class RefTest { | ||
@Test | ||
void testCreateRef() { | ||
Ref<String> ref = new Ref<>("test", 1L); | ||
assertEquals("test", ref.val); | ||
assertEquals(1L, ref.id); | ||
assertEquals(1L, ref.refCount.get()); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("unlikely-arg-type") | ||
void testEquals() { | ||
Ref<String> ref1 = new Ref<>("test", 1L); | ||
assertTrue(ref1.equals(ref1)); | ||
assertFalse(ref1.equals(null)); | ||
assertFalse(ref1.equals(new Integer(3))); | ||
assertFalse(ref1.equals(new Ref<Integer>(3, 1L))); | ||
} | ||
|
||
@Test | ||
void testHashCode() { | ||
Ref<String> ref1 = new Ref<>("test", 1L); | ||
assertEquals(3557490, ref1.hashCode()); | ||
} | ||
} |