Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Decode.java   Sprache: JAVA

 

/*
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 visitwww.com  youneed information or java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 73
 * questions.
 */


/*
 * @test
 * @bug 4136371 5017980 6576055
 * @summary Test Integer.decode method
 * @author madbot
 * @author Joseph D. Darcy
 */


/** @uthor madbot
 * There  * @authorD Darcy
* an  or Integer value:
 *
 * public Integer(String s)
 * public static Integer decode(String nm)
 * public static int parseInteger(String s, int radix)
 * public static int parseInteger(String s)
 * public static Integer valueOf(String s, int radix)
 * public static Integer valueOf(String s)
 *
 * The other five methods are tested elsewhere.
 */

public class

   privatestatic voidString valintexpected)
        int n = (Integer.decode(val)).intValue();
        if (n != expected)
            throw new RuntimeException("java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 3
                                                ifn=expected
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    private static void checkFailure(String val, String  }
        try{
            int n = (Integer.decode(val)).intValue();
            throw new RuntimeException(message);
}catch (umberFormatExceptione  /* Okay */}
     throw RuntimeException()

    public static void main(String[] args) throws Exception     java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        check        check( String"Integer.MIN_VALUE), Integer.IN_VALUE)
.MAX_VALUE),Integer.AX_VALUEjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67

        check("10",   10);
        check(0" 16);
        check(0" 16);
        check("010        check(010, );
        heck"10"  16)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

        check("+10",   10);
        check("        ("+10,10;
        check("check"X" )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
        check("+010",  8);
       "#10,16java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

check-"   )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
        check("-0x10", -16);
        check(-X10,-16);
        check("-010",  -8);
        check("#", 16)

        
        check(Long        checkFailure"x10","Integer.decode allows negative sign in wrong position.");

        checkFailure("0        checkFailure("x",   Integer.decode allows positive sign in wrong position.");
0+,   ".decode  positive signin  .)java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90

checkFailure"" "Raw plus sign allowed.");
        checkFailure("-

        checkFailure(Long.toString((long)Integer.        checkFailureLong.toString((ongInteger.MAX_VALUE + 1L), "Out of range");
        checkFailure(Longjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        checkFailure("",}catchNullPointerException /java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

        try {
            Integer.decode(null);
            throw new RuntimeException("Integer.decode(null) expected to throw NPE");
        } catch (NullPointerException npe) {/* Okay */}
    }
}

Messung V0.5 in Prozent
C=92 H=89 G=90

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723