1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/counter_test.cc Mon Dec 05 17:03:31 2005 +0000
1.3 @@ -0,0 +1,64 @@
1.4 +/* -*- C++ -*-
1.5 + * test/counter_test.cc - Part of LEMON, a generic C++ optimization library
1.6 + *
1.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.9 + *
1.10 + * Permission to use, modify and distribute this software is granted
1.11 + * provided that this copyright notice appears in all copies. For
1.12 + * precise terms see the accompanying LICENSE file.
1.13 + *
1.14 + * This software is provided "AS IS" with no warranty of any kind,
1.15 + * express or implied, and with no claim as to its suitability for any
1.16 + * purpose.
1.17 + *
1.18 + */
1.19 +
1.20 +#include <lemon/counter.h>
1.21 +
1.22 +///\file \brief Test cases for time_measure.h
1.23 +///
1.24 +///\todo To be extended
1.25 +
1.26 +
1.27 +int fibonacci(int f)
1.28 +{
1.29 + static lemon::Counter count("Fibonacci steps: ");
1.30 + count++;
1.31 + if(f<1) return 0;
1.32 + else if(f==1) return 1;
1.33 + else return fibonacci(f-1)+fibonacci(f-2);
1.34 +}
1.35 +
1.36 +int main()
1.37 +{
1.38 + fibonacci(10);
1.39 +
1.40 + {
1.41 + typedef lemon::Counter MyCounter;
1.42 + MyCounter c("Main counter: ");
1.43 + c++;
1.44 + c++;
1.45 + MyCounter::SubCounter d(c,"Subcounter: ");
1.46 + d++;
1.47 + d++;
1.48 + MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
1.49 + e++;
1.50 + e++;
1.51 + }
1.52 +
1.53 + {
1.54 + typedef lemon::NoCounter MyCounter;
1.55 + MyCounter c("Main counter: ");
1.56 + c++;
1.57 + c++;
1.58 + MyCounter::SubCounter d(c,"Subcounter: ");
1.59 + d++;
1.60 + d++;
1.61 + MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
1.62 + e++;
1.63 + e++;
1.64 + }
1.65 +
1.66 + return 0;
1.67 +}