diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pulsedata_t.txt | 1 | ||||
-rw-r--r-- | tests/pulsedata_x.txt | 1 | ||||
-rw-r--r-- | tests/signal.sce | 119 | ||||
-rw-r--r-- | tests/test.sce | 125 |
4 files changed, 243 insertions, 3 deletions
diff --git a/tests/pulsedata_t.txt b/tests/pulsedata_t.txt new file mode 100644 index 0000000..cc9dcc6 --- /dev/null +++ b/tests/pulsedata_t.txt @@ -0,0 +1 @@ +0.000000 0.025000 0.050000 0.075000 0.100000 0.125000 0.150000 0.175000 0.200000 0.225000 0.250000 0.275000 0.300000 0.325000 0.350000 0.375000 0.400000 0.425000 0.450000 0.475000 0.500000 0.525000 0.550000 0.575000 0.600000 0.625000 0.650000 0.675000 0.700000 0.725000 0.750000 0.775000 0.800000 0.825000 diff --git a/tests/pulsedata_x.txt b/tests/pulsedata_x.txt new file mode 100644 index 0000000..800ef63 --- /dev/null +++ b/tests/pulsedata_x.txt @@ -0,0 +1 @@ +0.000000 0.010800 0.036700 -0.045200 0.017200 0.006400 -0.026200 -0.008700 0.006900 0.071600 0.055400 -0.027000 0.060700 5.014500 4.998700 5.014300 4.995900 4.997500 5.029800 0.028200 0.028300 0.013400 -0.024100 0.014300 0.032600 0.009800 0.020700 0.014500 -0.006100 0.005900 -0.015700 0.017800 -0.022900 4.978600 diff --git a/tests/signal.sce b/tests/signal.sce new file mode 100644 index 0000000..c1e3786 --- /dev/null +++ b/tests/signal.sce @@ -0,0 +1,119 @@ +disp("Testing arburg function from signal package") +a = octave_fun("arburg","signal", [1,2,3,4,5],2) +pause + + +disp("Testing aryule function from signal package") +a = octave_fun("aryule","signal", [1,2,3,4,5],2) +pause + + +disp("Testing filter function from signal package") +a = [1 0.1 -0.8]; +v = 0.4; +rand("seed", 0); +w = sqrt(v)*rand(15000,1); +x=octave_fun("filter","signal",1,a,w); +pause + +disp("Testing xcorr function from signal package") +r=octave_fun("xcorr","signal",x); +pause + +disp("Testing levinson function from signal package") +ar=octave_fun("levinson","signal",r,length(a)-1) +pause + +disp("Testing sigmoid_train function from signal package") +s = octave_fun("sigmoid_train",0.1,[1:3],[4]) +pause + + +disp("Testing circshift function from signal package") + M = [1 2 3 4]; + R = octave_fun("circshift",M,[0 1]) +pause + + +disp("Testing kaiser function from signal package") +win = octave_fun("kaiser",6,[0.2]) +pause + + + +disp("Testing autoreg_matrix function from signal package") +m = octave_fun("autoreg_matrix",[1 2 3],[2]) +pause + + +disp("Testing arch_rnd function from signal package") +a = [1 2 3 4 5]; +b = [7 8 9 10]; +t = 5 ; +rand("seed", 0) +m = octave_fun("arch_rnd",a,b,t) +pause + + +disp("Testing postpad function from signal package") +y = octave_fun("postpad",[1 2 3],6) +pause + + +disp("Testing wconv function from signal package") +a = [1 2 3 4 5]; +b = [7 8 9 10]; +y = octave_fun("wconv",[1],a,b) +pause + + +disp("Testing dctmtx function from signal package") +T = octave_fun("dctmtx",[3]) +pause + + +disp("Testing medfilt1 function from signal package") + +fs = 100; +t = 0:1/fs:1; +x = sin(2*%pi*t*3)+0.25*sin(2*%pi*t*40); + +y = octave_fun("medfilt1","signal",x,10); +pause + + +disp("Testing arma_rnd function from signal package") + +a = [1 2 3 4 5]; +b = [7; 8; 9; 10; 11]; +t = 5 ; +v = 10 ; +n = 100 ; +rand("seed", 0) +m = octave_fun("arma_rnd","signal",a, b, v, t, n) +pause + + +disp("Testing ncauer function from signal package") +[z p g] = octave_fun("ncauer","signal",3, 10, 4) +pause + + +disp("Testing ellipap function from signal package") +[z p g] = octave_fun("ellipap","signal",4, 3, 10) +pause + + +disp("Testing besselap function from signal package") +[z p g] = octave_fun("besselap","signal",5) +pause + + +disp("Testing zp2tf function from signal package") +[num, den] = octave_fun("zp2tf","signal",[1 2 3], [4 5 6], 5) +pause + +disp("Testing tf2zp function from signal package") +[z p k] = octave_fun("tf2zp","signal",[1 2 3], [4 5 6]); +pause + diff --git a/tests/test.sce b/tests/test.sce index e7bb727..857e392 100644 --- a/tests/test.sce +++ b/tests/test.sce @@ -1,5 +1,5 @@ -exec build.sce +//exec build.sce test_pass=[] res=[] @@ -251,15 +251,134 @@ else test_pass=[test_pass,0] disp("tf2zp Test failed") end + +/////////Test case for buttap ////////// + +n = 5 ; +[z p g] = octave_fun("buttap", n); +g = round(g*10000)/10000; + +if(g == 1) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("buttap Test failed") +end + +/////////Test case for cheb1ap ////////// + +[z p g] = octave_fun("cheb1ap", 10, 3); +g = round(g*10000)/10000; + +if(g == 0.002) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("cheb1ap Test failed") +end + +/////////Test case for sftrans ////////// +//fc = 100; +//[z p k] = octave_fun("tf2zp","signal",[1 2 3], [4 5 6]) +//[Sz, Sp, Sg] = octave_fun("sftrans",z, p, k, 2*%pi*fc, %f); +//Sz = round(Sz*10000)/10000; + + +//if(Sz ~= 0) +// test_pass=[test_pass,1] +//else +// test_pass=[test_pass,0] +// disp("sftrans Test failed") +//end + +/////////Test case for bilinear ////////// + +[b a] = octave_fun("bilinear","signal",[1 2 3], [4 5 6], 1, 1); +b = round(b*10000)/10000; +a = round(a*10000)/10000; + + +if(b == [0 -0.1667 -0.3333 2.5] & a == [1 7.3333 17.6667 14]) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("bilinear Test failed") +end +/////////Test case for buttord ////////// +[n, Wn] = octave_fun("buttord",40/500, 150/500, 3, 60); +Wn = round(Wn*10000)/10000; + +if(n == 5 & Wn == 0.08) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("buttord Test failed") +end + +/////////Test case for butter ////////// + +[b a] = octave_fun("butter","signal",4,0.3,"high") +b = round(b*10000)/10000; +a = round(a*10000)/10000; + +if(b == [0.2754 -1.1017 1.6525 -1.1017 0.2754] & a == [1 -1.5704 1.2756 -0.4844 0.0762]) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("butter Test failed") +end + +/////////Test case for cheb1ord ////////// + +[n, Wn]=octave_fun("cheb1ord","signal",[0.25 0.3],[0.24 0.31],3,10) +Wn = round(Wn*10000)/10000; + +if(n == 3 & Wn == [0.25 0.3]) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("cheb1ord Test failed") +end + +/////////Test case for cheby1 ////////// + +[z, p]=octave_fun("cheby1","signal",2,6,0.7,"high")// Note it shld return k as well +z = round(z*10000)/10000; +p = round(p*10000)/10000; +k = round(k*10000)/10000; + +if(z == [1 1] & p == [-0.6292+0.5537*%i -0.6292-0.5537*%i] & k == 0.0556) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("cheby1 Test failed") +end + +/////////Test case for cheb2ord ////////// + +Wp = 40/500; +Ws = 150/500; +Rp = 3; +Rs = 60; +[n,Ws] = octave_fun("cheb2ord",Wp,Ws,Rp,Rs) +Ws = round(Ws*10000)/10000; + +if(n == 4 & Ws == 0.3) + test_pass=[test_pass,1] +else + test_pass=[test_pass,0] + disp("cheb2ord Test failed") +end + ///////////////////////////////////////////// res=find(test_pass==0) if(res~=[]) disp("One or more tests failed in test1") disp(length(test_pass),"Total functions tested:") - exit(1) + //exit(1) else disp(length(test_pass),"Total functions tested:") disp("ALL OK") -exit() +//exit() end |