Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/2d/unittest/TestBase.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "TestBase.h"
8
9
#include <sstream>
10
11
using namespace std;
12
13
int
14
TestBase::RunTests(int *aFailures)
15
0
{
16
0
  int testsRun = 0;
17
0
  *aFailures = 0;
18
0
19
0
  for(unsigned int i = 0; i < mTests.size(); i++) {
20
0
    stringstream stream;
21
0
    stream << "Test (" << mTests[i].name << "): ";
22
0
    LogMessage(stream.str());
23
0
    stream.str("");
24
0
25
0
    mTestFailed = false;
26
0
27
0
    // Don't try this at home! We know these are actually pointers to members
28
0
    // of child clases, so we reinterpret cast those child class pointers to
29
0
    // TestBase and then call the functions. Because the compiler believes
30
0
    // these function calls are members of TestBase.
31
0
    ((*reinterpret_cast<TestBase*>((mTests[i].implPointer))).*(mTests[i].funcCall))();
32
0
33
0
    if (!mTestFailed) {
34
0
      LogMessage("PASSED\n");
35
0
    } else {
36
0
      LogMessage("FAILED\n");
37
0
      (*aFailures)++;
38
0
    }
39
0
    testsRun++;
40
0
  }
41
0
42
0
  return testsRun;
43
0
}
44
45
void
46
TestBase::LogMessage(string aMessage)
47
0
{
48
0
  printf("%s", aMessage.c_str());
49
0
}