/
visualstudiooutput.h
49 lines (38 loc) · 1.52 KB
/
visualstudiooutput.h
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
// Copyright Joakim Karlsson & Kim Gräsman 2010.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef IGLOO_VISUALSTUDIOOUTPUT_H
#define IGLOO_VISUALSTUDIOOUTPUT_H
namespace igloo {
class VisualStudioResultsOutput
{
public:
VisualStudioResultsOutput(std::ostream& output)
: output_(output)
{}
void PrintResult(const TestResults& results)
{
TestResults::FailedTestsType::const_iterator it;
for(it = results.FailedTests().begin(); it != results.FailedTests().end(); it++)
{
output_ << FormatOriginString(*it) << " : assertion failed error I001: " << (*it).GetContextName() << "::" << (*it).GetSpecName() << ": " << (*it).GetErrorMessage() << std::endl;
}
output_ << "Test run complete. " << results.NumberOfTestsRun() << " tests run, " << results.NumberOfSucceededTests() << " succeeded, " << results.NumberOfFailedTests() << " failed." << std::endl;
}
private:
std::string FormatOriginString(const FailedTestResult& result)
{
if(result.HasLineNumber() && result.HasFilename())
{
std::ostringstream builder;
builder << result.Filename() << "(" << result.LineNumber() << ")";
return builder.str();
}
// Default to toolname if no location information is available
return "Igloo";
}
std::ostream& output_;
};
}
#endif