Skip to content

Commit

Permalink
Add POSIX tests
Browse files Browse the repository at this point in the history
b/316954263

Change-Id: Ib248c50b9fc3b1c1f80955ffde8e86e6b1413af9
  • Loading branch information
madhurajayaraman committed Jan 8, 2024
1 parent 39a4ee5 commit 0f8e19c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@

namespace starboard {
namespace nplb {
namespace posix_compliance {
namespace {

#if SB_API_VERSION >= 16
TEST(SbStringCompareNoCaseNPosixTest, SunnyDaySelf) {
TEST(PosixCompareNoCaseNTest, SunnyDaySelf) {
const char kString[] = "0123456789";
EXPECT_EQ(0, strncasecmp(kString, kString, strlen(kString)));
EXPECT_EQ(0, strncasecmp("", "", 0));
}

TEST(SbStringCompareNoCaseNPosixTest, SunnyDayEmptyLessThanNotEmpty) {
TEST(PosixCompareNoCaseNTest, SunnyDayEmptyLessThanNotEmpty) {
const char kString[] = "0123456789";
EXPECT_GT(0, strncasecmp("", kString, strlen(kString)));
}

TEST(SbStringCompareNoCaseNPosixTest, SunnyDayEmptyZeroNEqual) {
TEST(PosixCompareNoCaseNTest, SunnyDayEmptyZeroNEqual) {
const char kString[] = "0123456789";
EXPECT_EQ(0, strncasecmp("", kString, 0));
}

TEST(SbStringCompareNoCaseNPosixTest, SunnyDayBigN) {
TEST(PosixCompareNoCaseNTest, SunnyDayBigN) {
const char kString[] = "0123456789";
EXPECT_EQ(0, strncasecmp(kString, kString, strlen(kString) * 2));
}

TEST(SbStringCompareNoCaseNPosixTest, SunnyDayCase) {
TEST(PosixCompareNoCaseNTest, SunnyDayCase) {
const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz";
EXPECT_EQ(0, strncasecmp(kString1, kString2, strlen(kString1)));
Expand All @@ -57,5 +58,6 @@ TEST(SbStringCompareNoCaseNPosixTest, SunnyDayCase) {
#endif // SB_API_VERSION >= 16

} // namespace
} // namespace posix_compliance
} // namespace nplb
} // namespace starboard
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,29 @@

namespace starboard {
namespace nplb {
namespace posix_compliance {
namespace {

#if SB_API_VERSION >= 16
TEST(SbStringCompareNoCasePosixTest, SunnyDaySelf) {
TEST(PosixCompareNoCaseTest, SunnyDaySelf) {
const char kString[] = "0123456789";
EXPECT_EQ(0, strcasecmp(kString, kString));
EXPECT_EQ(0, strcasecmp("", ""));
}

TEST(SbStringCompareNoCasePosixTest, SunnyDayEmptyLessThanNotEmpty) {
TEST(PosixCompareNoCaseTest, SunnyDayEmptyLessThanNotEmpty) {
const char kString[] = "0123456789";
EXPECT_GT(0, strcasecmp("", kString));
}

TEST(SbStringCompareNoCasePosixTest, SunnyDayCase) {
TEST(PosixCompareNoCaseTest, SunnyDayCase) {
const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz";
EXPECT_EQ(0, strcasecmp(kString1, kString2));
EXPECT_EQ(0, strcasecmp(kString2, kString1));
}
#endif // SB_API_VERSION >= 16
} // namespace
} // namespace posix_compliance
} // namespace nplb
} // namespace starboard

0 comments on commit 0f8e19c

Please sign in to comment.