forked from movetk/movetk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rows2cols.cpp
More file actions
83 lines (70 loc) · 2.32 KB
/
Copy pathtest_rows2cols.cpp
File metadata and controls
83 lines (70 loc) · 2.32 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2018-2020 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
#include "catch2/catch.hpp"
#include <iostream>
#include "movetk/utils/Transpose.h"
TEST_CASE("convert row to col", "[row2col]")
{
using Row = std::tuple<std::string, int, float>;
Row row0{"abc", 5, 33.13};
Row row1{"ghi", 4, 11.30};
Row row2{"aaa", 3, 21.20};
std::vector<Row> input = {row0, row1, row2};
std::vector<std::string> col0{"abc", "ghi", "aaa"};
std::vector<int> col1{5, 4, 3};
std::vector<float> col2{33.13, 11.30, 21.20};
std::tuple<std::vector<std::string>,
std::vector<int>, std::vector<float>>
expected = {col0, col1, col2};
auto output = Transpose(input)();
// auto output = r2call.convert_row_to_column<0, 1,2>();
// auto output = convert_rows_to_cols(input);
// auto output = expected;
// Row2Col<0> r2c0;
// auto output0 = r2c0.convert_row_to_column(input);
// Row2Col<1> r2c1;
// auto output1 = r2c1.convert_row_to_column(input);
// Row2Col<2> r2c2;
// auto output2 = r2c2.convert_row_to_column(input);
// auto output = std::make_tuple(output0, output1, output2);
std::cout << "col0: ";
auto out0 = std::get<0>(output);
for (auto x : out0)
{
std::cout << x << " ";
}
std::cout << std::endl;
std::cout << "col1: ";
auto out1 = std::get<1>(output);
for (auto x : out1)
{
std::cout << x << " ";
}
std::cout << std::endl;
std::cout << "col2: ";
auto out2 = std::get<2>(output);
for (auto x : out2)
{
std::cout << x << " ";
}
std::cout << std::endl;
REQUIRE(col0 == out0);
REQUIRE(col1 == out1);
REQUIRE(col2 == out2);
}