xref: /aosp_15_r20/test/dittosuite/test/result.cpp (revision 6fa2df46f119dce7527f5beb2814eca0e6f886ac)
1 // Copyright (C) 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <ditto/arg_parser.h>
16 #include <gtest/gtest.h>
17 
18 
19 namespace dittosuite {
20 
21 class DittoResult : public testing::TestWithParam<std::tuple<ResultsOutput, std::string_view>> {};
22 
TEST_P(DittoResult,ArgParseString)23 TEST_P(DittoResult, ArgParseString) {
24   auto const& param = GetParam();
25   ASSERT_EQ(ArgToResultsOutput(std::get<1>(param)), (std::get<0>(param)));
26 }
27 
28 INSTANTIATE_TEST_SUITE_P(String, DittoResult,
29                          testing::Values(std::make_tuple(ResultsOutput::kReport, "report"),
30                                          std::make_tuple(ResultsOutput::kCsv, "csv"),
31                                          std::make_tuple(ResultsOutput::kPb, "pb"),
32                                          std::make_tuple(ResultsOutput::kNull, "null")));
33 
34 INSTANTIATE_TEST_SUITE_P(Number, DittoResult,
35                          testing::Values(std::make_tuple(ResultsOutput::kReport, "0"),
36                                          std::make_tuple(ResultsOutput::kCsv, "1"),
37                                          std::make_tuple(ResultsOutput::kPb, "2"),
38                                          std::make_tuple(ResultsOutput::kNull, "-1")));
39 
40 INSTANTIATE_TEST_SUITE_P(Invalid, DittoResult,
41                          testing::Values(std::make_tuple(ResultsOutput::kReport, "UNKNOWN"),
42                                          std::make_tuple(ResultsOutput::kReport, "-2"),
43                                          std::make_tuple(ResultsOutput::kReport, "3")));
44 
45 }  // namespace dittosuite
46