/
replace_and_remove.cc
39 lines (34 loc) · 1.11 KB
/
replace_and_remove.cc
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
#include <iterator>
#include <string>
#include <vector>
#include "test_framework/generic_test.h"
#include "test_framework/timed_executor.h"
using std::string;
using std::vector;
int ReplaceAndRemove(int size, char s[]) {
// TODO - you fill in here.
return 0;
}
vector<string> ReplaceAndRemoveWrapper(TimedExecutor& executor, int size,
const vector<string>& s) {
std::vector<char> s_copy(s.size(), '\0');
for (int i = 0; i < s.size(); ++i) {
if (!s[i].empty()) {
s_copy[i] = s[i][0];
}
}
int res_size =
executor.Run([&] { return ReplaceAndRemove(size, s_copy.data()); });
vector<string> result;
for (int i = 0; i < res_size; ++i) {
result.emplace_back(string(1, s_copy[i]));
}
return result;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"executor", "size", "s"};
return GenericTestMain(args, "replace_and_remove.cc",
"replace_and_remove.tsv", &ReplaceAndRemoveWrapper,
DefaultComparator{}, param_names);
}