From: guido Date: Fri, 5 Feb 1999 19:57:40 +0000 (+0000) Subject: more tests for Smartpointer X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9a68dff1a3c4ad3b41c259167539214ec341f3d;p=dealii-svn.git more tests for Smartpointer git-svn-id: https://svn.dealii.org/trunk@766 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/.cvsignore b/tests/base/.cvsignore new file mode 100644 index 0000000000..edba865efd --- /dev/null +++ b/tests/base/.cvsignore @@ -0,0 +1 @@ +*.go reference logtest tensor diff --git a/tests/base/Makefile b/tests/base/Makefile index 2bc758d93e..a3aad1aeae 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -5,14 +5,7 @@ D=../.. -CXX = c++ -INCLUDE = -I$D/deal.II/include -I$D/lac/include \ - -I$D/base/include - -CXXFLAGS = -DDEBUG -g -Wall -W -pedantic -Wconversion \ - -Winline -Woverloaded-virtual \ - $(INCLUDE) -Ddeal_II_dimension=$(deal_II_dimension) - +include $D/deal.II/Make.global_options %.go : %.cc @echo ============================ Compiling with debugging information: $< @@ -26,11 +19,6 @@ vpath %.a: $D/base/lib vpath %.a: $D/lac/lib vpath %.a: $D/deal.II/lib -ifeq ($(shell uname),Linux) -CXX = /home/wolf/bin/gcc/bin/c++ -endif - - test: run-reference run-logtest run-tensor @@ -38,19 +26,19 @@ reference: reference.go $(CXX) $(CXXFLAGS) -o $@ $^ $D/base/lib/libbase.g.a run-reference: reference - ./reference + -./reference logtest: logtest.go $(CXX) $(CXXFLAGS) -o $@ $^ $D/base/lib/libbase.g.a run-logtest: logtest - ./logtest + -./logtest tensor: tensor.go $(CXX) $(CXXFLAGS) -o $@ $^ $D/base/lib/libbase.g.a run-tensor: tensor - ./tensor + -./tensor clean: diff --git a/tests/base/reference.cc b/tests/base/reference.cc index e98fda917c..1ba549345e 100644 --- a/tests/base/reference.cc +++ b/tests/base/reference.cc @@ -6,7 +6,17 @@ class Test : public Subscriptor { + const char* name; public: + Test(const char* n) : + name(n) + { + cout << "Construct " << name << endl; + } + ~Test() + { + cout << "Destruct " << name << endl; + } void f() { cout << "mutable" << endl; @@ -21,20 +31,37 @@ public: main() { - Test a; - const Test b; + Test a("A"); + const Test b("B"); SmartPointer r=&a; SmartPointer s=&a; // SmartPointer t=&b; // this one should not work SmartPointer t=const_cast(&b); SmartPointer u=&b; + + cout << "a "; a.f(); // should print "mutable", since #a# is not const + cout << "b "; b.f(); // should print "const", since #b# is const + cout << "r "; r->f(); // should print "mutable", since it points to the non-const #a# - s->f(); // should print "const", since it points to the non-const #a# + cout << "s "; + s->f(); // should print "const", since it points to the const #b# // but we made it const + cout << "t "; t->f(); // should print "mutable", since #b# is const, but // we casted the constness away + cout << "u "; u->f(); // should print "const" since #b# is const + // Now try if subscriptor works + { + Test c("C"); + r = &c; + Test d("D"); + r = &d; + } } + +void abort() +{}