Search in sources :

Example 56 with BXMLItem

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

the class ArrayTest method testArrayToString.

@Test
public void testArrayToString() {
    String[] strArray = { "aaa", "bbb", "ccc" };
    BStringArray bStringArray = new BStringArray(strArray);
    Assert.assertEquals(bStringArray.stringValue(), "[\"aaa\", \"bbb\", \"ccc\"]");
    long[] longArray = { 6, 3, 8, 4 };
    BIntArray bIntArray = new BIntArray(longArray);
    Assert.assertEquals(bIntArray.stringValue(), "[6, 3, 8, 4]");
    double[] doubleArray = { 6.4, 3.7, 8.8, 7.4 };
    BFloatArray bFloatArray = new BFloatArray(doubleArray);
    Assert.assertEquals(bFloatArray.stringValue(), "[6.4, 3.7, 8.8, 7.4]");
    int[] boolArray = { 1, 1, 0 };
    BBooleanArray bBooleanArray = new BBooleanArray(boolArray);
    Assert.assertEquals(bBooleanArray.stringValue(), "[true, true, false]");
    BXMLItem[] xmlArray = { new BXMLItem("<foo/>"), new BXMLItem("<bar>hello</bar>") };
    BRefValueArray bXmlArray = new BRefValueArray(xmlArray, BTypes.typeXML);
    Assert.assertEquals(bXmlArray.stringValue(), "[<foo/>, <bar>hello</bar>]");
}
Also used : BXMLItem(org.ballerinalang.model.values.BXMLItem) BBooleanArray(org.ballerinalang.model.values.BBooleanArray) BRefValueArray(org.ballerinalang.model.values.BRefValueArray) BFloatArray(org.ballerinalang.model.values.BFloatArray) BStringArray(org.ballerinalang.model.values.BStringArray) BIntArray(org.ballerinalang.model.values.BIntArray) Test(org.testng.annotations.Test)

Aggregations

BXMLItem (org.ballerinalang.model.values.BXMLItem)56 Test (org.testng.annotations.Test)46 BValue (org.ballerinalang.model.values.BValue)42 BJSON (org.ballerinalang.model.values.BJSON)36 BString (org.ballerinalang.model.values.BString)26 OMNode (org.apache.axiom.om.OMNode)18 BXML (org.ballerinalang.model.values.BXML)17 BStruct (org.ballerinalang.model.values.BStruct)6 OMElement (org.apache.axiom.om.OMElement)5 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)5 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)4 ArrayList (java.util.ArrayList)3 OMText (org.apache.axiom.om.OMText)3 BXMLSequence (org.ballerinalang.model.values.BXMLSequence)3 OMDocument (org.apache.axiom.om.OMDocument)2 BBooleanArray (org.ballerinalang.model.values.BBooleanArray)2 BFloatArray (org.ballerinalang.model.values.BFloatArray)2 BIntArray (org.ballerinalang.model.values.BIntArray)2 BStringArray (org.ballerinalang.model.values.BStringArray)2 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)2