/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2006 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #include #include "test_tools.h" #include class Test { int &_counter; public: Test(int &co) : _counter(co) { std::cerr << "Init\n"; _counter++; } ~Test() { std::cerr << "Destroy\n"; _counter--; } int &counter() { return _counter; } }; int main() { int c=0; { RefPtr a = new Test(c); check(a->counter() == 1, "Wrong number of initialization"); { RefPtr b = a; check((*b).counter() == 1, "Wrong number of initialization"); b=a; a=b; check((*a).counter() == 1, "Wrong number of initialization"); } check(a->counter() == 1, "Wrong number of initialization"); } check(c == 0, "Wrong number of initialization"); return 0; }