2
0
mirror of https://github.com/boostorg/locale.git synced 2026-01-19 04:22:08 +00:00

345 Commits

Author SHA1 Message Date
Alexander Grund
9458c4207c Add more character info to show_config 2025-11-02 14:10:43 +01:00
Alexander Grund
ac0e7d588c Add exclusions for expected uncovered lines in test_encoding 2025-11-02 14:10:16 +01:00
Alexander Grund
cd43cdcf0f Fix inefficiency in test_stream_io 2025-10-26 20:34:30 +01:00
Alexander Grund
4dfebd3152 Add checks for writing test file to test_stream_io 2025-10-26 20:33:40 +01:00
Alexander Grund
43d208375a Add context and EOF check to test_stream_io 2025-10-25 17:44:29 +02:00
Alexander Grund
d3a0eecd03 Unify subtests 2025-10-25 17:44:29 +02:00
Alexander Grund
e980689bb3 Fix output and locale name usage in test_std_convert 2025-10-25 17:44:28 +02:00
Alexander Grund
516964fbbd Simplify get_std_name 2025-10-25 17:44:28 +02:00
Alexander Grund
8be54fefd7 Fix comment of expected test output 2025-10-25 17:44:28 +02:00
Alexander Grund
a491e766b3 Enhance test output for test_encoding 2025-10-25 17:44:28 +02:00
Alexander Grund
6b54fe44be Simplify test by using std::put_money 2025-10-25 17:44:28 +02:00
Alexander Grund
3bf2339c7f Skip remaining parser test if stdlib can't do it 2025-10-25 17:44:27 +02:00
Alexander Grund
a6beef1a36 Test value only after successful parsing
Avoid subsequent failure reports if the parsing already failed
2025-10-25 17:44:27 +02:00
Alexander Grund
5170818f6d Don't use iconv directly in test
This would require linking the test executable against IConv to avoid
missing symbols.
Just use the (relatively) thin wrapper from Boost.Locale.
2025-10-24 14:48:32 +02:00
Alexander Grund
5e2fd97143 Handle Apple Iconv using WTF-8 in test
The Apple Iconv library uses WTF-8 when UTF-8 is requested and does not
return an error for invalid UTF-32 input.

Run iconv directly in test to detect this issue and adapt the expected values.
2025-10-23 16:46:35 +02:00
Alexander Grund
9e6d3d53d9 Enhance handling of (faulty) Apple Iconv in test 2025-10-23 12:31:01 +02:00
Alexander Grund
88bdae9d5d Write to std::cerr in show_config
Use unbuffered stream to get easier access to output when program crashes.
2025-07-08 19:50:10 +02:00
Alexander Grund
d56bad6d69 Add some tests for missed cases
- Date formatting for UInt64
- Error cases
- Practically unreachable cases
2025-01-16 09:11:08 +01:00
Alexander Grund
86e59b6c03 Reduce verbosity of formatting_common test 2025-01-15 13:57:44 +01:00
Alexander Grund
d03c4ed396 Fix test failure for POSIX formatting when locale is not available
Falls back to C locale where output doesn't match.
2025-01-15 13:57:44 +01:00
Alexander Grund
8019e889c4 Remove left-over condition 2025-01-15 13:57:44 +01:00
Alexander Grund
ae0da49613 Avoid corner cases with ICUs scientific format parsing
`boost::charconv::detail::parser` is not made for parsing (large)
integers in exponential notation.
It is mainly tested for parsing floating point numbers in hexadecimal format.

Given we know ICU will output either an integer string or a number in
"E notation" (1.2E2) we can convert that rather easily to a "regular"
integer string by "moving" the dot to the right according to the
exponent. The trailing gap is filled with zeros before passing it to
`from_chars` which is now able to handle the range checks for us.

This avoids overflows that can happen when multiplying the
significant by the exponent which, due to integer arithmetic, would be
cumbersome to guard against.

Any situation that could yield a fractional or a too large value can be caught early.
2025-01-15 13:57:44 +01:00
Alexander Grund
42e65d0d3d Implement support for uint64_t values in ICU backend
ICU doesn't support uint64_t directly but provides access to formatting
and parsing of decimal number strings.
Use Boost.Charconv to interface with that.

