#This file is part of SECONDO. # #Copyright (C) 2004, University in Hagen, Department of Computer Science, #Database Systems for New Applications. # #SECONDO is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2 of the License, or #(at your option) any later version. # #SECONDO is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with SECONDO; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ######################################################################### # Testing the TemporalUnitAlgebra # # Here: Testing stream operators and auxiliary operators # # Written Sept 2006 by Chrstian Duentgen # # run with : TestRunner -c SecondoConfig.ini < temporalunit.test ######################################################################### # clean up what may be left over from e.g. a segfault delete database tempunittest; ######################## # set up test database # ######################## #setup create database tempunittest; open database tempunittest; let p = [const point value (1500.0 1500.0)]; let ci = [const int value 1000]; let ui1 = [const uint value (("2003-11-20-06:00" "2003-11-20-07:00" TRUE FALSE) 1500)]; (create ten : (rel(tuple((No int))))); (update ten := ((rel(tuple((No int))))((1)(2)(3)(4)(5)(6)(7)(8)(9)(10)))); restore zug5 from '$(SECONDO_BUILD_DIR)/Tests/Testspecs/tempunitalg/zug5'; #################### # stream operators # #################### #testcase feed #yields (int 1) query ui1 feed count; #testcase transformstream_S_TS #yields ((rel (tuple ((Elem int)))) ((1) (2) (3) (4) (5) (6) (7) (8) (9) (10))) query intstream(1,10) transformstream consume; #testcase transformstream_TS_S #yields (int 3) query ten feed transformstream filter[. >7] count; #testcase transformstream_TS_S_TS #yields ((rel (tuple ((Elem int)))) ((8) (9) (10))) query ten feed transformstream filter[. >7] transformstream consume; #testcase feed transformstream consume #yields ((rel (tuple ((Elem int)))) ((1000))) query ci feed transformstream consume; #testcase use_SN 1 #yields (int 100000) query intstream(1,100000) use[ fun(i:STREAMELEM) i*i ] count; #testcase use_SN 2 #yields ((rel (tuple ((Elem int)))) ((1) (4) (9) (16) (25) (36))) query intstream(1,6) use[ fun(i:STREAMELEM) i*i ] transformstream consume; #testcase use_SS 1 #yields (int 15) query intstream(1,6) use[ fun(i:int) intstream(i,5) ] count; #testcase use_SS 2 #yields ((rel (tuple ((Elem int)))) ((1) (2) (3) (4) (5) (2) (3) (4) (5) (3) (4) (5) (4) (5) (5))) query intstream(1,6) use[ fun(i:STREAMELEM) intstream(i,5) ] transformstream consume; #testcase use2_SNN #yields (int 5) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] count; #testcase use2_SNN_2 #yields ((rel (tuple ((Elem int)))) ((4) (5) (6) (7) (8))) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] transformstream consume; #testcase use2_SNS 1 #yields (int 15) query intstream(1,5) [const int value 5] use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] count; #testcase use2_SNS 2 #yields ((rel (tuple ((Elem int)))) ((1) (2) (3) (4) (5) (2) (3) (4) (5) (3) (4) (5) (4) (5) (5) )) query intstream(1,5) [const int value 5] use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] transformstream consume; #testcase use2_NSN 1 #yields (int 5) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] count; #testcase use2_NSN 2 #yields ((rel (tuple ((Elem int)))) ((4) (5) (6) (7) (8) )) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] transformstream consume; #testcase use2_NSS 1 #yields (int 6) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] count; #testcase use2_NSS 2 #yields ((rel (tuple ((Elem int)))) ( (3) (3) (4) (3) (4) (5) ) ) query [const int value 3] intstream(1,5) use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] transformstream consume; #testcase use2_SSN 1 #yields (int 100) query intstream(6,15) intstream(3,12) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] count; #testcase use2_SSN 2 #yields ((rel (tuple ((Elem int)))) ( (2) (3) (4) (3) (4) (5) (4) (5) (6) ) ) query intstream(1,3) intstream(1,3) use2[ fun(i:STREAMELEM, j:STREAMELEM2) i+j ] transformstream consume; #testcase use2_SSS 1 #yields (int 9) query intstream(1,2) intstream(1,3) use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] count; #testcase use2_SSS 2 #yields ((rel (tuple ((Elem int)))) ((1) (1) (2) (1) (2) (3) (2) (2) (3))) query intstream(1,2) intstream(1,3) use2[ fun(i:STREAMELEM, j:STREAMELEM2) intstream(i,j) ] transformstream consume; #testcase aggregateS 1 #yields (int 10) query intstream(1,0) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 10]; #testcase aggregateS 2 #yields (int 1) query intstream(1,1) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 10]; #testcase aggregateS 3 #yields (int 3) query intstream(1,2) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 0]; #testcase aggregateS 4 #yields (int 10) query intstream(1,4) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 0]; #testcase aggregateS 5 #yields (int 36) query intstream(1,8) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 0]; #testcase aggregateS 6 #yields (int 6) query intstream(1,3) aggregateS[ fun(i1:STREAMELEM, i2:STREAMELEM) i1+i2 ; 0]; #testcase aggregateS 7 #yields (int 15) query intstream(1,5) aggregateS[ fun(i:STREAMELEM, j:STREAMELEM) i+j ; 15]; #testcase makemvalue #tolerance_real 0.001 #yields @$(SECONDO_BUILD_DIR)/Tests/Testspecs/tempunitalg/zug5_res query units(zug5) transformstream makemvalue[Elem]; ####################### # auxiliary operators # ####################### #tolerance_real 0.001 #testcase get_duration periods #yields (duration (0 2050000) ) query get_duration(deftime(zug5)); #tolerance_real 0.1 #testcase point2d #yields (point (1417.25 1417.27)) query point2d(deftime(zug5)); #tolerance_real 0.001 #testcase queryrect2d #yields (rect (-106751991167.3006 1417.273611111111 1417.273611111111 106751991167.3006)) query queryrect2d([const instant value "2003-11-20-06:34"]); #tolerance_real 0.001 #testcase circle #yields (region((((1419.098300562505 1441.221474770753)(1400.0 1500.0)(1419.098300562505 1558.778525229247)(1469.098300562505 1595.105651629515)(1530.901699437495 1595.105651629515)(1580.901699437495 1558.778525229247)(1600.0 1500.0)(1580.901699437495 1441.221474770753)(1530.901699437495 1404.894348370485)(1469.098300562505 1404.894348370485))))) query circle(p, 100.0, 10); ############################ # mopping up test database # ############################ #teardown close database; delete database tempunittest;