2
* Compiz configuration system library
4
* Copyright (C) 2012 Canonical Ltd.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
* Sam Spilsbury <sam.spilsbury@canonical.com>
23
#ifndef _COMPIZCONFIG_CCS_ITEM_IN_LIST_MATCHER_H
24
#define _COMPIZCONFIG_CCS_ITEM_IN_LIST_MATCHER_H
26
using ::testing::Matcher;
27
using ::testing::MatcherInterface;
28
using ::testing::MatchResultListener;
29
using ::testing::MakeMatcher;
31
template <typename I, typename L>
32
class ItemInCCSListMatcher :
33
public ::testing::MatcherInterface <L>
37
ItemInCCSListMatcher (const Matcher<I> &matcher) :
42
virtual bool MatchAndExplain (L list, MatchResultListener *listener) const
48
const I &i = *(reinterpret_cast <I *> (iter->data));
50
if (mMatcher.MatchAndExplain (i, listener))
59
virtual void DescribeTo (std::ostream *os) const
61
*os << "found in list (";
62
mMatcher.DescribeTo (os);
66
virtual void DescribeNegationTo (std::ostream *os) const
68
*os << "not found in list (";
69
mMatcher.DescribeNegationTo (os);
78
template <typename I, typename L>
79
Matcher<L> IsItemInCCSList (const Matcher<I> &matcher)
81
return MakeMatcher (new ItemInCCSListMatcher <I, L> (matcher));
84
typedef struct _CCSString CCSString;
85
typedef struct _CCSStringList * CCSStringList;
86
typedef struct _CCSSettingValue CCSSettingValue;
87
typedef struct _CCSSettingValueList * CCSSettingValueList;
89
/* A workaround for templates inside of macros not
90
* expanding correctly */
93
Matcher <CCSStringList>
94
IsStringItemInStringCCSList (const Matcher <CCSString> &matcher)
96
return IsItemInCCSList <CCSString, CCSStringList> (matcher);
99
Matcher <CCSSettingValueList>
100
IsSettingValueInSettingValueCCSList (const Matcher <CCSSettingValue> &matcher)
102
return IsItemInCCSList <CCSSettingValue, CCSSettingValueList> (matcher);