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