1 /*
2 -------------------------------------------------------------------------
3  CxxTest: A lightweight C++ unit testing library.
4  Copyright (c) 2008 Sandia Corporation.
5  This software is distributed under the LGPL License v3
6  For more information, see the COPYING file in the top CxxTest directory.
7  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8  the U.S. Government retains certain rights in this software.
9 -------------------------------------------------------------------------
10 */
11 
12 #ifndef __cxxtest__StdTestSuite_h__
13 #define __cxxtest__StdTestSuite_h__
14 
15 //
16 // This provides explicit partial specializations for STL-based
17 // TestSuite comparison functions
18 //
19 
20 namespace CxxTest
21 {
22 
23 #ifdef _CXXTEST_PARTIAL_TEMPLATE_SPECIALIZATION
24 
25 template<class X, class Y, class D>
26 struct delta<std::vector<X>, std::vector<Y>, D>
27 {
28     static bool test(std::vector<X> x, std::vector<Y> y, D d)
29     {
30         if (x.size() != y.size())
31         {
32             return false;
33         }
34         for (size_t i = 0; i < x.size(); ++i)
35             if (! delta<X, Y, D>::test(x[i], y[i], d))
36             {
37                 return false;
38             }
39         return true;
40     }
41 };
42 
43 template<class X, class Y, class D>
44 struct delta<std::list<X>, std::list<Y>, D>
45 {
46     static bool test(std::list<X> x, std::list<Y> y, D d)
47     {
48         typename std::list<X>::const_iterator x_it = x.begin();
49         typename std::list<Y>::const_iterator y_it = y.begin();
50         for (; x_it != x.end(); ++x_it, ++y_it)
51         {
52             if (y_it == y.end())
53             {
54                 return false;
55             }
56             if (! delta<X, Y, D>::test(*x_it, *y_it, d))
57             {
58                 return false;
59             }
60         }
61         return y_it == y.end();
62     }
63 };
64 
65 #endif
66 
67 } // namespace CxxTest
68 
69 #endif // __cxxtest__StdTestSuite_h__
70 
71