summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test_string/scilabcode/main.sci
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/test_string/scilabcode/main.sci')
-rw-r--r--tests/unit_tests/test_string/scilabcode/main.sci30
1 files changed, 30 insertions, 0 deletions
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