/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.reflection.util;

import java.math.BigDecimal;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class ClassTraitsTest {
    
    public ClassTraitsTest() {
    }

    @Test
    public void testIsPrimitive() {
        assertTrue( ClassTraits.isPrimitive(byte.class));
        assertTrue( ClassTraits.isPrimitive(short.class));
        assertTrue( ClassTraits.isPrimitive(int.class));
        assertTrue( ClassTraits.isPrimitive(long.class));
        assertTrue( ClassTraits.isPrimitive(char.class));
        assertTrue( ClassTraits.isPrimitive(float.class));
        assertTrue( ClassTraits.isPrimitive(double.class));
        assertTrue( ClassTraits.isPrimitive(boolean.class));
        assertTrue( ClassTraits.isPrimitive(void.class));
        
        assertFalse( ClassTraits.isPrimitive(Byte.class));
        assertFalse( ClassTraits.isPrimitive(Integer.class));
        assertFalse( ClassTraits.isPrimitive(Number.class));
    }
    
    @Test
    public void testIsBoxed() {
        assertTrue( ClassTraits.isBoxed(Byte.class));
        assertTrue( ClassTraits.isBoxed(Short.class));
        assertTrue( ClassTraits.isBoxed(Integer.class));
        assertTrue( ClassTraits.isBoxed(Long.class));
        assertTrue( ClassTraits.isBoxed(Character.class));
        assertTrue( ClassTraits.isBoxed(Float.class));
        assertTrue( ClassTraits.isBoxed(Double.class));
        assertTrue( ClassTraits.isBoxed(Boolean.class));
        assertTrue( ClassTraits.isBoxed(Void.class));
        
        assertFalse( ClassTraits.isBoxed(byte.class));
        assertFalse( ClassTraits.isBoxed(int.class));
        assertFalse( ClassTraits.isBoxed(Number.class));
    }
    
    @Test
    public void testIsPrimitiveArray() {
        assertTrue( ClassTraits.isPrimitiveArray(byte[].class));
        assertTrue( ClassTraits.isPrimitiveArray(short[].class));
        assertTrue( ClassTraits.isPrimitiveArray(int[].class));
        
        assertFalse( ClassTraits.isPrimitiveArray(byte.class));
        
        assertFalse( ClassTraits.isPrimitiveArray(Byte[].class));
        assertFalse( ClassTraits.isPrimitiveArray(Integer[].class));
        assertFalse( ClassTraits.isPrimitiveArray(Number[].class));
    }
    
    @Test
    public void testIsBool() {
        
        assertTrue( ClassTraits.isBool(Boolean.class));
        assertTrue( ClassTraits.isBool(boolean.class));
        
        assertFalse( ClassTraits.isBool(Number.class));
    }
    
    @Test
    public void testIsNumber() {
        assertTrue( ClassTraits.isNumber(Byte.class));
        assertTrue( ClassTraits.isNumber(Short.class));
        assertTrue( ClassTraits.isNumber(Integer.class));
        assertTrue( ClassTraits.isNumber(Long.class));
        assertTrue( ClassTraits.isNumber(Float.class));
        assertTrue( ClassTraits.isNumber(Double.class));
        
        assertTrue( ClassTraits.isNumber(byte.class));
        assertTrue( ClassTraits.isNumber(short.class));
        assertTrue( ClassTraits.isNumber(int.class));
        assertTrue( ClassTraits.isNumber(long.class));
        assertTrue( ClassTraits.isNumber(float.class));
        assertTrue( ClassTraits.isNumber(double.class));
        
        assertTrue( ClassTraits.isNumber(Number.class));
        assertTrue( ClassTraits.isNumber(BigDecimal.class));

        // char isn't number, if you use it as unsigned short, that's a hack
        assertFalse( ClassTraits.isNumber(Character.class));
        assertFalse( ClassTraits.isNumber(char.class));
        
        assertFalse( ClassTraits.isNumber(Boolean.class));
        assertFalse( ClassTraits.isNumber(Void.class));
        assertFalse( ClassTraits.isNumber(boolean.class));
        assertFalse( ClassTraits.isNumber(void.class));

    }
    
}
