-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimpl-list.cpp
43 lines (36 loc) · 1.32 KB
/
impl-list.cpp
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
#include "impl-list.hpp"
#include "common-cxx.hpp"
#include "misc.hpp"
const test_description all_funcs[] = {
{"toupper_rawloop", toupper_rawloop, "Raw C-style loop", NONE},
{"toupper_rawloop_algo", toupper_rawloop_algo, "Raw C-style loop after <algo>", NONE},
{"toupper_transform", toupper_transform, "C toupper after including <algorithm>", NONE},
{"toupper_branch", toupper_branch, "Branchy ASCII", NONE},
{"toupper_lookup", toupper_lookup, "Lookup ASCII", NONE},
};
auto b() -> decltype(get_all().begin()) {
return get_all().begin();
}
auto e() -> decltype(get_all().end()) {
return get_all().end();
}
const test_description* get_by_name(const std::string& name) {
auto it = std::find_if(b(), e(), [&](auto d) { return name == d.name; });
return it == e() ? nullptr : &*it;
}
std::vector<test_description> get_by_list(const std::string& list) {
std::vector<test_description> ret;
for (auto& name : split(list, ",")) {
auto t = get_by_name(name);
if (!t) {
throw std::runtime_error("no test named " + name);
}
ret.push_back(*t);
}
return ret;
}
const std::vector<test_description>& get_all() {
static std::vector<test_description> all =
std::vector<test_description>(all_funcs, all_funcs + COUNT_OF(all_funcs));
return all;
}