xref: /aosp_15_r20/external/openscreen/cast/streaming/message_fields_unittest.cc (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "cast/streaming/message_fields.h"
6 
7 #include <array>
8 #include <cstring>
9 #include <vector>
10 
11 #include "gtest/gtest.h"
12 
13 namespace openscreen {
14 namespace cast {
15 namespace {
16 
17 // NOTE: We don't do an exhaustive check of all values here, to avoid
18 // unnecessary duplication, but want to ensure that lookup is working properly.
TEST(MessageFieldsTest,CanParseEnumToString)19 TEST(MessageFieldsTest, CanParseEnumToString) {
20   EXPECT_STREQ("aac", CodecToString(AudioCodec::kAac));
21   EXPECT_STREQ("vp8", CodecToString(VideoCodec::kVp8));
22 }
23 
TEST(MessageFieldsTest,CanStringToEnum)24 TEST(MessageFieldsTest, CanStringToEnum) {
25   EXPECT_EQ(AudioCodec::kOpus, StringToAudioCodec("opus").value());
26   EXPECT_EQ(VideoCodec::kHevc, StringToVideoCodec("hevc").value());
27 }
28 
TEST(MessageFieldsTest,Identity)29 TEST(MessageFieldsTest, Identity) {
30   EXPECT_STREQ("opus", CodecToString(StringToAudioCodec("opus").value()));
31   EXPECT_STREQ("vp8", CodecToString(StringToVideoCodec("vp8").value()));
32 }
33 
34 }  // namespace
35 }  // namespace cast
36 }  // namespace openscreen
37