File: CSVResultPrinter.cpp

package info (click to toggle)
skypat 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 664 kB
  • sloc: cpp: 2,545; makefile: 220; ansic: 78; sh: 67
file content (53 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (4)
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
//===- CSVResultPrinter.cpp -----------------------------------------------===//
//
//                     The SkyPat Team
//
// This file is distributed under the New BSD License. 
// See LICENSE for details.
//
//===----------------------------------------------------------------------===//
#include <skypat/Listeners/CSVResultPrinter.h>
#include <skypat/ADT/Color.h>
#include <iostream>

using namespace skypat;

//===----------------------------------------------------------------------===//
// CSVResultPrinter
//===----------------------------------------------------------------------===//
CSVResultPrinter::CSVResultPrinter()
  : m_OStream() {
}

CSVResultPrinter::~CSVResultPrinter()
{
  if (m_OStream.is_open())
    m_OStream.close();
}

bool CSVResultPrinter::open(const std::string& pFileName)
{
  if (m_OStream.is_open())
    return false;

  m_OStream.open(pFileName.c_str(), std::ostream::out | std::ostream::app);
  return m_OStream.good();
}

void CSVResultPrinter::OnTestEnd(const testing::TestInfo& pTestInfo)
{
  if (!pTestInfo.result().performance().empty()) {
    testing::TestResult::Performance::const_iterator perf =
                                      pTestInfo.result().performance().begin();
    testing::TestResult::Performance::const_iterator pEnd =
                                      pTestInfo.result().performance().end();
    m_OStream << pTestInfo.getTestName() << ",";
    while (perf != pEnd) {
      m_OStream << (*perf)->getTimerNum();
      ++perf;
      if (perf != pEnd)
        m_OStream << ",";
    }
    m_OStream << std::endl;
  }
}