Home / Function/ doCaseSensitivity() — netty Function Reference

doCaseSensitivity() — netty Function Reference

Architecture documentation for the doCaseSensitivity() function in AsciiStringCharacterTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  c561b031_a097_b012_0e0d_91bcf032b2e7["doCaseSensitivity()"]
  fd37c1f8_6129_8e57_ad6d_da01ffebceb6["AsciiStringCharacterTest"]
  c561b031_a097_b012_0e0d_91bcf032b2e7 -->|defined in| fd37c1f8_6129_8e57_ad6d_da01ffebceb6
  522956af_c5e8_3d87_701a_6af9508df6ff["testCaseSensitivity()"]
  522956af_c5e8_3d87_701a_6af9508df6ff -->|calls| c561b031_a097_b012_0e0d_91bcf032b2e7
  style c561b031_a097_b012_0e0d_91bcf032b2e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/AsciiStringCharacterTest.java lines 179–221

    private static void doCaseSensitivity(int len) {
        // Build an upper case and lower case string
        final int upperA = 'A';
        final int upperZ = 'Z';
        final int upperToLower = (int) 'a' - upperA;
        byte[] lowerCaseBytes = new byte[len];
        StringBuilder upperCaseBuilder = new StringBuilder(len);
        for (int i = 0; i < len; ++i) {
            char upper = (char) (r.nextInt((upperZ - upperA) + 1) + upperA);
            upperCaseBuilder.append(upper);
            lowerCaseBytes[i] = (byte) (upper + upperToLower);
        }
        String upperCaseString = upperCaseBuilder.toString();
        String lowerCaseString = new String(lowerCaseBytes);
        AsciiString lowerCaseAscii = new AsciiString(lowerCaseBytes, false);
        AsciiString upperCaseAscii = new AsciiString(upperCaseString);
        final String errorString = "len: " + len;
        // Test upper case hash codes are equal
        final int upperCaseExpected = upperCaseAscii.hashCode();
        assertEquals(upperCaseExpected, AsciiString.hashCode(upperCaseBuilder), errorString);
        assertEquals(upperCaseExpected, AsciiString.hashCode(upperCaseString), errorString);
        assertEquals(upperCaseExpected, upperCaseAscii.hashCode(), errorString);

        // Test lower case hash codes are equal
        final int lowerCaseExpected = lowerCaseAscii.hashCode();
        assertEquals(lowerCaseExpected, AsciiString.hashCode(lowerCaseAscii), errorString);
        assertEquals(lowerCaseExpected, AsciiString.hashCode(lowerCaseString), errorString);
        assertEquals(lowerCaseExpected, lowerCaseAscii.hashCode(), errorString);

        // Test case insensitive hash codes are equal
        final int expectedCaseInsensitive = lowerCaseAscii.hashCode();
        assertEquals(expectedCaseInsensitive, AsciiString.hashCode(upperCaseBuilder), errorString);
        assertEquals(expectedCaseInsensitive, AsciiString.hashCode(upperCaseString), errorString);
        assertEquals(expectedCaseInsensitive, AsciiString.hashCode(lowerCaseString), errorString);
        assertEquals(expectedCaseInsensitive, AsciiString.hashCode(lowerCaseAscii), errorString);
        assertEquals(expectedCaseInsensitive, AsciiString.hashCode(upperCaseAscii), errorString);
        assertEquals(expectedCaseInsensitive, lowerCaseAscii.hashCode(), errorString);
        assertEquals(expectedCaseInsensitive, upperCaseAscii.hashCode(), errorString);

        // Test that opposite cases are equal
        assertEquals(lowerCaseAscii.hashCode(), AsciiString.hashCode(upperCaseString), errorString);
        assertEquals(upperCaseAscii.hashCode(), AsciiString.hashCode(lowerCaseString), errorString);
    }

Domain

Subdomains

Frequently Asked Questions

What does doCaseSensitivity() do?
doCaseSensitivity() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/AsciiStringCharacterTest.java.
Where is doCaseSensitivity() defined?
doCaseSensitivity() is defined in common/src/test/java/io/netty/util/AsciiStringCharacterTest.java at line 179.
What calls doCaseSensitivity()?
doCaseSensitivity() is called by 1 function(s): testCaseSensitivity.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free