/******************************************** -*-c-*- ***********************************************/
/* */
/* testMain.c: */
/* */
/****************************************************************************************************/
/****************************************************************************************************/
/* */
/* Copyright (C) 2004 Joerg Kunze */
/* */
/* This file is part of siliconBrainLib. */
/* */
/* siliconBrainLib is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* siliconBrainLib 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 this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/****************************************************************************************************/
char *siliconBrainRelease = "$siliconBrainRelease: 0.0.4 $";
char *siliconBrainRcsIdentifier = "$Id: testMain.main.c,v 1.12 2004/12/14 23:09:01 joerg Exp $";
char *siliconBrainSaveStamp = "$siliconBrainSaveStamp: 2004/12/14 22:31:04, Joerg Kunze$";
/****************************************************************************************************/
/* */
/* include: */
/* */
/****************************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include "siliconBrainLib"
#define testAssert( expression ) \
if( !(expression) ) { \
fprintf( stderr, "%s: %s: %d: \"%s\" is not true\n", __FILE__, __FUNCTION__, __LINE__, #expression );\
exit( 42 );\
}
/****************************************************************************************************/
/* */
/* main: */
/* */
/****************************************************************************************************/
int main() {
int returnCode = 0;
puts( "testMain: starting all tests for siliconBrainLib ..." );
if( returnCode = system( "testXmlPrint" ) ) {
fprintf( stderr, "%s: %s: %d: Error %d in %s\n", __FILE__, __FUNCTION__, __LINE__, WEXITSTATUS( returnCode ), "testXmlPrint" );
exit( 42 );
}
testAssert( !stringToBool( 0 ) );
testAssert( stringToBool( "" ) );
testAssert( stringToBool( "true" ) );
testAssert( !stringToBool( "false" ) );
//------------------------------------------------------------------------------------------------
puts( "testing Memory interface ..." );
//------------------------------------------------------------------------------------------------
// or: do not use strings, which grow, but streams of small strings
Memory memory;
memoryInit( memory );
String string0 = c( "foo bar" );
String string1 = stringNull;
copy( memory, string1, string0 );
println( string0 );
println( string1 );
String string2 = c( "foo bar FOO BAR" );
copy( memory, string1, string2 ); // check for capacity !!!!!!!!!!!!!!!!!!!!!!!
testAssert( equal( string1, string2 ) );
String s3 = c( "High Ute, du Schnecke" );
testAssert( !equal( string1, s3 ) );
String s4 = stringNull;
copy_a( s4, s3 );
println( string1 );
memoryDestroy( memory );
String s5 = c( "High Ute, du Schnecke" );
testAssert( equal( s4, s5 ) );
println( s4 );
//------------------------------------------------------------------------------------------------
puts( "testing pipes ..." );
//------------------------------------------------------------------------------------------------
return 0;
}
/*
$Log: testMain.main.c,v $
Revision 1.12 2004/12/14 23:09:01 joerg
published for new release 0.0.4
Revision 1.11 2004/12/14 23:02:56 joerg
published for new release 0.0.3
Revision 1.10 2004/12/14 22:44:36 joerg
allFiles: all sources have a Log CVS keyword at the end now.
*/