Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package utfcpp for openSUSE:Factory checked in at 2023-01-21 19:11:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/utfcpp (Old) and /work/SRC/openSUSE:Factory/.utfcpp.new.32243 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "utfcpp" Sat Jan 21 19:11:23 2023 rev:8 rq:1060057 version:3.2.3 Changes: -------- --- /work/SRC/openSUSE:Factory/utfcpp/utfcpp.changes 2022-11-16 15:43:21.499830644 +0100 +++ /work/SRC/openSUSE:Factory/.utfcpp.new.32243/utfcpp.changes 2023-01-21 19:11:34.481303074 +0100 @@ -1,0 +2,7 @@ +Tue Jan 3 08:43:42 UTC 2023 - Dirk Müller <[email protected]> + +- update to v3.2.3: + * A minor release that includes a fix for Clang Compiler Warnings + and build system improvements + +------------------------------------------------------------------- Old: ---- utfcpp-3.2.2.tar.xz New: ---- utfcpp-3.2.3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ utfcpp.spec ++++++ --- /var/tmp/diff_new_pack.hhAxYy/_old 2023-01-21 19:11:34.909305516 +0100 +++ /var/tmp/diff_new_pack.hhAxYy/_new 2023-01-21 19:11:34.913305538 +0100 @@ -1,7 +1,7 @@ # # spec file for package utfcpp # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: utfcpp -Version: 3.2.2 +Version: 3.2.3 Release: 0 Summary: A library for handling UTF-8 encoded strings License: BSL-1.0 @@ -63,6 +63,6 @@ %{_includedir}/utf8cpp/utf8/cpp17.h %{_includedir}/utf8cpp/utf8/unchecked.h %dir %{_libdir}/cmake/utf8cpp -%{_libdir}/cmake/utf8cpp/utf8cppConfig.cmake +%{_libdir}/cmake/utf8cpp/utf8cpp*.cmake %changelog ++++++ _service ++++++ --- /var/tmp/diff_new_pack.hhAxYy/_old 2023-01-21 19:11:34.949305744 +0100 +++ /var/tmp/diff_new_pack.hhAxYy/_new 2023-01-21 19:11:34.953305767 +0100 @@ -3,7 +3,7 @@ <param name="url">https://github.com/nemtrif/utfcpp.git</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v3.2.2</param> + <param name="revision">v3.2.3</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> </service> ++++++ utfcpp-3.2.2.tar.xz -> utfcpp-3.2.3.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/CMakeLists.txt new/utfcpp-3.2.3/CMakeLists.txt --- old/utfcpp-3.2.2/CMakeLists.txt 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/CMakeLists.txt 2022-12-28 18:47:32.000000000 +0100 @@ -19,6 +19,7 @@ add_library(utf8::cpp ALIAS utf8cpp) if(UTF8_INSTALL) + include(CMakePackageConfigHelpers) if(MSVC) set(DEF_INSTALL_CMAKE_DIR CMake) else() @@ -26,10 +27,28 @@ set(DEF_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/utf8cpp) endif() + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/utf8cppConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion + ) + + configure_package_config_file( + ${PROJECT_SOURCE_DIR}/utf8cppConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/utf8cppConfig.cmake + INSTALL_DESTINATION ${DEF_INSTALL_CMAKE_DIR} + ) + install(DIRECTORY source/ DESTINATION include/utf8cpp) - install(TARGETS utf8cpp EXPORT utf8cppConfig) - install(EXPORT utf8cppConfig DESTINATION ${DEF_INSTALL_CMAKE_DIR}) - export(EXPORT utf8cppConfig) + install(TARGETS utf8cpp EXPORT utf8cppTargets) + install(EXPORT utf8cppTargets DESTINATION ${DEF_INSTALL_CMAKE_DIR}) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/utf8cppConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/utf8cppConfigVersion.cmake + DESTINATION + ${DEF_INSTALL_CMAKE_DIR} + ) endif() if(UTF8_SAMPLES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/extern/ftest/ftest.h new/utfcpp-3.2.3/extern/ftest/ftest.h --- old/utfcpp-3.2.2/extern/ftest/ftest.h 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/extern/ftest/ftest.h 2022-12-28 18:47:32.000000000 +0100 @@ -146,7 +146,7 @@ std::cout << "\n " << failed_count << " FAILED TESTS\n"; } - return failed_count; + return static_cast<int>(failed_count); } const std::vector<TestCase*>& test_cases() const { return m_test_cases; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/source/utf8/checked.h new/utfcpp-3.2.3/source/utf8/checked.h --- old/utfcpp-3.2.2/source/utf8/checked.h 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/source/utf8/checked.h 2022-12-28 18:47:32.000000000 +0100 @@ -50,6 +50,7 @@ uint8_t u8; public: invalid_utf8 (uint8_t u) : u8(u) {} + invalid_utf8 (char c) : u8(static_cast<uint8_t>(c)) {} virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; } uint8_t utf8_octet() const {return u8;} }; @@ -75,24 +76,7 @@ if (!utf8::internal::is_code_point_valid(cp)) throw invalid_code_point(cp); - if (cp < 0x80) // one octet - *(result++) = static_cast<uint8_t>(cp); - else if (cp < 0x800) { // two octets - *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else if (cp < 0x10000) { // three octets - *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else { // four octets - *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0); - *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - return result; + return internal::append(cp, result); } template <typename octet_iterator, typename output_iterator> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/source/utf8/core.h new/utfcpp-3.2.3/source/utf8/core.h --- old/utfcpp-3.2.2/source/utf8/core.h 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/source/utf8/core.h 2022-12-28 18:47:32.000000000 +0100 @@ -297,6 +297,55 @@ return utf8::internal::validate_next(it, end, ignored); } + // Internal implementation of both checked and unchecked append() function + // This function will be invoked by the overloads below, as they will know + // the octet_type. + template <typename octet_iterator, typename octet_type> + octet_iterator append(uint32_t cp, octet_iterator result) { + if (cp < 0x80) // one octet + *(result++) = static_cast<octet_type>(cp); + else if (cp < 0x800) { // two octets + *(result++) = static_cast<octet_type>((cp >> 6) | 0xc0); + *(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80); + } + else if (cp < 0x10000) { // three octets + *(result++) = static_cast<octet_type>((cp >> 12) | 0xe0); + *(result++) = static_cast<octet_type>(((cp >> 6) & 0x3f) | 0x80); + *(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80); + } + else { // four octets + *(result++) = static_cast<octet_type>((cp >> 18) | 0xf0); + *(result++) = static_cast<octet_type>(((cp >> 12) & 0x3f)| 0x80); + *(result++) = static_cast<octet_type>(((cp >> 6) & 0x3f) | 0x80); + *(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80); + } + return result; + } + + // One of the following overloads will be invoked from the API calls + + // A simple (but dangerous) case: the caller appends byte(s) to a char array + inline char* append(uint32_t cp, char* result) { + return append<char*, char>(cp, result); + } + + // Hopefully, most common case: the caller uses back_inserter + // i.e. append(cp, std::back_inserter(str)); + template<typename container_type> + std::back_insert_iterator<container_type> append + (uint32_t cp, std::back_insert_iterator<container_type> result) { + return append<std::back_insert_iterator<container_type>, + typename container_type::value_type>(cp, result); + } + + // The caller uses some other kind of output operator - not covered above + // Note that in this case we are not able to determine octet_type + // so we assume it's uint_8; that can cause a conversion warning if we are wrong. + template <typename octet_iterator> + octet_iterator append(uint32_t cp, octet_iterator result) { + return append<octet_iterator, uint8_t>(cp, result); + } + } // namespace internal /// The library API - functions intended to be called by the users diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/source/utf8/unchecked.h new/utfcpp-3.2.3/source/utf8/unchecked.h --- old/utfcpp-3.2.2/source/utf8/unchecked.h 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/source/utf8/unchecked.h 2022-12-28 18:47:32.000000000 +0100 @@ -37,24 +37,7 @@ template <typename octet_iterator> octet_iterator append(uint32_t cp, octet_iterator result) { - if (cp < 0x80) // one octet - *(result++) = static_cast<uint8_t>(cp); - else if (cp < 0x800) { // two octets - *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else if (cp < 0x10000) { // three octets - *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - else { // four octets - *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0); - *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80); - *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80); - *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80); - } - return result; + return internal::append(cp, result); } template <typename octet_iterator, typename output_iterator> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/CMakeLists.txt new/utfcpp-3.2.3/tests/CMakeLists.txt --- old/utfcpp-3.2.2/tests/CMakeLists.txt 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/tests/CMakeLists.txt 2022-12-28 18:47:32.000000000 +0100 @@ -1,17 +1,9 @@ add_executable(negative ${PROJECT_SOURCE_DIR}/tests/negative.cpp) add_executable(cpp11 ${PROJECT_SOURCE_DIR}/tests/test_cpp11.cpp) add_executable(cpp17 ${PROJECT_SOURCE_DIR}/tests/test_cpp17.cpp) -add_executable(apitests - ${PROJECT_SOURCE_DIR}/tests/test_checked_api.cpp - ${PROJECT_SOURCE_DIR}/tests/test_unchecked_api.cpp - ${PROJECT_SOURCE_DIR}/tests/test_checked_iterator.cpp - ${PROJECT_SOURCE_DIR}/tests/test_unchecked_iterator.cpp -) +add_executable(apitests ${PROJECT_SOURCE_DIR}/tests/apitests.cpp) -add_executable(noexceptionstests - ${PROJECT_SOURCE_DIR}/tests/test_unchecked_api.cpp - ${PROJECT_SOURCE_DIR}/tests/test_unchecked_iterator.cpp -) +add_executable(noexceptionstests ${PROJECT_SOURCE_DIR}/tests/noexceptionstests.cpp) target_link_libraries(negative PRIVATE utf8::cpp) target_link_libraries(cpp11 PRIVATE utf8::cpp) @@ -21,7 +13,7 @@ target_compile_options(${PROJECT_NAME} INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/W4> - $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>) + $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Wconversion>) target_compile_options(noexceptionstests PUBLIC -fno-exceptions) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/apitests.cpp new/utfcpp-3.2.3/tests/apitests.cpp --- old/utfcpp-3.2.2/tests/apitests.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/apitests.cpp 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,6 @@ +#include "../extern/ftest/ftest.h" + +#include "test_checked_api.h" +#include "test_checked_iterator.h" +#include "test_unchecked_api.h" +#include "test_unchecked_iterator.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/noexceptionstests.cpp new/utfcpp-3.2.3/tests/noexceptionstests.cpp --- old/utfcpp-3.2.2/tests/noexceptionstests.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/noexceptionstests.cpp 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,4 @@ +#include "../extern/ftest/ftest.h" + +#include "test_unchecked_api.h" +#include "test_unchecked_iterator.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_checked_api.cpp new/utfcpp-3.2.3/tests/test_checked_api.cpp --- old/utfcpp-3.2.2/tests/test_checked_api.cpp 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_checked_api.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,189 +0,0 @@ -#define F_TEST_NO_MAIN -#include "../extern/ftest/ftest.h" -#include "utf8.h" - -#include <string> -#include <vector> -using namespace utf8; -using namespace std; - - -TEST(CheckedAPITests, test_append) -{ - unsigned char u[5] = {0,0,0,0,0}; - append(0x0448, u); - EXPECT_EQ (u[0], 0xd1); - EXPECT_EQ (u[1], 0x88); - EXPECT_EQ (u[2], 0); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x65e5, u); - EXPECT_EQ (u[0], 0xe6); - EXPECT_EQ (u[1], 0x97); - EXPECT_EQ (u[2], 0xa5); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x3044, u); - EXPECT_EQ (u[0], 0xe3); - EXPECT_EQ (u[1], 0x81); - EXPECT_EQ (u[2], 0x84); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x10346, u); - EXPECT_EQ (u[0], 0xf0); - EXPECT_EQ (u[1], 0x90); - EXPECT_EQ (u[2], 0x8d); - EXPECT_EQ (u[3], 0x86); - EXPECT_EQ (u[4], 0); -} - -TEST(CheckedAPITests, test_next) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - const char* w = twochars; - int cp = next(w, twochars + 6); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, twochars + 3); - - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - w = threechars; - - cp = next(w, threechars + 9); - EXPECT_EQ (cp, 0x10346); - EXPECT_EQ (w, threechars + 4); - - cp = next(w, threechars + 9); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, threechars + 7); - - cp = next(w, threechars + 9); - EXPECT_EQ (cp, 0x0448); - EXPECT_EQ (w, threechars + 9); -} - -TEST(CheckedAPITests, test_peek_next) -{ - const char* const cw = "\xe6\x97\xa5\xd1\x88"; - 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); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, twochars); - - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - w = threechars + 9; - cp = prior(w, threechars); - EXPECT_EQ (cp, 0x0448); - EXPECT_EQ (w, threechars + 7); - cp = prior(w, threechars); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, threechars + 4); - cp = prior(w, threechars); - EXPECT_EQ (cp, 0x10346); - EXPECT_EQ (w, threechars); -} - -TEST(CheckedAPITests, test_advance) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - const char* w = threechars; - advance(w, 2, threechars + 9); - EXPECT_EQ(w, threechars + 7); - advance(w, -2, threechars); - EXPECT_EQ(w, threechars); - advance(w, 3, threechars + 9); - EXPECT_EQ(w, threechars + 9); - advance(w, -2, threechars); - EXPECT_EQ(w, threechars + 4); - advance(w, -1, threechars); - EXPECT_EQ(w, threechars); -} - -TEST(CheckedAPITests, test_distance) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - size_t dist = utf8::distance(twochars, twochars + 5); - EXPECT_EQ (dist, 2); -} - -TEST(CheckedAPITests, test_utf32to8) -{ - int utf32string[] = {0x448, 0x65E5, 0x10346, 0}; - string utf8result; - utf32to8(utf32string, utf32string + 3, back_inserter(utf8result)); - EXPECT_EQ (utf8result.size(), 9); -} - -TEST(CheckedAPITests, test_utf8to32) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - vector<int> utf32result; - utf8to32(twochars, twochars + 5, back_inserter(utf32result)); - EXPECT_EQ (utf32result.size(), 2); -} - -TEST(CheckedAPITests, test_utf16to8) -{ - unsigned short utf16string[] = {0x41, 0x0448, 0x65e5, 0xd834, 0xdd1e}; - string utf8result; - utf16to8(utf16string, utf16string + 5, back_inserter(utf8result)); - EXPECT_EQ (utf8result.size(), 10); -} - -TEST(CheckedAPITests, test_utf8to16) -{ - char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; - vector <unsigned short> utf16result; - utf8to16(utf8_with_surrogates, utf8_with_surrogates + 9, back_inserter(utf16result)); - EXPECT_EQ (utf16result.size(), 4); - EXPECT_EQ (utf16result[2], 0xd834); - EXPECT_EQ (utf16result[3], 0xdd1e); -} - -TEST(CheckedAPITests, test_replace_invalid) -{ - char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z"; - vector<char> replace_invalid_result; - replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), std::back_inserter(replace_invalid_result), '?'); - bool bvalid = is_valid(replace_invalid_result.begin(), replace_invalid_result.end()); - EXPECT_TRUE (bvalid); - const char fixed_invalid_sequence[] = "a????z"; - EXPECT_EQ (sizeof(fixed_invalid_sequence), replace_invalid_result.size()); - EXPECT_TRUE (std::equal(replace_invalid_result.begin(), replace_invalid_result.begin() + sizeof(fixed_invalid_sequence), fixed_invalid_sequence)); -} - -TEST(CheckedAPITests, test_find_invalid) -{ - char utf_invalid[] = "\xe6\x97\xa5\xd1\x88\xfa"; - char* invalid = find_invalid(utf_invalid, utf_invalid + 6); - EXPECT_EQ (invalid, utf_invalid + 5); -} - -TEST(CheckedAPITests, test_is_valid) -{ - char utf_invalid[] = "\xe6\x97\xa5\xd1\x88\xfa"; - bool bvalid = is_valid(utf_invalid, utf_invalid + 6); - EXPECT_FALSE (bvalid); - char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; - bvalid = is_valid(utf8_with_surrogates, utf8_with_surrogates + 9); - EXPECT_TRUE (bvalid); -} - -TEST(CheckedAPITests, test_starts_with_bom) -{ - unsigned char byte_order_mark[] = {0xef, 0xbb, 0xbf}; - bool bbom = starts_with_bom(byte_order_mark, byte_order_mark + sizeof(byte_order_mark)); - EXPECT_TRUE (bbom); - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - bool no_bbom = starts_with_bom(threechars, threechars + sizeof(threechars)); - EXPECT_FALSE (no_bbom); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_checked_api.h new/utfcpp-3.2.3/tests/test_checked_api.h --- old/utfcpp-3.2.2/tests/test_checked_api.h 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_checked_api.h 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,198 @@ +#ifndef UTF8_FOR_CPP_TEST_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 +#define UTF8_FOR_CPP_TEST_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 + +#include "utf8.h" + +#include <string> +#include <vector> +using namespace utf8; +using namespace std; + + +TEST(CheckedAPITests, test_append) +{ + unsigned char u[5] = {0,0,0,0,0}; + append(0x0448, u); + EXPECT_EQ (u[0], 0xd1); + EXPECT_EQ (u[1], 0x88); + EXPECT_EQ (u[2], 0); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + append(0x65e5, u); + EXPECT_EQ (u[0], 0xe6); + EXPECT_EQ (u[1], 0x97); + EXPECT_EQ (u[2], 0xa5); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + append(0x3044, u); + EXPECT_EQ (u[0], 0xe3); + EXPECT_EQ (u[1], 0x81); + EXPECT_EQ (u[2], 0x84); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + append(0x10346, u); + EXPECT_EQ (u[0], 0xf0); + EXPECT_EQ (u[1], 0x90); + EXPECT_EQ (u[2], 0x8d); + EXPECT_EQ (u[3], 0x86); + EXPECT_EQ (u[4], 0); + + // Ensure no warnings with plain char + char c[2] = {0,0}; + append('a', c); + EXPECT_EQ (c[0], 'a'); + EXPECT_EQ (c[1], 0); +} + +TEST(CheckedAPITests, test_next) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + const char* w = twochars; + unsigned int cp = next(w, twochars + 6); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, twochars + 3); + + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + w = threechars; + + cp = next(w, threechars + 9); + EXPECT_EQ (cp, 0x10346); + EXPECT_EQ (w, threechars + 4); + + cp = next(w, threechars + 9); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, threechars + 7); + + cp = next(w, threechars + 9); + EXPECT_EQ (cp, 0x0448); + EXPECT_EQ (w, threechars + 9); +} + +TEST(CheckedAPITests, test_peek_next) +{ + const char* const cw = "\xe6\x97\xa5\xd1\x88"; + 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; + unsigned int cp = prior (w, twochars); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, twochars); + + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + w = threechars + 9; + cp = prior(w, threechars); + EXPECT_EQ (cp, 0x0448); + EXPECT_EQ (w, threechars + 7); + cp = prior(w, threechars); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, threechars + 4); + cp = prior(w, threechars); + EXPECT_EQ (cp, 0x10346); + EXPECT_EQ (w, threechars); +} + +TEST(CheckedAPITests, test_advance) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + const char* w = threechars; + advance(w, 2, threechars + 9); + EXPECT_EQ(w, threechars + 7); + advance(w, -2, threechars); + EXPECT_EQ(w, threechars); + advance(w, 3, threechars + 9); + EXPECT_EQ(w, threechars + 9); + advance(w, -2, threechars); + EXPECT_EQ(w, threechars + 4); + advance(w, -1, threechars); + EXPECT_EQ(w, threechars); +} + +TEST(CheckedAPITests, test_distance) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + size_t dist = static_cast<size_t>(utf8::distance(twochars, twochars + 5)); + EXPECT_EQ (dist, 2); +} + +TEST(CheckedAPITests, test_utf32to8) +{ + unsigned int utf32string[] = {0x448, 0x65E5, 0x10346, 0}; + string utf8result; + utf32to8(utf32string, utf32string + 3, back_inserter(utf8result)); + EXPECT_EQ (utf8result.size(), 9); +} + +TEST(CheckedAPITests, test_utf8to32) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + vector<unsigned int> utf32result; + utf8to32(twochars, twochars + 5, back_inserter(utf32result)); + EXPECT_EQ (utf32result.size(), 2); +} + +TEST(CheckedAPITests, test_utf16to8) +{ + unsigned short utf16string[] = {0x41, 0x0448, 0x65e5, 0xd834, 0xdd1e}; + string utf8result; + utf16to8(utf16string, utf16string + 5, back_inserter(utf8result)); + EXPECT_EQ (utf8result.size(), 10); +} + +TEST(CheckedAPITests, test_utf8to16) +{ + char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; + vector <unsigned short> utf16result; + utf8to16(utf8_with_surrogates, utf8_with_surrogates + 9, back_inserter(utf16result)); + EXPECT_EQ (utf16result.size(), 4); + EXPECT_EQ (utf16result[2], 0xd834); + EXPECT_EQ (utf16result[3], 0xdd1e); +} + +TEST(CheckedAPITests, test_replace_invalid) +{ + char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z"; + vector<char> replace_invalid_result; + replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), std::back_inserter(replace_invalid_result), '?'); + bool bvalid = is_valid(replace_invalid_result.begin(), replace_invalid_result.end()); + EXPECT_TRUE (bvalid); + const char fixed_invalid_sequence[] = "a????z"; + EXPECT_EQ (sizeof(fixed_invalid_sequence), replace_invalid_result.size()); + EXPECT_TRUE (std::equal(replace_invalid_result.begin(), replace_invalid_result.begin() + sizeof(fixed_invalid_sequence), fixed_invalid_sequence)); +} + +TEST(CheckedAPITests, test_find_invalid) +{ + char utf_invalid[] = "\xe6\x97\xa5\xd1\x88\xfa"; + char* invalid = find_invalid(utf_invalid, utf_invalid + 6); + EXPECT_EQ (invalid, utf_invalid + 5); +} + +TEST(CheckedAPITests, test_is_valid) +{ + char utf_invalid[] = "\xe6\x97\xa5\xd1\x88\xfa"; + bool bvalid = is_valid(utf_invalid, utf_invalid + 6); + EXPECT_FALSE (bvalid); + char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; + bvalid = is_valid(utf8_with_surrogates, utf8_with_surrogates + 9); + EXPECT_TRUE (bvalid); +} + +TEST(CheckedAPITests, test_starts_with_bom) +{ + unsigned char byte_order_mark[] = {0xef, 0xbb, 0xbf}; + bool bbom = starts_with_bom(byte_order_mark, byte_order_mark + sizeof(byte_order_mark)); + EXPECT_TRUE (bbom); + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + bool no_bbom = starts_with_bom(threechars, threechars + sizeof(threechars)); + EXPECT_FALSE (no_bbom); +} + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_checked_iterator.cpp new/utfcpp-3.2.3/tests/test_checked_iterator.cpp --- old/utfcpp-3.2.2/tests/test_checked_iterator.cpp 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_checked_iterator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -#define F_TEST_NO_MAIN -#include "../extern/ftest/ftest.h" -#include "utf8.h" - -using namespace utf8; - - -TEST(CheckedIteratrTests, test_increment) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - utf8::iterator<const char*> it(threechars, threechars, threechars + 9); - utf8::iterator<const char*> it2 = it; - EXPECT_EQ (it2, it); - EXPECT_EQ (*it, 0x10346); - EXPECT_EQ (*(++it), 0x65e5); - EXPECT_EQ ((*it++), 0x65e5); - EXPECT_EQ (*it, 0x0448); - EXPECT_NE (it, it2); - utf8::iterator<const char*> endit (threechars + 9, threechars, threechars + 9); - EXPECT_EQ (++it, endit); -} - -TEST(CheckedIteratrTests, test_decrement) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - utf8::iterator<const char*> it(threechars+9, threechars, threechars + 9); - EXPECT_EQ (*(--it), 0x0448); - EXPECT_EQ ((*it--), 0x0448); - EXPECT_EQ (*it, 0x65e5); - EXPECT_EQ (--it, utf8::iterator<const char*>(threechars, threechars, threechars + 9)); - EXPECT_EQ (*it, 0x10346); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_checked_iterator.h new/utfcpp-3.2.3/tests/test_checked_iterator.h --- old/utfcpp-3.2.2/tests/test_checked_iterator.h 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_checked_iterator.h 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,35 @@ +#ifndef UTF8_FOR_CPP_TEST_CHECKED_ITERATOR_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 +#define UTF8_FOR_CPP_TEST_CHECKED_ITERATOR_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 + +#include "utf8.h" + +using namespace utf8; + + +TEST(CheckedIteratrTests, test_increment) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + utf8::iterator<const char*> it(threechars, threechars, threechars + 9); + utf8::iterator<const char*> it2 = it; + EXPECT_EQ (it2, it); + EXPECT_EQ (*it, 0x10346); + EXPECT_EQ (*(++it), 0x65e5); + EXPECT_EQ ((*it++), 0x65e5); + EXPECT_EQ (*it, 0x0448); + EXPECT_NE (it, it2); + utf8::iterator<const char*> endit (threechars + 9, threechars, threechars + 9); + EXPECT_EQ (++it, endit); +} + +TEST(CheckedIteratrTests, test_decrement) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + utf8::iterator<const char*> it(threechars+9, threechars, threechars + 9); + EXPECT_EQ (*(--it), 0x0448); + EXPECT_EQ ((*it--), 0x0448); + EXPECT_EQ (*it, 0x65e5); + EXPECT_EQ (--it, utf8::iterator<const char*>(threechars, threechars, threechars + 9)); + EXPECT_EQ (*it, 0x10346); +} + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_unchecked_api.cpp new/utfcpp-3.2.3/tests/test_unchecked_api.cpp --- old/utfcpp-3.2.2/tests/test_unchecked_api.cpp 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_unchecked_api.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,161 +0,0 @@ -#include "../extern/ftest/ftest.h" -#include "utf8/unchecked.h" - -#include <string> -#include <vector> -using namespace utf8::unchecked; -using namespace std; - -TEST(UnCheckedAPITests, test_append) -{ - unsigned char u[5] = {0,0,0,0,0}; - append(0x0448, u); - EXPECT_EQ (u[0], 0xd1); - EXPECT_EQ (u[1], 0x88); - EXPECT_EQ (u[2], 0); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x65e5, u); - EXPECT_EQ (u[0], 0xe6); - EXPECT_EQ (u[1], 0x97); - EXPECT_EQ (u[2], 0xa5); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x3044, u); - EXPECT_EQ (u[0], 0xe3); - EXPECT_EQ (u[1], 0x81); - EXPECT_EQ (u[2], 0x84); - EXPECT_EQ (u[3], 0); - EXPECT_EQ (u[4], 0); - - append(0x10346, u); - EXPECT_EQ (u[0], 0xf0); - EXPECT_EQ (u[1], 0x90); - EXPECT_EQ (u[2], 0x8d); - EXPECT_EQ (u[3], 0x86); - EXPECT_EQ (u[4], 0); -} - -TEST(UnCheckedAPITests, test_next) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - const char* w = twochars; - int cp = utf8::unchecked::next(w); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, twochars + 3); - - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - w = threechars; - - cp = utf8::unchecked::next(w); - EXPECT_EQ (cp, 0x10346); - EXPECT_EQ (w, threechars + 4); - - cp = utf8::unchecked::next(w); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, threechars + 7); - - cp = utf8::unchecked::next(w); - EXPECT_EQ (cp, 0x0448); - EXPECT_EQ (w, threechars + 9); -} - -TEST(UnCheckedAPITests, test_peek_next) -{ - const char* const cw = "\xe6\x97\xa5\xd1\x88"; - 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); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, twochars); - - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - w = threechars + 9; - cp = prior(w); - EXPECT_EQ (cp, 0x0448); - EXPECT_EQ (w, threechars + 7); - cp = prior(w); - EXPECT_EQ (cp, 0x65e5); - EXPECT_EQ (w, threechars + 4); - cp = prior(w); - EXPECT_EQ (cp, 0x10346); - EXPECT_EQ (w, threechars); -} - -TEST(UnCheckedAPITests, test_advance) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - const char* w = threechars; - utf8::unchecked::advance(w, 2); - EXPECT_EQ(w, threechars + 7); - utf8::unchecked::advance(w, -2); - EXPECT_EQ(w, threechars); - utf8::unchecked::advance(w, 3); - EXPECT_EQ(w, threechars + 9); - utf8::unchecked::advance(w, -2); - EXPECT_EQ(w, threechars + 4); - utf8::unchecked::advance(w, -1); - EXPECT_EQ(w, threechars); -} - -TEST(UnCheckedAPITests, test_distance) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - size_t dist = utf8::unchecked::distance(twochars, twochars + 5); - EXPECT_EQ (dist, 2); -} - -TEST(UnCheckedAPITests, test_utf32to8) -{ - int utf32string[] = {0x448, 0x65E5, 0x10346, 0}; - string utf8result; - utf32to8(utf32string, utf32string + 3, back_inserter(utf8result)); - EXPECT_EQ (utf8result.size(), 9); -} - -TEST(UnCheckedAPITests, test_utf8to32) -{ - const char* twochars = "\xe6\x97\xa5\xd1\x88"; - vector<int> utf32result; - utf8to32(twochars, twochars + 5, back_inserter(utf32result)); - EXPECT_EQ (utf32result.size(), 2); -} - -TEST(UnCheckedAPITests, test_utf16to8) -{ - unsigned short utf16string[] = {0x41, 0x0448, 0x65e5, 0xd834, 0xdd1e}; - string utf8result; - utf16to8(utf16string, utf16string + 5, back_inserter(utf8result)); - EXPECT_EQ (utf8result.size(), 10); -} - -TEST(UnCheckedAPITests, test_utf8to16) -{ - char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; - vector <unsigned short> utf16result; - utf8to16(utf8_with_surrogates, utf8_with_surrogates + 9, back_inserter(utf16result)); - EXPECT_EQ (utf16result.size(), 4); - EXPECT_EQ (utf16result[2], 0xd834); - EXPECT_EQ (utf16result[3], 0xdd1e); -} - -TEST(UnCheckedAPITests, test_replace_invalid) -{ - char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z"; - vector<char> replace_invalid_result; - replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), std::back_inserter(replace_invalid_result), '?'); - bool bvalid = utf8::is_valid(replace_invalid_result.begin(), replace_invalid_result.end()); - EXPECT_TRUE (bvalid); - const char fixed_invalid_sequence[] = "a????z"; - EXPECT_EQ (sizeof(fixed_invalid_sequence), replace_invalid_result.size()); - EXPECT_TRUE (std::equal(replace_invalid_result.begin(), replace_invalid_result.begin() + sizeof(fixed_invalid_sequence), fixed_invalid_sequence)); -} - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_unchecked_api.h new/utfcpp-3.2.3/tests/test_unchecked_api.h --- old/utfcpp-3.2.2/tests/test_unchecked_api.h 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_unchecked_api.h 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,164 @@ +#ifndef UTF8_FOR_CPP_TEST_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 +#define UTF8_FOR_CPP_TEST_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 + +#include "utf8/unchecked.h" + +#include <string> +#include <vector> + +using namespace std; + +TEST(UnCheckedAPITests, test_append) +{ + unsigned char u[5] = {0,0,0,0,0}; + utf8::unchecked::append(0x0448, u); + EXPECT_EQ (u[0], 0xd1); + EXPECT_EQ (u[1], 0x88); + EXPECT_EQ (u[2], 0); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + utf8::unchecked::append(0x65e5, u); + EXPECT_EQ (u[0], 0xe6); + EXPECT_EQ (u[1], 0x97); + EXPECT_EQ (u[2], 0xa5); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + utf8::unchecked::append(0x3044, u); + EXPECT_EQ (u[0], 0xe3); + EXPECT_EQ (u[1], 0x81); + EXPECT_EQ (u[2], 0x84); + EXPECT_EQ (u[3], 0); + EXPECT_EQ (u[4], 0); + + utf8::unchecked::append(0x10346, u); + EXPECT_EQ (u[0], 0xf0); + EXPECT_EQ (u[1], 0x90); + EXPECT_EQ (u[2], 0x8d); + EXPECT_EQ (u[3], 0x86); + EXPECT_EQ (u[4], 0); +} + +TEST(UnCheckedAPITests, test_next) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + const char* w = twochars; + unsigned int cp = utf8::unchecked::next(w); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, twochars + 3); + + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + w = threechars; + + cp = utf8::unchecked::next(w); + EXPECT_EQ (cp, 0x10346); + EXPECT_EQ (w, threechars + 4); + + cp = utf8::unchecked::next(w); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, threechars + 7); + + cp = utf8::unchecked::next(w); + EXPECT_EQ (cp, 0x0448); + EXPECT_EQ (w, threechars + 9); +} + +TEST(UnCheckedAPITests, test_peek_next) +{ + const char* const cw = "\xe6\x97\xa5\xd1\x88"; + unsigned int cp = utf8::unchecked::peek_next(cw); + EXPECT_EQ (cp, 0x65e5); +} + +TEST(UnCheckedAPITests, test_prior) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + const char* w = twochars + 3; + unsigned int cp = utf8::unchecked::prior (w); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, twochars); + + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + w = threechars + 9; + cp = utf8::unchecked::prior(w); + EXPECT_EQ (cp, 0x0448); + EXPECT_EQ (w, threechars + 7); + cp = utf8::unchecked::prior(w); + EXPECT_EQ (cp, 0x65e5); + EXPECT_EQ (w, threechars + 4); + cp = utf8::unchecked::prior(w); + EXPECT_EQ (cp, 0x10346); + EXPECT_EQ (w, threechars); +} + +TEST(UnCheckedAPITests, test_advance) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + const char* w = threechars; + utf8::unchecked::advance(w, 2); + EXPECT_EQ(w, threechars + 7); + utf8::unchecked::advance(w, -2); + EXPECT_EQ(w, threechars); + utf8::unchecked::advance(w, 3); + EXPECT_EQ(w, threechars + 9); + utf8::unchecked::advance(w, -2); + EXPECT_EQ(w, threechars + 4); + utf8::unchecked::advance(w, -1); + EXPECT_EQ(w, threechars); +} + +TEST(UnCheckedAPITests, test_distance) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + size_t dist = static_cast<size_t>(utf8::unchecked::distance(twochars, twochars + 5)); + EXPECT_EQ (dist, 2); +} + +TEST(UnCheckedAPITests, test_utf32to8) +{ + unsigned int utf32string[] = {0x448, 0x65E5, 0x10346, 0}; + string utf8result; + utf8::unchecked::utf32to8(utf32string, utf32string + 3, back_inserter(utf8result)); + EXPECT_EQ (utf8result.size(), 9); +} + +TEST(UnCheckedAPITests, test_utf8to32) +{ + const char* twochars = "\xe6\x97\xa5\xd1\x88"; + vector<unsigned int> utf32result; + utf8::unchecked::utf8to32(twochars, twochars + 5, back_inserter(utf32result)); + EXPECT_EQ (utf32result.size(), 2); +} + +TEST(UnCheckedAPITests, test_utf16to8) +{ + unsigned short utf16string[] = {0x41, 0x0448, 0x65e5, 0xd834, 0xdd1e}; + string utf8result; + utf8::unchecked::utf16to8(utf16string, utf16string + 5, back_inserter(utf8result)); + EXPECT_EQ (utf8result.size(), 10); +} + +TEST(UnCheckedAPITests, test_utf8to16) +{ + char utf8_with_surrogates[] = "\xe6\x97\xa5\xd1\x88\xf0\x9d\x84\x9e"; + vector <unsigned short> utf16result; + utf8::unchecked::utf8to16(utf8_with_surrogates, utf8_with_surrogates + 9, back_inserter(utf16result)); + EXPECT_EQ (utf16result.size(), 4); + EXPECT_EQ (utf16result[2], 0xd834); + EXPECT_EQ (utf16result[3], 0xdd1e); +} + +TEST(UnCheckedAPITests, test_replace_invalid) +{ + char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z"; + vector<char> replace_invalid_result; + utf8::unchecked::replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), std::back_inserter(replace_invalid_result), '?'); + bool bvalid = utf8::is_valid(replace_invalid_result.begin(), replace_invalid_result.end()); + EXPECT_TRUE (bvalid); + const char fixed_invalid_sequence[] = "a????z"; + EXPECT_EQ (sizeof(fixed_invalid_sequence), replace_invalid_result.size()); + EXPECT_TRUE (std::equal(replace_invalid_result.begin(), replace_invalid_result.begin() + sizeof(fixed_invalid_sequence), fixed_invalid_sequence)); +} + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_unchecked_iterator.cpp new/utfcpp-3.2.3/tests/test_unchecked_iterator.cpp --- old/utfcpp-3.2.2/tests/test_unchecked_iterator.cpp 2022-11-06 22:14:17.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_unchecked_iterator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,34 +0,0 @@ -#define F_TEST_NO_MAIN -#include "../extern/ftest/ftest.h" - -#include "utf8/unchecked.h" - -using namespace utf8::unchecked; - - -TEST(UnCheckedIteratrTests, test_increment) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - utf8::unchecked::iterator<const char*> it(threechars); - utf8::unchecked::iterator<const char*> it2 = it; - EXPECT_EQ (it2, it); - EXPECT_EQ (*it, 0x10346); - EXPECT_EQ (*(++it), 0x65e5); - EXPECT_EQ ((*it++), 0x65e5); - EXPECT_EQ (*it, 0x0448); - EXPECT_NE (it, it2); - utf8::unchecked::iterator<const char*> endit (threechars + 9); - EXPECT_EQ (++it, endit); -} - -TEST(UnCheckedIteratrTests, test_decrement) -{ - const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; - utf8::unchecked::iterator<const char*> it(threechars+9); - EXPECT_EQ (*(--it), 0x0448); - EXPECT_EQ ((*it--), 0x0448); - EXPECT_EQ (*it, 0x65e5); - EXPECT_EQ (--it, utf8::unchecked::iterator<const char*>(threechars)); - EXPECT_EQ (*it, 0x10346); - -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/tests/test_unchecked_iterator.h new/utfcpp-3.2.3/tests/test_unchecked_iterator.h --- old/utfcpp-3.2.2/tests/test_unchecked_iterator.h 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/tests/test_unchecked_iterator.h 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,36 @@ +#ifndef UTF8_FOR_CPP_TEST_UNCHECKED_ITERATOR_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 +#define UTF8_FOR_CPP_TEST_UNCHECKED_ITERATOR_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 + +#include "utf8/unchecked.h" + +using namespace utf8::unchecked; + + +TEST(UnCheckedIteratrTests, test_increment) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + utf8::unchecked::iterator<const char*> it(threechars); + utf8::unchecked::iterator<const char*> it2 = it; + EXPECT_EQ (it2, it); + EXPECT_EQ (*it, 0x10346); + EXPECT_EQ (*(++it), 0x65e5); + EXPECT_EQ ((*it++), 0x65e5); + EXPECT_EQ (*it, 0x0448); + EXPECT_NE (it, it2); + utf8::unchecked::iterator<const char*> endit (threechars + 9); + EXPECT_EQ (++it, endit); +} + +TEST(UnCheckedIteratrTests, test_decrement) +{ + const char* threechars = "\xf0\x90\x8d\x86\xe6\x97\xa5\xd1\x88"; + utf8::unchecked::iterator<const char*> it(threechars+9); + EXPECT_EQ (*(--it), 0x0448); + EXPECT_EQ ((*it--), 0x0448); + EXPECT_EQ (*it, 0x65e5); + EXPECT_EQ (--it, utf8::unchecked::iterator<const char*>(threechars)); + EXPECT_EQ (*it, 0x10346); + +} + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/utfcpp-3.2.2/utf8cppConfig.cmake.in new/utfcpp-3.2.3/utf8cppConfig.cmake.in --- old/utfcpp-3.2.2/utf8cppConfig.cmake.in 1970-01-01 01:00:00.000000000 +0100 +++ new/utfcpp-3.2.3/utf8cppConfig.cmake.in 2022-12-28 18:47:32.000000000 +0100 @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/utf8cppTargets.cmake") +check_required_components( "utf8cpp" ) + +add_library(utf8::cpp ALIAS utf8cpp)
