]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/detail/test/test_utf8_codecvt.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / detail / test / test_utf8_codecvt.cpp
index 8edfb0416cac3d9dde81016b6a04ee49c65efbe5..a91328589fddce70c939b2b79afb17a6829d91b6 100644 (file)
@@ -261,6 +261,18 @@ test_main(int /* argc */, char * /* argv */[]) {
         BOOST_TEST_EQ(utf8_len, res);
     }
 
+    // Test that length calculation detects character boundaries
+    {
+        std::codecvt<wchar_t, char, std::mbstate_t> const& fac = std::use_facet< std::codecvt<wchar_t, char, std::mbstate_t> >(utf8_locale);
+        std::mbstate_t mbs = std::mbstate_t();
+        // The first 5 bytes of utf8_encoding contain 3 complete UTF-8 characters (taking 4 bytes in total) and 1 byte of an incomplete character.
+        // This last byte should not be accounted by length().
+        const int input_len = 5;
+        const int utf8_len = 4;
+        int res = fac.length(mbs, reinterpret_cast< const char* >(td::utf8_encoding), reinterpret_cast< const char* >(td::utf8_encoding + input_len), ~static_cast< std::size_t >(0u));
+        BOOST_TEST_EQ(utf8_len, res);
+    }
+
     return EXIT_SUCCESS;
 }