summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test_string
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/test_string')
-rw-r--r--tests/unit_tests/test_string/scilabcode/asciitest.sci11
-rw-r--r--tests/unit_tests/test_string/scilabcode/asciitest2.sci5
-rw-r--r--tests/unit_tests/test_string/scilabcode/main.sci30
-rw-r--r--tests/unit_tests/test_string/scilabcode/strchrtest.sci6
-rw-r--r--tests/unit_tests/test_string/scilabcode/strcspntest.sci6
-rw-r--r--tests/unit_tests/test_string/scilabcode/strncpytest.sci6
6 files changed, 64 insertions, 0 deletions
diff --git a/tests/unit_tests/test_string/scilabcode/asciitest.sci b/tests/unit_tests/test_string/scilabcode/asciitest.sci
new file mode 100644
index 0000000..aa0017d
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/asciitest.sci
@@ -0,0 +1,11 @@
+//This function test the ascii function in scilab.
+//Ascii function takes the input string and then gives the ascii code of the string.
+// The output for the scilab will be:-
+//[97. 110. 107. 105. 116. 32. 105. 115. 32. 114. 97. 106.]
+
+function asciitest()
+ y="ankit is raj"; //This is the input string for testing the function.
+ x=ascii(y); //calling of the function
+ disp(x);
+endfunction
+
diff --git a/tests/unit_tests/test_string/scilabcode/asciitest2.sci b/tests/unit_tests/test_string/scilabcode/asciitest2.sci
new file mode 100644
index 0000000..ca7dcb7
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/asciitest2.sci
@@ -0,0 +1,5 @@
+function asciitest2()
+ d=[97 98 99 100 101];
+ si=ascii(d);
+ disp(si);
+endfunction
diff --git a/tests/unit_tests/test_string/scilabcode/main.sci b/tests/unit_tests/test_string/scilabcode/main.sci
new file mode 100644
index 0000000..4030ee0
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/main.sci
@@ -0,0 +1,30 @@
+//This is the demo function to test a set of string functions
+// ascii->converts the input char vector/array to corresponding ascii code or vice versa
+// strchr-> it finds the occurence of a charcter in a given string
+// strncpy->copy charcters from string
+// strspn-> get span of character set in string
+
+function main()
+ strascii1="ankit is raj"; //This is the input string for testing the function.
+ asciiout1=ascii(strascii1); //calling of the function
+ disp(asciiout1);
+
+ strascii2=[97 98 99 100 101]; //Input as the ascii code to get converted to string
+ asciiout2=ascii(strascii2); //calling the function
+ disp(asciiout2);
+
+ str="This is a sample string";
+ ch="s";
+ out1=strchr(str,ch);
+ disp(out1);
+
+ ss="Ankit Raj";
+ nn=5;
+ resu=strncpy(ss,nn);
+ disp(resu);
+
+ strsample2="Hello this is Ankit";
+ a="Ank";
+ oup2=strspn(a,strsample2);
+ disp(oup2)
+endfunction
diff --git a/tests/unit_tests/test_string/scilabcode/strchrtest.sci b/tests/unit_tests/test_string/scilabcode/strchrtest.sci
new file mode 100644
index 0000000..f8d3419
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/strchrtest.sci
@@ -0,0 +1,6 @@
+function strchrtest()
+ s="This is a sample string";
+ ch="s";
+ y=strchr(s,ch);
+ disp(y);
+endfunction
diff --git a/tests/unit_tests/test_string/scilabcode/strcspntest.sci b/tests/unit_tests/test_string/scilabcode/strcspntest.sci
new file mode 100644
index 0000000..9a03c57
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/strcspntest.sci
@@ -0,0 +1,6 @@
+function strcspntest()
+ x="123243545assdsc";
+ y="anki5t3";
+ z=strcspn(y,x);
+ disp(z);
+endfunction
diff --git a/tests/unit_tests/test_string/scilabcode/strncpytest.sci b/tests/unit_tests/test_string/scilabcode/strncpytest.sci
new file mode 100644
index 0000000..14eceb8
--- /dev/null
+++ b/tests/unit_tests/test_string/scilabcode/strncpytest.sci
@@ -0,0 +1,6 @@
+function strncpytest()
+ ss="Ankit Raj";
+ nn=5;
+ resu=strncpy(ss,nn);
+ disp(resu);
+endfunction