[jboss-cvs] jbossretro/src/test/org/jboss/test/lang ...
Elias Ross
genman at noderunner.net
Wed Jan 24 18:26:42 EST 2007
User: genman
Date: 07/01/24 18:26:42
Added: src/test/org/jboss/test/lang NumberTestCase.java
Log:
JBAOP-351 - Retro compiler support for Integer bit methods
Revision Changes Path
1.1 date: 2007/01/24 23:26:42; author: genman; state: Exp;jbossretro/src/test/org/jboss/test/lang/NumberTestCase.java
Index: NumberTestCase.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.test.lang;
import junit.framework.TestCase;
public class NumberTestCase extends TestCase
{
public void testBits()
{
int i = 0x0ff;
long l = 0x0ff;
assertEquals(8, Integer.bitCount(i));
assertEquals(8, Long.bitCount(l));
assertEquals(2, Integer.lowestOneBit(0xe));
assertEquals(2, Long.lowestOneBit(0xe));
assertEquals(0x80, Integer.highestOneBit(i));
assertEquals(0x80, Long.highestOneBit(l));
assertEquals(-16777216, Integer.reverse(i));
assertEquals(-72057594037927936L, Long.reverse(i));
assertEquals(24, Integer.numberOfLeadingZeros(i));
assertEquals(24 + 32, Long.numberOfLeadingZeros(i));
assertEquals(0xff0, Integer.rotateLeft(i, 4));
assertEquals(0xff0, Long.rotateLeft(i, 4));
assertEquals(0xF000000F, Integer.rotateRight(i, 4));
assertEquals(0xF00000000000000FL, Long.rotateRight(i, 4));
assertEquals(1, Integer.signum(i));
assertEquals(1, Long.signum(i));
assertEquals(-1, Integer.signum(-4));
assertEquals(-1, Long.signum(-2));
assertEquals(0xff000000, Integer.reverseBytes(i));
assertEquals(0xff00000000000000L, Long.reverseBytes(i));
}
}
More information about the jboss-cvs-commits
mailing list