ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/buf/TestHexUtils.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/buf/TestHexUtils.java
Status
scanned
Type
file
Name
TestHexUtils.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2815 (2.7 KB)
MD5
474a4f4ce84a68ac4d8e847ed6d07373
SHA1
402ef9476b47c0da2cb05ba106ee461707b3a3e7
SHA256
7efc493ebdd3cfde825664b15fe65f55185c236365bc0ed00a45529df823b0c3
SHA512

      
    
SHA1_git
ca0cb29e8ff4489779dd3a903b0e3a6f9fe3cfa4
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestHexUtils.java | 2.7 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.buf; import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.junit.Test; /** * Test cases for {@link HexUtils}. */ public class TestHexUtils { private static final String TEST01_STRING = "Hello World"; private static final byte[] TEST01_BYTES = TEST01_STRING.getBytes(StandardCharsets.UTF_8); private static final String TEST02_STRING = "foo"; private static final byte[] TEST02_BYTES = TEST02_STRING.getBytes(StandardCharsets.UTF_8); @Test public void testGetDec() { Assert.assertEquals(0, HexUtils.getDec('0')); Assert.assertEquals(9, HexUtils.getDec('9')); Assert.assertEquals(10, HexUtils.getDec('a')); Assert.assertEquals(15, HexUtils.getDec('f')); Assert.assertEquals(10, HexUtils.getDec('A')); Assert.assertEquals(15, HexUtils.getDec('F')); Assert.assertEquals(-1, HexUtils.getDec(0)); Assert.assertEquals(-1, HexUtils.getDec('Z')); Assert.assertEquals(-1, HexUtils.getDec(255)); Assert.assertEquals(-1, HexUtils.getDec(-60)); } @Test public void testRoundTrip01() { Assert.assertArrayEquals(TEST01_STRING, TEST01_BYTES, HexUtils.fromHexString(HexUtils.toHexString(TEST01_BYTES))); } @Test public void testRoundTrip02() { Assert.assertArrayEquals(TEST02_STRING, TEST02_BYTES, HexUtils.fromHexString(HexUtils.toHexString(TEST02_BYTES))); } @Test(expected=IllegalArgumentException.class) public void testFromHex01() { HexUtils.fromHexString("Not a hex string"); } @Test(expected=IllegalArgumentException.class) public void testFromHex02() { // Odd number of hex characters HexUtils.fromHexString("aaa"); } @Test public void testToHex01() { Assert.assertEquals("fedc", HexUtils.toHexString((char) 0xfedc)); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
37.9
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9