test/refptr_test.cc
author kpeter
Thu, 13 Nov 2008 16:17:50 +0000
changeset 2630 d239741cfd44
parent 2391 14a343be7a5a
permissions -rw-r--r--
Various improvements in NetworkSimplex.

- Faster variant of "Altering Candidate List" pivot rule using make_heap
instead of partial_sort.
- Doc improvements.
- Removing unecessary inline keywords.
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2008
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #include<lemon/refptr.h>
    20 #include "test_tools.h"
    21 #include <iostream>
    22 
    23 class Test 
    24 {
    25   int &_counter;
    26 public:
    27   Test(int &co) : _counter(co)
    28   {
    29     std::cerr << "Init\n";
    30     _counter++;
    31   }
    32   ~Test()
    33   {
    34     std::cerr << "Destroy\n";
    35     _counter--;
    36   }
    37   int &counter() { return _counter; }
    38   
    39 };
    40 
    41 int main()
    42 {
    43   int c=0;
    44   
    45   {
    46     RefPtr<Test> a = new Test(c);
    47     check(a->counter() == 1, "Wrong number of initialization");
    48     {
    49       RefPtr<Test> b = a;
    50       check((*b).counter() == 1, "Wrong number of initialization");
    51       b=a;
    52       a=b;
    53       check((*a).counter() == 1, "Wrong number of initialization");
    54     }
    55     check(a->counter() == 1, "Wrong number of initialization");
    56   }
    57   check(c == 0, "Wrong number of initialization");
    58 
    59   return 0;
    60 }
    61