use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class TypeCastExprTest method testFloatToInt.
// @Test
// public void testXMLToJSON() {
// BValue[] args = {new BXML("<name>chanaka</name>")};
// BValue[] returns = Functions.invoke(bLangProgram, "xmltojson", args);
// Assert.assertTrue(returns[0] instanceof BJSON);
// final String expected = "{\"name\":\"chanaka\"}";
// Assert.assertEquals(returns[0].stringValue(), expected);
// }
//
// @Test
// public void testJSONToXML() {
// BValue[] args = {new BJSON("{\"name\":\"chanaka\"}")};
// BValue[] returns = BTestUtils.invoke(result, "jsontoxml", args);
// Assert.assertTrue(returns[0] instanceof BXML);
// final String expected = "<name>chanaka</name>";
// Assert.assertEquals(returns[0].stringValue(), expected);
// }
@Test
public void testFloatToInt() {
BValue[] args = { new BFloat(222222.44444f) };
BValue[] returns = BRunUtil.invoke(result, "floattoint", args);
Assert.assertTrue(returns[0] instanceof BInteger);
final String expected = "222222";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class TypeCastExprTest method testIntToFloat.
@Test
public void testIntToFloat() {
BValue[] args = { new BInteger(55555555) };
BValue[] returns = BRunUtil.invoke(result, "inttofloat", args);
Assert.assertTrue(returns[0] instanceof BFloat);
double expected = 5.5555555E7;
Assert.assertEquals(((BFloat) returns[0]).floatValue(), expected, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class ValueTypeCastExprTest method testFloatToAny.
@Test
public void testFloatToAny() {
BValue[] args = { new BFloat(111.333f) };
BValue[] returns = BRunUtil.invoke(result, "floatToAny", args);
Assert.assertTrue(returns[0] instanceof BFloat);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class ValueTypeCastExprTest method testBooleanToFloat.
@Test
public void testBooleanToFloat() {
BValue[] args = { new BBoolean(true) };
BValue[] returns = BRunUtil.invoke(result, "booleanToFloat", args);
Assert.assertTrue(returns[0] instanceof BFloat);
final double expected = 1.0;
Assert.assertEquals(((BFloat) returns[0]).floatValue(), expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class ValueTypeCastExprTest method testFloatToInt.
@Test
public void testFloatToInt() {
BValue[] args = { new BFloat(222222.44444f) };
BValue[] returns = BRunUtil.invoke(result, "floatToInt", args);
Assert.assertTrue(returns[0] instanceof BInteger);
final String expected = "222222";
Assert.assertEquals(returns[0].stringValue(), expected);
}
Aggregations