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

GothenburgBitFactory / taskwarrior / 10152339701

29 Jul 2024 09:45PM UTC coverage: 84.437% (+0.07%) from 84.372%
10152339701

push

github

web-flow
Merge pull request #3566 from felixschurk/add-clang-format

Add clang-format to enforce style guide

12359 of 13760 new or added lines in 147 files covered. (89.82%)

123 existing lines in 42 files now uncovered.

19070 of 22585 relevant lines covered (84.44%)

19724.02 hits per line

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

81.72
/test/variant_exp.test.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2013 - 2021, Göteborg Bit Factory.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <Variant.h>
31
#include <test.h>
32

33
#include <iostream>
34

35
////////////////////////////////////////////////////////////////////////////////
36
int main(int, char**) {
1✔
37
  UnitTest t(38);
1✔
38

39
  Variant v0(true);
1✔
40
  Variant v1(42);
1✔
41
  Variant v2(3.14);
1✔
42
  Variant v3("foo");
1✔
43
  Variant v4(1234567890, Variant::type_date);
1✔
44
  Variant v5(1200, Variant::type_duration);
1✔
45

46
  // boolean ^ boolean  -> ERROR
47
  try {
48
    Variant v00 = v0 ^ v0;
1✔
NEW
49
    t.fail("true ^ true --> error");
×
50
  } catch (...) {
1✔
51
    t.pass("true ^ true --> error");
1✔
52
  }
1✔
53

54
  // boolean ^ integer  -> ERROR
55
  try {
56
    Variant v01 = v0 ^ v1;
1✔
NEW
57
    t.fail("true ^ 42 --> error");
×
58
  } catch (...) {
1✔
59
    t.pass("true ^ 42 --> error");
1✔
60
  }
1✔
61

62
  // boolean ^ real     -> ERROR
63
  try {
64
    Variant v02 = v0 ^ v2;
1✔
NEW
65
    t.fail("true ^ 3.14 --> error");
×
66
  } catch (...) {
1✔
67
    t.pass("true ^ 3.14 --> error");
1✔
68
  }
1✔
69

70
  // boolean ^ string   -> ERROR
71
  try {
72
    Variant v03 = v0 ^ v3;
1✔
NEW
73
    t.fail("true ^ foo --> error");
×
74
  } catch (...) {
1✔
75
    t.pass("true ^ foo --> error");
1✔
76
  }
1✔
77

78
  // boolean ^ date     -> ERROR
79
  try {
80
    Variant v04 = v0 ^ v4;
1✔
NEW
81
    t.fail("true ^ 1234567890 --> error");
×
82
  } catch (...) {
1✔
83
    t.pass("true ^ 1234567890 --> error");
1✔
84
  }
1✔
85

86
  // boolean ^ duration -> ERROR
87
  try {
88
    Variant v05 = v0 ^ v5;
1✔
NEW
89
    t.fail("true ^ 1200 --> error");
×
90
  } catch (...) {
1✔
91
    t.pass("true ^ 1200 --> error");
1✔
92
  }
1✔
93

94
  // integer ^ boolean  -> ERROR
95
  try {
96
    Variant v10 = v1 ^ v0;
1✔
NEW
97
    t.fail("42 ^ true --> error");
×
98
  } catch (...) {
1✔
99
    t.pass("42 ^ true --> error");
1✔
100
  }
1✔
101

102
  // integer ^ integer  -> integer
103
  Variant v11 = v1 ^ Variant(2);
1✔
104
  t.is(v11.type(), Variant::type_integer, "42 ^ 2 --> integer");
1✔
105
  t.is(v11.get_integer(), 1764, "42 ^ 2 --> 1764");
1✔
106

107
  // integer ^ real     -> real
108
  try {
109
    Variant v12 = v1 ^ v2;
1✔
NEW
110
    t.fail("42 ^ 3.14 --> error");
×
111
  } catch (...) {
1✔
112
    t.pass("42 ^ 3.14 --> error");
1✔
113
  }
1✔
114

115
  // integer ^ string   -> ERROR
116
  try {
117
    Variant v13 = v1 ^ v3;
1✔
NEW
118
    t.fail("42 ^ foo --> error");
×
119
  } catch (...) {
1✔
120
    t.pass("42 ^ foo --> error");
1✔
121
  }
1✔
122

123
  // integer ^ date     -> ERROR
124
  try {
125
    Variant v14 = v1 ^ v4;
1✔
NEW
126
    t.fail("42 ^ 1234567890 --> error");
×
127
  } catch (...) {
1✔
128
    t.pass("42 ^ 1234567890 --> error");
1✔
129
  }
1✔
130

131
  // integer ^ duration -> ERROR
132
  try {
133
    Variant v15 = v1 ^ v5;
1✔
NEW
134
    t.fail("42 ^ 1200 --> error");
×
135
  } catch (...) {
1✔
136
    t.pass("42 ^ 1200 --> error");
1✔
137
  }
1✔
138

139
  // real ^ boolean  -> ERROR
140
  try {
141
    Variant v20 = v2 ^ v0;
1✔
NEW
142
    t.fail("3.14 ^ true --> error");
×
143
  } catch (...) {
1✔
144
    t.pass("3.14 ^ true --> error");
1✔
145
  }
1✔
146

147
  // real ^ integer  -> real
148
  Variant v21 = v2 ^ Variant(2);
1✔
149
  t.is(v21.type(), Variant::type_real, "3.14 ^ 2 --> real");
1✔
150
  t.is(v21.get_real(), 9.8596, 0.001, "3.14 ^ 2 --> 9.8596");
1✔
151

152
  // real ^ real     -> ERROR
153
  try {
154
    Variant v22 = v2 ^ v2;
1✔
NEW
155
    t.fail("3.14 ^ 3.14 --> error");
×
156
  } catch (...) {
1✔
157
    t.pass("3.14 ^ 3.14 --> error");
1✔
158
  }
1✔
159

160
  // real ^ string   -> ERROR
161
  try {
162
    Variant v23 = v2 ^ v3;
1✔
NEW
163
    t.fail("3.14 ^ foo --> error");
×
164
  } catch (...) {
1✔
165
    t.pass("3.14 ^ foo --> error");
1✔
166
  }
1✔
167

168
  // real ^ date     -> ERROR
169
  try {
170
    Variant v24 = v2 ^ v4;
1✔
NEW
171
    t.fail("3.14 ^ 1234567890 --> error");
×
172
  } catch (...) {
1✔
173
    t.pass("3.14 ^ 1234567890 --> error");
1✔
174
  }
1✔
175

176
  // real ^ duration -> ERROR
177
  try {
178
    Variant v25 = v2 ^ v5;
1✔
NEW
179
    t.fail("3.14 ^ 1200 --> error");
×
180
  } catch (...) {
1✔
181
    t.pass("3.14 ^ 1200 --> error");
1✔
182
  }
1✔
183

184
  // string ^ boolean  -> ERROR
185
  try {
186
    Variant v30 = v3 ^ v0;
1✔
NEW
187
    t.fail("foo ^ true --> error");
×
188
  } catch (...) {
1✔
189
    t.pass("foo ^ true --> error");
1✔
190
  }
1✔
191

192
  // string ^ integer  -> ERROR
193
  try {
194
    Variant v31 = v3 ^ v1;
1✔
NEW
195
    t.fail("foo ^ 42 --> error");
×
196
  } catch (...) {
1✔
197
    t.pass("foo ^ 42 --> error");
1✔
198
  }
1✔
199

200
  // string ^ real     -> ERROR
201
  try {
202
    Variant v32 = v3 ^ v2;
1✔
NEW
203
    t.fail("foo ^ 3.14 --> error");
×
204
  } catch (...) {
1✔
205
    t.pass("foo ^ 3.14 --> error");
1✔
206
  }
1✔
207

208
  // string ^ string   -> ERROR
209
  try {
210
    Variant v33 = v3 ^ v3;
1✔
NEW
211
    t.fail("foo ^ foo --> error");
×
212
  } catch (...) {
1✔
213
    t.pass("foo ^ foo --> error");
1✔
214
  }
1✔
215

216
  // string ^ date     -> ERROR
217
  try {
218
    Variant v34 = v3 ^ v4;
1✔
NEW
219
    t.fail("foo ^ 1234567890 --> error");
×
220
  } catch (...) {
1✔
221
    t.pass("foo ^ 1234567890 --> error");
1✔
222
  }
1✔
223

224
  // string ^ duration -> ERROR
225
  try {
226
    Variant v35 = v3 ^ v5;
1✔
NEW
227
    t.fail("foo ^ 1200 --> error");
×
228
  } catch (...) {
1✔
229
    t.pass("foo ^ 1200 --> error");
1✔
230
  }
1✔
231

232
  // date ^ boolean  -> ERROR
233
  try {
234
    Variant v40 = v4 ^ v0;
1✔
NEW
235
    t.fail("1234567890 ^ true --> error");
×
236
  } catch (...) {
1✔
237
    t.pass("1234567890 ^ true --> error");
1✔
238
  }
1✔
239

240
  // date ^ integer  -> ERROR
241
  try {
242
    Variant v41 = v4 ^ v1;
1✔
NEW
243
    t.fail("1234567890 ^ 42 --> error");
×
244
  } catch (...) {
1✔
245
    t.pass("1234567890 ^ 42 --> error");
1✔
246
  }
1✔
247

248
  // date ^ real     -> ERROR
249
  try {
250
    Variant v42 = v4 ^ v2;
1✔
NEW
251
    t.fail("1234567890 ^ 3.14 --> error");
×
252
  } catch (...) {
1✔
253
    t.pass("1234567890 ^ 3.14 --> error");
1✔
254
  }
1✔
255

256
  // date ^ string   -> ERROR
257
  try {
258
    Variant v43 = v4 ^ v3;
1✔
NEW
259
    t.fail("1234567890 ^ foo --> error");
×
260
  } catch (...) {
1✔
261
    t.pass("1234567890 ^ foo --> error");
1✔
262
  }
1✔
263

264
  // date ^ date     -> ERROR
265
  try {
266
    Variant v44 = v4 ^ v4;
1✔
NEW
267
    t.fail("1234567890 ^ 1234567890 --> error");
×
268
  } catch (...) {
1✔
269
    t.pass("1234567890 ^ 1234567890 --> error");
1✔
270
  }
1✔
271

272
  // date ^ duration -> ERROR
273
  try {
274
    Variant v45 = v4 ^ v5;
1✔
NEW
275
    t.fail("1234567890 ^ 1200 --> error");
×
276
  } catch (...) {
1✔
277
    t.pass("1234567890 ^ 1200 --> error");
1✔
278
  }
1✔
279

280
  // duration ^ boolean  -> ERROR
281
  try {
282
    Variant v50 = v5 ^ v0;
1✔
NEW
283
    t.fail("1200 ^ true --> error");
×
284
  } catch (...) {
1✔
285
    t.pass("1200 ^ true --> error");
1✔
286
  }
1✔
287

288
  // duration ^ integer  -> ERROR
289
  try {
290
    Variant v51 = v5 ^ v1;
1✔
NEW
291
    t.fail("1200 ^ 42 --> error");
×
292
  } catch (...) {
1✔
293
    t.pass("1200 ^ 42 --> error");
1✔
294
  }
1✔
295

296
  // duration ^ real     -> ERROR
297
  try {
298
    Variant v52 = v5 ^ v2;
1✔
NEW
299
    t.fail("1200 ^ 3.14 --> error");
×
300
  } catch (...) {
1✔
301
    t.pass("1200 ^ 3.14 --> error");
1✔
302
  }
1✔
303

304
  // duration ^ string   -> ERROR
305
  try {
306
    Variant v53 = v5 ^ v3;
1✔
NEW
307
    t.fail("1200 ^ foo --> error");
×
308
  } catch (...) {
1✔
309
    t.pass("1200 ^ foo --> error");
1✔
310
  }
1✔
311

312
  // duration ^ date     -> ERROR
313
  try {
314
    Variant v54 = v5 ^ v4;
1✔
NEW
315
    t.fail("1200 ^ 1234567890 --> error");
×
316
  } catch (...) {
1✔
317
    t.pass("1200 ^ 1234567890 --> error");
1✔
318
  }
1✔
319

320
  // duration ^ duration -> ERROR
321
  try {
322
    Variant v55 = v5 ^ v5;
1✔
NEW
323
    t.fail("1200 ^ 1200 --> error");
×
324
  } catch (...) {
1✔
325
    t.pass("1200 ^ 1200 --> error");
1✔
326
  }
1✔
327

328
  return 0;
1✔
329
}
1✔
330

331
////////////////////////////////////////////////////////////////////////////////
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