Package org.rococoa.cocoa.foundation

Examples of org.rococoa.cocoa.foundation.NSNumber.intValue()


        // We can cope with 64 bits on 64 and 32
        Number nativeValue = new Long(number.id().longValue());
        NSNumber converted = (NSNumber) converter.fromNative(nativeValue, null);
        assertEquals(converted.id(), number.id());
        assertEquals(45, converted.intValue());       

        // We must cope with 32 bits on 32-bit
        if (NativeLong.SIZE == 4) {
            nativeValue = new Integer(number.id().intValue());
            converted = (NSNumber) converter.fromNative(nativeValue, null);
View Full Code Here


        // We must cope with 32 bits on 32-bit
        if (NativeLong.SIZE == 4) {
            nativeValue = new Integer(number.id().intValue());
            converted = (NSNumber) converter.fromNative(nativeValue, null);
            assertEquals(45, converted.intValue());       
        }   
    }
   
    @Test public void convertsReturnedNilToNull() {
  // Again I'm not sure that this is desirable, but it is what happens.
View Full Code Here

        assertEquals("string value", value.toString());
   
        NSNumber value2 = Rococoa.cast(
                dictionary.objectForKey("int key"),
                NSNumber.class);
        assertEquals(42, value2.intValue());
    }

}
View Full Code Here

                NSNumber.CLASS.numberWithInt(42),
                NSNumber.CLASS.numberWithInt(64)
        );
        assertEquals(2, array.count());
        NSNumber second = Rococoa.cast(array.objectAtIndex(1), NSNumber.class);
        assertEquals(64, second.intValue());
    }
   
}
View Full Code Here

@SuppressWarnings("nls")
public class RococoaTest extends RococoaTestCase {
       
    @Test public void testCreate() {
        NSNumber fortyTwo = NSNumber.CLASS.numberWithInt(42);
        assertEquals(42, fortyTwo.intValue());       
    }
   
    @Test public void testEqualsWithAliases() {
        NSNumber fortyTwo = NSNumber.CLASS.numberWithInt(42);
        NSNumber fortyTwoAlias = Rococoa.wrap(fortyTwo.id(), NSNumber.class);
View Full Code Here

        assertEquals(s1, s2);
    }
  
    @Test public void testReturnTypes() {
        NSNumber e = NSNumber.CLASS.numberWithDouble(Math.E);
        assertEquals(2, e.intValue());
        assertEquals(2, e.longValue());
        assertEquals((float) Math.E, e.floatValue(), 0.001);
        assertEquals(Math.E, e.doubleValue(), 0.001);
    }
   
View Full Code Here

        NSAutoreleasePool pool = NSAutoreleasePool.new_();
        TestShunt shunt = Rococoa.create("TestShunt", TestShunt.class);
        ObjCObjectByReference reference = new ObjCObjectByReference();
        shunt.testNSNumberByReference_with(reference, 42);
        NSNumber value = reference.getValueAs(NSNumber.class);
        assertEquals(42, value.intValue());

        // we better have retained the result by the time it gets back
        assertEquals(3, value.retainCount());
        pool.drain();
        assertEquals(2, value.retainCount());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.