use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testReplace.
@Test
public void testReplace() {
BValue[] args = { new BString("Best Company is Google"), new BString("Google"), new BString("WSO2") };
BValue[] returns = BRunUtil.invoke(result, "replace", args);
Assert.assertTrue(returns[0] instanceof BString);
Assert.assertEquals(returns[0].stringValue(), "Best Company is WSO2");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testLength.
@Test
public void testLength() {
BValue[] args = { new BString("Bandwagon") };
BValue[] returns = BRunUtil.invoke(result, "length", args);
Assert.assertTrue(returns[0] instanceof BInteger);
Assert.assertEquals(((BInteger) returns[0]).intValue(), 9);
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testSubString.
@Test
public void testSubString() {
BValue[] args = { new BString("testValues"), new BInteger(0), new BInteger(9) };
BValue[] returns = BRunUtil.invoke(result, "subString", args);
Assert.assertTrue(returns[0] instanceof BString);
Assert.assertEquals(returns[0].stringValue(), "testValue");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testTrimNull.
@Test(expectedExceptions = { BLangRuntimeException.class }, expectedExceptionsMessageRegExp = ".*error:.*NullReferenceException.*")
public void testTrimNull() {
BValue[] args = { new BString(null) };
BValue[] returns = BRunUtil.invoke(result, "trim", args);
Assert.assertTrue(returns[0] instanceof BString);
Assert.assertEquals(returns[0].stringValue(), "This is a String");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testToBlob.
@Test
public void testToBlob() throws UnsupportedEncodingException {
String content = "Sample Content";
BValue[] args = { new BString(content), new BString("UTF-8") };
BValue[] returns = BRunUtil.invoke(result, "toBlob", args);
Assert.assertEquals(((BBlob) returns[0]).blobValue(), content.getBytes("UTF-8"), "Produced Blob value is wrong");
}
Aggregations