diff options
author | Abhinav Dronamraju | 2017-07-10 22:08:27 +0530 |
---|---|---|
committer | Abhinav Dronamraju | 2017-07-10 22:08:27 +0530 |
commit | f80b5800ddb8417530f68049f6895beccb89cadf (patch) | |
tree | 564a23878bc400ecc0873bb4b1f5b172af22cfc6 /2.3-1/tests | |
parent | c1874d367d68cb47b82cc7a1173caaf38e9e3d68 (diff) | |
parent | 2e9eadc75e51483c41a30544496b4e05c0cf7c41 (diff) | |
download | Scilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.tar.gz Scilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.tar.bz2 Scilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.zip |
Pulled from upstream master
Diffstat (limited to '2.3-1/tests')
42 files changed, 377 insertions, 1 deletions
diff --git a/2.3-1/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci b/2.3-1/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci index 13624cfb..c6e09a0c 100644 --- a/2.3-1/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci +++ b/2.3-1/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci @@ -1,4 +1,4 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= FLOAT
function mainfunction()
diff --git a/2.3-1/tests/unit_tests/test01_DCT/scilabcode/main.sci b/2.3-1/tests/unit_tests/test01_DCT/scilabcode/main.sci new file mode 100644 index 00000000..33c44622 --- /dev/null +++ b/2.3-1/tests/unit_tests/test01_DCT/scilabcode/main.sci @@ -0,0 +1,7 @@ +//SCI2C: DEFAULT_PRECISION= FLOAT +//test for discrete cosine tranform using precision as float +function main() + b=([5 2 6 7;1 9 7 6+%i]) + y=dct(b,1) //calling dct + disp(y) +endfunction diff --git a/2.3-1/tests/unit_tests/test02_IDCT/scilabcode/testidct.sci b/2.3-1/tests/unit_tests/test02_IDCT/scilabcode/testidct.sci new file mode 100644 index 00000000..deed0f99 --- /dev/null +++ b/2.3-1/tests/unit_tests/test02_IDCT/scilabcode/testidct.sci @@ -0,0 +1,7 @@ +//SCI2C: DEFAULT_PRECISION= FLOAT +//test for inverse discrete cosine tranfrom +function testidct() + b=[1 2 3;4 5 6+%i] //declaring complex matrix + y=idct(b) //calling idct + disp(y) +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/analog_check.sci b/2.3-1/tests/unit_tests/testArduino/analog_check.sci new file mode 100644 index 00000000..779f5b7f --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/analog_check.sci @@ -0,0 +1,7 @@ +function analog_check() + cmd_analog_out(1,3,50) + cmd_analog_out(1,5,100) + cmd_analog_out(1,6,175) + cmd_analog_out(1,9,255) + +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/analog_in_check_volt.sci b/2.3-1/tests/unit_tests/testArduino/analog_in_check_volt.sci new file mode 100644 index 00000000..16e79054 --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/analog_in_check_volt.sci @@ -0,0 +1,4 @@ +function analog_in_check_volt() + val = cmd_analog_in_volt(1,0) + cmd_analog_out_volt(1,6,val) +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/blink_13.sci b/2.3-1/tests/unit_tests/testArduino/blink_13.sci new file mode 100644 index 00000000..37dc93fd --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/blink_13.sci @@ -0,0 +1,6 @@ +function blink_13() + cmd_digital_out(1,13,1) //--To turn on the LED on pin no. 13 + sleep(1000) //---delay of 1 second + cmd_digital_out(1,13,0) //--To turn on the LED off pin no. 13 + sleep(1000) //---delay of 1 second +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/board_test_release2.sci b/2.3-1/tests/unit_tests/testArduino/board_test_release2.sci new file mode 100644 index 00000000..fd21cff7 --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/board_test_release2.sci @@ -0,0 +1,11 @@ +function board_test_release2() + cmd_dcmotor_setup(1,3,1,9,10) + cmd_dcmotor_run(1,1,255) + sleep(3000) + cmd_dcmotor_release(1,1) + sleep(3000) + cmd_dcmotor_run(1,1,-255) + sleep(3000) + cmd_dcmotor_release(1,1) + sleep(3000) +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/digital_in_check.sci b/2.3-1/tests/unit_tests/testArduino/digital_in_check.sci new file mode 100644 index 00000000..4dfbeb6e --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/digital_in_check.sci @@ -0,0 +1,10 @@ +function digital_in_check() + a=cmd_digital_in(1,7) + if a==1 then + cmd_digital_out(1,13,1) + cmd_digital_out(1,9,0) + else + cmd_digital_out(1,9,1) + cmd_digital_out(1,13,0) + end +endfunction diff --git a/2.3-1/tests/unit_tests/testArduino/i2c_master.sci b/2.3-1/tests/unit_tests/testArduino/i2c_master.sci new file mode 100644 index 00000000..2636185a --- /dev/null +++ b/2.3-1/tests/unit_tests/testArduino/i2c_master.sci @@ -0,0 +1,9 @@ +function i2c_master()
+
+ dev1 = cmd_i2c_dev(1);
+ cmd_i2c_write(dev1,10);
+ sleep(1000);
+ cmd_i2c_write(dev1,9);
+ sleep(1000);
+
+endfunction
diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvd.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvd.sci new file mode 100644 index 00000000..c5da4cd3 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvd.sci @@ -0,0 +1,6 @@ +function testsvd() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + s = svd(A) // Calling Function Sequence + disp(s) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdeconomy.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdeconomy.sci new file mode 100644 index 00000000..0459c790 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdeconomy.sci @@ -0,0 +1,11 @@ +function testsvdeconomy() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt] = svd(A,'e') // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdim.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdim.sci new file mode 100644 index 00000000..16633cce --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdim.sci @@ -0,0 +1,6 @@ +// Function double_complex - test data. +function svdim() + b = [ (5.91+5.69*%i),(3.15-4.08*%i),(4.89+4.20*%i),(7.09+2.72*%i);(1.89+3.27*%i),(4.10+6.70*%i),(7.78+4.06*%i),(4.57+2.07*%i);(3.28+3.84*%i),(-0.79+7.21*%i),(3.88+3.30*%i),(3.84+1.19*%i)] + s = svd(b) + disp(s) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdrank.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdrank.sci new file mode 100644 index 00000000..108acde8 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdrank.sci @@ -0,0 +1,13 @@ +function testsvdrank() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt,rk] = svd(A) // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) + disp("Rank") + disp(rk) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdreal.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdreal.sci new file mode 100644 index 00000000..0e68e003 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/test_svd/testsvdreal.sci @@ -0,0 +1,11 @@ +function testsvdreal() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt] = svd(A) // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci new file mode 100644 index 00000000..49d3c7a2 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci @@ -0,0 +1,7 @@ +function testfullrf() + A = [1,2,3;4,5,6;7,8,9] + [Q,M,rk] = fullrf(A) + disp(Q) + disp(M) + disp(rk) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci new file mode 100644 index 00000000..3ef0d284 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci @@ -0,0 +1,7 @@ +function testgivens() + a = [1] + b = [2] + [u,c] = givens(a,b) + disp(u) + disp(c) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci new file mode 100644 index 00000000..f991ae9f --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci @@ -0,0 +1,5 @@ +function testhess() + a = [0,0,0,0;0,6,7,8;9,10,11,12;13,14,15,16]; + h = hess(a) + disp(h) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci new file mode 100644 index 00000000..30b4c20e --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci @@ -0,0 +1,6 @@ +function testhouseholder() + A = [1;2;3;4;5] + B = [6;7;8;9;10] + u = householder(A,B) + disp(u) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci new file mode 100644 index 00000000..727a895f --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci @@ -0,0 +1,6 @@ +//* Function to find, norm(a,2) +function testnorm() + a = [1,2,3;4,5,6;7,8,9] // Matrix + d = norm(a,2); // Calling NORM function. + disp(d) // display output +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci new file mode 100644 index 00000000..292e1cba --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci @@ -0,0 +1,8 @@ +function testQR() + A = [1,2,3;4,5,6] + [u,a,rk,e] = qr(A); + disp(u) + disp(a) + disp(rk) + disp(e) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci new file mode 100644 index 00000000..f8da9482 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci @@ -0,0 +1,6 @@ +function testrcomp() + A = [1,2,3;4,5,6] + [u,rk] = rowcomp(A,"qr") + disp(u) + disp(rk) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci new file mode 100644 index 00000000..6e9346d4 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci @@ -0,0 +1,9 @@ +function testspec() + A = [1,2,3;4,5,6;7,8,9] + B = [10,11,12;13,14,15;16,17,18] + [R,diagevals,c,d] = spec(A,B) + disp(R) + disp(diagevals) + disp(c) + disp(d) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci new file mode 100644 index 00000000..63db1f49 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci @@ -0,0 +1,5 @@ +function testsqroot() + a = [1,2,3;4,5,6;7,8,9]; + e = sqroot(a); + disp(e) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci new file mode 100644 index 00000000..c7107236 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci @@ -0,0 +1,7 @@ +function testsva() + a = [1,2,3,4;5,6,7,8;9,10,11,12] + [u,s,v] = sva(a) + disp(u) + disp(s) + disp(v) +endfunction diff --git a/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci b/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci new file mode 100644 index 00000000..b199ec36 --- /dev/null +++ b/2.3-1/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci @@ -0,0 +1,9 @@ +// function Singular Value Approx. + +function testsvatol() + a = [1,2,3,4;5,6,7,8;9,10,11,12] + [u,s,v] = sva(a,1) + disp(u) + disp(s) + disp(v) +endfunction diff --git a/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/main.sci b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/main.sci new file mode 100644 index 00000000..85fc494c --- /dev/null +++ b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/main.sci @@ -0,0 +1,33 @@ +// This is the demo function to test the analog filters +// They are of 4 types butterworth,chebyshev-1,chebyshev-2 and elliptic +// We are going to test here the butterworth, chebyshev-1 and chebyshev-2 filters +//zpbutt->butterworth filter +//zpch1 ->chebyshev type-1 filter +//zpch2 ->chebyshev type-2 filter +function main() + n=5; //n is the filter order + fl=3; //fl is the cutoff frequency + [pb,gb]=zpbutt(n,fl); + disp("poles of butterworth filter") + disp(pb); + disp("gain of butterworth filter"); + disp(gb); + + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [pc1,gc1]=zpch1(n,e,wc); + disp("poles of chebyshev-1 filter") + disp(pc1); + disp("gain of chebyshev-1 filter") + disp(gc1); + + a=4; //a is the attenuation in stop band + w=5; //w (omega) is the cutoff frequency + [zc2,pc2,gc2]=zpch2(n,a,w); + disp("zeros of chebyshev-2 filter") + disp(zc2); + disp("poles of chebyshev-2 filter") + disp(pc2); + disp("gain of chebyshev-2 filter") + disp(gc2); +endfunction diff --git a/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci new file mode 100644 index 00000000..1ea723d6 --- /dev/null +++ b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci @@ -0,0 +1,7 @@ +function zpbutttest() + n=5; + fl=3; + [p,g]=zpbutt(n,fl); + disp(p); + disp(g); +endfunction diff --git a/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci new file mode 100644 index 00000000..4f29e0d4 --- /dev/null +++ b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci @@ -0,0 +1,9 @@ +function zpch1test() + + N=5; //N is the filter order + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [p,g]=zpch1(N,e,wc); + disp(p); + disp(g); +endfunction diff --git a/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci new file mode 100644 index 00000000..665fb41c --- /dev/null +++ b/2.3-1/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci @@ -0,0 +1,9 @@ +function zpch2test() + n=5; + a=4; + w=5; + [z,p,g]=zpch2(n,a,w); + disp(z); + disp(p); + disp(g); +endfunction diff --git a/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci new file mode 100644 index 00000000..c7426c2d --- /dev/null +++ b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci @@ -0,0 +1,7 @@ +function buttmagtest() + smp=[1:5]; + od=6; + frq=2.2; + oup=buttmag(od,frq,smp); + disp(oup); +endfunction diff --git a/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci new file mode 100644 index 00000000..7d096375 --- /dev/null +++ b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci @@ -0,0 +1,8 @@ +function cheb1magtest() + od=5; + wfc=3; + eps=0.3; + sap=[1:5]; + out=cheb1mag(od,wfc,eps,sap); + disp(out); +endfunction diff --git a/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci new file mode 100644 index 00000000..b53c435d --- /dev/null +++ b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci @@ -0,0 +1,7 @@ +function ell1magtest() + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/main.sci b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/main.sci new file mode 100644 index 00000000..6a8cbc59 --- /dev/null +++ b/2.3-1/tests/unit_tests/test_filterResponse/scilabcode/main.sci @@ -0,0 +1,20 @@ +function main() + + order=5; + sample1=[1:5]; + frq=2.2; + out1=buttmag(order,frq,sample1); + disp(out1); + + wfc=3; + eps=0.3; + sample2=[1:5]; + out2=cheb1mag(order,wfc,eps,sample2); + disp(out2); + + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/2.3-1/tests/unit_tests/test_jacobi/scilabcode/main.sci b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/main.sci new file mode 100644 index 00000000..ee229ebe --- /dev/null +++ b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/main.sci @@ -0,0 +1,18 @@ +// Demo function to test %sn and %k functions +// %sn is the Jacobi's elliptic function +// %k is the Jacobi's complete integral +function main() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); + m=[0.1 0.2 0.3]; // parametrt of Jacobi complete integral + s=%k(m); + disp(s); +endfunction + +//Output +//for %sn +// 1.5641568 - 0.2037920i 1.0580372 + 0.0100213i 1.1386855 - 0.4631921i +// for %k +// 1.6124413 1.6596236 1.7138894 diff --git a/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modktest.sci b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modktest.sci new file mode 100644 index 00000000..613cd33b --- /dev/null +++ b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modktest.sci @@ -0,0 +1,5 @@ +function modktest() + m=[0.1 0.2 0.3]; + s=%k(m); + disp(s); +endfunction diff --git a/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci new file mode 100644 index 00000000..dc5d4353 --- /dev/null +++ b/2.3-1/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci @@ -0,0 +1,6 @@ +function modsntest() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); +endfunction diff --git a/2.3-1/tests/unit_tests/test_string/scilabcode/asciitest.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/asciitest.sci new file mode 100644 index 00000000..aa0017d7 --- /dev/null +++ b/2.3-1/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/2.3-1/tests/unit_tests/test_string/scilabcode/asciitest2.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/asciitest2.sci new file mode 100644 index 00000000..ca7dcb7e --- /dev/null +++ b/2.3-1/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/2.3-1/tests/unit_tests/test_string/scilabcode/main.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/main.sci new file mode 100644 index 00000000..4030ee09 --- /dev/null +++ b/2.3-1/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/2.3-1/tests/unit_tests/test_string/scilabcode/strchrtest.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/strchrtest.sci new file mode 100644 index 00000000..f8d34198 --- /dev/null +++ b/2.3-1/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/2.3-1/tests/unit_tests/test_string/scilabcode/strcspntest.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/strcspntest.sci new file mode 100644 index 00000000..9a03c576 --- /dev/null +++ b/2.3-1/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/2.3-1/tests/unit_tests/test_string/scilabcode/strncpytest.sci b/2.3-1/tests/unit_tests/test_string/scilabcode/strncpytest.sci new file mode 100644 index 00000000..14eceb83 --- /dev/null +++ b/2.3-1/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 |