2 * Eddie Kohler, Yandong Mao, Robert Morris
3 * Copyright (c) 2012-2013 President and Fellows of Harvard College
4 * Copyright (c) 2012-2013 Massachusetts Institute of Technology
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, subject to the conditions
9 * listed in the Masstree LICENSE file. These conditions include: you must
10 * preserve this copyright notice, and you cannot mention the copyright
11 * holders in advertising related to the Software without their permission.
12 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
13 * notice is a summary of the Masstree LICENSE file; the license in that file
16 #include "testrunner.hh"
21 testrunner_base* testrunner_base::thehead;
22 testrunner_base* testrunner_base::thetail;
24 void testrunner_base::print_names(FILE* stream, int ncol) {
25 masstree_precondition(ncol >= 1);
27 std::vector<lcdf::String> names;
28 for (testrunner_base* tr = thehead; tr; tr = tr->next_)
29 names.push_back(tr->name());
32 std::vector<int> colwidth;
34 percol = (names.size() + ncol - 1) / ncol;
35 colwidth.assign(ncol, 0);
36 for (size_t i = 0; i != names.size(); ++i)
37 colwidth[i/percol] = std::max(colwidth[i/percol], names[i].length());
39 || std::accumulate(colwidth.begin(), colwidth.end(), 0)
45 for (size_t row = 0; row != percol; ++row) {
47 for (int col = 0; col != ncol; ++col, off += percol)
48 if (off < names.size())
49 fprintf(stream, "%*s %s",
50 col ? colwidth[col-1] - names[off-percol].length() : 0, "",
52 fprintf(stream, "\n");