test/src/SuiteMaker.cc
author Krista Bennett <krista@pep-project.org>
Thu, 03 May 2018 12:01:06 +0200
branchlocal_cpptest
changeset 2644 271d7a25c8d3
parent 2642 7dbfc6c3f3c8
child 2645 a1932fb654b8
permissions -rw-r--r--
Will need to fix generation, but now set up to run suites in various ways.
krista@2637
     1
#include <cpptest.h>
krista@2634
     2
#include <cpptest-suite.h>
krista@2644
     3
#include <memory>
krista@2644
     4
#include <vector>
krista@2634
     5
krista@2644
     6
krista@2644
     7
// Begin where we should generate stuff
krista@2634
     8
#include "DecorateTests.h"
krista@2642
     9
#include "AppleMailTests.h"
krista@2642
    10
krista@2644
    11
#include "SuiteMaker.h"
krista@2637
    12
krista@2644
    13
const char* SuiteMaker::all_suites[] = {
krista@2642
    14
    "DecorateTests",
krista@2644
    15
    "AppleMailTests"
krista@2642
    16
};
krista@2642
    17
krista@2644
    18
// This file is generated, so magic constants are ok.
krista@2644
    19
int SuiteMaker::num_suites = 2;
krista@2644
    20
krista@2644
    21
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
krista@2634
    22
    if (strcmp(test_class_name, "DecorateTests") == 0)
krista@2644
    23
        *test_suite = new DecorateTests(test_class_name, test_home);
krista@2641
    24
    else if (strcmp(test_class_name, "AppleMailTests") == 0)
krista@2644
    25
        *test_suite = new AppleMailTests(test_class_name, test_home);    
krista@2634
    26
}
krista@2644
    27
krista@2644
    28
void SuiteMaker::suitemaker_buildlist(const char** test_class_names, int num_to_run, const char* test_home, std::vector<Test::Suite*>& test_suites) {
krista@2644
    29
    for (int i = 0; i < num_to_run; i++) {
krista@2644
    30
        Test::Suite* suite = NULL;
krista@2644
    31
        SuiteMaker::suitemaker_build(test_class_names[i], test_home, &suite);
krista@2644
    32
        if (!suite)
krista@2644
    33
            throw std::runtime_error("Could not create a test suite instance."); // FIXME, better error, cleanup, obviously
krista@2644
    34
        test_suites.push_back(suite);
krista@2644
    35
    }    
krista@2644
    36
}
krista@2644
    37
krista@2644
    38
void SuiteMaker::suitemaker_buildall(const char* test_home, std::vector<Test::Suite*>& test_suites) {
krista@2644
    39
    SuiteMaker::suitemaker_buildlist(SuiteMaker::all_suites, SuiteMaker::num_suites, test_home, test_suites);
krista@2644
    40
}