diff options
Diffstat (limited to 'raslib/test')
-rw-r--r-- | raslib/test/Makefile | 192 | ||||
-rw-r--r-- | raslib/test/errtxts | 244 | ||||
-rw-r--r-- | raslib/test/test_endian.cc | 156 | ||||
-rw-r--r-- | raslib/test/test_error.cc | 223 | ||||
-rw-r--r-- | raslib/test/test_metaobject.cc | 332 | ||||
-rw-r--r-- | raslib/test/test_minterval.cc | 118 | ||||
-rw-r--r-- | raslib/test/test_miter.cc | 334 | ||||
-rw-r--r-- | raslib/test/test_miterd | bin | 0 -> 241129 bytes | |||
-rw-r--r-- | raslib/test/test_miterd.cc | 75 | ||||
-rw-r--r-- | raslib/test/test_miterf.cc | 118 | ||||
-rw-r--r-- | raslib/test/test_oid.cc | 181 | ||||
-rw-r--r-- | raslib/test/test_params.cc | 101 | ||||
-rw-r--r-- | raslib/test/test_point.cc | 90 | ||||
-rw-r--r-- | raslib/test/test_rmdebug.cc | 179 | ||||
-rw-r--r-- | raslib/test/test_sinterval.cc | 164 | ||||
-rw-r--r-- | raslib/test/test_timer.cc | 101 |
16 files changed, 2608 insertions, 0 deletions
diff --git a/raslib/test/Makefile b/raslib/test/Makefile new file mode 100644 index 0000000..379b344 --- /dev/null +++ b/raslib/test/Makefile @@ -0,0 +1,192 @@ +# -*-Makefile-*- +# +# This file is part of rasdaman community. +# +# Rasdaman community 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 3 of the License, or +# (at your option) any later version. +# +# Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +# +# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +# rasdaman GmbH. +# +# For more information please see <http://www.rasdaman.org> +# or contact Peter Baumann via <baumann@rasdaman.com>. # Top Level makefile. This points to the various modules that have to be build +# and/or deployed +# +# MAKEFILE FOR: +# test programs of module raslib +# +# +# COMMENTS: +# +################################################################## +# +# This is just an example Makefile for a test program. +# The dependency of the test program on the lib of the +# corresponding module is in the Makefile of the module. +# + +######################### Definitions ############################ + +# standard include with general options +include $(RMANBASE)/Makefile.inc + +# uses our own mem management routine: +MYMALLOC_H := ../../mymalloc/mymalloc.hh +MYMALLOC_O := ../../mymalloc/mymalloc_cln.o + +# use client specific flags +CXXFLAGS := $(CLIENTCXXFLAGS) $(I_SYM)$(MYMALLOC_H) +LDFLAGS := $(CLIENTLDFLAGS) $(L_SYM)$(MYMALLOC_O) + +# raslib has its own template directory because of the name clashes with O2 + +ifneq ($(OSTYPE),linux-gnu) + CXXFLAGS := -ptr$(RMANBASE)/rasodmg/ptrepository $(CXXFLAGS) + LDFLAGS := -ptr$(RMANBASE)/rasodmg/ptrepository $(LDFLAGS) +endif + +# all test programs +ALLTESTS = test_error + +# test_sinterval test_point test_minterval test_rmdebug \ +# test_metaobject test_oid test_timer test_miter test_miterf \ +# test_params + +########################### Targets ############################## + +# test target for class r_Minterval +.PHONY : minterval +minterval: test_module test_minterval + +# test target for class r_Miter +.PHONY : miterd +miterd: test_module test_miterd + +# test target for class r_Miter +.PHONY : miter +miter: test_module test_miter + +# test target for class r_MiterFloat +.PHONY : miterf +miterf: test_module test_miterf + +# test target for class r_Sinterval +.PHONY : sinterval +sinterval: test_module test_sinterval + +# test target for class r_Point +.PHONY : point +point: test_module test_point + +# test target for class r_Error and its subclasses +.PHONY : error +error: test_module test_error + +# test target for class RMDebug +.PHONY : rmdebug +rmdebug: test_module test_rmdebug + +# test target for class r_Meta_Object and its subclasses +.PHONY : metaobject +metaobject: test_module test_metaobject + +# test target for class r_OId +.PHONY : oid +oid: test_module test_oid + +# test target for RMTimer +.PHONY : timer +timer: test_module test_timer + +# test target for lincomstreams +.PHONY : params +params: test_module test_params + +.PHONY : test_module +test_module: + cd $(RMANBASE)/raslib; $(MAKE) + +test_minterval: test_minterval.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_miterd: test_miterd.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -lm -o $@ $^ + +test_miter: test_miter.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -lm -o $@ $^ + +test_miterf: test_miterf.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -lm -o $@ $^ + +test_sinterval: test_sinterval.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_point: test_point.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_error: test_error.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_rmdebug: test_rmdebug.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_metaobject: test_metaobject.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_oid: test_oid.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_timer: test_timer.o $(RASLIB) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +test_params: test_params.o $(RASLIB) $(CLIENTCOMM) + $(PURIFY) $(CXX) $(LDFLAGS) -o $@ $^ + +.PHONY : clean +clean: + -rm $(ALLTESTS) + -rm *.o + +# deletes all non modified, but checked out files +.PHONY : rcsclean +rcsclean: + -rcsclean + +# perform all tests as part of general systemtest +.PHONY: systemtest +systemtest: $(ALLTESTS) + cp $(RMANBASE)/bin/errtxts . # needed by test_error + for PROG in $^; \ + do \ + $$PROG; \ + done + +######################## Dependencies ############################ + +test_minterval.o: test_minterval.cc $(RMANBASE)/raslib/minterval.hh + +test_miter.o: test_miter.cc $(RMANBASE)/raslib/miter.hh + +test_miterf.o: test_miterf.cc $(RMANBASE)/raslib/miterf.hh + +test_sinterval.o: test_sinterval.cc $(RMANBASE)/raslib/sinterval.hh + +test_point.o: test_point.cc $(RMANBASE)/raslib/point.hh + +test_error.o: test_error.cc $(RMANBASE)/raslib/error.hh + +test_oid.o: test_oid.cc $(RMANBASE)/raslib/oid.hh + +test_timer.o: test_timer.cc $(RMANBASE)/raslib/ + +test_params.o: test_params.cc $(RMANBASE)/raslib/parseparams.hh diff --git a/raslib/test/errtxts b/raslib/test/errtxts new file mode 100644 index 0000000..0004f30 --- /dev/null +++ b/raslib/test/errtxts @@ -0,0 +1,244 @@ +190 +# Increment the number above every time you add a new exception +# +# +# This file contains types and textual descriptions of RasDaMan errors. +# The ascending error numbers are used as index to the descriptions. Each +# line follows the following syntax: +# +# number^type^description. +# +# The character '^' is used as delimiter and with '#' a comment line is +# started. Empty lines are not allowed. +# +# +# +# +66^E^Exception: Memory allocation failed. +100^E^Exception: Internal error: DL parse error. +200^E^Exception: The result is no point. +201^E^Exception: The result is no interval. +202^E^Exception: Index violation ( index range [$low,$high], index $index ). +203^E^Exception: Dimension mismatch between $dim1 and $dim2. +204^E^Exception: Stream initialization overflow. +205^E^Exception: Result is no cell. +206^E^Serialisable exception r_Ebase_dbms: error in base DBMS. +207^E^Internal client exception in class $class, method $method: $code. +208^E^Exception: Access type $aType does not fit base type $bType. +209^E^Exception: RasType $type is unknown. +210^E^Exception: Base type $type is not supported yet. +211^E^Exception: Database is not open. +212^E^Exception: RPC layer connection to RasDaMan failed. +213^E^Exception: Wrong URL format (should be http://address:port) +214^E^Exception: Illegal java long value $val for server base type ULong. +215^E^Exception: Illegal java integer value $val for server base type UShort. +216^E^Exception: System collection is not writable. +217^E^Exception: System collection has no OID. +218^E^Exception: Conversion format is not supported. +219^E^Exception: The specified tile size is smaller than the length of the base type of the mdd object. +220^E^Exception: The tiling strategy in the storage layout is not compatible with the marray. +221^E^Exception: The domain passed as an argument was not initialised correctly (dimension is 0). +222^E^Exception: The type name or type structure does not represent a marray type. +223^E^Exception: The rc index requires a marray type that has a specified domain (with fixed borders in all dimensions). +224^E^Exception: The tile configuration is incompatible to the marray domain. +229^E^Exception: The parameterized query has invalid parameter format. +230^E^Exception: The r_Object was already assigned a type. +231^E^Exception: The Marray has no base type. +232^E^Exception: The interval has at least one open bound. +233^E^Exception: The intervals don't have the same dimension. +234^E^Exception: The string passed to the tiling object was not correct. +235^E^Exception: Connection to server already closed. +236^E^Exception: Error in compression engine +237^E^Exception: Client communication failure +# +300^E^Parsing error $errorNo in line $lineNo, column $columnNo: Unexpected name $token. +301^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: All cell values of an MDD must be of the same type. +302^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Number of cells specified does not match the number of cells of the given spatial domain. +303^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: OId is not valid. +308^E^Parsing error: Unexpected end of query. +309^E^Parsing error: Unknown error. +310^E^Lexical analysing error $errorNo in line $lineNo, column $columnNo: Unexpected characters $token. +311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type (i.e. float or double). +312^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Variable already defined. +313^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Only constant interval bounds allowed. +# +330^E^Preprocessing error $errorNo in line $lineNo, column $columnNo: Unexpected name $token: +331^E^Preprocessing error $errorNo in line $lineNo, column $columnNo, token $token: attempt to redefine function. +332^E^Preprocessing error $errorNo in line $lineNo, column $columnNo, token $token: number of actual arguments for the called function differs from the number of formal arguments. +333^E^Preprocessing error $errorNo in line $lineNo, column $columnNo, token $token: the called function name is ambiguous, try the full qualified name. +# +349^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand out of range. +350^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: General. +351^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Spatial domains of the binary induce operands are incompatible. +352^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand types are incompatible. +353^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of quantifier must be multidimensional. +354^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of quantifier must be of type r_Marray<d_Boolean>. +355^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Collection name is unknown. +356^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Specified domain does not intersect with spatial domain of MDD. +357^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Variable is unknown. +358^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Projection operand is not of type r_Marray<T>. +359^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Result of the where clause must be of type boolean. +360^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Type of operand is not supported. +361^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Multiple query targets are not supported. +362^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Specified domain dimensionality does not equal defined dimensionality of MDD. +# +363^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Cell base types of binary induce operation are incompatible. +364^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Cell base type and scalar type of binary induce operation are incompatible. +365^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Scalar types of binary operation are incompatible. +366^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Cell base type of unary induce operation is not supported. +367^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Scalar type of unary operation is not supported. +368^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Cell base type for induced dot operation must be complex. +369^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Scalar type for dot operation must be complex. +370^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Struct selector is not valid. +371^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Retrieval query must start with a SELECT statement. +372^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Update query must start with an INSERT, UPDATE, DELETE, DROP or CREATE statement. +373^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Unsatisfied MDD constant parameter. +380^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Data type can not be converted to selected data exchange format. +381^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Error in convertor of the selected data exchange format. +382^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Unknown conversion format. +383^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Parameter of oid function must be a persistent object of type MDD. +384^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: OId is not valid. +385^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operation is not supported on strings. +386^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Base name of oid is not matching the currently opened one. +387^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: System name of oid is not matching the currently used one. +388^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Interval bound must be either an integer expression or an asterisk. +389^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: No interval (in case of fixed bounds, the upper one can not be smaller than the lower one). +390^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Minterval dimension specifications must be either of type interval or integer. +391^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Spatial operation must be either of type minterval, point, or integer. +393^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of operation lo/hi must be of type interval. +394^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operation lo/hi can not be used for an open bound. +395^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of function sdom() must be of type MDD. +396^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Selection operation is not supported on this data type. +397^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of minterval selection must be of type integer. +398^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Index for minterval selection is out of range. +399^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of point selection must be of type integer. +# +# +# +400^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Domain of MDD constructor has to be defined. +401^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Can not evaluate domain expression to an minterval. +402^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Projected cell is not defined. +403^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Binary operation is not supported on these data types. +404^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Type of cell expression is not supported. +405^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: First operand of shift function must be of type MDD. +406^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Second operand of shift function must be of type Point. +407^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Dimensionality of MDD and point expression are not matching. +408^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Second operand of shift function must be a constant expression. +409^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Spatial domain shift of open bounds is not supported. +# +# +# +410^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of point expression must be of type integer. +411^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Index for point selection is out of range. +412^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Value expression must be either of type atomic or complex. +413^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Condition expression must be of type boolean. +415^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Operand of count_cells must be of type r_Marray<d_Boolean>. +# +416^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: First operand of scale function must be of type MDD. +417^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Second operand of scale function must be either of type Point, Integer or Float. +# +418^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Second operand of bit function must be of integral type. +419^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Could not scale the domain. +# +499^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: Language feature is not supported. +# +510^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: The argument is outside the function domain. +511^E^Execution error $errorNo in line $lineNo, column $columnNo, near token $token: The function result exceeds the allowed range. +# +# 7XX errors for problems with Administration (some Oracle specific) +# +700^E^Admin error: General error creating RasDaMan database. +701^E^Admin error: Error creating table in tablespace RAS_DB_SCHEMA. +702^E^Admin error: Error inserting into table RAS_COUNTERS. +703^E^Admin error: Error creating table in tablespace RAS_DB_BLOB. +704^E^Admin error: Error creating index in tablespace RAS_DB_INDEX. +705^E^Admin error: Error inserting into table RAS_BASETYPENAMES. +706^E^Admin error: Error creating table in default tablespace. +707^E^Admin error: Error on COMMIT creating RasDaMan database. +708^E^Admin error: Database to be created already exists. +# +# 8xx errors for RasManager problems +# +800^E^RasManager Error: Could not connect to RasServer $url. +801^E^RasManager Error: System overloaded, please try again later. +802^E^RasManager Error: Acces denied, incorect user/password. +803^E^RasManager Error: Acces denied, no permission for operation. +804^E^RasManager Error: Acces denied, capability refused. +805^E^RasManager Error: No suitable servers started, call rasadmin. +806^E^RasManager Error: Write transaction in progress, please retry again later. +807^E^RasManager Error: Requested database unknown. +808^E^RasManager Error: Request format error. +# +# 9xx errors: Evaluation errors +# +900^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: Type in typedef definition not supported. +901^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: Set template type has to be a type reference. +902^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: Type reference not found. +903^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: MDD base type has to be a type reference or an atomic type. +904^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: MDD type must have a domain specification. +905^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: Struct type name exists already. +906^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: MDD type name exists already. +907^E^Evaluation error $errorNo in line $lineNo, column $columnNo, near token $token: Set type name exists already. +# +950^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update target must be an iterator variable. +951^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update source must be an expression resulting in an r_Marray<>. +952^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update base type does not match MDD base type. +953^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update domain is not within MDD definition domain. +954^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update target expression must be an assignable value (l-value). +955^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Collection name exists already. +956^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Unknown collection type. +957^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Unknown collection name. +958^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Allocation of new oid failed. +959^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: MDD and collection types are incompatible. +960^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Insert expression must be of type MDD. +961^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update domain must be of type Minterval. +962^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Number of update intervals must match source dimensionaltiy. +963^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Update domain dimensionality must match target MDD dimensionaltiy. +964^E^Update error $errorNo in line $lineNo, column $columnNo, near token $token: Type is not persistent. +965^E^Update error $errorNo: MDD type $token unknown. +966^E^Update error $errorNo: MDD type is missing. +# +# 1xxx errors: General errors +# +1000^E^General error: RasDaMan tables inconsistent. +1001^E^General error: RasDaMan server incompatible with database. +1002^E^General error: Blob with zero length encountered. +1003^E^General error: Tile container for TC index not found. +1004^E^General error: Index of MDD Object is not defined. +1005^E^General error: Storage structure of MDD Object is not defined. +1006^E^General error: Unknown index type requested. +1007^E^General error: Illegal index type choosen. +1008^E^General error: No valid collection type passed to MDD collection. +1009^E^General error: MDD object not valid or not persistent. +1010^E^General error: No valid MDD type passed to MDD object. +1011^E^General error: An illegal state has been reached. This is caused by a compiler bug or a library bug. +1012^E^General error: Invalid collection type passed to MDD collection. +1013^E^General error: The name of the type is too long. +1014^E^General error: Invalid name of the object, should contain only [a-zA-Z0-9_] +# +# 2xxx errors: Internal errors +# +2000^E^Internal error: There seems to be another database open. +2001^E^Internal error: Invalid OId type encountered. +2002^E^Internal error: Entry in user defined type not found. +2003^E^Internal error: Entry in user defined type out of bounds. +2004^E^Internal error: Transient index used instead of persistent index. +2005^E^Internal error: Index returned tiles multiple times. +2006^E^Internal error: Tile was not inserted into index. +2007^E^Internal error: Transient index access out of bounds. +2008^E^Internal error: MDD object exists multiple times in cache. +2009^E^Internal error: Some tile(s) were not inserted into the MDD object. +2010^E^Internal error: A conversion module returned an incorrect base type. +2011^E^Internal error: The collection type has no element type. +2012^E^Internal error: The marray type has no base type. +2013^E^Internal error: The property has no base type. +2014^E^Internal error: The scalar was passed a NULL value. +2015^E^Internal error: The index node that had to be split was not found in its parent. +2016^E^Internal error: The index found more cells than allowed. +2017^E^Internal error: The storage layout is incompatible with the index entries. +2018^E^Internal error: Object does not support swaping. +2019^E^Internal error: Error encountered during swaping. +# +# The last, the unexpected error in server +# +10000^E^Unexpected internal server error. diff --git a/raslib/test/test_endian.cc b/raslib/test/test_endian.cc new file mode 100644 index 0000000..250892a --- /dev/null +++ b/raslib/test/test_endian.cc @@ -0,0 +1,156 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * INCLUDE: test_endian.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * + * COMMENTS: + * + ************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <iostream> + + +#ifdef EARLY_TEMPLATE +#define __EXECUTABLE__ +#endif + +#include "raslib/basetype.hh" +#include "raslib/primitivetype.hh" +#include "raslib/minterval.hh" +#include "raslib/rminit.hh" +#include "raslib/endian.hh" + + +RMINITGLOBALS('C') + + +static void print_numbers(const unsigned char *data, int size) +{ + int i; + + for (i=0; i<size; i++) + { + if ((i & 15) == 0) + { + if (i != 0) + printf("\n"); + + printf("%04x: ", i); + } + printf("%02x ", data[i]); + } + printf("\n"); fflush(stdout); +} + +static void test_endian(const char *schema, const r_Minterval &dom) +{ + r_Base_Type *type; + r_Primitive_Type *primType; + unsigned char *srcArray; + unsigned char *testArray; + unsigned char *smallArray; + unsigned long size; + unsigned long smallSize; + unsigned long i; + + cout << "test type <" << schema << ">" << endl; + + type = (r_Base_Type*)r_Type::get_any_type(schema); + primType = (r_Primitive_Type*)r_Type::get_any_type("long"); + + size = type->size() * dom.cell_count(); + + srcArray = new unsigned char[size]; + + for (i=0; i<size; i++) + srcArray[i] = (unsigned char)(i & 0xff); + + r_Minterval iterDom(dom.dimension()); + for (i=0; i<dom.dimension(); i++) + iterDom << r_Sinterval(dom[i].low(), (r_Range)(dom[i].low() + (dom[i].high() - dom[i].low() + 1) / 2)); + + cout << "dom = " << dom << ", iterDom = " << iterDom << endl; + + print_numbers(srcArray, 64); + + smallSize = type->size() * iterDom.cell_count(); + + testArray = new unsigned char[size]; + memset(testArray, 0, size); + smallArray = new unsigned char[smallSize]; + memset(smallArray, 0, smallSize); + + cout << "Linear change..." << endl; + r_Endian::swap_array(primType, size, srcArray, testArray); + print_numbers(testArray, 64); + + cout << "Semi-generic change, full..." << endl; + r_Endian::swap_array(type, dom, dom, srcArray, testArray); + print_numbers(testArray, 64); + + cout << "Semi-generic change, half..." << endl; + r_Endian::swap_array(type, dom, iterDom, srcArray, testArray); + print_numbers(testArray, 64); + + cout << "Fully generic change, full..." << endl; + r_Endian::swap_array(type, dom, dom, dom, dom, srcArray, testArray); + print_numbers(testArray, 64); + + cout << "Fully generic change, half..." << endl; + r_Endian::swap_array(type, dom, iterDom, iterDom, iterDom, srcArray, smallArray); + print_numbers(smallArray, 64); + + delete type; + delete primType; + + delete [] smallArray; + delete [] testArray; + delete [] srcArray; +} + + +int main(int argc, char *argv[]) +{ + r_Minterval dom(2); + + dom << r_Sinterval((r_Range)0, (r_Range)123) + << r_Sinterval((r_Range)10, (r_Range)456); + + test_endian("char", dom); + test_endian("short", dom); + test_endian("long", dom); + test_endian("float", dom); + test_endian("double", dom); + test_endian("struct {short, short, long}", dom); + + return 0; +} diff --git a/raslib/test/test_error.cc b/raslib/test/test_error.cc new file mode 100644 index 0000000..1f5fdb9 --- /dev/null +++ b/raslib/test/test_error.cc @@ -0,0 +1,223 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_error.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * Test program to test class r_Error and its subclasses. + * + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include <malloc.h> +#include "raslib/error.hh" + +#include "raslib/rminit.hh" + +RMINITGLOBALS('C') + +int main() +{ + cout << endl << "0. reading from errortxts table ----------------------------------" << endl; + try + { + throw r_Error( 10000 ); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "1. Throwing r_Error() -------------------------------------------" << endl; + try + { + throw r_Error(); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "2. Throwing r_Error( r_Error::r_Error_DatabaseUnknown ) ---------" << endl; + try + { + throw r_Error( r_Error::r_Error_DatabaseUnknown ); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "3. Throwing r_Eno_interval() ------------------------------------" << endl; + try + { + throw r_Eno_interval(); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "4. Throwing r_Eindex_violation( 10, 20, 25 ) --------------------" << endl; + try + { + throw r_Eindex_violation( 10, 20, 25 ); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + + cout << endl << "5. Throwing r_Edim_mismatch( 2, 3 ) -----------------------------" << endl; + try + { + throw r_Edim_mismatch( 2, 3 ); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + + cout << endl << "6. Throwing r_Einit_overflow() ----------------------------------" << endl; + try + { + throw r_Einit_overflow(); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + + cout << endl << "7. Throwing r_Eno_cell() ----------------------------------------" << endl; + try + { + throw r_Eno_cell(); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "8. Throwing r_Equery_execution_failed( 99, 5, 7, 'SELECT' ) -----" << endl; + try + { + throw r_Equery_execution_failed( 99, 5, 7, "SELECT" ); + } + catch( r_Error &err ) + { + cout << err.what() << endl; + } + + cout << endl << "8. Testing r_Ebase_dbms ------------------------------------------" << endl; + cout << endl << "8.1 Throwing (4711, 'This is a test') ----------------------------" << endl; + try + { + throw r_Ebase_dbms( 4711, "This is a test" ); + } + catch( r_Error &err ) + { + cout << "Output of what() catching an r_Error &err" << endl; + cout << err.what() << endl; + } + try + { + throw r_Ebase_dbms( 4711, "This is a test" ); + } + catch( r_Ebase_dbms &err ) + { + cout << "Output of what() catching an r_Ebase_dbms &err" << endl; + cout << err.what() << endl; + } + + cout << endl << "8.2 Testing serialisation of r_Ebase_dbms ------------------------" << endl; + char* serialErr; + try + { + throw r_Ebase_dbms( 4711, "This is a test" ); + } + catch( r_Error &err ) + { + serialErr = err.serialiseError(); + cout << "serialised form: " << serialErr << endl; + } + try + { + cout << "Throwing error constructed from serialised form." << endl; + r_Error* testErr = r_Error::getAnyError(serialErr); + // for some strange reason a simple throw(*testErr) does not work here. It does not work + // if an r_Ebase_dbms is caught (core dump), it works if an r_Error is caught. Hmm, makes + // some sense since *r_Error is not polymorphic anymore. But it should not core dump. + // Well strange, but like this it works and this will be done only once in clientcomm.cc. + if(testErr->get_errorno () == 206) { + r_Ebase_dbms correctErr(*(r_Ebase_dbms*)testErr); + delete testErr; + throw correctErr; + } + else + cout << "Unexpected error read from serialised representation." << endl; + } + catch( r_Ebase_dbms &err ) + { + cout << "Output of what() catching an r_Ebase_dbms &err" << endl; + cout << err.what() << endl; + } + try + { + cout << "Throwing error constructed from serialised form." << endl; + r_Error* testErr = r_Error::getAnyError(serialErr); + if(testErr->get_errorno () == 206) { + r_Ebase_dbms correctErr(*(r_Ebase_dbms*)testErr); + delete testErr; + throw correctErr; + } + else + cout << "Unexpected error read from serialised representation." << endl; + } + catch( r_Error &err ) + { + cout << "Output of what() catching an r_Error &err" << endl; + cout << err.what() << endl; + } + cout << "Done" << endl; + free(serialErr); + + cout << endl; + + cout << "freeing error text table..."; + freeTextTable(); + cout << "ok." << endl; + + cout << endl << "------------------------------------------------------------------" << endl; + + return 0; +} diff --git a/raslib/test/test_metaobject.cc b/raslib/test/test_metaobject.cc new file mode 100644 index 0000000..4f93882 --- /dev/null +++ b/raslib/test/test_metaobject.cc @@ -0,0 +1,332 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_metaobject.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> + +#ifdef __VISUALC__ + #define __EXECUTABLE__ + #include "raslib/itertype.hh" + #include "raslib/structuretype.hh" + #include "raslib/attribute.hh" + #include "raslib/primitivetype.hh" + #include "raslib/rminit.hh" + #include "raslib/basetype.hh" + #include "raslib/marraytype.hh" + #undef __EXECUTABLE__ +#else + #include "raslib/itertype.hh" + #include "raslib/structuretype.hh" + #include "raslib/attribute.hh" + #include "raslib/primitivetype.hh" + #include "raslib/rminit.hh" + #include "raslib/basetype.hh" + #include "raslib/marraytype.hh" +#endif + +#include "raslib/error.hh" +#include "raslib/type.hh" +#include "raslib/structure.hh" +#include "raslib/primitive.hh" + +RMINITGLOBALS('C') + + +void testType( const char* stringType ) +{ + r_Type* type = NULL; + + cout << "Create " << stringType << endl; + + try + { + type = r_Type::get_any_type( stringType ); + } + catch( r_Error& errorObj ) + { + cout << errorObj.what() << endl << endl; + } + + cout << " Type: "; + + if( type ) + { + type->print_status( cout ); + cout << endl; + cout << type->type_id() << endl; + } + else + { + cout << "<not available>" << endl; + } + cout << endl; + delete type; + +} + +/* +void testEndian() +{ + r_Primitive_Type boolType("Bool", r_Primitive_Type::BOOL); + r_Primitive_Type shortType("Short", r_Primitive_Type::SHORT); + r_Primitive_Type uLongType("ULong", r_Primitive_Type::ULONG); + r_Type* structType; + structType = r_Type::get_any_type( "struct{bool e1, short e2, ulong e3}" ); + + char cChar = 47; + short cShort = 1065; + unsigned long cULong = 92753; + + char *boolCell = (char*)&cChar; + char *shortCell = (char*)&cShort; + char *uLongCell = (char*)&cULong; + char structCell[7] = { 1, 2, 3, 4, 5, 6, 7 }; + + cout << "Before convertToLittleEndian:" << endl; + cout << "Char: " << (long)*boolCell << endl + << "Short: " << (long)*shortCell << " " << (long)*(shortCell+1) << endl + << "ULong: " << (long)*uLongCell << " " << (long)*(uLongCell+1) << " " + << (long)*(uLongCell+2) << " " << (long)*(uLongCell+3) + << endl + << "Struct: " << (long)*structCell << " " << (long)*(structCell+1) + << " " << (long)*(structCell+2) << " " + << (long)*(structCell+3) << " " + << (long)*(structCell+4) << " " + << (long)*(structCell+5) << " " + << (long)*(structCell+6) << " " + << endl; + + boolType.convertToLittleEndian(boolCell, 1); + shortType.convertToLittleEndian(shortCell, 1); + uLongType.convertToLittleEndian(uLongCell, 1); + structType->convertToLittleEndian(structCell, 1); + + cout << "After convertToLittleEndian:" << endl; + cout << "Char: " << (long)*boolCell << endl + << "Short: " << (long)*shortCell << " " << (long)*(shortCell+1) << endl + << "ULong: " << (long)*uLongCell << " " << (long)*(uLongCell+1) << " " + << (long)*(uLongCell+2) << " " << (long)*(uLongCell+3) + << endl + << "Struct: " << (long)*structCell << " " << (long)*(structCell+1) + << " " << (long)*(structCell+2) << " " + << (long)*(structCell+3) << " " + << (long)*(structCell+4) << " " + << (long)*(structCell+5) << " " + << (long)*(structCell+6) << " " + << endl; + + boolType.convertToBigEndian(boolCell, 1); + shortType.convertToBigEndian(shortCell, 1); + uLongType.convertToBigEndian(uLongCell, 1); + structType->convertToLittleEndian(structCell, 1); + + cout << "After convertToBigEndian:" << endl; + cout << "Char: " << (long)*boolCell << endl + << "Short: " << (long)*shortCell << " " << (long)*(shortCell+1) << endl + << "ULong: " << (long)*uLongCell << " " << (long)*(uLongCell+1) << " " + << (long)*(uLongCell+2) << " " << (long)*(uLongCell+3) + << endl + << "Struct: " << (long)*structCell << " " << (long)*(structCell+1) + << " " << (long)*(structCell+2) << " " + << (long)*(structCell+3) << " " + << (long)*(structCell+4) << " " + << (long)*(structCell+5) << " " + << (long)*(structCell+6) << " " + << endl; + + delete structType; +} +*/ + +int main() +{ + cout << "Creating definining primitive types ..." << endl; + r_Primitive_Type myBool("Bool", r_Primitive_Type::BOOL); + myBool.print_status( cout ); cout << endl; + r_Primitive_Type myULong("ULong", r_Primitive_Type::ULONG); + myULong.print_status( cout ); cout << endl; + + r_Primitive_Type tmp = myBool; + tmp.print_status( cout ); cout << endl; + + r_Attribute tmpAtt("tmpAtt",tmp ); + tmpAtt.print_status( cout ); cout << endl; + + cout << "Creating a struct out of them ..." << endl; + r_Attribute myAttrs[2]; + myAttrs[0] = r_Attribute("Attr1", myBool ); + myAttrs[1] = r_Attribute("Attr2", myULong ); + + r_Structure_Type myStruct("aStruct", 2, myAttrs); + myStruct.print_status( cout ); cout << endl; + + cout << "Iterating attributes of struct:" << endl; + r_Structure_Type::attribute_iterator + iter(myStruct.defines_attribute_begin()); + while(iter != myStruct.defines_attribute_end()) + { + cout << " Name of Attribute: " << (*iter).name() << endl; + cout << " Offset of Attribute: " << (*iter).offset() << endl; + cout << " Size of type of Attribute: " + << (*iter).type_of().size() << endl; + cout << " Name of type of Attribute: " + << (*iter).type_of().name() << endl; + ++iter; + } + + testType("char"); + + testType("octet"); + testType("short"); + testType("ushort"); + testType("long"); + testType("ulong"); + testType("bool"); + testType("float"); + testType("double"); + + testType("struct{ char }"); + testType("struct{ char band1 }"); + + testType("struct{ char, octet, ulong, short }"); + + testType("struct{ char elem1, octet elem2, ulong elem3, short elem4 }"); + testType("struct{ char red, char green, char blue }" ); + testType("struct{char red, char green, char blue}" ); + + testType("struct{ struct{ char, char, char }, ulong }"); + testType("struct{ struct{ char elem1, char elem2, char elem3 } record, ulong value }"); + + + testType("marray< char >"); + testType("marray< char green>"); + testType("marray< struct{ char red} >"); + + testType("marray< struct{char red, char green, char blue} >" ); + + testType("set< marray< char > >"); + testType("set< marray< struct{ char red, char green, char blue } > >" ); + + testType("interval"); + testType("minterval"); + testType("point"); + testType("oid"); + + testType("set< interval >"); + testType("set< minterval >"); + testType("set< point >"); + testType("set< oid >"); + + /* shouldn't work */ + cout << endl << "Testing combinations which are not allowed..." << endl; + testType("set< marray< interval > >"); + testType("set< marray< minterval > >"); + testType("set< marray< point > >"); + testType("set< marray< oid > >"); + + testType("interval<set< marray< char > > >"); + testType("interval<struct{ point blue, interval green}>"); + testType("set< marray{ char > >"); + testType("struct<char>"); + + + + r_Type* type = NULL; + char* stringType = "marray< char blue>"; + + cout << "Create " << stringType << endl; + + try + { + type = r_Type::get_any_type( stringType ); + } + catch( r_Error& errorObj ) + { + cout << errorObj.what() << endl << endl; + } + + cout << " Type: "; + + if( type ) + { + type->print_status( cout ); + } + else + { + cout << "<not available>" << endl; + } + cout << endl; + + // cout << ((r_Marray_Type*)type)->getBaseType() << endl; + + cout << "Erzeugen einer Kopie und Ausgabe..." << endl; + r_Marray_Type my_marray; + + my_marray = *((r_Marray_Type*)(type)); + my_marray.print_status( cout ); + + cout << endl; + // cout << my_marray.getBaseType() << endl; + + delete type; + + r_Type* type2 = r_Type::get_any_type("struct{ short band1, char band2 }"); + + if( type2->isBaseType() ) + { + r_Base_Type* baseType2 = (r_Base_Type*)type2; + + cout << "Type: " << flush; + baseType2->print_status(); + cout << endl; + cout << "Size: " << baseType2->size() << endl; + } + + struct structType{ short band1r; char band2i; }; + + structType structValue = { 1, 2 }; + + r_Structure structObject( (const char*)&structValue, (const r_Structure_Type*)type2 ); + + structObject.print_status( cout ); + + cout << endl; + + delete type2; + + /* testEndian(); */ + return 0; +} + + diff --git a/raslib/test/test_minterval.cc b/raslib/test/test_minterval.cc new file mode 100644 index 0000000..f8f388f --- /dev/null +++ b/raslib/test/test_minterval.cc @@ -0,0 +1,118 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_sinterval.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include <malloc.h> + +#include "raslib/minterval.hh" +#include "raslib/sinterval.hh" + +#include "raslib/rminit.hh" +RMINITGLOBALS('C') + +int main() +{ + cout << endl << endl; + cout << "Minterval Examples" << endl; + cout << "===================" << endl << endl; + + cout << "initializing interval [1:2,3:3] : " << endl; + r_Minterval m1 = r_Minterval(2); + m1 << r_Sinterval(1l,2l) << 3; + cout << m1 << endl << endl; + + cout << "copy the interval with copy constructor" << endl; + r_Minterval copy( m1 ); + cout << copy << endl << endl; + + cout << "test for equality: "; + if( copy == m1 ) + cout << "OK" << endl << endl; + else + cout << "FAILED" << endl << endl; + + cout << "union of [1:4,3:6] and [3:6,1:4] :" << endl; + r_Minterval m2 = r_Minterval(2) << r_Sinterval(1l,4l) << r_Sinterval(3l,6l); + r_Minterval m3 = r_Minterval(2) << r_Sinterval(3l,6l) << r_Sinterval(1l,4l); + try + { + m2 += m3; + } + catch( r_Error& ex1 ) + { + cerr << ex1.what() << endl; + } + cout << m2 << endl << endl; + + cout << "union of [1:4,3:6] and [3:6,8:9] : " << endl; + r_Minterval m4 = r_Minterval(2) << r_Sinterval(1l,4l) << r_Sinterval(3l,6l); + r_Minterval m5 = r_Minterval(2) << r_Sinterval(3l,6l) << r_Sinterval(8l,9l); + try + { + m4 += m5; + } + catch( r_Error& ex2 ) + { + cerr << ex2.what() << endl; + } + cout << m4 << endl << endl; + + cout << "closure of [1:4,3:6] and [7:9,1:2] : " << endl; + r_Minterval m6 = r_Minterval(2) << r_Sinterval(1l,4l) << r_Sinterval(3l,6l); + r_Minterval m7 = r_Minterval(2) << r_Sinterval(7l,9l) << r_Sinterval(1l,2l); + try + { + m6.closure_with( m7 ); + } + catch( r_Error& ex2 ) + { + cerr << ex2.what() << endl; + } + cout << m6 << endl << endl; + + cout << "intersection of [7:9,1:2] and [ " << m6[0].low() << ":" << m6[0].high() << "," << m6[1].low() << ":" << m6[1].high() << "]" << endl; + cout << m7.intersects_with( m6 ); + cout << endl; + + cout << "initializing domain [1:4,*:6,7:*]" << endl; + r_Minterval m8 = r_Minterval(3) << r_Sinterval(1l,4l) << r_Sinterval('*',6l) << r_Sinterval(7l,'*'); + char* stringRepresentation = m8.get_string_representation(); + cout << "string representation " << stringRepresentation << " should be " << m8 << endl; + + r_Minterval m9 = r_Minterval( stringRepresentation ); + cout << "recreation of the string delivers " << m9 << endl; + free( stringRepresentation ); + + return 0; +} diff --git a/raslib/test/test_miter.cc b/raslib/test/test_miter.cc new file mode 100644 index 0000000..55b2930 --- /dev/null +++ b/raslib/test/test_miter.cc @@ -0,0 +1,334 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_miter.cc + * + * MODULE: raslib + * + ************************************************************/ + +#include <iostream> +#include <math.h> +#include <stdlib.h> + +#include "raslib/miter.hh" +#include "raslib/minterval.hh" +#include "raslib/rminit.hh" +#include "raslib/rmdebug.hh" +RMINITGLOBALS('C') + +// structure storing information on iteration for each dimension +// (perhaps add dimension for reordering later) +typedef struct { + int repeat; // total number of repeats + int inc; // increment per repeat + int curr; // current repeat +} incArrElem; + +// for repeating inside the test functions +const int numRepeat = 100; + +r_Minterval +createCube(int size, int dim) +{ + int i; + long c = pow((double)size, 1.0/(double)dim); + + r_Minterval res(dim); + + for(i=0; i<dim; i++) + res << r_Sinterval(0l, c-1); + + i = 0; + while(res.cell_count() < size) { + res[i].set_high(res[i].high() + 1); + i++; + } + if(res.cell_count() > size) + res[i-1].set_high(res[i-1].high() - 1); + + return res; +} + +void +test_Miter( r_Minterval& m1, r_Minterval& m2, char* data ) +{ + char* currCell; + + // just to do something inside the loop + unsigned long sum = 0; + + cout <<"Iteration r_Miter: "; + + // for performance measurement + RMTimer mIterTimer("Iterator","r_Miter" ); + mIterTimer.start( ); + + r_Miter iter(&m2, &m1, 4, (char*)data); + for(int i=0; i<numRepeat; i++) { + iter.reset(); + while(!iter.isDone()) { + currCell = iter.nextCell(); + sum += *(long*)currCell; + } + } + + mIterTimer.stop( ); + cout << sum << endl; +} + +void +test_DirectIter( r_Minterval& m1, r_Minterval& m2, char* data ) +{ + int opSize = 4; + int dim = m1.dimension(); + int i; + char* currCell; + + // just to do something inside the loop + unsigned long sum = 0; + + incArrElem* incArrIter; + + cout <<"Iteration direct: "; + + // for performance measurement + RMTimer iterTimer("Iterator","directIter" ); + iterTimer.start( ); + + for(int r=0; r<numRepeat; r++) { + + // stores the increments + incArrIter = new incArrElem[dim]; + + currCell = (char*)data; + + // the following initializes incArrIter and calculates the first offset + int tIncIter = 1; // total increment for current dimension + int prevTIncIter = 1; // total increment for previous dimension + int incIter = 4; // current increment, corresponds to cell size + int firstOff = 0; + + for( i=0; i<dim; i++ ) { + // in RasDaMan the order of dimensions is the other way round! + int r = dim - i - 1; + // used for counting in iteration, initialize with 0 + incArrIter[i].curr = 0; + // how often is the increment added? + incArrIter[i].repeat = m2[r].high() - m2[r].low() + 1; + // the increment for the result tile (higher dimensions calculated + // further down) + incArrIter[i].inc = incIter; + + // calculate starting offset and increments for higher dimensions + // firstOff is the offset in chars of the first cell + firstOff += (m2[r].low()-m1[r].low()) * prevTIncIter * 4; + // tInc is the increment if the dimension would be skipped + tIncIter = (m1[r].high() - m1[r].low()+1) * prevTIncIter; + // inc is the real increment, after some cells in the dimensions + // have been iterated through. + incIter = (tIncIter - incArrIter[i].repeat*prevTIncIter) * 4; + // remember total increment of last dimension + prevTIncIter = tIncIter; + } + + currCell += firstOff; + + int done = 0; + // get first adresses + + while(!done) { + // iterate through lowest dimension + for(i=0; i<incArrIter[0].repeat; i++) { + // execute operation + sum += *(long*)currCell; + // increment adresses + currCell += incArrIter[0].inc; + } + // increment other dimensions + for(i=1; i<dim; i++) { + incArrIter[i].curr++; + currCell += incArrIter[i].inc; + if(incArrIter[i].curr < incArrIter[i].repeat) { + // no overflow in this dimension + break; + } else { + // overflow in this dimension + incArrIter[i].curr = 0; + } + } + if( i == dim ) { + // overflow in last dimension + done = 1; + } + } + delete [] incArrIter; + } + iterTimer.stop(); + cout << sum << endl; +} + +void +test_OldIter( r_Minterval& m1, r_Minterval& m2, char* data ) +{ + // just to do something inside the loop + unsigned long sum = 0; + + cout <<"Iteration oldIter: "; + // for performance measurement + RMTimer oldIterTimer("Iterator","oldIter" ); + oldIterTimer.start( ); + + r_Point pOp(m2.dimension()); + int done; + int recalc; + int i, j; + const int opSize = 4; + int dim = m2.dimension(); + int innerExtent = (m2.get_extent())[dim-1]; + char* cellOp; + + // initialize points + for(i = 0; i < dim; i++) + { + pOp << 0; + } + + for(int r=0; r<numRepeat; r++) { + done = 0; + recalc = 0; + + // initialize points + for(i = 0; i < dim; i++) + { + pOp[i] = m2[i].low(); + } + + cellOp = (char*)data + m1.cell_offset(pOp)*4; + + // iterate over all cells + while(!done) + { + if( recalc ) + { + cellOp = (char*)data + m1.cell_offset(pOp)*4; + recalc = 0; + } + + // iterate through innermost dimension + for(j = 0; j < innerExtent; j++ ) { + // execute operation on cell + sum += *(long*)cellOp; + cellOp += opSize; + } + + // increment coordinates + i = dim - 2; + // special case! 1-D operands! + if( i < 0 ) + break; + ++pOp[i]; + recalc = 1; + while( pOp[i] > m2[i].high() ) + { + pOp[i] = m2[i].low(); + i--; + if(i < 0) + { + done = 1; + break; + } + ++pOp[i]; + } + } + } + + oldIterTimer.stop(); + cout << sum << endl; +} + +void +test_CppIter( unsigned long cells, char* data ) +{ + unsigned long sum = 0; + RMTimer cppIterTimer("Iterator", "cppIter"); + cppIterTimer.start(); + + for(int r=0; r<numRepeat; r++) { + for(int i = 0; i<1048576; i++) { + sum += data[i]; + } + } + + cppIterTimer.stop(); + cout <<"Iteration C++: " << sum << endl; +} + +int main() +{ + const unsigned long noCells = 1048576; + unsigned long* data; + + for(int dim=1; dim<=7; dim++) { + r_Minterval m2; + r_Minterval m1(dim); + + m2 = createCube(noCells, dim); + + for(int i=0; i<dim; i++) { + m1 << r_Sinterval(m2[i].low()-1, m2[i].high()+1); + } + + // as basis for the operations + data = new unsigned long[m1.cell_count()]; + for(int i=0; i < m1.cell_count(); i++) { + data[i] = i; + } + + cout <<"Iterate through " << m2 << " in "<< m1 << endl; + + RMInit::bmOut << "Dimensionality: " << dim << ", cells: " + << m2.cell_count() << endl; + + for(int i=0; i<5; i++) { + test_Miter( m1, m2, (char*)data ); + test_OldIter( m1, m2, (char*)data ); + test_DirectIter( m1, m2, (char*)data ); + } + delete [] data; + } + + RMInit::bmOut << "1-D Iteration in C++:" << endl; + + data = new unsigned long[noCells]; + + for(int i=0; i < noCells; i++) { + data[i] = i; + } + + for(int i=0; i<5; i++) { + test_CppIter( noCells, (char*)data ); + } + delete [] data; +} diff --git a/raslib/test/test_miterd b/raslib/test/test_miterd Binary files differnew file mode 100644 index 0000000..7ee9a45 --- /dev/null +++ b/raslib/test/test_miterd diff --git a/raslib/test/test_miterd.cc b/raslib/test/test_miterd.cc new file mode 100644 index 0000000..e664aec --- /dev/null +++ b/raslib/test/test_miterd.cc @@ -0,0 +1,75 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_miter.cc + * + * MODULE: raslib + * + ************************************************************/ + +#include <iostream> +#include <math.h> +#include <stdlib.h> + +#include "raslib/miterd.hh" +#include "raslib/minterval.hh" +#include "raslib/rminit.hh" +#include "raslib/rmdebug.hh" +RMINITGLOBALS('C') + +int +main(int i, char** argv) + { + unsigned short src[][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; + for (r_Dimension i = 0; i < 4; i++) + { + for (r_Dimension c = 0; c < 4; c++) + { + cout << src[i][c] << " "; + } + cout << endl; + } + for (r_Dimension i = 0; i < 4; i++) + { + for (r_Dimension c = 0; c < 4; c++) + { + cout << src[c][i] << " "; + } + cout << endl; + } + /* + r_MiterDirect iter(src, r_Minterval("[0:3,0:3]"), r_Minterval("[0:3,0:3]"), 2, 0); + r_Dimension order[] = {1,1}; + unsigned int step[] = {1,0}; + r_Dimension order2[] = {0}; + while (!iter.isDone()) + { + iter.iterateUserOrder(order, step); + cout << *(unsigned short*)(iter.getData()) << " " << endl;; + cout << "pos " << iter << endl; + // cout << *(unsigned short*)(iter.getData()) << " "; + iter.operator++(); + } + */ + } diff --git a/raslib/test/test_miterf.cc b/raslib/test/test_miterf.cc new file mode 100644 index 0000000..43660f9 --- /dev/null +++ b/raslib/test/test_miterf.cc @@ -0,0 +1,118 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_miterf.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + + +#include <iostream> +#include <math.h> +#include <stdlib.h> + +#include "raslib/mddtypes.hh" +#include "raslib/miterf.hh" +#include "raslib/minterval.hh" +#include "raslib/rminit.hh" +#include "raslib/rmdebug.hh" + + + +RMINITGLOBALS('C') + + +int main(int argc, char *argv[]) +{ + r_Dimension dim = 3; + r_Minterval iv(dim); + r_Dimension i; + double *iterMin, *iterMax, *iterStep; + int typeLength = 1; + long totalSize = typeLength; + long totalSteps = 1; + double stepBy = 1.5; + + i = 1; + while (i < argc) + { + if (strcmp(argv[i], "-s") == 0) + { + stepBy = atof(argv[++i]); + } + i++; + } + + cout << "Step by " << stepBy << endl; + + iterMin = new double[dim]; iterMax = new double[dim]; + iterStep = new double[dim]; + for (i=0; i<dim; i++) + { + int steps; + + iterStep[i] = stepBy; + iterMin[i] = 0; + iterMax[i] = (1<<(4+i)) - 1; + iv << r_Sinterval((r_Range)(iterMin[i]), (r_Range)(iterMax[i])); + totalSize *= (r_Range)(iterMax[i]) - (r_Range)(iterMin[i]) + 1; + steps = (int)((iterMax[i] - iterMin[i]) / iterStep[i]); + totalSteps *= (steps + 1); + iterMax[i] = iterMin[i] + (steps + 0.5)*iterStep[i]; // rounding effects + } + + char *srcData = new char[totalSize]; + + cout << "Total size: 0x" << hex << totalSize + << ", base address " << (void*)srcData << endl; + + r_MiterFloat iter(&iv, iterMin, iterMax, iterStep, typeLength, srcData); + + long steps = 0; + while (!iter.isDone()) + { + char *cell = iter.nextCell(); + + if (cell + typeLength > srcData + totalSize) + { + cout << dec << "Overflow by " << (cell - srcData) - totalSize << endl; + } + steps++; + } + + cout << dec << "Did " << steps << " steps out of " << totalSteps << endl; + if (steps != totalSteps) + cout << "!!! WRONG NUMBER OF STEPS !!!" << endl; + + delete [] srcData; + + delete [] iterMin; delete [] iterMax; delete [] iterStep; + + return 0; +} diff --git a/raslib/test/test_oid.cc b/raslib/test/test_oid.cc new file mode 100644 index 0000000..d7c3170 --- /dev/null +++ b/raslib/test/test_oid.cc @@ -0,0 +1,181 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_oid.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include <iomanip.h> +// #include <limits.h> +#include "raslib/oid.hh" + +#include "raslib/rminit.hh" +RMINITGLOBALS('C') + +int main() +{ + cout << endl << endl; + cout << "OId Examples" << endl; + cout << "============" << endl << endl; + + cout << "Create oid1" << endl; + r_OId oid1( "testSystem", "testBase", 99 ); + cout << " oid1........: " << oid1 << endl; + cout << " system name: " << oid1.get_system_name() << endl; + cout << " base name: " << oid1.get_base_name() << endl; + cout << " local oid..: " << oid1.get_local_oid() << endl << endl; + + cout << "Create oid2 with string representation of oid1" << endl; + r_OId oid2( oid1.get_string_representation() ); + cout << " oid2........: " << oid2 << endl; + cout << " system name: " << oid2.get_system_name() << endl; + cout << " base name: " << oid2.get_base_name() << endl; + cout << " local oid..: " << oid2.get_local_oid() << endl << endl; + + cout << "Assign oid1 to oid2" << endl; + oid2 = oid1; + cout << " oid2........: " << oid2 << endl; + cout << " system name: " << oid2.get_system_name() << endl; + cout << " base name: " << oid2.get_base_name() << endl; + cout << " local oid..: " << oid2.get_local_oid() << endl << endl; + + cout << "Assign temporary oid to oid2" << endl; + oid2 = r_OId( "testSystem|testBase|100" ); + cout << " oid2........: " << oid2 << endl; + cout << " system name: " << oid2.get_system_name() << endl; + cout << " base name: " << oid2.get_base_name() << endl; + cout << " local oid..: " << oid2.get_local_oid() << endl << endl; + + cout << "Assign oid1 to oid1" << endl; + oid1 = oid1; + cout << " oid1........: " << oid1 << endl; + cout << " system name: " << oid1.get_system_name() << endl; + cout << " base name: " << oid1.get_base_name() << endl; + cout << " local oid..: " << oid1.get_local_oid() << endl << endl; + + cout << "Create oid3 as a copy of oid1 with the copy constructor" << endl; + r_OId oid3( oid1 ); + cout << " oid3........: " << oid3 << endl; + cout << " system name: " << oid3.get_system_name() << endl; + cout << " base name: " << oid3.get_base_name() << endl; + cout << " local oid..: " << oid3.get_local_oid() << endl << endl; + + cout << "Create oid4 with string testSystem|testBase|100" << endl; + r_OId oid4( "testSystem|testBase|100" ); + cout << " oid4........: " << oid4 << endl; + cout << " system name: " << oid4.get_system_name() << endl; + cout << " base name: " << oid4.get_base_name() << endl; + cout << " local oid..: " << oid4.get_local_oid() << endl << endl; + + cout << "Create oid5 with string |testBase|100" << endl; + r_OId oid5( "|testBase|100" ); + cout << " oid5........: " << oid5 << endl; + cout << " system name: " << oid5.get_system_name() << endl; + cout << " base name: " << oid5.get_base_name() << endl; + cout << " local oid..: " << oid5.get_local_oid() << endl << endl; + + cout << "Create oid6 with string ||100" << endl; + r_OId oid6( "||100" ); + cout << " oid6........: " << oid6 << endl; + cout << " system name: " << oid6.get_system_name() << endl; + cout << " base name: " << oid6.get_base_name() << endl; + cout << " local oid..: " << oid6.get_local_oid() << endl << endl; + + cout << "Create oid7 with string |||" << endl; + r_OId oid7( "|||" ); + cout << " oid7........: " << oid7 << endl; + cout << " system name: " << oid7.get_system_name() << endl; + cout << " base name: " << oid7.get_base_name() << endl; + cout << " local oid..: " << oid7.get_local_oid() << endl << endl; + + cout << "Create oid8 with an empty string" << endl; + r_OId oid8( "" ); + cout << " oid8........: " << oid8 << endl; + cout << " system name: " << oid8.get_system_name() << endl; + cout << " base name: " << oid8.get_base_name() << endl; + cout << " local oid..: " << oid8.get_local_oid() << endl << endl; + + cout << "Create oid9 with just a local oid" << endl; + r_OId oid9( 0, 0, 100 ); + cout << " oid8........: " << oid9 << endl; + cout << " system name: " << oid9.get_system_name() << endl; + cout << " base name: " << oid9.get_base_name() << endl; + cout << " local oid..: " << oid9.get_local_oid() << endl << endl; + + cout << "Create oid10 with copy constructor from oid1" << endl; + r_OId oid10( oid1 ); + cout << " oid10.......: " << oid10 << endl; + cout << " system name: " << oid10.get_system_name() << endl; + cout << " base name: " << oid10.get_base_name() << endl; + cout << " local oid..: " << oid10.get_local_oid() << endl << endl; + + cout << "Compare r_OId( \"testSystem1|testBase|99\") < r_OId( \"testSystem2|testBase|99\")" << endl; + cout << (r_OId( "testSystem1|testBase|99") < r_OId( "testSystem2|testBase|99")) << endl << endl; + + cout << "Compare r_OId( \"testSystem|testBase1|99\") < r_OId( \"testSystem|testBase2|99\")" << endl; + cout << (r_OId( "testSystem|testBase1|99") < r_OId( "testSystem|testBase2|99")) << endl << endl; + + cout << "Compare r_OId( \"testSystem|testBase|99\") < r_OId( \"testSystem|testBase|100\")" << endl; + cout << (r_OId( "testSystem1|testBase|99") < r_OId( "testSystem2|testBase|100")) << endl << endl; + + cout << "Compare r_OId( \"testSystem1|testBase|99\") > r_OId( \"testSystem2|testBase|99\")" << endl; + cout << (r_OId( "testSystem1|testBase|99") > r_OId( "testSystem2|testBase|99")) << endl << endl; + + cout << "Compare r_OId( \"testSystem|testBase1|99\") > r_OId( \"testSystem|testBase2|99\")" << endl; + cout << (r_OId( "testSystem|testBase1|99") > r_OId( "testSystem|testBase2|99")) << endl << endl; + + cout << "Compare r_OId( \"testSystem|testBase|99\") > r_OId( \"testSystem|testBase|100\")" << endl; + cout << (r_OId( "testSystem1|testBase|99") > r_OId( "testSystem2|testBase|100")) << endl << endl; + + cout << "Create oid11" << endl; + // cout << "Double limit: " << DBL_MAX << "= 0x" << hex << DBL_MAX << dec << endl; + double maxDouble = 0xffffffffffff; + cout << "48bit : " << setprecision(30) << maxDouble << endl; + cout << "48bit - 1 : " << setprecision(30) << maxDouble-1 << endl; + cout << "48bit + 1 : " << setprecision(30) << maxDouble+1 << endl; + r_OId oid11( "testSystem", "testBase", maxDouble ); + cout << " oid11.......: " << oid11 << endl; + cout << " system name: " << oid11.get_system_name() << endl; + cout << " base name: " << oid11.get_base_name() << endl; + cout << " local oid..: " << oid11.get_local_oid() << endl << endl; + + cout << endl; + + cout << "Create oid12 with string ''" << endl; + r_OId oid12( "" ); + cout << " oid12.......: " << oid12 << endl; + cout << " system name: " << oid12.get_system_name() << endl; + cout << " base name: " << oid12.get_base_name() << endl; + cout << " local oid..: " << oid12.get_local_oid() << endl << endl; + + return 0; +} + diff --git a/raslib/test/test_params.cc b/raslib/test/test_params.cc new file mode 100644 index 0000000..4be15df --- /dev/null +++ b/raslib/test/test_params.cc @@ -0,0 +1,101 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * INCLUDE: test_params.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <stdio.h> +#include <iostream> +#include <string.h> +#include <stdlib.h> + +#include "raslib/rminit.hh" +#include "raslib/parseparams.hh" + + +RMINITGLOBALS('C') + + +typedef struct test_params_s { + r_Parse_Params *pp; + int zlevel; + double fidelity; + char *lstream; +} test_params_t; + + +static void test_params(test_params_t ¶ms, char *str) +{ + cout << "Processing (" << str << ") ..." << endl; + + params.pp->process(str); + + cout << "zlevel = " << params.zlevel + << ", fidelity = " << params.fidelity + << ", stream = <" << params.lstream << ">" << endl; + + // string was allocated with strdup, free now + free(str); +} + + +int main(int argc, char *argv[]) +{ + r_Parse_Params pp; + test_params_t params = {&pp, -1, -1.0, NULL}; + + pp.add("zlevel", ¶ms.zlevel, r_Parse_Params::param_type_int); + pp.add("fidelity", ¶ms.fidelity, r_Parse_Params::param_type_double); + pp.add("stream", ¶ms.lstream, r_Parse_Params::param_type_string); + + // Note: must use strdup() because Purify doesn't find reads over the end of + // static strings! + test_params(params, strdup("0123")); + test_params(params, strdup("zlevel, fidelity=0.1")); + test_params(params, strdup("zlevel=a")); + test_params(params, strdup("zlevel=6")); + test_params(params, strdup("\"zlevel=6\"")); + test_params(params, strdup("fidelity=0.90")); + test_params(params, strdup("stream=rle")); + test_params(params, strdup("stream=eee ")); + test_params(params, strdup("stream=\"rle\"")); + test_params(params, strdup("zlevel=9, fidelity=0.75, stream=zlib")); + test_params(params, strdup("stream=rle, zlevel=5")); + test_params(params, strdup("zlevel=1, foobar=hello")); + test_params(params, strdup("foobar=hello, zlevel=2")); + test_params(params, strdup(" stream=\"zlib\" ")); + test_params(params, strdup(" foobar=\"hello, you there\", stream=\"rle\"")); + + if (params.lstream != NULL) + delete [] params.lstream; + + return 0; +} diff --git a/raslib/test/test_point.cc b/raslib/test/test_point.cc new file mode 100644 index 0000000..63b2f05 --- /dev/null +++ b/raslib/test/test_point.cc @@ -0,0 +1,90 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_point.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include <stdlib.h> + +#include "raslib/point.hh" + +#include "raslib/rminit.hh" +RMINITGLOBALS('C') + +int main() +{ + cout << endl << endl; + cout << "Point Examples" << endl; + cout << "===============" << endl << endl; + + cout << "initialize 1D-point: " << flush; + r_Point d1(1); + cout << d1 << endl; + + cout << "set value to 9 : " << flush; + d1[0] = 9; + cout << d1 << endl; + + r_Point a(3); + a << 1 << 2 << 3; + cout << "stream initializing point (1,2,3) : " << a << endl << endl; + + try{ + cout << "read out of range : " << a[3] << endl; + } + catch( r_Eindex_violation& ex ){ + cout << ex.what(); + } + cout << endl << endl; + + r_Point b = r_Point(3) << 1 << 2 << 3; + cout << "assignment point (1,2,3) : " << b << endl << endl; + + cout << "temp. obj. (1,2,3), access second coord. : " << ( r_Point(3) << 1 << 2 << 3 )[1] << endl << endl; + + a[1] = 4; + cout << "assignment a[1]=4 to a(1,2,3) : " << a << endl << endl; + + r_Point c = b; + cout << "equal operator test: " << flush; + if( c == b ) + cout << "OK" << endl; + else + cout << "FALSE" << endl; + + char* stringRep = b.get_string_representation(); + cout << endl << "String representation of point " << b << ": " << stringRep << endl; + cout << "Result of string constructor: " << r_Point( stringRep ) << endl; + free( stringRep ); + + cout << "Result of r_Point(\"[ 0, 5, 3]\"): " << r_Point("[ 0, 5, 3]") << endl; +} diff --git a/raslib/test/test_rmdebug.cc b/raslib/test/test_rmdebug.cc new file mode 100644 index 0000000..c6f29ca --- /dev/null +++ b/raslib/test/test_rmdebug.cc @@ -0,0 +1,179 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_rmdebug.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include "raslib/rmdebug.hh" + +#include "raslib/rminit.hh" + +// number of repetitions for performance tests +static const int repeat = 100000; + +RMINITGLOBALS('C') + +void testFunc1() +{ + RMDebug localRMDebug = RMDebug("Class1", "testFunc1", "Module1", + __FILE__, __LINE__); +} + +void testFunc2(int reclevel) +{ + RMDebug localRMDebug = RMDebug("Class1", "testFunc2", "Module1", + __FILE__, __LINE__); + + if(reclevel > 1) + testFunc2(reclevel - 1); +} + +void testFunc3(void) +{ + RMDebug localRMDebug("Class1", "testFunc3", "server", + __FILE__, __LINE__); + + RMDBGMOUT( 2, RMDebug::module_server, NULL, "D: testing 1" ); + RMDBGMOUT( 3, RMDebug::module_server, "Class1", "D: testing 2" ); + RMDBGMINOUT( 4, RMDebug::module_server, "Class1", "D: testing 3" ); +} + +void testFunc4(int reclevel) +{ + RMDebug localRMDebug(1, "Class2", "testFunc4", RMDebug::module_raslib, + __FILE__, __LINE__); + + if (reclevel > 1) + testFunc4(reclevel - 1); +} + +// this was used to test correctness + +void oldMain() +{ + int i; + + for(i = 1; i<=5; i++) + testFunc1(); + + testFunc2(5); + + testFunc3(); + + testFunc4(4); + + cout << "Test of RMTimer" << endl; + + cout << "The following should hold approximately: timer2 + timer3 = timer1" << endl << endl; + + RMTimer* timer1 = new RMTimer("main","timer1"); + RMTimer* timer2 = new RMTimer("main","timer2"); + + timer2->pause(); + + RMTimer* timer3 = new RMTimer("main","timer3"); + for( long busy=0; busy <= 50000000; busy++ ); + delete timer3; + + timer2->resume(); + + for( busy=0; busy <= 30000000; busy++ ); + + delete timer2; + delete timer1; + + cout << "Benchmark level set to " << RManBenchmark << endl; + + RMInit::bmOut << "test output in benchmark stream" << endl; +} + +double testStatic(double dummy) +{ + RMTIMER("test_rmdebug", "testStatic"); + + for(int i=0; i<repeat; i++) + dummy = dummy*4711.4712; + return dummy; +} + +double testDynamic(double dummy) +{ +#ifdef RMANBENCHMARK + RMTimer* localRMTimer = 0; + + if( RManBenchmark >= 3 ) + localRMTimer = new RMTimer("test_rmdebug", "testDynamic"); +#endif + + for(int i=0; i<repeat; i++) + dummy = dummy*4711.4712; + +#ifdef RMANBENCHMARK + if( localRMTimer ) delete localRMTimer; +#endif + + return dummy; +} + +// Evaluating time needed for measurement with different uses +// of RMTimer. + +void testPerf() +{ + double dummy = 3.14; + + cout << "Testing dynamic RMTimer vs. static RMTimer." << endl; + + // to put in cache + dummy = testStatic(dummy); + cout << "Static:" << endl; + dummy = testStatic(dummy); + + // to put in cache + dummy = testDynamic(dummy); + cout << "Dynamic:" << endl; + dummy = testDynamic(dummy); +} + +int main() +{ + RMDebug::initRMDebug(); + RManBenchmark = 4; + RMInit::bmOut = cout.rdbuf(); + + oldMain(); + // testPerf(); + + return 0; +} + + diff --git a/raslib/test/test_sinterval.cc b/raslib/test/test_sinterval.cc new file mode 100644 index 0000000..fa2fbc5 --- /dev/null +++ b/raslib/test/test_sinterval.cc @@ -0,0 +1,164 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_sinterval.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include <stdlib.h> + +#include "raslib/sinterval.hh" + +#include "raslib/rminit.hh" +RMINITGLOBALS('C') + +int main() +{ + r_Sinterval interval1, interval2; + + char Buffer[256]; + + cout << "lower bound ? "; + cin >> Buffer; + cout << endl; + + if( Buffer[0] == '*' ) + interval1.set_low('*'); + else + interval1.set_low( atol( Buffer ) ); + + cout << "upper bound ? "; + cin >> Buffer; + cout << endl; + + if( Buffer[0] == '*' ) + interval1.set_high('*'); + else + interval1.set_high( atol( Buffer ) ); + + cout << "interval1 = ["; + interval1.print_status( cout ); + cout << "]" << endl << endl; + + cout << "lower bound ? "; + cin >> Buffer; + cout << endl; + + if( Buffer[0] == '*' ) + interval2.set_low('*'); + else + interval2.set_low( atol( Buffer ) ); + + cout << "upper bound ? "; + cin >> Buffer; + cout << endl; + + if( Buffer[0] == '*' ) + interval2.set_high('*'); + else + interval2.set_high( atol( Buffer ) ); + + cout << "interval1 = ["; + interval2.print_status( cout ); + cout << "]" << endl << endl; + + r_Sinterval result; + + try{ + result.union_of( interval1, interval2 ); + + cout << "union = ["; + result.print_status( cout ); + cout << "]" << endl; + } + catch( r_Eno_interval error ) + { + cerr << "union " << error.what() << endl; + } + + try{ + result.difference_of( interval1, interval2 ); + + cout << "difference = ["; + result.print_status( cout ); + cout << "]" << endl; + } + catch( r_Eno_interval error ) + { + cerr << "difference " << error.what() << endl; + } + + try{ + result.intersection_of( interval1, interval2 ); + + cout << "intersection = ["; + result.print_status( cout ); + cout << "]" << endl; + } + catch( r_Eno_interval error ) + { + cerr << "intersection " << error.what() << endl; + } + + try{ + result.closure_of( interval1, interval2 ); + + cout << "closure = ["; + result.print_status( cout ); + cout << "]" << endl; + } + catch( r_Eno_interval error ) + { + cerr << "closure " << error.what() << endl; + } + + if( interval1.intersects_with( interval2 ) ) + cerr << "The intervals intersect." << endl; + else + cerr << "The intervals do not intersect." << endl; + + cerr << endl; + + r_Sinterval b( 4l, 10l ); + char* stringRep = b.get_string_representation(); + cout << endl << "String representation of interval " << b << ": " << stringRep << endl; + cout << "Result of string constructor: " << r_Sinterval( stringRep ) << endl; + free( stringRep ); + + cout << "Result of r_Sinterval(\" 10 : 100\"): " << r_Sinterval(" 10 : 100") << endl; + cout << "Result of r_Sinterval(\" * : 100\"): " << r_Sinterval(" * : 100") << endl; + cout << "Result of r_Sinterval(\" 10 : * \"): " << r_Sinterval(" 10 : * ") << endl; + cout << "Result of r_Sinterval(\" * : * \"): " << r_Sinterval(" * : * ") << endl; + + return 0; +} + + diff --git a/raslib/test/test_timer.cc b/raslib/test/test_timer.cc new file mode 100644 index 0000000..797c0fa --- /dev/null +++ b/raslib/test/test_timer.cc @@ -0,0 +1,101 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see <http://www.gnu.org/licenses/>. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see <http://www.rasdaman.org> +* or contact Peter Baumann via <baumann@rasdaman.com>. +*/ +/************************************************************* + * + * SOURCE: test_timer.cc + * + * MODULE: raslib + * + * PURPOSE: + * + * Test program to test class RMTimer. + * + * + * COMMENTS: + * + ************************************************************/ + +#include <iostream> +#include "raslib/rmdebug.hh" + + +RMINITGLOBALS('C') + +class Exp { + +public: + Exp( char* name ); + + void useTimer( ); + + ~Exp( ); + + RMTimer* t1; + RMTimer t2; + char* name; +}; + +Exp::Exp( char* n) + :t2("Test Timer ", "t2" ), name( n ) +{ + t1 = new RMTimer( "Test Timer ", "t1" ); +} + +void Exp::useTimer( ) +{ + cout << "useTimer "<< name << " t1 ... "<<endl; + t1->start( ); + t1->stop( ); + cout << "and t2"<<endl; + t2.start( ); + t2.stop( ); +} + +Exp::~Exp( ) +{ + cout << "Exp::~Exp( " << name << " ) "<< endl; + delete t1; +} + +static const Exp exp1("Static Exp Object"); + +int main() +{ + + /* + RMTimer tt( "Test Timer ", "tt" ); + + cout << "RMTimer start( )" <<endl; + tt.start( ); + tt.stop( ); + */ + + Exp e( "Exp Object" ); + e.useTimer( ); + + Exp* ep = new Exp("Pointer to Exp Object"); + ep->useTimer( ); + delete ep; + + return 0; +} |