-
Notifications
You must be signed in to change notification settings - Fork 30
/
test_flatten.cpp
46 lines (34 loc) · 1.2 KB
/
test_flatten.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
44
45
46
#include <iostream>
#include <cassert>
#include <vector>
#include <cstdint>
//'flatten' is defined in ak-link_chains.cpp
void flatten(std::vector< uint32_t > &closest, std::vector< float > const &lengths, bool is_loop);
int main(int argc, char **argv) {
auto test = [](std::vector< uint32_t > closest, std::vector< float > lengths) {
if (lengths.empty()) {
lengths.assign(closest.size(), 1.0f);
}
assert(lengths.size() == closest.size());
std::vector< uint32_t > before = closest;
std::cout << "Flatten from:";
for (auto c : closest) {
std::cout << ' ' << c;
};
std::cout << std::endl;
flatten(closest, lengths, true);
std::cout << " to:";
for (auto c : closest) {
std::cout << ' ' << c;
};
std::cout << std::endl;
};
test(std::vector< uint32_t >{5,5,5,5,5,5}, std::vector< float >{});
test(std::vector< uint32_t >{5,5,5,2,2,5}, std::vector< float >{});
test(std::vector< uint32_t >{1,1,2,1,2,2,2,1},
std::vector< float >{1,1,1,1,1,1,1,1});
test(std::vector< uint32_t >{1,1,2,1,2,2,2,1},
std::vector< float >{1,1,1,5,1,1,1,1});
test(std::vector< uint32_t >{5,1,1,1,2,2,5,5,3,4,4,4,4,1,1,3,3,5,5,2,2,5}, std::vector< float >{});
return 0;
}