30 Commits

Author SHA1 Message Date
Alexander Grund
e540a63c0b Enable char8_t strings where available, remove Clang condition
The issue was caused by using an incompatible libstdc++.
For Clang 13 & 14 libstdc++ 11 works.
2025-01-10 13:33:10 +01:00
Alexander Grund
5a58e65bda Remove superflous subfolders of src
The shorter paths make the sources easier to navigate.

Basically revert of #99 / f44b3bb771f01fb94614260d57e1d09cdfe1cdff
after the underlying issue is resolved.
2025-01-10 12:50:45 +01:00
Alexander Grund
f0d95b079b
Add TEST_CONTEXT
Avoid to require manual output in anticipation of failures.
2024-12-01 19:36:58 +01:00
Alexander Grund
eb8a91db4d
Workaround MSVC test failures
CI shows that MSVC calls the allocator 3 times as often as expected.
This is due to some internal structures.
Hence only count char and wchar_t allocations
2024-07-05 17:57:53 +02:00
Alexander Grund
36e853653b Test: Use a single variable for the allocator tracking
Cygwin doesn't (reliably) use the actual allocator type but possibly one
obtained via `rebind` which makes all checks for e.g. `Alloc::usedId`
fail as the value stays zero.

Use a single variable in a private namespace and access it by reference.
2024-07-05 13:28:51 +02:00
Alexander Grund
730dd18aa9 Add all default typedefs to CustomAllocator
At least Cygwin seems to require those.
2024-07-04 10:14:25 +02:00
Alexander Grund
413db431aa Test: Don't derive CustomAllocator from std::allocator 2024-07-03 11:10:04 +02:00
Alexander Grund
787cc4d2e0 Allow passing an allocator without specifying the conversion method
Add overloads without the method type such that the allocator can be
directly passed.
2024-07-02 19:01:14 +02:00
Alexander Grund
7f6a22a60e Add test for allocator aware utf_to_utf 2024-07-02 19:01:14 +02:00
Alexander Grund
e65d4bb218
Avoid test failure due to known IConv issue 2024-02-11 20:33:03 +01:00
Alexander Grund
66560801a5
Add more debug info to test_encoding 2024-02-09 17:11:18 +01:00
Alexander Grund
ab989963dd Don't assume GBK/ISO-2022-CN exists for tests 2023-11-28 20:19:20 +01:00
Alexander Grund
48b65c65b7 Add assertions to IConv converter
Assert post-conditions of calling `iconv` and add test for a possible
violation of that.
2023-11-28 20:19:20 +01:00
Alexander Grund
8ec7d666cc
Add test for UTF<->GBK conversion
Test for #196, should pass, especially without crashing.
2023-10-10 11:43:04 +02:00
Alexander Grund
324a66752b Use dedicated macro to check availability of std::basic_string<char8_t>
Allow to disable for non-conforming compilers/stdlibs
2023-09-13 09:20:05 +02:00
Alexander Grund
efed993fae Check for availability of std::string<char8_t> 2023-09-12 13:18:28 +02:00
Alexander Grund
0faa3c10cc Add implementations for char8_t where available
Allows to e.g. convert `std::u8string`s, translate them and run boundary
analysis.
Formatting isn't possible due to lack of facets
(more specifically: their IDs) in the standard libraries
2023-09-12 10:07:45 +02:00
Alexander Grund
26469cd230
Suppress or handle missing coverage of test code
Try to achieve 100% test code coverage to find accidentally missed ones.
Especially the WinAPI tests had some wrongly uncovered lines at function
start/end which needed to be excluded.
2023-06-27 23:04:08 +02:00
Alexander Grund
c702d0a0b0 Fix wrong arguments of make_narrow_converter in test_encoding 2023-06-27 13:22:31 +02:00
Alexander Grund
4d1fc2ac24 Mark charset_converter visible & remove vptr-UBSAN workaround
To avoid the UBSAN failure it is enough to mark the class as VISIBLE
similar to e.g. exception types.
This allows to remove the workaround with custom deleter and
UBSAN-supression macros which makes the code more readable
2023-06-24 10:24:45 +02:00
Alexander Grund
aa4031a8c2
Add test for simple_encoding_table 2023-06-22 23:12:07 +02:00
Alexander Grund
825562182c
Use utf_to_utf when target/source encoding is known to be UTF-8
Improves speed by using static dispatch and inlining.
2023-05-29 18:36:01 +02:00
Alexander Grund
3236f80021 Supress UBSAN false positive in convert functions
Clang reports an error due to the use of an unexported (because private
implementation) class:
```
boost/locale/encoding.hpp:243:87: runtime error: member call on address 0x7fb7b7405d60 which does not point to an object of type 'boost::locale::conv::detail::charset_converter<char, char>'
0x7fb7b7405d60: note: object is of type 'boost::locale::conv::impl::iconv_to_utf<char>'
 6e 67 00 00  28 f5 b6 0c 01 00 00 00  90 5d 40 b7 b7 7f 00 00  00 00 00 00 69 6e 74 20  55 32 30 61
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'boost::locale::conv::impl::iconv_to_utf<char>'
    #0 0x10ca8c63c in boost::locale::conv::utf_encoder<char>::convert(boost::basic_string_view<char, std::__1::char_traits<char> > const&) const+0xcc (test_encoding:x86_64+0x10002063c)
```
2023-05-13 11:37:07 +02:00
Alexander Grund
ce9c2f845a Introduce converter classes as alternative to to_utf/from_utf/between
May save some overhead creating implementation classes and allows to
write shorter code for doing the same conversions repeatatly.
Also allows a hook for testing each backend individually.
2023-05-10 14:17:12 +02:00
Alexander Grund
f9a2b85ec7
Add test for boost::locale::conv::between 2023-05-09 14:18:46 +02:00
Alexander Grund
50f768125d
Include test for utf_to_utf overloads taking a std::(basic_)string 2023-05-09 14:18:45 +02:00
Alexander Grund
9fecee872a
Add test for wrong charset error in to/from_utf 2023-05-09 14:18:45 +02:00
Alexander Grund
2df3ffc0a4
Remove redundant test cases in test_encoding
No need to always test all overloads.
2023-05-09 14:18:45 +02:00
Alexander Grund
4b9f3f7f04
Refactor test_encoding.cpp
- Don't loop over backends as that is ignored by the conversion functions
- Rename functions (e.g. `test_simple_conversions` -> `test_latin1_conversions`, add `error` in `test_to/from_utf`)
- Add `test_utf_to_utf`
2023-05-09 14:18:45 +02:00
Alexander Grund
0892f4d0fa
Split test_codepage into test_stream_io & test_encoding
Especially to create a test file to test the `encoding.hpp` header (i.e. the `to_utf`, `from_utf` functions)
2023-05-09 14:18:44 +02:00