From 1669228c5d67169717932a10d671cc079c9bfd28 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@dune-project.org>
Date: Mon, 7 Dec 2009 10:19:47 +0000
Subject: [PATCH] test default constructor, cast to bool, and some reset
 methods

[[Imported from SVN: r5747]]
---
 dune/common/test/smartpointertest.cc | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dune/common/test/smartpointertest.cc b/dune/common/test/smartpointertest.cc
index 4541af670..66c091f59 100644
--- a/dune/common/test/smartpointertest.cc
+++ b/dune/common/test/smartpointertest.cc
@@ -6,6 +6,8 @@
 #endif
 
 #include <dune/common/shared_ptr.hh>
+
+#include <cassert>
 #include <iostream>
 #include <vector>
 #include <cstdlib>
@@ -14,11 +16,35 @@ int main(){
   using namespace Dune;
   int ret=0;
   {
+    // test default constructor
+    shared_ptr<int> foo;
+
+    // test cast-to-bool
+    if (foo) {
+      std::cout << "Default constructor doesn't create a NULL pointer!" << std::endl;
+      ret=1;
+    }
+
+    // test constructor from a given pointer
+    shared_ptr<double> bar(new double(43.0));
+    assert(bar);
+
+    // test reset()
+    bar.reset();
+    assert(!bar);
+
+    // test reset(T*)
+    bar.reset(new double(44.0));
+    assert(bar);
+    assert(bar.use_count()==1);
+
+    // test constructor from a given pointer
     shared_ptr<double> b(new double(42.0));
     {
       shared_ptr<double> d(b);
       *b = 7;
     }
+
     if(b.use_count()!=1) {
       std::cout << "Reference count is wrong! "<<__LINE__<<":"<<
       __FILE__<<std::endl;
-- 
GitLab