xref: /aosp_15_r20/hardware/interfaces/broadcastradio/common/tests/ProgramIdentifier_test.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker /*
2*4d7e907cSAndroid Build Coastguard Worker  * Copyright (C) 2017 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker  *
4*4d7e907cSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker  *
8*4d7e907cSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker  *
10*4d7e907cSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker  * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker  */
16*4d7e907cSAndroid Build Coastguard Worker 
17*4d7e907cSAndroid Build Coastguard Worker #include <broadcastradio-utils-2x/Utils.h>
18*4d7e907cSAndroid Build Coastguard Worker #include <gtest/gtest.h>
19*4d7e907cSAndroid Build Coastguard Worker 
20*4d7e907cSAndroid Build Coastguard Worker #include <optional>
21*4d7e907cSAndroid Build Coastguard Worker 
22*4d7e907cSAndroid Build Coastguard Worker namespace {
23*4d7e907cSAndroid Build Coastguard Worker 
24*4d7e907cSAndroid Build Coastguard Worker namespace utils = android::hardware::broadcastradio::utils;
25*4d7e907cSAndroid Build Coastguard Worker 
TEST(ProgramIdentifierTest,hdRadioStationName)26*4d7e907cSAndroid Build Coastguard Worker TEST(ProgramIdentifierTest, hdRadioStationName) {
27*4d7e907cSAndroid Build Coastguard Worker     auto verify = [](std::string name, uint64_t nameId) {
28*4d7e907cSAndroid Build Coastguard Worker         auto id = utils::make_hdradio_station_name(name);
29*4d7e907cSAndroid Build Coastguard Worker         EXPECT_EQ(nameId, id.value) << "Failed to convert '" << name << "'";
30*4d7e907cSAndroid Build Coastguard Worker     };
31*4d7e907cSAndroid Build Coastguard Worker 
32*4d7e907cSAndroid Build Coastguard Worker     verify("", 0);
33*4d7e907cSAndroid Build Coastguard Worker     verify("Abc", 0x434241);
34*4d7e907cSAndroid Build Coastguard Worker     verify("Some Station 1", 0x54415453454d4f53);
35*4d7e907cSAndroid Build Coastguard Worker     verify("Station1", 0x314e4f4954415453);
36*4d7e907cSAndroid Build Coastguard Worker     verify("!@#$%^&*()_+", 0);
37*4d7e907cSAndroid Build Coastguard Worker     verify("-=[]{};':\"0", 0x30);
38*4d7e907cSAndroid Build Coastguard Worker }
39*4d7e907cSAndroid Build Coastguard Worker 
40*4d7e907cSAndroid Build Coastguard Worker }  // anonymous namespace
41