head	1.3;
access;
symbols
	bg2_23:1.3
	bg2_22:1.3
	bg2_21:1.3
	bg2_20:1.3
	bg2_16:1.3
	bg2_15:1.3
	bg2_12:1.3
	bg2_07:1.3
	isorc2008_submission:1.2
	handbook_alpha_edition:1.1;
locks; strict;
comment	@# @;


1.3
date	2008.02.24.19.28.02;	author martin;	state Exp;
branches;
next	1.2;
commitid	515f47c1c53d4567;

1.2
date	2007.11.17.19.54.27;	author martin;	state Exp;
branches;
next	1.1;
commitid	ca9473f46f14567;

1.1
date	2007.09.30.11.57.42;	author martin;	state Exp;
branches;
next	;
commitid	6f346ff8f334567;


desc
@@


1.3
log
@JOP goes GPL
@
text
@/*
  This file is part of JOP, the Java Optimized Processor
    see <http://www.jopdesign.com/>

  Copyright (C) 2007, Alberto Andreotti

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program 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 for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package jdk;

import jvm.TestCase;

public class PrimitiveClasses extends TestCase {

	public String getName() {
		return "PrimitiveClasses";
	}
	public boolean test() {
	boolean Ok=true;	
	
	//BOOLEAN
	Boolean myBoolean1=new Boolean(true);
	////possible issue when parameter is the string "TRuE"
	Boolean myBoolean2=new Boolean("true");
	//possible issue when parameter is null
	Boolean myBoolean3=new Boolean(false);
	Boolean myBoolean4=new Boolean("fAlSe");
	
	//test constructors
	Ok=Ok&& myBoolean1.booleanValue();
	Ok=Ok&& myBoolean2.booleanValue();
	Ok=Ok&& ! myBoolean3.booleanValue();
	
	//equals()
	Ok=Ok &&  myBoolean1.equals(myBoolean2);
	Ok=Ok &&  myBoolean3.equals(myBoolean4);
	Ok=Ok &&  !myBoolean1.equals(myBoolean3);
	
	//hashCode
	Ok=Ok && myBoolean1.hashCode()==myBoolean1.hashCode();
	Ok=Ok && myBoolean1.hashCode()==myBoolean2.hashCode();
	Ok=Ok && myBoolean3.hashCode()==myBoolean4.hashCode();
	Ok=Ok && myBoolean1.hashCode()!=myBoolean3.hashCode();

	//toString
	//TODO:check String.equalsIgnoreCase, possible issue.
	//Avoid the use of equalsIgnoreCase
		
	Ok=Ok && (myBoolean1.toString()).equals("true");
	Ok=Ok && (myBoolean3.toString()).equals("false");
	Ok=Ok &&!(myBoolean1.toString()).equals("false");
	Ok=Ok &&!(myBoolean3.toString()).equals("true");
		
	//valueOf(String)
	//this method should receive a String instead of a boolean
	//Ok=Ok && (Boolean.valueOf("true")).equals(myBoolean1);
	
	//BYTE
	Byte myByte1=new Byte((byte)122);
	Byte myByte2=new Byte((byte)122);
	//The constructor Byte(string) is not defined
	//Byte myByte2=new Byte("22");
	Ok=Ok && ((byte)122)==myByte1.byteValue();
	//Ok=Ok && ((byte)22)==myByte1.byteValue();
	//check if NumberFormatException is thrown 
	//new Byte("myWrongString");
	
	//parseByte(String)
	Ok=Ok && 123==Byte.parseByte("123");
	Ok=Ok && 127==Byte.parseByte("127");
	Ok=Ok && -128==Byte.parseByte("-128");
	Ok=Ok && !(123==Byte.parseByte("121"));
	
	//check for exception
	//Ok=Ok && !(123==Byte.parseByte("129"));
	
	//equals(Object)
	Byte myByte3=myByte2;
	Ok=Ok && myByte2.equals(myByte3);
	Ok=Ok && myByte2.equals(myByte1);
	myByte3=new Byte((byte)123);
	Ok=Ok && !myByte2.equals(myByte3);
	
	//hashCode
	Ok=Ok && myByte1.hashCode()==myByte1.hashCode();
	Ok=Ok && (myByte1.hashCode()==myByte2.hashCode());
	Ok=Ok && !(myByte3.hashCode()==myByte1.hashCode());
	
	//toString
	Ok=Ok && (myByte3.toString()).equals("123");
	return Ok;
	}
}
@


1.2
log
@additional tests
@
text
@d1 20
@


1.1
log
@new test cases
@
text
@d2 1
a3 2
//import JOPlibrary.lang.Boolean;
//import JOPlibrary.lang.Byte;
d20 1
d38 8
a45 5
	Ok=Ok&&(myBoolean1.toString()).equalsIgnoreCase("true");
	Ok=Ok&&(myBoolean3.toString()).equalsIgnoreCase("false");
	Ok=Ok&&!(myBoolean1.toString()).equalsIgnoreCase("false");
	Ok=Ok&&!(myBoolean3.toString()).equalsIgnoreCase("true");
	
d47 2
a48 1
	//Ok=Ok && (Boolean.valueOf("true")).equalsIgnoreCase("true");
d52 1
d66 2
d69 14
a84 2
	
	
@

