1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <optional> 20 #include <string> 21 #include <variant> 22 23 #include <gtest/gtest.h> 24 25 #include "common/libs/utils/result.h" 26 #include "host/commands/cvd/flag.h" 27 #include "host/commands/cvd/types.h" 28 29 namespace cuttlefish { 30 31 // use this only when std::optional is not nullopt 32 template <typename T> Get(const std::optional<FlagCollection::ValueVariant> & opt_var)33static Result<T> Get( 34 const std::optional<FlagCollection::ValueVariant>& opt_var) { 35 CF_EXPECT(opt_var != std::nullopt); 36 std::variant<std::int32_t, bool, std::string> var = *opt_var; 37 auto* ptr = std::get_if<T>(&var); 38 CF_EXPECT(ptr != nullptr); 39 return *ptr; 40 } 41 42 class CvdFlagCollectionTest : public testing::Test { 43 protected: 44 CvdFlagCollectionTest(); 45 46 cvd_common::Args input_; 47 FlagCollection flag_collection_; 48 }; 49 50 } // namespace cuttlefish 51