• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cpputest / cpputest / 15141709115

20 May 2025 03:31PM UTC coverage: 99.281%. Remained the same
15141709115

push

github

web-flow
Merge pull request #1859 from mtfurlan/ci/run-docker

ci: actually run docker builds

6765 of 6814 relevant lines covered (99.28%)

46692.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.73
/src/CppUTest/TestFilter.cpp
1
/*
2
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *     * Redistributions of source code must retain the above copyright
8
 *       notice, this list of conditions and the following disclaimer.
9
 *     * Redistributions in binary form must reproduce the above copyright
10
 *       notice, this list of conditions and the following disclaimer in the
11
 *       documentation and/or other materials provided with the distribution.
12
 *     * Neither the name of the <organization> nor the
13
 *       names of its contributors may be used to endorse or promote products
14
 *       derived from this software without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
17
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

28
#include "CppUTest/CppUTestConfig.h"
29
#include "CppUTest/TestFilter.h"
30

31
TestFilter::TestFilter() : strictMatching_(false), invertMatching_(false), next_(NULLPTR)
3✔
32
{
33
}
3✔
34

35
TestFilter::TestFilter(const SimpleString& filter) : strictMatching_(false), invertMatching_(false), next_(NULLPTR)
119✔
36
{
37
    filter_ = filter;
119✔
38
}
119✔
39

40
TestFilter::TestFilter(const char* filter) : strictMatching_(false), invertMatching_(false), next_(NULLPTR)
54✔
41
{
42
    filter_ = filter;
54✔
43
}
54✔
44

45
TestFilter* TestFilter::add(TestFilter* filter)
120✔
46
{
47
    next_ = filter;
120✔
48
    return this;
120✔
49
}
50

51
TestFilter* TestFilter::getNext() const
58,225✔
52
{
53
    return next_;
58,225✔
54
}
55

56
void TestFilter::strictMatching()
127✔
57
{
58
    strictMatching_ = true;
127✔
59
}
127✔
60

61
void TestFilter::invertMatching()
31✔
62
{
63
    invertMatching_ = true;
31✔
64
}
31✔
65

66
bool TestFilter::match(const SimpleString& name) const
59,532✔
67
{
68
    bool matches = false;
59,532✔
69

70
    if(strictMatching_)
59,532✔
71
        matches = name == filter_;
59,511✔
72
    else
73
        matches = name.contains(filter_);
21✔
74

75
    return invertMatching_ ? !matches : matches;
119,057✔
76
}
59,525✔
77

78
bool TestFilter::operator==(const TestFilter& filter) const
37✔
79
{
80
    return (filter_ == filter.filter_ &&
37✔
81
            strictMatching_ == filter.strictMatching_ &&
71✔
82
            invertMatching_ == filter.invertMatching_);
71✔
83
}
84

85
bool TestFilter::operator!=(const TestFilter& filter) const
33✔
86
{
87
    return !(filter == *this);
33✔
88
}
89

90
SimpleString TestFilter::asString() const
6✔
91
{
92
    SimpleString textFilter =  StringFromFormat("TestFilter: \"%s\"", filter_.asCharString());
6✔
93
    if (strictMatching_ && invertMatching_)
6✔
94
        textFilter += " with strict, invert matching";
1✔
95
    else if (strictMatching_)
5✔
96
        textFilter += " with strict matching";
1✔
97
    else if (invertMatching_)
4✔
98
        textFilter += " with invert matching";
1✔
99

100
    return textFilter;
6✔
101
}
×
102

103
SimpleString StringFrom(const TestFilter& filter)
6✔
104
{
105
    return filter.asString();
6✔
106
}
107

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc