#include <algorithm>
#include <locale>
-#include <string>
#include <testsuite_hooks.h>
struct test_offsets_ok
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
for (auto t : offsets)
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, array_size (out));
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
}
== 0);
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
}
}
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
+
in[t.replace_pos] = old_char;
}
}
VERIFY (char_traits<InternT>::length (in) == 4);
VERIFY (char_traits<ExternT>::length (exp) == 10);
- const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4, 10}};
+ test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4, 10}};
for (auto t : offsets)
{
ExternT out[array_size (exp) - 1] = {};
VERIFY (char_traits<InternT>::length (in) == 4);
VERIFY (char_traits<ExternT>::length (exp) == 10);
- const test_offsets_partial offsets[] = {
+ test_offsets_partial offsets[] = {
{1, 0, 0, 0}, // no space for first CP
{2, 1, 1, 1}, // no space for second CP
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
for (auto t : offsets)
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, array_size (out));
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
}
== 0);
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
}
}
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
+
in[t.replace_pos] = old_char;
}
}
VERIFY (char_traits<InternT>::length (in) == 5);
VERIFY (char_traits<ExternT>::length (exp) == 10);
- const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5, 10}};
+ test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5, 10}};
for (auto t : offsets)
{
ExternT out[array_size (exp) - 1] = {};
VERIFY (char_traits<InternT>::length (in) == 5);
VERIFY (char_traits<ExternT>::length (exp) == 10);
- const test_offsets_partial offsets[] = {
+ test_offsets_partial offsets[] = {
{1, 0, 0, 0}, // no space for first CP
{2, 1, 1, 1}, // no space for second CP
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
for (auto t : offsets)
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, array_size (out));
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
}
== 0);
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
}
}
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
+
in[t.replace_pos] = old_char;
}
}
VERIFY (char_traits<InternT>::length (in) == 3);
VERIFY (char_traits<ExternT>::length (exp) == 6);
- const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}};
+ test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}};
for (auto t : offsets)
{
ExternT out[array_size (exp) - 1] = {};
VERIFY (char_traits<InternT>::length (in) == 3);
VERIFY (char_traits<ExternT>::length (exp) == 6);
- const test_offsets_partial offsets[] = {
+ test_offsets_partial offsets[] = {
{1, 0, 0, 0}, // no space for first CP
{2, 1, 1, 1}, // no space for second CP
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
for (auto t : offsets)
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, array_size (out));
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
}
char in[array_size (input) * 2];
InternT exp[array_size (expected)];
- auto in_iter = begin (in);
utf16_to_bytes (begin (input), end (input), begin (in), endianess);
copy (begin (expected), end (expected), begin (exp));
== 0);
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
}
}
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
+
input[t.replace_pos] = old_char;
}
}
copy (begin (input), end (input), begin (in));
utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess);
- const test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 10}};
+ test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 10}};
for (auto t : offsets)
{
char out[array_size (exp) - 2] = {};
copy (begin (input), end (input), begin (in));
utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess);
- const test_offsets_partial offsets[] = {
+ test_offsets_partial offsets[] = {
{1, 0, 0, 0}, // no space for first CP
{1, 1, 0, 0}, // no space for first CP
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
for (auto t : offsets)
VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
if (t.out_size < array_size (out))
VERIFY (out[t.out_size] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, array_size (out));
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.in_size);
}
}
char in[array_size (input) * 2];
InternT exp[array_size (expected)];
- auto in_iter = begin (in);
utf16_to_bytes (begin (input), end (input), begin (in), endianess);
copy (begin (expected), end (expected), begin (exp));
== 0);
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
}
}
if (t.expected_out_next < array_size (out))
VERIFY (out[t.expected_out_next] == 0);
+ state = {};
+ auto len = cvt.length (state, in, in + t.in_size, t.out_size);
+ VERIFY (len >= 0);
+ VERIFY (static_cast<size_t> (len) == t.expected_in_next);
+
input[t.replace_pos] = old_char;
}
}
copy (begin (input), end (input), begin (in));
utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess);
- const test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}};
+ test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}};
for (auto t : offsets)
{
char out[array_size (exp) - 2] = {};
copy (begin (input), end (input), begin (in));
utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess);
- const test_offsets_partial offsets[] = {
+ test_offsets_partial offsets[] = {
{1, 0, 0, 0}, // no space for first CP
{1, 1, 0, 0}, // no space for first CP