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

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

      
    
Rootfs path

      
    
Size
2547 (2.5 KB)
MD5
46c6439d44ebdba48871b037d0ec4fc1
SHA1
cbe08f8b052bc20f28c544fcc1785ea66d1c6de5
SHA256
bfe771295b0bdf123dc7e4fffc96b3b2f8a1fb62d14d8d34fc515d17bedc8b52
SHA512

      
    
SHA1_git
0212d184999548fb235702ca6a7801533c720e49
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestAscii.java | 2.5 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.math.BigInteger; import org.junit.Assert; import org.junit.Test; public class TestAscii { @Test public void testParseLong1() { String value = "9223372036854775807"; // Long.MAX_VALUE byte[] bytes = value.getBytes(); long result = Ascii.parseLong(bytes, 0, bytes.length); Assert.assertEquals(value, String.valueOf(result)); } @Test(expected = NumberFormatException.class) public void testParseLong2() { byte[] bytes = "9223372036854775808".getBytes(); // Long.MAX_VALUE + 1 long result = Ascii.parseLong(bytes, 0, bytes.length); Assert.fail("NumberFormatException expected, got: " + result); } @Test(expected = NumberFormatException.class) public void testParseLong3() { byte[] bytes = "9223372036854775810".getBytes(); // Long.MAX_VALUE + 3 long result = Ascii.parseLong(bytes, 0, bytes.length); Assert.fail("NumberFormatException expected, got: " + result); } @Test(expected = NumberFormatException.class) public void testParseLong4() { BigInteger x = BigInteger.valueOf(5000000000L).shiftLeft(32); byte[] bytes = String.valueOf(x).getBytes(); long result = Ascii.parseLong(bytes, 0, bytes.length); Assert.fail("NumberFormatException expected, got: " + result); } @Test public void testParseLong5() { String value = "9223372036854775806"; // Long.MAX_VALUE - 1 byte[] bytes = value.getBytes(); long result = Ascii.parseLong(bytes, 0, bytes.length); Assert.assertEquals(value, String.valueOf(result)); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
41.75
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