Added string function tests

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@636 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
new file mode 100644
index 0000000..a66b00f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr01.aql
@@ -0,0 +1,28 @@
+/*
+ * Test case Name : cpttostr01.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Pass the codepoints which are in the internal dataset to the function. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open{
+id:int32,
+cpt:[int32]
+}
+
+create dataset testds(TestType) partitioned by key id;
+
+// insert codepoint data into internal dataset testds here into the cpt attribute
+
+insert into dataset testds({"id":123,"cpt":[0048,0045,0057,0044,0065,0045,0090]});
+
+write output to nc1:"rttest/string_cpttostr01.adm";
+
+for $l in dataset('testds')
+return codepoint-to-string($l.cpt)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql
new file mode 100644
index 0000000..1e99989
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr02.aql
@@ -0,0 +1,17 @@
+/*
+ * Test case Name : cpttostr02.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ *                : Inputs are codepoint values for lowecase, uppercase and special characters
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+write output to nc1:"rttest/string_cpttostr02.adm";
+
+let $c1 := codepoint-to-string([0065,0066,0067,0068,0069,0070,0071,0072,0073,0074,0075,0076,0077,0078,0079,0080,0081,0082,0083,0084,0085,0086,0087,0088,0089,0090]) 
+
+let $c2 := codepoint-to-string([0097,0098,0099,0100,0101,0102,0103,0104,0105,0106,0107,0108,0109,0110,0111,0112,0113,0114,0115,0116,0117,0118,0119,0120,0121,0122]) 
+
+let $c3 := codepoint-to-string([0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0052,0053,0054,0055,0063,0064]) 
+
+return {"c1":$c1,"c2":$c2,"c3":$c3}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql
new file mode 100644
index 0000000..9e177c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/cpttostr04.aql
@@ -0,0 +1,13 @@
+/*
+ * Test case Name : cpttostr04.aql
+ * Description    : Test codepoint-to-string(codepoint) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+//Input = Output
+
+write output to nc1:"rttest/string_cpttostr04.adm";
+
+let $c1 := codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))
+return { "c1":$c1 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql b/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql
new file mode 100644
index 0000000..cfca775
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/endwith02.aql
@@ -0,0 +1,16 @@
+/*
+ * Testcase Name : endwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+write output to nc1:"rttest/string_endwith02.adm";
+
+for $a in [end-with("aBCDEFghIa",codepoint-to-string([0041])),
+end-with("AbCDEFghIA",codepoint-to-string([0041])),
+end-with("AbCdEfGhIjKlMnOpQrStUvWxYz","xYz"),
+end-with("abcdef",lowercase("ABCDEf")),
+end-with("abcdef","abcdef"),
+end-with("abcdef123","ef123")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
new file mode 100644
index 0000000..832efbc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/endwith03.aql
@@ -0,0 +1,33 @@
+/*
+ * Testcase Name : endwith03.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 20th April 2012
+ */
+
+// create internal dataset, insert string data into string field and pass the string filed as input to end-with function
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Jim Jones"});
+insert into dataset testds({"name":"Ravi Kumar"});
+insert into dataset testds({"name":"Bruce Li"});
+insert into dataset testds({"name":"Marian Jones"});
+insert into dataset testds({"name":"Phil Jones"});
+insert into dataset testds({"name":"I am Jones"});
+
+write output to nc1:"rttest/string_endwith03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+where end-with($l.name,"Jones")
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql
new file mode 100644
index 0000000..1018f02
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches02.aql
@@ -0,0 +1,23 @@
+/*
+ * Testcase Name  :  matches02.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+write output to nc1:"rttest/string_matches02.adm";
+
+let $c1:="Hello World"
+let $c2:="Hello World"
+let $c3:=matches($c1,$c2)
+let $c4:=matches("Asterix for Dummies","Asterix for Dummies")
+let $c5:=matches("semistructured data",lowercase("SEMISTRUCTURED DATA"))
+let $c6:=matches("Mega Living!","Mega")
+let $c7:=matches("Mega Living!","ving!")
+let $c8:=matches("Mega Living!"," ")
+let $c9:=matches("Mega Living!","a l")
+let $c10:=matches("Mega Living!","")
+let $c11:=matches(" "," ")
+let $c12:=matches("aaaa","aaaaa")
+return {"c3":$c3,"c4":$c4,"c5":$c5,"c6":$c6,"c7":$c7,"c8":$c8,"c9":$c9,"c10":$c10,"c11":$c11,"c12":$c12}
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql
new file mode 100644
index 0000000..7f4623c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches03.aql
@@ -0,0 +1,26 @@
+/*
+ * Testcase Name  :  matches03.aql
+ * Description    :  Positive tests
+ *                :  Test matches functions with regular expressions as third input parameter
+ * Success        :  Yes
+ * Date           :  23th April 2012
+ */
+
+
+write output to nc1:"rttest/string_matches03.adm";
+
+for $a in [matches("1234567890","[^a-z]"),
+matches("1234567890","[^a-zA-Z]"),
+matches("abcdefghABCDEFGH","[^a-zA-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^a-zA-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^A-Z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^a-z]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[^0-9]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[0-9]"),
+matches("adefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[a-z&&[^bc]]"),
+matches("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","[a-z&&[^bc]]"),
+matches("bc","[a-z&&[^bc]]"),
+matches("mnop","[a-z&&[^m-p]]"),
+matches("abcdmnop","[a-z&&[^m-p]]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql
new file mode 100644
index 0000000..829a176
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches04.aql
@@ -0,0 +1,17 @@
+/*
+ * Testcase Name  :  matches04.aql
+ * Description    :  Positive tests
+ * Success        :  Yes (tests to check for patterns using regular expressions)
+ * Date           :  20th April 2012
+ */
+
+write output to nc1:"rttest/string_matches04.adm";
+
+for $a in [matches("UCI UCI UCI UCI UCI UCI","[UCI{6}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{3,6}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{7}]"),
+matches("UCI UCI UCI UCI UCI UCI","[UCI{1}]"),
+matches("UCI UCI UCI","[UCI+]"),
+matches("false","[true|false]"),
+matches("YX","[XY]")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
new file mode 100644
index 0000000..2f7b83e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches05.aql
@@ -0,0 +1,34 @@
+/*
+ * Testcase Name  :  matches05.aql
+ * Description    :  Positive tests
+ *                :  Create two internal datasets and insert string data and perform match of fname using matches function.
+ * Success        :  Yes
+ * Date           :  25th April 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType1 as{
+fname:string,
+lname:string,
+id:int32
+}
+
+create dataset testds1(TestType1) partitioned by key id;
+
+insert into dataset testds1({"fname":"Test","lname":"Test","id":123});
+insert into dataset testds1({"fname":"Testa","lname":"Test","id":124});
+insert into dataset testds1({"fname":"Test1","lname":"Test1","id":125});
+insert into dataset testds1({"fname":"Test","lname":"Testb","id":126});
+insert into dataset testds1({"fname":"Test2","lname":"Test2","id":127});
+
+write output to nc1:"rttest/string_matches05.adm";
+
+//Perform the match for fname and lname
+for $l in dataset('testds1')
+order by $l.id
+where matches($l.fname,$l.lname)
+return $l
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql
new file mode 100644
index 0000000..0e18a84
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches06.aql
@@ -0,0 +1,25 @@
+/*
+ * Description  : Test matches string function using regular expressions
+ * Expected Res : Success
+ * Date         : May 21 2012
+ */
+
+write output to nc1:"rttest/string_matches06.adm";
+
+for $a in [matches("mnop","."),
+matches("abcdefABCDEF","/d"),
+matches("12345","\d"),
+matches("abcdefGHIJK","\D"),
+matches("       ","\s"),
+matches("       ","\S"),
+matches("Welcome to pattern matching!","[a-zA-Z_0-9]"),
+matches("!@#$%^&*()","[a-zA-Z_0-9]"),
+matches("!@#$%^&*()","[^\W]"),
+matches("!@#$%^&*","[^\w]"),
+matches("0xffff","[\p{XDigit}]"),
+matches("FFFFFFFF","[\p{XDigit}]"),
+matches("abcdefgh","[\p{javaLowerCase}]"),
+matches("ABCDEF","[\p{javaLowerCase}]"),
+matches(codepoint-to-string([0163]),"[\p{Sc}]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
new file mode 100644
index 0000000..1e96b5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/matches11.aql
@@ -0,0 +1,16 @@
+/*
+ * Testcase Name  :  matches11.aql
+ * Description    :  Positive tests
+ * Success        :  Yes
+ * Date           :  20th April 2012
+ */
+
+write output to nc1:"rttest/string_matches11.adm";
+
+for $a in [matches("hello",null),
+matches("hello","helllo"),
+matches("hello"," "),
+matches(null,"hello"),
+matches("hello","[^a-z]")]
+return $a
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql
new file mode 100644
index 0000000..b4ab93a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith02.aql
@@ -0,0 +1,26 @@
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_startwith02.adm";
+
+for $a in [start-with("Hello","H"),
+start-with("Hello",lowercase("He")),
+start-with("Hello",""),
+start-with("Hello"," "),
+start-with("Hello",null),
+start-with("abcdef",lowercase("ABCDEf")),
+start-with("abcdef","abcdef"),
+start-with("abcdef","abc "),
+start-with("abc\tdef","abc\t"),
+start-with(" abcdef","abc"),
+start-with("0x1FF","0"),
+start-with("<ID>","<"),
+start-with("aBCDEFghI",codepoint-to-string([0041])),
+start-with("AbCDEFghI",codepoint-to-string([0041]))]
+return $a
+
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
new file mode 100644
index 0000000..68f09ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/startwith03.aql
@@ -0,0 +1,35 @@
+/*
+ * Testcase Name : startwith02.aql
+ * Description   : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+// Create internal dataset, insert string data into string field and pass the string field as first input to start-with function
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"John Smith"});
+insert into dataset testds({"name":"John Doe"});
+insert into dataset testds({"name":"John Wayne"});
+insert into dataset testds({"name":"Johnson Ben"});
+insert into dataset testds({"name":"Johnny Walker"});
+insert into dataset testds({"name":"David Smith"});
+insert into dataset testds({"name":"Not a Name"});
+
+write output to nc1:"rttest/string_startwith03.adm;
+
+// Return all names that start with John
+
+for $l in dataset('testds')
+order by $l.name
+where start-with($l.name,"John")
+return $l
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
new file mode 100644
index 0000000..0b3941d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strconcat01.aql
@@ -0,0 +1,38 @@
+/*
+ * Test case Name : strconcat01.aql
+ * Description    : Test string-concat([string]) function.
+ *                : Pass the strings(which are in internal dataset) to string-concat function for concatenation. 
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open{
+id:int32,
+fname:string,
+lname:string
+}
+
+create dataset testds(TestType) partitioned by key id;
+
+// insert string data into internal dataset testds into the name attribute
+
+insert into dataset testds({"id":123,"fname":"John","lname":"Smith"});
+insert into dataset testds({"id":124,"fname":"Bob","lname":"Jones"});
+insert into dataset testds({"id":125,"fname":"Mike","lname":"Carey"});
+insert into dataset testds({"id":126,"fname":"Chen","lname":"Li"});
+insert into dataset testds({"id":121,"fname":"Young Seok","lname":"Kim"});
+insert into dataset testds({"id":122,"fname":"Alex","lname":"Behm"});
+insert into dataset testds({"id":127,"fname":"Raman","lname":"Grover"});
+insert into dataset testds({"id":128,"fname":"Yingyi","lname":"Bu"});
+insert into dataset testds({"id":129,"fname":"Vinayak","lname":"Borkar"});
+
+write output to nc1:"rttest/string_strconcat01.adm";
+
+for $l in dataset('testds')
+order by $l.id
+return { "Full Name": string-concat([$l.fname,$l.lname]) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql
new file mode 100644
index 0000000..4991bde
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strconcat02.aql
@@ -0,0 +1,11 @@
+/*
+ * Description    : Test string-concat([string]) function.
+ * Success        : Yes
+ * Date           : 16th April 2012
+ */
+
+
+write output to nc1:"rttest/string_strconcat02.adm";
+
+for $a in [string-concat([codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")),codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")),codepoint-to-string(string-to-codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"))]),string-concat([" ","a","b","  ","c","d","e","f","g","p","o","q","r","s","t"," "]),string-concat(["This is a test","and all tests must pass","and life is good..."])]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql
new file mode 100644
index 0000000..852570f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen02.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Test string-length(string) function 
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+
+/*
+for $a in [ string-length("abcdefghijklmnopqrstu"),
+string-length("ABCDEFGHIJKLMNOPQRSTU"),
+string-length("abcdEFGHijklMNOPqrstu"),
+string-length("abcd EFGH ijkl MNOP qrstu"),
+string-length("   Hello World    !!!!....:-)"),
+string-length(string-concat(["test string to","concatenate"])),
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+return $a
+*/
+
+write output to nc1:"rttest/string_strlen02.adm";
+
+for $a in [ string-length("abcdefghijklmnopqrstu"),
+string-length("ABCDEFGHIJKLMNOPQRSTU"),
+string-length("abcdEFGHijklMNOPqrstu"),
+string-length("abcd EFGH ijkl MNOP qrstu"),
+string-length("   Hello World    !!!!....:-)"),
+string-length("~!@#$%^&*()_+{}:?<>/.,';`][\")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
new file mode 100644
index 0000000..bba2a7f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strlen03.aql
@@ -0,0 +1,37 @@
+/*
+ * Description    : Test string-length(string) function 
+ * Expected Res   : Success
+ * Date           : 19th April 2012
+ */
+
+
+// Create internal dataset, insert string data and pass the string attribute to string-length function, and verify results.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Maradona"});
+insert into dataset testds({"name":"Pele"});
+insert into dataset testds({"name":"Roberto Baggio"});
+insert into dataset testds({"name":"Beckham David"});
+insert into dataset testds({"name":"Rooney"});
+insert into dataset testds({"name":"Ronaldinho"});
+insert into dataset testds({"name":"Ronaldo"});
+insert into dataset testds({"name":"Zinadine Zidane"});
+insert into dataset testds({"name":"Cristiano Ronaldo"});
+insert into dataset testds({"name":"Messi"});
+insert into dataset testds({"name":"Tevez"});
+insert into dataset testds({"name":"Henry"});
+
+write output to nc1:"rttest/string_strlen03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+return string-length($l.name)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql
new file mode 100644
index 0000000..fdbf014
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt01.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with valid inputs
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt01.adm";
+
+let $x := "ABCDEFGHIJKLMNOPQRSTUVWXYZ-01234567890"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql
new file mode 100644
index 0000000..b203f6d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt02.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt02.adm";
+
+let $x := "\"'-=_+|\,./<>?:;~`"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql
new file mode 100644
index 0000000..6daf0fe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/strtocpt03.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : Test string to codepoint function with special characters 
+ * Expected Res : Success
+ * Date         : 7th Aug 2012
+ */
+
+write output to nc1:"rttest/string_strtocpt03.adm";
+
+let $x := "!@#$%^&*()"
+return string-to-codepoint($x)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql
new file mode 100644
index 0000000..791e7c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr01.aql
@@ -0,0 +1,30 @@
+/*
+ * Testcase Name  : substr01.aql
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+write output to nc1:"rttest/string_substr01.adm";
+
+let $str1:="Hello World"
+let $str2:=substring2($str1,10)
+
+let $str3:="This is a test string"
+let $str4:=substring2($str3,21)
+
+let $str5:="This is a test string"
+let $str6:=substring2($str5,22)
+
+let $str7:="This is a test string"
+let $str8:=substring2($str7,0)
+
+let $str9:="This is a test string"
+let $str10:=substring2($str9,-1)
+
+let $str11:="This is a test string"
+let $str12:="This is a another test string"
+let $str13:=substring2(string-concat([$str11,$str12]),21)
+
+let $str14:=substring2("UC Irvine",string-length("UC Irvine")/2)
+return { "str2":$str2,"str4":$str4,"str6":$str6,"str8":$str8,"str10":$str10,"str13":$str13,"str14":$str14}
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql
new file mode 100644
index 0000000..880499c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr04.aql
@@ -0,0 +1,21 @@
+/*
+ * Testcase Name  : substr04.aql
+ * Description    : Test substring2(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 18th April 2012
+ */
+
+write output to nc1:"rttest/string_substr04.adm";
+
+for $a in [ substring2("hello world",7,11),
+substring2("hello world",1,11),
+substring2("hello world",3,7),
+substring2("ABCD",3,6),
+substring2("ABCD",0,4),
+substring2("UC Irvine",4,string-length("UC Irvine")),
+substring2("UC Irvine",0,string-length("UC Irvine")),
+substring2("UC Irvine",1,string-length("UC Irvine")),
+substring2(substring2("UC Irvine",4),0,string-length("Irvine")),
+substring2(substring2("UC Irvine",4),0,(string-length("Irvine")/2))
+]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
new file mode 100644
index 0000000..fbdcba4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr05.aql
@@ -0,0 +1,33 @@
+/*
+ * Testcase Name  : substr05.aql
+ * Description    : Test substring2(string,position,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+// To test substring2 function with string data stored in an internal dataset.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+name : string
+}
+
+create dataset testdst(TestType) partitioned by key name;
+
+insert into dataset testdst({"name":"UC Berkeley"});
+insert into dataset testdst({"name":"UC Irvine"});
+insert into dataset testdst({"name":"UC LA"});
+insert into dataset testdst({"name":"UC Riverside"});
+insert into dataset testdst({"name":"UC San Diego"});
+insert into dataset testdst({"name":"UC Santa Barbara"});
+insert into dataset testdst({"name":"UT Austin "});
+insert into dataset testdst({"name":"UT Dallas"});
+
+write output to nc1:"rttest/string_substr05.adm";
+
+for $a in dataset('testdst')
+order by $a.name
+return substring2($a.name,4,string-length($a.name));
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
new file mode 100644
index 0000000..82d21c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/substr06.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Test substring2(string,position) built in function.
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+// To test substring function with string data stored in an internal dataset.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+name : string
+}
+
+create dataset testdst(TestType) partitioned by key name;
+
+insert into dataset testdst({"name":"UC Berkeley"});
+insert into dataset testdst({"name":"UC Irvine"});
+insert into dataset testdst({"name":"UC LA"});
+insert into dataset testdst({"name":"UC Riverside"});
+insert into dataset testdst({"name":"UC San Diego"});
+insert into dataset testdst({"name":"UC Santa Barbara"});
+insert into dataset testdst({"name":"UT Austin "});
+insert into dataset testdst({"name":"UT Dallas"});
+
+write output to nc1:"rttest/string_substr06.adm";
+
+for $a in dataset('testdst')
+order by $a.name
+return substring2($a.name,4);
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql
new file mode 100644
index 0000000..2c16e01
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase02.aql
@@ -0,0 +1,23 @@
+/*
+ * Testcase Name : toLowerCas02.aql
+ * Description   : Test lowercase(string) function
+ *               : Positive tests
+ * Success       : Yes
+ * Date          : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_toLowerCase02.adm";
+
+for $a in [lowercase("a   b  c  d  e  f  g"),
+    lowercase("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"),
+    lowercase("abcdefghij KLMNOP qrstu VWXYZ"),
+    lowercase("abcdefghijklmnopqrstuvwxyz"),
+    lowercase("this is a test string"),
+    lowercase("smaller string"),
+    lowercase("ABCD"),
+    lowercase("AbCdEfGhIjKlMnOpQrStUvWxYz"),
+    lowercase("abcdefghijkABCDEFGHIJK"),
+    lowercase("HIJKLMNOPQRhijklmnopqr"),
+    lowercase(substring2("ABCDEFghIJKLMnopQRSTuvwxYZ01234",0)),
+    lowercase("A33B2CD1EF78GHijk123LMNopqrstUVW3x2y01035Z")]
+return $a
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
new file mode 100644
index 0000000..411dacf
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase03.aql
@@ -0,0 +1,39 @@
+/*
+ * Test case Name : toLowerCas03.aql
+ * Description    : Test lowercase(string) function 
+ *                : This test case covers Positive tests
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+
+// Create internal dataset, insert string data and pass the string attribute to lowercase function, and verify results.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as {
+name:string
+}
+
+create dataset testds(TestType) partitioned by key name;
+
+insert into dataset testds({"name":"Maradona"});
+insert into dataset testds({"name":"Pele"});
+insert into dataset testds({"name":"Roberto Baggio"});
+insert into dataset testds({"name":"Beckham David"});
+insert into dataset testds({"name":"Rooney"});
+insert into dataset testds({"name":"Ronaldinho"});
+insert into dataset testds({"name":"Ronaldo"});
+insert into dataset testds({"name":"Zinadine Zidane"});
+insert into dataset testds({"name":"Cristiano Ronaldo"});
+insert into dataset testds({"name":"Messi"});
+insert into dataset testds({"name":"Tevez"});
+insert into dataset testds({"name":"Henry"});
+
+write output to nc1:"rttest/string_toLowerCase03.adm";
+
+for $l in dataset('testds')
+order by $l.name
+return lowercase($l.name)
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql
new file mode 100644
index 0000000..3d99aab
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/string/toLowerCase04.aql
@@ -0,0 +1,12 @@
+/*
+ * Test case Name : toLowerCas04.aql
+ * Description    : Test lowercase(string) function 
+ *                : Convert all upper case english alphabets A-Z to lower case a-z
+ * Success        : Yes
+ * Date           : 19th April 2012
+ */
+
+write output to nc1:"rttest/string_toLowerCase04.adm";
+
+for $a in[lowercase(codepoint-to-string([0065,0066,0067,0068,0069,0070,0071,0072,0073,0074,0075,0076,0077,0078,0079,0080,0081,0082,0083,0084,0085,0086,0087,0088,0089,0090])),lowercase(string-concat(["ABCDEFGHIJKLMNOP","QRSTUVWXYZ"]))]
+return $a