use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class TypeCastExprTest method testIntToString.
/*@Test
public void testStringToXML() {
BValue[] args = {new BString("<name>chanaka</name>")};
BValue[] returns = BTestUtils.invoke(result, "stringtoxml", args);
Assert.assertTrue(returns[0] instanceof BXML);
final String expected = "<name>chanaka</name>";
Assert.assertEquals(returns[0].stringValue(), expected);
}*/
@Test
public void testIntToString() {
BValue[] args = { new BInteger(111) };
BValue[] returns = BRunUtil.invoke(result, "inttostring", args);
Assert.assertTrue(returns[0] instanceof BString);
final String expected = "111";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.model.values.BInteger 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.BInteger 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.BInteger 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);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class ValueTypeCastExprTest method testBooleanToInt.
@Test
public void testBooleanToInt() {
BValue[] args = { new BBoolean(true) };
BValue[] returns = BRunUtil.invoke(result, "booleanToInt", args);
Assert.assertTrue(returns[0] instanceof BInteger);
final int expected = 1;
Assert.assertEquals(((BInteger) returns[0]).intValue(), expected);
}
Aggregations