Skip to content

Commit

Permalink
Fix -Wconversion warnings in tests when -funsigned-char option is used.
Browse files Browse the repository at this point in the history
This change affects only tests.
  • Loading branch information
nemtrif committed Dec 24, 2022
1 parent 780bd57 commit d736c29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion extern/ftest
Submodule ftest updated 1 files
+1 −1 ftest.h
12 changes: 6 additions & 6 deletions tests/test_checked_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST(CheckedAPITests, test_next)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
const char* w = twochars;
int cp = next(w, twochars + 6);
unsigned int cp = next(w, twochars + 6);
EXPECT_EQ (cp, 0x65e5);
EXPECT_EQ (w, twochars + 3);

Expand All @@ -67,15 +67,15 @@ TEST(CheckedAPITests, test_next)
TEST(CheckedAPITests, test_peek_next)
{
const char* const cw = "\xe6\x97\xa5\xd1\x88";
int cp = peek_next(cw, cw + 6);
unsigned int cp = peek_next(cw, cw + 6);
EXPECT_EQ (cp, 0x65e5);
}

TEST(CheckedAPITests, test_prior)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
const char* w = twochars + 3;
int cp = prior (w, twochars);
unsigned int cp = prior (w, twochars);
EXPECT_EQ (cp, 0x65e5);
EXPECT_EQ (w, twochars);

Expand Down Expand Up @@ -111,13 +111,13 @@ TEST(CheckedAPITests, test_advance)
TEST(CheckedAPITests, test_distance)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
size_t dist = utf8::distance(twochars, twochars + 5);
size_t dist = static_cast<size_t>(utf8::distance(twochars, twochars + 5));
EXPECT_EQ (dist, 2);
}

TEST(CheckedAPITests, test_utf32to8)
{
int utf32string[] = {0x448, 0x65E5, 0x10346, 0};
unsigned int utf32string[] = {0x448, 0x65E5, 0x10346, 0};
string utf8result;
utf32to8(utf32string, utf32string + 3, back_inserter(utf8result));
EXPECT_EQ (utf8result.size(), 9);
Expand All @@ -126,7 +126,7 @@ TEST(CheckedAPITests, test_utf32to8)
TEST(CheckedAPITests, test_utf8to32)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
vector<int> utf32result;
vector<unsigned int> utf32result;
utf8to32(twochars, twochars + 5, back_inserter(utf32result));
EXPECT_EQ (utf32result.size(), 2);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/test_unchecked_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEST(UnCheckedAPITests, test_next)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
const char* w = twochars;
int cp = utf8::unchecked::next(w);
unsigned int cp = utf8::unchecked::next(w);
EXPECT_EQ (cp, 0x65e5);
EXPECT_EQ (w, twochars + 3);

Expand All @@ -65,15 +65,15 @@ TEST(UnCheckedAPITests, test_next)
TEST(UnCheckedAPITests, test_peek_next)
{
const char* const cw = "\xe6\x97\xa5\xd1\x88";
int cp = peek_next(cw);
unsigned int cp = peek_next(cw);
EXPECT_EQ (cp, 0x65e5);
}

TEST(UnCheckedAPITests, test_prior)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
const char* w = twochars + 3;
int cp = prior (w);
unsigned int cp = prior (w);
EXPECT_EQ (cp, 0x65e5);
EXPECT_EQ (w, twochars);

Expand Down Expand Up @@ -109,13 +109,13 @@ TEST(UnCheckedAPITests, test_advance)
TEST(UnCheckedAPITests, test_distance)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
size_t dist = utf8::unchecked::distance(twochars, twochars + 5);
size_t dist = static_cast<size_t>(utf8::unchecked::distance(twochars, twochars + 5));
EXPECT_EQ (dist, 2);
}

TEST(UnCheckedAPITests, test_utf32to8)
{
int utf32string[] = {0x448, 0x65E5, 0x10346, 0};
unsigned int utf32string[] = {0x448, 0x65E5, 0x10346, 0};
string utf8result;
utf32to8(utf32string, utf32string + 3, back_inserter(utf8result));
EXPECT_EQ (utf8result.size(), 9);
Expand All @@ -124,7 +124,7 @@ TEST(UnCheckedAPITests, test_utf32to8)
TEST(UnCheckedAPITests, test_utf8to32)
{
const char* twochars = "\xe6\x97\xa5\xd1\x88";
vector<int> utf32result;
vector<unsigned int> utf32result;
utf8to32(twochars, twochars + 5, back_inserter(utf32result));
EXPECT_EQ (utf32result.size(), 2);
}
Expand Down

0 comments on commit d736c29

Please sign in to comment.