Fixes #235
2025-01-15 13:57:44 +01:00
Alexander Grund
211734c2c8 Add test for formatting large (u)int64 numbers
As reported in #235 formatting the first number which doesn't fit into
int64_t anymore fails to add the thousands separators.
I.e.:
`9223372036854775807` -> `9,223,372,036,854,775,807`
`9223372036854775808` -> `9223372036854775808`

Add a test reproducing that that for all backends.
2025-01-15 13:57:44 +01:00
Alexander Grund
5f24abe113 Fix returning false from TEST macro 2025-01-12 18:59:11 +01:00
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
ac069b6096 Fix handling of + prefix in try_to_int 2025-01-10 13:33:09 +01:00
Alexander Grund
e8f9544352 Replace some TEST_REQUIRE by if TEST 2025-01-10 13:33:08 +01:00
Alexander Grund
1abbbb3d6d Allow to check success of TEST macro at call site.
Useful if next check(s) depend on previous ones.
2025-01-10 13:33:08 +01:00
Alexander Grund
258e959402 Use Boost::charconv for try_to_int 2025-01-10 13:33:05 +01:00
Alexander Grund
b919614216 Move try_to_int to extra header 2025-01-10 13:33:03 +01:00
Alexander Grund
5a58e65bda Remove superflous subfolders of src
The shorter paths make the sources easier to navigate.

Basically revert of #99 / f44b3bb771
after the underlying issue is resolved.
2025-01-10 12:50:45 +01:00
Alexander Grund
843fdc9157 Replace (semi-)absolute includes to implementation headers by relative ones
Makes it easier to see the distinction, especially for tools.
2025-01-04 20:55:49 +01:00
Alexander Grund
ec1676280e Raise minimum ICU version to 4.8.1
A lot of checks and a major workaround are for ICU 4.8 or earlier which
can be removed.
An annoying bug (Parsing of timezones like "GMT" in "full" format followed by unrelated text)
fixed in 4.8.1 is worth avoiding by requiring this version over 4.8.0.
2024-12-27 12:14:43 +01:00
Alexander Grund
34611eadae Raise minimum ICU version to 4.2
StringPiece is only available in 4.2+ and is required for proper parsing
and formatting.
As this version is now "old enough", just assume 4.2+ removing many
conditionals.
2024-12-27 12:14:43 +01:00
Alexander Grund
d52908bb3c Refactor test_formatting
- Make spelling of "ICU" consistently uppercase (except at start of names)
- Move definitions related to existance of ICU together and sort by name
2024-12-27 12:13:10 +01:00
Alexander Grund
396ec24b58 Add support for ISO-15924 abbreviation script code to locale_data
The value is (currently) ignored but this allows to parse locale names
returned by ICU.
2024-12-03 12:19:04 +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
9f4424d7db test: Include file in error message
Also move the error reporting to a single function
2024-12-01 19:33:38 +01:00
Alexander Grund
e3b9e2eea6 Workaround missing thousand sep in some POSIX backends
The Drone CI fails because the en_US.UTF-8 `locale_t` does not have a
grouping and thousand separator so "12,345" fails to parse.
Format instead to have the expected format as input.
2024-11-12 16:16:07 +01:00
Alexander Grund
9a346dd5f8 Fix parsing of numbers in floating point format to integers
When parsing a string like "123.456" to an integer the ICU backend would
first parse it greedily to a floating point value and then cast/truncate
it to an integer.
Set the flag to only parse integers when parsing to an integral number.
Care must be taken not to set that when parsing e.g. a currency or date
to an integer where the truncation is intended.
2024-11-11 15:48:24 +01:00
Rene Rivera
9277c65aa7 Make the library modular usable. 2024-08-26 17:21:00 +02: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
René Ferdinand Rivera Morell
f7b1de5403 Don't use obsolete predef/checks/predef.jam B2 module. 2024-04-20 21:01:54 +02:00
Alexander Grund
de51c1a142 Add test that date_time handles sub-seconds
Only applies if the backend supports it so test with the mockcalendar
2024-02-28 09:56:08 +01:00