This file is indexed.

/usr/include/cpptest-suite.h is in libcpptest-dev 1.1.1-0ubuntu1.

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
// ---
//
// $Id: cpptest-suite.h,v 1.4 2010/03/26 04:45:14 hartwork Exp $
//
// CppTest - A C++ Unit Testing Framework
// Copyright (c) 2003 Niklas Lundell
//
// ---
//
// 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_SUITE_H
#define CPPTEST_SUITE_H

#include <list>
#include <memory>
#include <string>

#include "cpptest-time.h"
#include "cpptest-source.h"

namespace Test
{
	class Output;
	
	/// \brief Unit testing suite.
	///
	/// Base class for all suites. Derive from this class to create own
	/// test suites.
	///
	/// %Test functions in derived classes are registered as tests using the
	/// TEST_ADD(func). Testing is started by run(). Note that suites may be
	/// embedded in other suites using add().
	///
	class Suite
	{
	public:	
		Suite();
		virtual ~Suite();
		
		void add(std::auto_ptr<Suite> suite);
		
		bool run(Output& output, bool cont_after_fail = true);
		
	protected:
		/// Pointer to a test function.
		///
		typedef void (Suite::*Func)();
		
		bool continue_after_failure() const { return _continue; }
		
		virtual void setup()     {}
		virtual void tear_down() {}
		
		void register_test(Func func, const std::string& name);
		void assertment(Source s);
		
	private:
		struct DoRun;
		struct ExecTests;
		struct SubSuiteTests;
		struct SuiteTime;
		struct SubSuiteTime;
		
		friend struct DoRun;
		friend struct ExecTests;
		friend struct SubSuiteTests;
		friend struct SubSuiteTime;
		
		struct Data
		{
			Func			_func;
			std::string		_name;
			Time			_time;
		
			Data(Func func, const std::string& name)
				: _func(func), _name(name) {}
		};
		
		typedef std::list<Data> 	Tests;
		typedef std::list<Suite*> 	Suites;
		
		std::string			_name;			// Suite name
		const std::string*	_cur_test;		// Current test func name
        Suites				_suites;		// External test suites
		Tests 				_tests;			// All tests
		Output*				_output;		// Output handler
		bool				_result   : 1;	// Test result
		bool				_success  : 1;	// Set if no test failed
		bool				_continue : 1;	// Continue func after failures
		
		void do_run(Output* os, bool cont_after_fail);
		int total_tests() const;
		Time total_time(bool recursive) const;
		
		// Disable
		//
		Suite(const Suite&);
		Suite& operator=(const Suite&);
	};

	/// Adds a test function to the enclosing suite. Note that test functions
	/// should be added in the suites constructor.
	///
	/// \param func Function to add, must be of type Suite::Func.
	///
	/// \par Example:
	/// \code
	///	MySuite::MySuite()
	///	{
	/// 	TEST_ADD(&MySuite::test_1)
	/// 	TEST_ADD(&MySuite::test_2)
	/// 	...
	///	}
	/// \endcode
	///
	#define TEST_ADD(func)\
		register_test(static_cast<Func>(&func), #func);
	
} // namespace Test

#endif // #ifndef CPPTEST_SUITE_H