Skip to content

Commit

Permalink
Remove inet_poem and byte_swap macros (#2168)
Browse files Browse the repository at this point in the history
- Create a new NPLB arpa_inet_test
- Delete inet_poem.h and starboard/common/byte_swap.h

b/317437129

Test-On-Device: true
  • Loading branch information
gbournou authored Jan 6, 2024
1 parent b6ceaee commit 98da637
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 117 deletions.
46 changes: 0 additions & 46 deletions starboard/client_porting/poem/inet_poem.h

This file was deleted.

1 change: 0 additions & 1 deletion starboard/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static_library("common") {
"//starboard/shared/media_session/playback_state.h",
"allocator.cc",
"allocator.h",
"byte_swap.h",
"common.cc",
"condition_variable.cc",
"condition_variable.h",
Expand Down
67 changes: 0 additions & 67 deletions starboard/common/byte_swap.h

This file was deleted.

1 change: 1 addition & 0 deletions starboard/nplb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target(gtest_target_type, "nplb") {
"//starboard/testing/fake_graphics_context_provider.h",
"accessibility_test.cc",
"align_test.cc",
"arpa_inet_test.cc",
"atomic_base_test.cc",
"atomic_test.cc",
"audio_sink_create_test.cc",
Expand Down
54 changes: 54 additions & 0 deletions starboard/nplb/arpa_inet_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2024 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if SB_API_VERSION >= 16

#include <arpa/inet.h>
#include <stdint.h>

#include "starboard/configuration.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace starboard {
namespace nplb {
namespace {

const uint16_t kTestU16 = 0xABCD;
const uint16_t kExpectedU16 = 0xCDAB;
const uint32_t kTestU32 = 0xFEDCBA98;
const uint32_t kExpectedU32 = 0x98BADCFE;

#if SB_IS(BIG_ENDIAN)
TEST(ArpaInet, BigEndian) {
EXPECT_EQ(kTestU16, htons(kTestU16));
EXPECT_EQ(kTestU16, ntohs(kTestU16));

EXPECT_EQ(kTestU32, htonl(kTestU32));
EXPECT_EQ(kTestU32, ntohl(kTestU32));
}
#else
TEST(SbByteSwapTest, LittleEndian) {
EXPECT_EQ(kExpectedU16, htons(kTestU16));
EXPECT_EQ(kExpectedU16, ntohs(kTestU16));

EXPECT_EQ(kExpectedU32, htonl(kTestU32));
EXPECT_EQ(kExpectedU32, ntohl(kTestU32));
}
#endif

} // namespace
} // namespace nplb
} // namespace starboard

#endif // SB_API_VERSION >= 16
8 changes: 5 additions & 3 deletions starboard/nplb/byte_swap_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "starboard/common/byte_swap.h"
#if SB_API_VERSION < 16

#include "starboard/byte_swap.h"

#include <iomanip>

Expand All @@ -36,7 +38,6 @@ const int64_t kTestS64 = static_cast<int64_t>(SB_INT64_C(0xFEDCBA9876543210));
const int64_t kExpectedS64 =
static_cast<int64_t>(SB_INT64_C(0x1032547698BADCFE));

#if SB_API_VERSION < 16
TEST(SbByteSwapTest, SunnyDay) {
EXPECT_EQ(kExpectedU16, SbByteSwapU16(kTestU16));
EXPECT_EQ(kExpectedS16, SbByteSwapS16(kTestS16));
Expand All @@ -47,7 +48,6 @@ TEST(SbByteSwapTest, SunnyDay) {
EXPECT_EQ(kExpectedU64, SbByteSwapU64(kTestU64));
EXPECT_EQ(kExpectedS64, SbByteSwapS64(kTestS64));
}
#endif

#if SB_IS(BIG_ENDIAN)
TEST(SbByteSwapTest, BigEndian) {
Expand Down Expand Up @@ -76,3 +76,5 @@ TEST(SbByteSwapTest, LittleEndian) {
} // namespace
} // namespace nplb
} // namespace starboard

#endif // SB_API_VERSION < 16

0 comments on commit 98da637

Please sign in to comment.