tests/libjava-mauve/src/gnu/testlet/java/lang/Character/CharacterTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 /* Copyright (C) 1999 Hewlett-Packard Company
       
     2 
       
     3    This file is part of Mauve.
       
     4 
       
     5    Mauve is free software; you can redistribute it and/or modify
       
     6    it under the terms of the GNU General Public License as published by
       
     7    the Free Software Foundation; either version 2, or (at your option)
       
     8    any later version.
       
     9 
       
    10    Mauve is distributed in the hope that it will be useful,
       
    11    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13    GNU General Public License for more details.
       
    14 
       
    15    You should have received a copy of the GNU General Public License
       
    16    along with Mauve; see the file COPYING.  If not, write to
       
    17    the Free Software Foundation, 59 Temple Place - Suite 330,
       
    18    Boston, MA 02111-1307, USA.
       
    19 */
       
    20 
       
    21 // Tags: JDK1.0
       
    22 
       
    23 package gnu.testlet.java.lang.Character;
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 public class CharacterTest implements Testlet
       
    28 {
       
    29   protected static TestHarness harness;
       
    30 	public void test_Basics()
       
    31 	{
       
    32 	  harness.check(!(Character.forDigit(8, 2) != '\0'), 
       
    33 	    "test_forDigit - 50");
       
    34 	  harness.check(!(Character.forDigit(-3, 2) != '\0'), 
       
    35 	    "test_forDigit - 51");
       
    36 	  harness.check(!(Character.forDigit(2, 8) != '2'), 
       
    37 	    "test_forDigit - 52");
       
    38 	  harness.check(!(Character.forDigit(12, 16) != 'c'), 
       
    39 	    "test_forDigit - 53");
       
    40 
       
    41 	  harness.check(!(Character.isJavaLetter('\uFFFF')), 
       
    42 	    "test_forDigit - 54");
       
    43 	  harness.check(!(!Character.isJavaLetter('a')), 
       
    44 	    "test_forDigit - 55");
       
    45 
       
    46 	  
       
    47 	    
       
    48 		harness.check(!( Character.MIN_VALUE != '\u0000' ), 
       
    49 			"test_Basics - 1" );
       
    50 		harness.check(!( Character.MAX_VALUE != '\uffff' ), 
       
    51 			"test_Basics - 2" );
       
    52 		harness.check(!( Character.MIN_RADIX != 2 ), 
       
    53 			"test_Basics - 3" );
       
    54 		harness.check(!( Character.MAX_RADIX != 36 ), 
       
    55 			"test_Basics - 4" );
       
    56 
       
    57 		Character ch = new Character('b');
       
    58 		harness.check(!( ch.charValue() != 'b' ), 
       
    59 			"test_Basics - 5" );
       
    60 	}
       
    61 
       
    62 	public void test_toString()
       
    63 	{
       
    64 		Character ch = new Character('a');
       
    65 		String str = ch.toString();
       
    66 
       
    67 		harness.check(!( str.length() != 1 || !str.equals("a")), 
       
    68 			"test_toString " );
       
    69 	}
       
    70 
       
    71 
       
    72 	public void test_equals()
       
    73 	{
       
    74 		Character ch1 = new Character('+');
       
    75 		Character ch2 = new Character('+');
       
    76 		Character ch3 = new Character('-');
       
    77 
       
    78 		harness.check(!( !ch1.equals(ch2) || ch1.equals(ch3) || ch1.equals(null)), 
       
    79 			"test_equals - 1" );
       
    80 	}
       
    81 
       
    82 	public void test_hashCode( )
       
    83 	{
       
    84 		Character ch1 = new Character('a');
       
    85 
       
    86 		harness.check(!( ch1.hashCode() != (int) 'a' ), 
       
    87 			"test_hashCode" );
       
    88 	}
       
    89 
       
    90 
       
    91 	public void test_isSpace( )
       
    92 	{
       
    93 		harness.check(!(!Character.isSpace('\t') ||
       
    94 			!Character.isSpace('\f') ||
       
    95 			!Character.isSpace('\r') ||
       
    96 			!Character.isSpace('\n') ||
       
    97 			!Character.isSpace(' ')  ||
       
    98 			Character.isSpace('+') ), 
       
    99 			"test_isSpace" );
       
   100 
       
   101 	}
       
   102 
       
   103 	public void test_digit( )
       
   104 	{
       
   105 		// radix wrong
       
   106 		harness.check(!( Character.digit( 'a' , Character.MIN_RADIX - 1 ) != -1 ), 
       
   107 			"test_digit - 1" );
       
   108 		harness.check(!( Character.digit( 'a' , Character.MAX_RADIX + 1 ) != -1 ), 
       
   109 			"test_digit - 2" );
       
   110 	}
       
   111 
       
   112 
       
   113 	public void test_others()
       
   114 	{
       
   115 		//calling them just for completion
       
   116 // not supported		Character.getNumericValue( 'a' );
       
   117 // not supported		Character.getType( 'a' );
       
   118 	  Character.isDefined( 'a' );
       
   119 	  Character.isDefined( '\uffff' );
       
   120 
       
   121 	  Character.digit('\u0665', 10);
       
   122 	  Character.digit('\u06F5', 10);
       
   123 	  Character.digit('\u0968', 10);
       
   124 	  Character.digit('\u06E8', 10);
       
   125 	  Character.digit('\u0A68', 10);
       
   126 	  Character.digit('\u0AE8', 10);
       
   127 	  Character.digit('\u0B68', 10);
       
   128 	  Character.digit('\u0BE8', 10);
       
   129 	  Character.digit('\u0C68', 10);
       
   130 	  Character.digit('\u0CE8', 10);
       
   131 	  Character.digit('\u0D68', 10);
       
   132 	  Character.digit('\u0E52', 10);
       
   133 	  Character.digit('\u0ED2', 10);
       
   134 	  Character.digit('\uFF12', 10);
       
   135 	  Character.digit('\uFFFF', 10);
       
   136 
       
   137 // not supported		Character.isISOControl( 'a' );
       
   138 // not supported		Character.isIdentifierIgnorable( 'a' );
       
   139 // not supported		Character.isJavaIdentifierPart( 'a' );
       
   140 // not supported		Character.isJavaIdentifierStart( 'a' );
       
   141 // not supported		Character.isJavaLetter( 'a' );
       
   142 	  Character.isJavaLetterOrDigit( 'a' );
       
   143 	  harness.check(!(Character.isJavaLetterOrDigit('\uFFFF')), 
       
   144 	      "isJavaLetterOrDigit - 60");
       
   145 	  harness.check(!(Character.isLetterOrDigit('\uFFFF')), 
       
   146 	      "isLetterOrDigit - 61");
       
   147 
       
   148 
       
   149 // not supported		Character.isLetter( 'a' );
       
   150 	      Character.isLetterOrDigit( 'a' );
       
   151 		Character.isLowerCase( 'A' );
       
   152 		Character.isLowerCase( 'a' );
       
   153 		Character.isSpace( 'a' );
       
   154 		
       
   155 // not supported		Character.isSpaceChar( 'a' );
       
   156 // not supported		Character.isTitleCase( 'a' );
       
   157 // not supported		Character.isUnicodeIdentifierPart( 'a' );
       
   158 // not supported		Character.isUnicodeIdentifierStart( 'a' );
       
   159 		Character.isUpperCase( 'a' );
       
   160 		Character.isUpperCase( 'A' );
       
   161 // not supported		Character.isWhitespace( 'a' );
       
   162 // not supported		Character.toTitleCase( 'a' );
       
   163 	}
       
   164 
       
   165 	public void testall()
       
   166 	{
       
   167 		test_Basics();
       
   168 		test_toString();
       
   169 		test_equals();
       
   170 		test_hashCode();
       
   171 		test_isSpace();
       
   172 		test_digit();
       
   173 		test_others();
       
   174 	}
       
   175 
       
   176   public void test (TestHarness the_harness)
       
   177   {
       
   178     harness = the_harness;
       
   179     testall ();
       
   180   }
       
   181 
       
   182 }