From d736c29d388694f7450bbca7da8800740de2c527 Mon Sep 17 00:00:00 2001 From: nemtrif Date: Sat, 24 Dec 2022 14:45:04 -0500 Subject: [PATCH] Fix -Wconversion warnings in tests when -funsigned-char option is used. This change affects only tests. --- extern/ftest | 2 +- tests/test_checked_api.cpp | 12 ++++++------ tests/test_unchecked_api.cpp | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/extern/ftest b/extern/ftest index bf75576..c4ad4af 160000 --- a/extern/ftest +++ b/extern/ftest @@ -1 +1 @@ -Subproject commit bf75576064fce2e07f52cd63a3e410f12358728b +Subproject commit c4ad4af0946b73ce1a40cbc72205d15d196c7e06 diff --git a/tests/test_checked_api.cpp b/tests/test_checked_api.cpp index b57e1bc..984f2be 100644 --- a/tests/test_checked_api.cpp +++ b/tests/test_checked_api.cpp @@ -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); @@ -67,7 +67,7 @@ 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); } @@ -75,7 +75,7 @@ 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); @@ -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(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); @@ -126,7 +126,7 @@ TEST(CheckedAPITests, test_utf32to8) TEST(CheckedAPITests, test_utf8to32) { const char* twochars = "\xe6\x97\xa5\xd1\x88"; - vector utf32result; + vector utf32result; utf8to32(twochars, twochars + 5, back_inserter(utf32result)); EXPECT_EQ (utf32result.size(), 2); } diff --git a/tests/test_unchecked_api.cpp b/tests/test_unchecked_api.cpp index c400ada..86826f4 100644 --- a/tests/test_unchecked_api.cpp +++ b/tests/test_unchecked_api.cpp @@ -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); @@ -65,7 +65,7 @@ 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); } @@ -73,7 +73,7 @@ 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); @@ -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(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); @@ -124,7 +124,7 @@ TEST(UnCheckedAPITests, test_utf32to8) TEST(UnCheckedAPITests, test_utf8to32) { const char* twochars = "\xe6\x97\xa5\xd1\x88"; - vector utf32result; + vector utf32result; utf8to32(twochars, twochars + 5, back_inserter(utf32result)); EXPECT_EQ (utf32result.size(), 2); }