Skip to content
Snippets Groups Projects
Commit 2b0431e7 authored by Thimo Neubauer's avatar Thimo Neubauer
Browse files

added small test-environments to common/ and lib/

[[Imported from SVN: r996]]
parent af80c6e5
No related branches found
No related tags found
No related merge requests found
# $Id$
SUBDIRS = . test
# the standard debug streams are put into the libdune
noinst_LTLIBRARIES = libcommon.la
......
Makefile
Makefile.in
.deps
.libs
semantic.cache
parsetest
test-stack
\ No newline at end of file
# $Id$
TESTPROGS = parsetest test-stack
# which tests to run
TESTS = $(TESTPROGS)
# programs just to build when "make check" is used
check_PROGRAMS = $(TESTPROGS)
# define the programs
parsetest_SOURCES = parsetest.cc
test_stack_SOURCES = test-stack.cc
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id$
/* test if the common headers can be parsed without errors */
#include <dune/common/array.hh>
#include <dune/common/debugstream.hh>
#include <dune/common/dlist.hh>
#include <dune/common/dynamictype.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/fixedarray.hh>
#include <dune/common/function.hh>
#include <dune/common/functionspace.hh>
#include <dune/common/fvector.hh>
#include <dune/common/mapping.hh>
#include <dune/common/matrix.hh>
#include <dune/common/matvec.hh>
#include <dune/common/misc.hh>
#include <dune/common/operator.hh>
#include <dune/common/simplevector.hh>
#include <dune/common/stack.hh>
#include <dune/common/stdstreams.hh>
#include <dune/common/timer.hh>
#include <dune/common/vectorspace.hh>
int main () {};
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id$
#include <cassert>
#include <dune/common/stack.hh>
// stack depth to test
static const int MAX = 100;
template <class SType>
void exercise_stack (SType &S) {
assert(S.empty());
// fill stack to maximum
for (int i = 0; i < MAX; ++i) {
assert(! S.full());
S.push(i);
assert(! S.empty());
};
for (int i = MAX - 1; i >= 0; --i) {
int x = S.top();
int y = S.pop();
assert(x == i);
assert(y == i);
};
assert(S.empty());
}
int main () {
// initialize both kinds of stack, push stuff and check if it comes out again
Dune::Stack<int> stack;
exercise_stack(stack);
Dune::FiniteStack<int, MAX> fixedstack;
exercise_stack(fixedstack);
// check error handling of Stack
try {
Dune::Stack<int> stack1;
assert(stack1.empty());
stack1.pop();
// exception has to happen
return 1;
} catch (Dune::RangeError &e) {
// exception was correctly reported
return 0;
} catch (...) {
// wrong type of exception
return 1;
}
};
# $Id$
SUBDIRS = . test
# the main library
lib_LTLIBRARIES = libdune.la
......
Makefile
Makefile.in
.deps
.libs
semantic.cache
test-stream
\ No newline at end of file
# $Id$
TESTPROGS = test-stream
# which tests to run
TESTS = $(TESTPROGS)
# programs just to build when "make check" is used
check_PROGRAMS = $(TESTPROGS)
# we want to check the library, thus link to it :)
LDADD = ../libdune.la
# define the programs
test_stream_SOURCES = test-stream.cc
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id$
/*
Test to check if the standard streams in libdune can be properly
linked with this program and if they work
*/
#include <fstream>
#include <dune/common/stdstreams.hh>
int main () {
try {
// let output happen but vanish
std::ofstream dummy("/dev/null");
Dune::derr.attach(dummy);
Dune::derr.push(true);
Dune::derr << "Teststring" << std::endl;
// instantiate private stream and connect global stream
{
Dune::DebugStream<> mystream(dummy);
Dune::derr.tie(mystream);
Dune::derr << "Blah" << std::endl;
// untie before mystream gets destructed
Dune::derr.untie();
}
Dune::derr << "Still working" << std::endl;
} catch (Dune::Exception &e) {
std::cerr << e << std::endl;
return 2;
} catch (...) {
return 1;
};
return 0;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment