OpenCoverage

qcommandlineoption.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qcommandlineoption.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5class QCommandLineOptionPrivate : public QSharedData-
6{-
7public:-
8 __attribute__((noinline))-
9 explicit QCommandLineOptionPrivate(const QString &name)-
10 : names(removeInvalidNames(QStringList(name))),-
11 hidden(false)-
12 { }
executed 167 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
167
13-
14 __attribute__((noinline))-
15 explicit QCommandLineOptionPrivate(const QStringList &names)-
16 : names(removeInvalidNames(names)),-
17 hidden(false)-
18 { }
executed 1110 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1110
19-
20 static QStringList removeInvalidNames(QStringList nameList);-
21-
22-
23 QStringList names;-
24-
25-
26-
27 QString valueName;-
28-
29-
30 QString description;-
31-
32-
33 QStringList defaultValues;-
34-
35-
36 bool hidden;-
37};-
38QCommandLineOption::QCommandLineOption(const QString &name)-
39 : d(new QCommandLineOptionPrivate(name))-
40{-
41}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QCommandLineParser
2
42QCommandLineOption::QCommandLineOption(const QStringList &names)-
43 : d(new QCommandLineOptionPrivate(names))-
44{-
45}
never executed: end of block
0
46QCommandLineOption::QCommandLineOption(const QString &name, const QString &description,-
47 const QString &valueName,-
48 const QString &defaultValue)-
49 : d(new QCommandLineOptionPrivate(name))-
50{-
51 setValueName(valueName);-
52 setDescription(description);-
53 setDefaultValue(defaultValue);-
54}
executed 165 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
165
55QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description,-
56 const QString &valueName,-
57 const QString &defaultValue)-
58 : d(new QCommandLineOptionPrivate(names))-
59{-
60 setValueName(valueName);-
61 setDescription(description);-
62 setDefaultValue(defaultValue);-
63}
executed 1110 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1110
64-
65-
66-
67-
68-
69-
70-
71QCommandLineOption::QCommandLineOption(const QCommandLineOption &other)-
72 : d(other.d)-
73{-
74}
executed 1278 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1278
75-
76-
77-
78-
79QCommandLineOption::~QCommandLineOption()-
80{-
81}-
82-
83-
84-
85-
86-
87QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other)-
88{-
89 d = other.d;-
90 return
never executed: return *this;
*this;
never executed: return *this;
0
91}-
92QStringList QCommandLineOption::names() const-
93{-
94 return
executed 2763 times by 2 tests: return d->names;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
d->names;
executed 2763 times by 2 tests: return d->names;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
2763
95}-
96-
97namespace {-
98 struct IsInvalidName-
99 {-
100 typedef bool result_type;-
101 typedef QString argument_type;-
102-
103 __attribute__((noinline))-
104 result_type operator()(const QString &name) const noexcept-
105 {-
106 if (__builtin_expect(!!(name.isEmpty()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEevaluated 2387 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
)
0-2387
107 return
never executed: return warn("be empty");
warn("be empty");
never executed: return warn("be empty");
0
108-
109 const QChar c = name.at(0);-
110 if (__builtin_expect(!!(c == QLatin1Char('-')), false)
__builtin_expe...('-')), false)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QCommandLineParser
FALSEevaluated 2386 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
)
1-2386
111 return
executed 1 time by 1 test: return warn("start with a '-'");
Executed by:
  • tst_QCommandLineParser
warn("start with a '-'");
executed 1 time by 1 test: return warn("start with a '-'");
Executed by:
  • tst_QCommandLineParser
1
112 if (__builtin_expect(!!(c == QLatin1Char('/')), false)
__builtin_expe...('/')), false)Description
TRUEnever evaluated
FALSEevaluated 2386 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
)
0-2386
113 return
never executed: return warn("start with a '/'");
warn("start with a '/'");
never executed: return warn("start with a '/'");
0
114 if (__builtin_expect(!!(name.contains(QLatin1Char('='))), false)
__builtin_expe...'='))), false)Description
TRUEnever evaluated
FALSEevaluated 2386 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
)
0-2386
115 return
never executed: return warn("contain a '='");
warn("contain a '='");
never executed: return warn("contain a '='");
0
116-
117 return
executed 2386 times by 2 tests: return false;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
false;
executed 2386 times by 2 tests: return false;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
2386
118 }-
119-
120 __attribute__((noinline))-
121 static bool warn(const char *what) noexcept-
122 {-
123 QMessageLogger(__FILE__, 279, __PRETTY_FUNCTION__).warning("QCommandLineOption: Option names cannot %s", what);-
124 return
executed 1 time by 1 test: return true;
Executed by:
  • tst_QCommandLineParser
true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_QCommandLineParser
1
125 }-
126 };-
127}-
128-
129-
130QStringList QCommandLineOptionPrivate::removeInvalidNames(QStringList nameList)-
131{-
132 if (__builtin_expect(!!(nameList.isEmpty()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEevaluated 1277 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
)
0-1277
133 QMessageLogger(__FILE__, 289, __PRETTY_FUNCTION__).warning("QCommandLineOption: Options must have at least one name");
never executed: QMessageLogger(__FILE__, 289, __PRETTY_FUNCTION__).warning("QCommandLineOption: Options must have at least one name");
0
134 else-
135 nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()),
executed 1277 times by 2 tests: nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end());
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1277
136 nameList.end());
executed 1277 times by 2 tests: nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end());
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1277
137 return
executed 1277 times by 2 tests: return nameList;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
nameList;
executed 1277 times by 2 tests: return nameList;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1277
138}-
139void QCommandLineOption::setValueName(const QString &valueName)-
140{-
141 d->valueName = valueName;-
142}
executed 1277 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1277
143QString QCommandLineOption::valueName() const-
144{-
145 return
executed 541 times by 2 tests: return d->valueName;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
d->valueName;
executed 541 times by 2 tests: return d->valueName;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
541
146}-
147void QCommandLineOption::setDescription(const QString &description)-
148{-
149 d->description = description;-
150}
executed 1275 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1275
151-
152-
153-
154-
155-
156-
157QString QCommandLineOption::description() const-
158{-
159 return
executed 1 time by 1 test: return d->description;
Executed by:
  • tst_QCommandLineParser
d->description;
executed 1 time by 1 test: return d->description;
Executed by:
  • tst_QCommandLineParser
1
160}-
161void QCommandLineOption::setDefaultValue(const QString &defaultValue)-
162{-
163 QStringList newDefaultValues;-
164 if (!defaultValue.isEmpty()
!defaultValue.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QCommandLineParser
FALSEevaluated 1275 times by 2 tests
Evaluated by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
) {
2-1275
165 newDefaultValues.reserve(1);-
166 newDefaultValues << defaultValue;-
167 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QCommandLineParser
2
168-
169 d->defaultValues.swap(newDefaultValues);-
170}
executed 1277 times by 2 tests: end of block
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
1277
171void QCommandLineOption::setDefaultValues(const QStringList &defaultValues)-
172{-
173 d->defaultValues = defaultValues;-
174}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QCommandLineParser
4
175-
176-
177-
178-
179-
180-
181QStringList QCommandLineOption::defaultValues() const-
182{-
183 return
executed 513 times by 2 tests: return d->defaultValues;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
d->defaultValues;
executed 513 times by 2 tests: return d->defaultValues;
Executed by:
  • tst_QCommandLineParser
  • tst_qdbusxml2cpp - unknown status
513
184}-
185void QCommandLineOption::setHidden(bool hide)-
186{-
187 d->hidden = hide;-
188}
never executed: end of block
0
189bool QCommandLineOption::isHidden() const-
190{-
191 return
executed 2 times by 1 test: return d->hidden;
Executed by:
  • tst_QCommandLineParser
d->hidden;
executed 2 times by 1 test: return d->hidden;
Executed by:
  • tst_QCommandLineParser
2
192}-
193-
194-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9