diff options
author | Nikolai Pretzell <np@openoffice.org> | 2002-03-08 13:25:40 +0000 |
---|---|---|
committer | Nikolai Pretzell <np@openoffice.org> | 2002-03-08 13:25:40 +0000 |
commit | 8913e1e75efa377a107fa37d22680ec223cb043c (patch) | |
tree | f2c7a438e6bfaab1a6c708a43afa1b2fc71ef6bc /cosv/source/unittest | |
parent | d4bc2730f1d2088e5d4537ce7eb7333822c747d6 (diff) |
Moving Autodoc to OpenOffice.org, module cosv: CommonServices
Diffstat (limited to 'cosv/source/unittest')
-rw-r--r-- | cosv/source/unittest/file_ut.cxx | 155 | ||||
-rw-r--r-- | cosv/source/unittest/makefile.mk | 109 | ||||
-rw-r--r-- | cosv/source/unittest/string_ut.cxx | 174 | ||||
-rw-r--r-- | cosv/source/unittest/ut.hxx | 87 | ||||
-rw-r--r-- | cosv/source/unittest/ut_main.cxx | 81 |
5 files changed, 606 insertions, 0 deletions
diff --git a/cosv/source/unittest/file_ut.cxx b/cosv/source/unittest/file_ut.cxx new file mode 100644 index 000000000000..9e14af854419 --- /dev/null +++ b/cosv/source/unittest/file_ut.cxx @@ -0,0 +1,155 @@ +/************************************************************************* + * + * $RCSfile: file_ut.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <precomp.h> +#include <cosv/file.hxx> + +// NOT FULLY DECLARED SERVICES +#include <ut.hxx> + +using csv::File; + + +/** @file + UnitTests for class File. +*/ + +FUT_DECL( File, Read ); +FUT_DECL( File, Write ); +FUT_DECL( File, Seek ); +FUT_DECL( File, SeekBack ); +FUT_DECL( File, SeekRelative ); + + +bool +classtest_File() +{ + csv::File aFile( "bigfile.txt", csv::CFM_RW, 0 ); + csv::File & rFile = aFile; + + rFile.Open(); + + bool ret = ftest_Read( rFile ); + ret = ftest_Write( rFile ) AND ret; + ret = ftest_SeekBack( rFile ) AND ret; + ret = ftest_SeekRelative( rFile ) AND ret; + + rFile.Close(); + + return ret; +} + + + +FUT_DECL( File, Read ) +{ + bool ret = true; + + rFile.SeekBack(0); + uintt nSourceSize = rFile.Position(); + rFile.Seek(0); + + char * pBuf = new char[nSourceSize+1]; + uintt nCount = rFile.Read(pBuf,nSourceSize); + + UT_CHECK( Read, nCount == nSourceSize ); + + return ret; +} + +FUT_DECL( File, Write ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( File, Seek ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( File, SeekBack ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( File, SeekRelative ) +{ + bool ret = true; + + + + return ret; +} + + + diff --git a/cosv/source/unittest/makefile.mk b/cosv/source/unittest/makefile.mk new file mode 100644 index 000000000000..8fc5ef4905b6 --- /dev/null +++ b/cosv/source/unittest/makefile.mk @@ -0,0 +1,109 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: np $ $Date: 2002-03-08 14:25:40 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=cosv +TARGET=cosv_unittest +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : static.mk + +.INCLUDE : $(PRJ)$/source$/fullcpp.mk + + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/file_ut.obj \ + $(OBJ)$/simplestring_ut.obj + + + + +APP1TARGET= $(TARGET) +APP1STACK= 1000000 +APP1OBJS= $(OBJ)$/ut_main.obj + +APP1STDLIBS= $(STATIC_LIBS) msvcirt.lib + + +APP1LIBS= $(LB)$/$(TARGET).lib $(LB)$/cosv.lib + + +APP1DEPN= $(LB)$/$(TARGET).lib $(LB)$/cosv.lib + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/cosv/source/unittest/string_ut.cxx b/cosv/source/unittest/string_ut.cxx new file mode 100644 index 000000000000..c660d1739096 --- /dev/null +++ b/cosv/source/unittest/string_ut.cxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * $RCSfile: string_ut.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <precomp.h> +#include <cosv/string.hxx> + +// NOT FULLY DECLARED SERVICES +#include <ut.hxx> + +using csv::SimpleString; + + +/** @file + UnitTests for class String. +*/ + +inline bool +check_value( const String & a, const char * b ) +{ + return strcmp( a.c_str(), b ) == 0; +} + + +bool +classtest_String( csv::SimpleString & rSimpleString ) +{ + bool ret = true; + + String x1; + UT_CHECK( String(), check_value(x1,"") ) + + const char * s2a = ""; + String x2a(s2a); + UT_CHECK( String(const char*), check_value(x2a,s2a) ) + + const char * s2b = "_zluoadninger prrg chii(/%$##@\\\"'''fh kl"; + String x2b(s2b); + UT_CHECK( String(const char*), check_value(x2b,s2b) ) + + + bool ret = ftest_Read( rSimpleString ); + ret = ftest_Write( rSimpleString ) AND ret; + ret = ftest_SeekBack( rSimpleString ) AND ret; + ret = ftest_SeekRelative( rSimpleString ) AND ret; + + rSimpleString.Close(); + + return ret; +} + + + + +#if 0 +FUT_DECL( SimpleString, Ctor_Def ); +FUT_DECL( SimpleString, Seek ); +FUT_DECL( SimpleString, SeekBack ); +FUT_DECL( SimpleString, SeekRelative ); + + + +FUT_DECL( SimpleString, Read ) +{ + bool ret = true; + + rSimpleString.SeekBack(0); + uintt nSourceSize = rSimpleString.Position(); + rSimpleString.Seek(0); + + char * pBuf = new char[nSourceSize+1]; + uintt nCount = rSimpleString.Read(pBuf,nSourceSize); + + UT_CHECK( Read, nCount == nSourceSize ); + + return ret; +} + +FUT_DECL( SimpleString, Write ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( SimpleString, Seek ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( SimpleString, SeekBack ) +{ + bool ret = true; + + + + return ret; +} + +FUT_DECL( SimpleString, SeekRelative ) +{ + bool ret = true; + + + + return ret; +} + +#endif + + diff --git a/cosv/source/unittest/ut.hxx b/cosv/source/unittest/ut.hxx new file mode 100644 index 000000000000..7695ea73b10c --- /dev/null +++ b/cosv/source/unittest/ut.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * $RCSfile: ut.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COSV_UNITTEST_UT_HXX +#define COSV_UNITTEST_UT_HXX + + +#define UT_CHECK( fname, cond ) \ + if ( NOT (cond) ) { std::cerr << "ftest_" << #fname << " " << #cond << endl; \ + ret = false; } + +#define CUT_DECL( nsp, cname ) \ + bool classtest_##cname() +#define FUT_DECL( cname, fname ) \ + bool ftest_##fname( cname & r##cname ) + +#define UT_RESULT( result ) \ + if (result ) std::cout << "All unit tests passed successfully." << std::endl; \ + else std::cout << "Errors in unit tests.\n" << std::endl + + + +CUT_DECL( csv, File ); +CUT_DECL( csv, String ); + +#endif + + + diff --git a/cosv/source/unittest/ut_main.cxx b/cosv/source/unittest/ut_main.cxx new file mode 100644 index 000000000000..230307bf287d --- /dev/null +++ b/cosv/source/unittest/ut_main.cxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * $RCSfile: ut_main.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:25:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <precomp.h> + +#include <cosv/file.hxx> +#include <cosv/simplestring.hxx> +#include "ut.hxx" + + + +int _cdecl +main(int argc, char * argv[]) +{ + bool ret = classtest_File(); + ret = classtest_SimpleString AND ret; + + UT_RESULT( ret ); + + return 0; +} + + |