use of org.ballerinalang.model.values.BRefValueArray in project ballerina by ballerina-lang.
the class SystemTest method testFormatStringWithPadding.
@Test
public void testFormatStringWithPadding() {
BRefValueArray fArgs = new BRefValueArray();
fArgs.add(0, new BString("Hello Ballerina"));
BValue[] args = { new BString("%9.2s"), fArgs };
BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args);
Assert.assertEquals(returns[0].stringValue(), " He");
}
use of org.ballerinalang.model.values.BRefValueArray in project ballerina by ballerina-lang.
the class SystemTest method testFormatFloat.
@Test
public void testFormatFloat() {
BRefValueArray fArgs = new BRefValueArray();
fArgs.add(0, new BFloat(3.25));
BValue[] args = { new BString("%f"), fArgs };
BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args);
Assert.assertEquals(returns[0].stringValue(), "3.250000");
}
use of org.ballerinalang.model.values.BRefValueArray in project ballerina by ballerina-lang.
the class SystemTest method testFormatDecimalWithPadding.
@Test
public void testFormatDecimalWithPadding() {
BRefValueArray fArgs = new BRefValueArray();
fArgs.add(0, new BInteger(12345));
BValue[] args = { new BString("%15d"), fArgs };
BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args);
Assert.assertEquals(returns[0].stringValue(), " 12345");
}
use of org.ballerinalang.model.values.BRefValueArray in project ballerina by ballerina-lang.
the class SystemTest method testFormatString.
@Test
public void testFormatString() {
String name = "John";
BRefValueArray fArgs = new BRefValueArray();
fArgs.add(0, new BString(name));
BValue[] args = { new BString("%s"), fArgs };
BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args);
Assert.assertEquals(returns[0].stringValue(), name);
}
use of org.ballerinalang.model.values.BRefValueArray in project ballerina by ballerina-lang.
the class SystemTest method testFormatOctal.
@Test
public void testFormatOctal() {
BRefValueArray fArgs = new BRefValueArray();
fArgs.add(0, new BInteger(57005));
BValue[] args = { new BString("%o"), fArgs };
BValue[] returns = BRunUtil.invoke(compileResult, "testSprintf", args);
Assert.assertEquals(returns[0].stringValue(), "157255");
}
Aggregations