This file is indexed.

/usr/include/wibble/tests.h is in libwibble-dev 0.1.28-1.

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
#ifndef WIBBLE_TESTS_H
#define WIBBLE_TESTS_H

/**
 * @file test-utils.h
 * @author Peter Rockai (mornfall) <me@mornfall.net>, Enrico Zini <enrico@enricozini.org>
 * @brief Utility functions for the unit tests
 */

#include <string>
#include <sstream>

#include <wibble/tests/tut.h>
#include <wibble/tests/tut_reporter.h>


#define TESTGRP(name) \
typedef test_group<name ## _shar> tg; \
typedef tg::object to; \
tg name ## _tg (#name);


namespace wibble {
namespace tests {

class Location
{
	std::string file;
	int line;
	std::string str;
	std::string testfile;
	int testline;
	std::string teststr;

public:

	Location(const std::string& file, int line, const std::string& str)
		: file(file), line(line), str(str) {}
	Location(const Location& loc,
		 const std::string& testfile, int testline, const std::string& str) :
		file(loc.file), line(loc.line), str(loc.str),
		testfile(testfile), testline(testline), teststr(str) {}

	std::string locstr() const;
	std::string msg(const std::string m) const;
};

#define ensure(x) wibble::tests::impl_ensure(wibble::tests::Location(__FILE__, __LINE__, #x), (x))
#define inner_ensure(x) wibble::tests::impl_ensure(wibble::tests::Location(loc, __FILE__, __LINE__, #x), (x))
void impl_ensure(const Location& loc, bool res);

#define ensure_equals(x, y) wibble::tests::impl_ensure_equals(wibble::tests::Location(__FILE__, __LINE__, #x " == " #y), (x), (y))
#define inner_ensure_equals(x, y) wibble::tests::impl_ensure_equals(wibble::tests::Location(loc, __FILE__, __LINE__, #x " == " #y), (x), (y))

template <class Actual,class Expected>
void impl_ensure_equals(const Location& loc, const Actual& actual, const Expected& expected)
{
	if( expected != actual )
	{
		std::stringstream ss;
		ss << "expected '" << expected << "' actual '" << actual << "'";
		throw tut::failure(loc.msg(ss.str()));
	}
}

#define ensure_similar(x, y, prec) wibble::tests::impl_ensure_similar(wibble::tests::Location(__FILE__, __LINE__, #x " == " #y), (x), (y), (prec))
#define inner_ensure_similar(x, y, prec) wibble::tests::impl_ensure_similar(wibble::tests::Location(loc, __FILE__, __LINE__, #x " == " #y), (x), (y), (prec))

template <class Actual, class Expected, class Precision>
void impl_ensure_similar(const Location& loc, const Actual& actual, const Expected& expected, const Precision& precision)
{
	if( actual < expected - precision || expected + precision < actual )
	{
		std::stringstream ss;
		ss << "expected '" << expected << "' actual '" << actual << "'";
                throw tut::failure(loc.msg(ss.str()));
	}
}


}
}

#endif