Search in sources :

Example 66 with BString

use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.

the class StringTest method testToLowerCase.

@Test
public void testToLowerCase() {
    BValue[] args = { new BString("COMPANY") };
    BValue[] returns = BRunUtil.invoke(result, "toLowerCase", args);
    Assert.assertTrue(returns[0] instanceof BString);
    Assert.assertEquals(returns[0].stringValue(), "company");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 67 with BString

use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.

the class StringTest method testFloatValueOf.

@Test
public void testFloatValueOf() {
    BValue[] args = { new BFloat(1.345f) };
    BValue[] returns = BRunUtil.invoke(result, "floatValueOf", args);
    Assert.assertTrue(returns[0] instanceof BString);
    final String expected = "1.345";
    Assert.assertEquals(returns[0].stringValue().substring(0, 5), expected);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BFloat(org.ballerinalang.model.values.BFloat) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 68 with BString

use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.

the class StringTest method testJsonValueOf.

@Test
public void testJsonValueOf() {
    BValue[] args = { new BJSON("{\"name\":\"chanaka\"}") };
    BValue[] returns = BRunUtil.invoke(result, "jsonValueOf", args);
    Assert.assertTrue(returns[0] instanceof BString);
    final String expected = "{\"name\":\"chanaka\"}";
    Assert.assertEquals(returns[0].stringValue(), expected);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) BString(org.ballerinalang.model.values.BString) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 69 with BString

use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.

the class StringTest method testHasSuffix.

@Test
public void testHasSuffix() {
    BValue[] args = { new BString("One Two"), new BString("Two") };
    BRunUtil.invoke(result, "hasSuffix", args);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 70 with BString

use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.

the class StringTest method testReplaceFirstByNull.

@Test(expectedExceptions = { BLangRuntimeException.class }, expectedExceptionsMessageRegExp = ".*error:.*NullReferenceException.*")
public void testReplaceFirstByNull() {
    BValue[] args = { new BString("abc is not abc as abc anymore"), new BString("abc"), new BString(null) };
    BRunUtil.invoke(result, "replaceFirst", args);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Aggregations

BString (org.ballerinalang.model.values.BString)418 BValue (org.ballerinalang.model.values.BValue)339 Test (org.testng.annotations.Test)321 BInteger (org.ballerinalang.model.values.BInteger)77 BStruct (org.ballerinalang.model.values.BStruct)76 BMap (org.ballerinalang.model.values.BMap)37 BBoolean (org.ballerinalang.model.values.BBoolean)36 BFloat (org.ballerinalang.model.values.BFloat)34 BJSON (org.ballerinalang.model.values.BJSON)28 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)21 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)18 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)11 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)11 CompileResult (org.ballerinalang.launcher.util.CompileResult)11 BBlob (org.ballerinalang.model.values.BBlob)11 BStringArray (org.ballerinalang.model.values.BStringArray)11 BType (org.ballerinalang.model.types.BType)10 BIntArray (org.ballerinalang.model.values.BIntArray)9 BRefType (org.ballerinalang.model.values.BRefType)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7