This file is indexed.

/usr/include/cpptest-assert.h is in libcpptest-dev 1.1.2-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// ---
//
// $Id: cpptest-assert.h,v 1.3 2005/06/08 08:08:06 nilu Exp $
//
// CppTest - A C++ Unit Testing Framework
// Copyright (c) 2003 Niklas Lundell
// Copyright (c) 2010 Nate Gallaher
//
// ---
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// ---

/** \file */

#ifndef CPPTEST_ASSERT_H
#define CPPTEST_ASSERT_H

#include <sstream>

/// Unconditional failure.
///
/// Used in conjunction with Test::Suite.
///
/// \param msg Provided message.
///
/// \par Example:
/// \code
/// void MySuite::test()
/// {
/// 	// ...
///
/// 	switch (flag)
/// 	{
/// 		// handling valid cases ...
///
/// 		default:
/// 			TEST_FAIL("This should not happen")
/// 	}
/// }
/// \endcode
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_FAIL(msg) \
	{																\
		assertment(::Test::Source(__FILE__, __LINE__, (msg) != 0 ? #msg : "")); \
		if (!continue_after_failure()) return;						\
	}

/// Verify an expression and issues an assertment if it fails.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
///
/// \see TEST_ASSERT_MSG(expr, msg)
///
/// \par Example:
/// \code
/// void MySuite::test()
/// {
/// 	int i;
///
/// 	// ...
///
/// 	TEST_ASSERT(i == 13)
/// }
/// \endcode
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT(expr)  											\
	{  																\
		if (!(expr))  												\
		{ 															\
			assertment(::Test::Source(__FILE__, __LINE__, #expr));	\
			if (!continue_after_failure()) return;					\
		} 															\
	}

/// Verify an expression and issues an assertment if it fails.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
/// \param msg  User message.
///
/// \see TEST_ASSERT(expr)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT_MSG(expr, msg)									\
	{  																\
		if (!(expr))  												\
		{ 															\
			assertment(::Test::Source(__FILE__, __LINE__, msg));	\
			if (!continue_after_failure()) return;					\
		} 															\
	}

/// Verify that two expressions are equal, issues an
/// assertment if it fails.  Requires the output operator (<<)
/// to be defined for both expected and got.
///
/// If the output operator is not available, you should use
/// TEST_ASSERT_EQUALS_OBJ(expected, got).
///
/// Used in conjunction with Test::Suite.
///
/// \param expected  Expected value.
/// \param got       Value to test against expected value.
///
/// \see TEST_ASSERT_EQUALS_MSG(expected, got, msg)
/// \see TEST_ASSERT_EQUALS_OBJ(expected, got)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT_EQUALS(expected, got)								\
	{																	\
		if (!((got) == (expected)))										\
		{																\
			std::stringstream tmpstream;								\
			tmpstream << "Got " << (got) << ", expected " << (expected);\
			assertment(::Test::Source(__FILE__, __LINE__,				\
						tmpstream.str().c_str()));						\
			if (!continue_after_failure()) return;						\
		}																\
	}

/// Verify that two expressions are equal, issues an
/// assertment if it fails.
///
/// If the output operator is defined for the objects being compared
/// you should use TEST_ASSERT_EQUALS(expected, got) instead for
/// more useful failure messages.
///
/// Used in conjunction with Test::Suite.
///
/// \param expected  Expected value.
/// \param got       Value to test against expected value.
///
/// \see TEST_ASSERT_EQUALS(expected, got)
/// \see TEST_ASSERT_EQUALS_MSG(expected, got, msg)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT_EQUALS_OBJ(expected, got)						\
	{																\
		if (!((got) == (expected)))									\
		{															\
			std::stringstream tmpstream;							\
			tmpstream << #expected << " object not equal to ";		\
			tmpstream << #got << " object.";						\
			assertment(::Test::Source(__FILE__, __LINE__, 			\
						tmpstream.str().c_str()));					\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify that two expressions are equal, issues an
/// assertment if it fails.  The output operator (<<) must be defined for the
/// object under test.  If the output operator is not available, you
/// should use TEST_ASSERT_EQUALS_OBJ(expected, got) instead.
///
/// Used in conjunction with Test::Suite.
///
/// \param expected  Expected value.
/// \param got       Value to test against expected value.
/// \param msg       User message to print out on failure.
///
/// \see TEST_ASSERT_EQUALS(expected, got)
/// \see TEST_ASSERT_EQUALS_OBJ(expected, got)
///
/// For a description of all asserts, see \ref asserts.
#define TEST_ASSERT_EQUALS_MSG(expected, got, msg)						\
	{																	\
		if (!((got) == (expected)))										\
		{																\
			std::stringstream tmpstream;								\
			tmpstream << (msg) << ": ";									\
			tmpstream << "Got " << (got) << ", expected " << (expected);\
			assertment(::Test::Source(__FILE__, __LINE__,				\
						tmpstream.str().c_str()));						\
			if (!continue_after_failure()) return;						\
		}																\
	}

/// Verify that two expressions are equal up to a constant, issues an
/// assertment if it fails.
///
/// Used in conjunction with Test::Suite.
///
/// \param a     First expression to test.
/// \param b     Second expression to test.
/// \param delta Constant.
///
/// \see TEST_ASSERT_DELTA_MSG(a, b, delta, msg)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT_DELTA(a, b, delta)								\
	{																\
		if (((b) < (a) - (delta)) || ((b) > (a) + (delta)))			\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, 			\
					   "delta(" #a ", " #b ", " #delta ")" ));		\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify that two expressions are equal up to a constant, issues an
/// assertment if it fails.
///
/// Used in conjunction with Test::Suite.
///
/// \param a     First expression to test.
/// \param b     Second expression to test.
/// \param delta Constant.
/// \param msg   User message.	
///
/// \see TEST_ASSERT_DELTA(a, b, delta)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_ASSERT_DELTA_MSG(a, b, delta, msg)						\
	{																\
		if (((b) < (a) - (delta)) || ((b) > (a) + (delta)))			\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, msg));	\
			if (!continue_after_failure()) return;					\
		}															\
	}
	
/// Verify an expression and expects an exception in return.
/// An assertment is issued if the exception is not thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
/// \param x    Expected exception.
///
/// \see TEST_THROWS_MSG(expr, x, msg)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS(expr, x)										\
	{																\
		bool __expected = false;									\
		try { expr; } 												\
		catch (x)			{ __expected = true; }					\
		catch (...)			{}										\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, #expr));	\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify an expression and expects an exception in return.
/// An assertment is issued if the exception is not thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
/// \param x    Expected exception.
/// \param msg  User message.
///
/// \see TEST_THROWS(expr, x)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS_MSG(expr, x, msg)								\
	{																\
		bool __expected = false;									\
		try { expr; } 												\
		catch (x)			{ __expected = true; }					\
		catch (...)			{}										\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, msg));	\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify an expression and expects any exception in return.
/// An assertment is issued if no exception is thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
///
/// \see TEST_THROWS_ANYTHING_MSG(expr, msg)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS_ANYTHING(expr)									\
	{																\
		bool __expected = false;									\
		try { expr; } 												\
		catch (...) { __expected = true; }							\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, #expr));	\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify an expression and expects any exception in return.
/// An assertment is issued if no exception is thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
/// \param msg  User message.
///
/// \see TEST_THROWS_ANYTHING(expr)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS_ANYTHING_MSG(expr, msg)							\
	{																\
		bool __expected = false;									\
		try { expr; }		 										\
		catch (...) { __expected = true; }							\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, msg));	\
			if (!continue_after_failure()) return;					\
		}															\
	}
	
/// Verify an expression and expects no exception in return.
/// An assertment is issued if any exception is thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
///
/// \see TEST_THROWS_NOTHING_MSG(expr, msg)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS_NOTHING(expr)									\
	{																\
		bool __expected = true;										\
		try { expr; } 												\
		catch (...) { __expected = false; }							\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, #expr));	\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// Verify an expression and expects no exception in return.
/// An assertment is issued if any exception is thrown.
///
/// Used in conjunction with Test::Suite.
///
/// \param expr Expression to test.
/// \param msg  User message.
///
/// \see TEST_THROWS_NOTHING(expr)
///
/// For a description of all asserts, see \ref asserts.
///
#define TEST_THROWS_NOTHING_MSG(expr, msg)							\
	{																\
		bool __expected = true;										\
		try { expr; } 												\
		catch (...) { __expected = false; }							\
		if (!__expected)											\
		{															\
			assertment(::Test::Source(__FILE__, __LINE__, msg));	\
			if (!continue_after_failure()) return;					\
		}															\
	}

/// \page asserts Available asserts
///
/// Normally, assert macros issues an assert if the given expression, if any,
/// fails (as defined by the macro). Assertments include information about the
/// current test suite, test function, source file, source file line, and a
/// message. The message is normally the offending expression, however, for
/// macros ending in _MSG it is possibly to supply a user defined message.
///
/// <b>General asserts</b>
/// - TEST_FAIL(msg)
///
/// <b>Comparision asserts</b>
/// - TEST_ASSERT(expr)
/// - TEST_ASSERT_MSG(expr, msg)
/// - TEST_ASSERT_EQUALS(expected, got)
/// - TEST_ASSERT_EQUALS_MSG(expected, got, msg)
/// - TEST_ASSERT_EQUALS_OBJ(expected, got)
/// - TEST_ASSERT_DELTA(a, b, delta)
/// - TEST_ASSERT_DELTA_MSG(a, b, delta, msg)
///
/// <b>Exception asserts</b>
/// - TEST_THROWS(expr, x)
/// - TEST_THROWS_MSG(expr, x, msg)
/// - TEST_THROWS_ANYTHING(expr)
/// - TEST_THROWS_ANYTHING_MSG(expr, msg)
/// - TEST_THROWS_NOTHING(expr)
/// - TEST_THROWS_NOTHING_MSG(expr, msg)
///

#endif // #ifndef CPPTEST_ASSERT_H