1 /* 2 * Copyright (C) 2020 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 #pragma once 17 18 namespace android::hardware::broadcastradio::V1_0::vts { 19 20 using android::hardware::broadcastradio::V1_0::Class; 21 22 /** 23 * Convert a string of Class name to its enum value. Fail the test if the enum 24 * value is not found. 25 * 26 * @param className string value of a Class enum. 27 * @return Class enum that matches the string value. 28 */ RadioClassFromString(std::string className)29Class RadioClassFromString(std::string className) { 30 if (className == "AM_FM") return Class::AM_FM; 31 if (className == "SAT") return Class::SAT; 32 if (className == "DT") return Class::DT; 33 // Fail the test run. 34 CHECK(false) << "Class name not found: " << className; 35 // Return some arbitrary enum. 36 return Class::AM_FM; 37 } 38 } // namespace android::hardware::broadcastradio::V1_0::vts 39