PlatformDependentTest Class — netty Architecture
Architecture documentation for the PlatformDependentTest class in PlatformDependentTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ff6bfe0a_3221_685f_da78_ee06b9ccc3c6["PlatformDependentTest"] 9275ea2f_e019_ea12_b8a3_4d236b7d77fd["PlatformDependentTest.java"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|defined in| 9275ea2f_e019_ea12_b8a3_4d236b7d77fd ceea74ab_d15a_788c_372a_9529b71123d9["testEqualsConsistentTime()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| ceea74ab_d15a_788c_372a_9529b71123d9 ae7336a0_d75b_e2a9_38a5_7221ab42cde4["testEquals()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| ae7336a0_d75b_e2a9_38a5_7221ab42cde4 29a97445_9d8f_273f_dd64_487afc7c4942["testIsZero()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| 29a97445_9d8f_273f_dd64_487afc7c4942 9c1274d9_2a09_e656_a236_b73212949bb4["randomCharInByteRange()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| 9c1274d9_2a09_e656_a236_b73212949bb4 46c18ccd_3735_78d8_7e50_d68475399232["testHashCodeAscii()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| 46c18ccd_3735_78d8_7e50_d68475399232 0912b2f4_cd2e_20a5_fb5c_051ca34ca2b3["testAllocateWithCapacity0()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| 0912b2f4_cd2e_20a5_fb5c_051ca34ca2b3 6883b03c_1254_9c1b_e2fc_149c59f4003b["java25MustHaveCleanerImplAvailable()"] ff6bfe0a_3221_685f_da78_ee06b9ccc3c6 -->|method| 6883b03c_1254_9c1b_e2fc_149c59f4003b
Relationship Graph
Source Code
common/src/test/java/io/netty/util/internal/PlatformDependentTest.java lines 34–172
public class PlatformDependentTest {
private static final Random r = new Random();
@Test
public void testEqualsConsistentTime() {
testEquals(new EqualityChecker() {
@Override
public boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
return PlatformDependent.equalsConstantTime(bytes1, startPos1, bytes2, startPos2, length) != 0;
}
});
}
@Test
public void testEquals() {
testEquals(new EqualityChecker() {
@Override
public boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
return PlatformDependent.equals(bytes1, startPos1, bytes2, startPos2, length);
}
});
}
@Test
public void testIsZero() {
byte[] bytes = new byte[100];
assertTrue(PlatformDependent.isZero(bytes, 0, 0));
assertTrue(PlatformDependent.isZero(bytes, 0, -1));
assertTrue(PlatformDependent.isZero(bytes, 0, 100));
assertTrue(PlatformDependent.isZero(bytes, 10, 90));
bytes[10] = 1;
assertTrue(PlatformDependent.isZero(bytes, 0, 10));
assertFalse(PlatformDependent.isZero(bytes, 0, 11));
assertFalse(PlatformDependent.isZero(bytes, 10, 1));
assertTrue(PlatformDependent.isZero(bytes, 11, 89));
}
private interface EqualityChecker {
boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length);
}
private static void testEquals(EqualityChecker equalsChecker) {
byte[] bytes1 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
byte[] bytes2 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
assertNotSame(bytes1, bytes2);
assertTrue(equalsChecker.equals(bytes1, 0, bytes2, 0, bytes1.length));
assertTrue(equalsChecker.equals(bytes1, 2, bytes2, 2, bytes1.length - 2));
bytes1 = new byte[] {1, 2, 3, 4, 5, 6};
bytes2 = new byte[] {1, 2, 3, 4, 5, 6, 7};
assertNotSame(bytes1, bytes2);
assertFalse(equalsChecker.equals(bytes1, 0, bytes2, 1, bytes1.length));
assertTrue(equalsChecker.equals(bytes2, 0, bytes1, 0, bytes1.length));
bytes1 = new byte[] {1, 2, 3, 4};
bytes2 = new byte[] {1, 2, 3, 5};
assertFalse(equalsChecker.equals(bytes1, 0, bytes2, 0, bytes1.length));
assertTrue(equalsChecker.equals(bytes1, 0, bytes2, 0, 3));
bytes1 = new byte[] {1, 2, 3, 4};
bytes2 = new byte[] {1, 3, 3, 4};
assertFalse(equalsChecker.equals(bytes1, 0, bytes2, 0, bytes1.length));
assertTrue(equalsChecker.equals(bytes1, 2, bytes2, 2, bytes1.length - 2));
bytes1 = new byte[0];
bytes2 = new byte[0];
assertNotSame(bytes1, bytes2);
assertTrue(equalsChecker.equals(bytes1, 0, bytes2, 0, 0));
bytes1 = new byte[100];
bytes2 = new byte[100];
for (int i = 0; i < 100; i++) {
bytes1[i] = (byte) i;
bytes2[i] = (byte) i;
}
assertTrue(equalsChecker.equals(bytes1, 0, bytes2, 0, bytes1.length));
bytes1[50] = 0;
assertFalse(equalsChecker.equals(bytes1, 0, bytes2, 0, bytes1.length));
assertTrue(equalsChecker.equals(bytes1, 51, bytes2, 51, bytes1.length - 51));
assertTrue(equalsChecker.equals(bytes1, 0, bytes2, 0, 50));
bytes1 = new byte[]{1, 2, 3, 4, 5};
Source
Frequently Asked Questions
What is the PlatformDependentTest class?
PlatformDependentTest is a class in the netty codebase, defined in common/src/test/java/io/netty/util/internal/PlatformDependentTest.java.
Where is PlatformDependentTest defined?
PlatformDependentTest is defined in common/src/test/java/io/netty/util/internal/PlatformDependentTest.java at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free