2021-05-10 20:08:50 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of PikoTools
|
|
|
|
* and is distributed under the (new) BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
|
|
|
* project may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "convert.h"
|
|
|
|
#include "test.h"
|
|
|
|
#include "convert/convert.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace pt
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace pt_convert_tests
|
|
|
|
{
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
|
2021-05-10 20:08:50 +02:00
|
|
|
void test_text1()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_white");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_white(0), false);
|
|
|
|
test(pt::is_white(1), false);
|
|
|
|
test(pt::is_white(9), true);
|
|
|
|
test(pt::is_white(10), true);
|
|
|
|
test(pt::is_white(30), false);
|
|
|
|
test(pt::is_white(32), true);
|
|
|
|
test(pt::is_white(40), false);
|
|
|
|
test(pt::is_white('a'), false);
|
|
|
|
test(pt::is_white(0xabcd), false);
|
|
|
|
|
|
|
|
test(pt::is_white(5, false, false), false);
|
|
|
|
test(pt::is_white(9, false, false), true);
|
|
|
|
test(pt::is_white(10, false, false), false);
|
|
|
|
test(pt::is_white(31, false, false), false);
|
|
|
|
test(pt::is_white(32, false, false), true);
|
|
|
|
test(pt::is_white('z', false, false), false);
|
|
|
|
test(pt::is_white(0xbbcc, false, false), false);
|
|
|
|
test(pt::is_white(0xffff, false, false), false);
|
|
|
|
test(pt::is_white(0x10ffff, false, false), false);
|
|
|
|
|
|
|
|
test(pt::is_white(0x000B, false, false), false);
|
|
|
|
test(pt::is_white(0x00A0, false, false), false);
|
|
|
|
test(pt::is_white(0x2001, false, false), false);
|
|
|
|
test(pt::is_white(0x2009, false, false), false);
|
|
|
|
test(pt::is_white(0xFEFF, false, false), false);
|
|
|
|
|
|
|
|
test(pt::is_white(0x000B, true, false), true);
|
|
|
|
test(pt::is_white(0x00A0, true, false), true);
|
|
|
|
test(pt::is_white(0x2001, true, false), true);
|
|
|
|
test(pt::is_white(0x2009, true, false), true);
|
|
|
|
test(pt::is_white(0xFEFF, true, false), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text2()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_digit");
|
|
|
|
|
|
|
|
int digit;
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit(0, 10, &digit), false);
|
|
|
|
test(pt::is_digit(1, 10, &digit), false);
|
|
|
|
test(pt::is_digit(10, 10, &digit), false);
|
|
|
|
test(pt::is_digit(32, 10, &digit), false);
|
|
|
|
test(pt::is_digit('z', 10, &digit), false);
|
|
|
|
test(pt::is_digit('x', 10, &digit), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('0', 2, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('1', 2, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 1);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('2', 2, &digit), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('0', 8, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('7', 8, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 7);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('8', 8, &digit), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('0', 10, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('1', 10, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 1);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('8', 10, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 8);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('9', 10, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 9);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('a', 10, &digit), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('a', 16, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0x0a);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('c', 16, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0x0c);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('f', 16, &digit), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
test(digit, 0x0f);
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_digit('g', 16, &digit), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text3()
|
|
|
|
{
|
|
|
|
reset_test_counter("skip_white");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white(""), "");
|
|
|
|
test(pt::skip_white(" "), "");
|
|
|
|
test(pt::skip_white("\n \n"), "");
|
|
|
|
test(pt::skip_white("hello world"), "hello world");
|
|
|
|
test(pt::skip_white(" hello world"), "hello world");
|
|
|
|
test(pt::skip_white(" hello world"), "hello world");
|
|
|
|
test(pt::skip_white(" hello world"), "hello world");
|
|
|
|
test(pt::skip_white(" hello world"), "hello world");
|
|
|
|
|
|
|
|
test(pt::skip_white("\n\nhello world"), "hello world");
|
|
|
|
test(pt::skip_white("\n\nhello world", true, true), "hello world");
|
|
|
|
test(pt::skip_white("\n\nhello world", true, false), "\n\nhello world");
|
|
|
|
test(pt::skip_white("\n\n \n\n \t\t\n\nhello world", true, true), "hello world");
|
|
|
|
|
|
|
|
test(pt::skip_white(L" hello world"), L"hello world");
|
|
|
|
test(pt::skip_white(L" hello world"), L"hello world");
|
|
|
|
test(pt::skip_white(L" hello world"), L"hello world");
|
|
|
|
test(pt::skip_white(L" hello world"), L"hello world");
|
|
|
|
|
|
|
|
test(pt::skip_white(L"\n\nhello world", true, true), L"hello world");
|
|
|
|
test(pt::skip_white(L"\n\nhello world", true, false), L"\n\nhello world");
|
|
|
|
test(pt::skip_white(L"\n\n \n\n \t\t\n\nhello world", true, true), L"hello world");
|
|
|
|
|
|
|
|
test(pt::skip_white(L"\x000B hello world", true, true), L"hello world");
|
|
|
|
test(pt::skip_white(L"\x000B hello world", false, true), L"\x000B hello world");
|
|
|
|
|
|
|
|
test(pt::skip_white(L"\x2029 hello world", true, true), L"hello world");
|
|
|
|
test(pt::skip_white(L"\x2029 hello world", false, true), L"\x2029 hello world");
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text4()
|
|
|
|
{
|
|
|
|
reset_test_counter("skip_white_from_back");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back(""), "");
|
|
|
|
test(pt::skip_white_from_back(" "), " ");
|
|
|
|
test(pt::skip_white_from_back("\n \n"), "\n \n");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back("hello world"), "");
|
|
|
|
test(pt::skip_white_from_back("hello world "), " ");
|
|
|
|
test(pt::skip_white_from_back("hello world "), " ");
|
|
|
|
test(pt::skip_white_from_back("hello world "), " ");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back("hello world\n\n"), "\n\n");
|
|
|
|
test(pt::skip_white_from_back("hello world\n\n", true, true), "\n\n");
|
|
|
|
test(pt::skip_white_from_back("hello world\n\n", true, false), "");
|
|
|
|
test(pt::skip_white_from_back("hello world\n\n \n\n \t\t\n\n", true, true), "\n\n \n\n \t\t\n\n");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back(L"hello world "), L" ");
|
|
|
|
test(pt::skip_white_from_back(L"hello world "), L" ");
|
|
|
|
test(pt::skip_white_from_back(L"hello world\n\n\n\t\t\t "), L"\n\n\n\t\t\t ");
|
|
|
|
test(pt::skip_white_from_back(L"hello world "), L" ");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back(L"hello world\n\n", true, true), L"\n\n");
|
|
|
|
test(pt::skip_white_from_back(L"hello world\n\n", true, false), L"");
|
|
|
|
test(pt::skip_white_from_back(L"hello world\n\n \n\n \t\t\n\n", true, true), L"\n\n \n\n \t\t\n\n");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back(L"hello world \x000B", true, true), L" \x000B");
|
|
|
|
test(pt::skip_white_from_back(L"hello world \x000B", false, true), L"");
|
2021-05-10 20:08:50 +02:00
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::skip_white_from_back(L"hello world \x2029", true, true), L" \x2029");
|
|
|
|
test(pt::skip_white_from_back(L"hello world \x2029", false, true), L"");
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text5()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_lower");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower((char)0), (char)0);
|
|
|
|
test(pt::to_lower((char)32), (char)32);
|
|
|
|
test(pt::to_lower((char)127), (char)127);
|
|
|
|
test(pt::to_lower((char)128), (char)128);
|
|
|
|
test(pt::to_lower((char)200), (char)200);
|
|
|
|
test(pt::to_lower((char)255), (char)255);
|
|
|
|
|
|
|
|
test(pt::to_lower('a'), 'a');
|
|
|
|
test(pt::to_lower('c'), 'c');
|
|
|
|
test(pt::to_lower('t'), 't');
|
|
|
|
test(pt::to_lower('z'), 'z');
|
|
|
|
test(pt::to_lower('0'), '0');
|
|
|
|
test(pt::to_lower('A'), 'a');
|
|
|
|
test(pt::to_lower('C'), 'c');
|
|
|
|
test(pt::to_lower('X'), 'x');
|
|
|
|
test(pt::to_lower('Z'), 'z');
|
|
|
|
test(pt::to_lower('@'), '@');
|
|
|
|
test(pt::to_lower('['), '[');
|
|
|
|
test(pt::to_lower('`'), '`');
|
|
|
|
test(pt::to_lower('{'), '{');
|
|
|
|
|
|
|
|
test(pt::to_lower((wchar_t)0), (wchar_t)0);
|
|
|
|
test(pt::to_lower((wchar_t)32), (wchar_t)32);
|
|
|
|
test(pt::to_lower((wchar_t)127), (wchar_t)127);
|
|
|
|
test(pt::to_lower((wchar_t)128), (wchar_t)128);
|
|
|
|
test(pt::to_lower((wchar_t)200), (wchar_t)200);
|
|
|
|
test(pt::to_lower((wchar_t)255), (wchar_t)255);
|
|
|
|
|
|
|
|
test(pt::to_lower(L'a'), L'a');
|
|
|
|
test(pt::to_lower(L't'), L't');
|
|
|
|
test(pt::to_lower(L'z'), L'z');
|
|
|
|
test(pt::to_lower(L'0'), L'0');
|
|
|
|
test(pt::to_lower(L'A'), L'a');
|
|
|
|
test(pt::to_lower(L'C'), L'c');
|
|
|
|
test(pt::to_lower(L'X'), L'x');
|
|
|
|
test(pt::to_lower(L'Z'), L'z');
|
|
|
|
test(pt::to_lower(L'@'), L'@');
|
|
|
|
test(pt::to_lower(L'['), L'[');
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text6()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_upper");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper((char)0), (char)0);
|
|
|
|
test(pt::to_upper((char)32), (char)32);
|
|
|
|
test(pt::to_upper((char)127), (char)127);
|
|
|
|
test(pt::to_upper((char)128), (char)128);
|
|
|
|
test(pt::to_upper((char)200), (char)200);
|
|
|
|
test(pt::to_upper((char)255), (char)255);
|
|
|
|
|
|
|
|
test(pt::to_upper('a'), 'A');
|
|
|
|
test(pt::to_upper('c'), 'C');
|
|
|
|
test(pt::to_upper('t'), 'T');
|
|
|
|
test(pt::to_upper('z'), 'Z');
|
|
|
|
test(pt::to_upper('0'), '0');
|
|
|
|
test(pt::to_upper('A'), 'A');
|
|
|
|
test(pt::to_upper('C'), 'C');
|
|
|
|
test(pt::to_upper('X'), 'X');
|
|
|
|
test(pt::to_upper('Z'), 'Z');
|
|
|
|
test(pt::to_upper('@'), '@');
|
|
|
|
test(pt::to_upper('['), '[');
|
|
|
|
test(pt::to_upper('`'), '`');
|
|
|
|
test(pt::to_upper('{'), '{');
|
|
|
|
|
|
|
|
test(pt::to_upper((wchar_t)0), (wchar_t)0);
|
|
|
|
test(pt::to_upper((wchar_t)32), (wchar_t)32);
|
|
|
|
test(pt::to_upper((wchar_t)127), (wchar_t)127);
|
|
|
|
test(pt::to_upper((wchar_t)128), (wchar_t)128);
|
|
|
|
test(pt::to_upper((wchar_t)200), (wchar_t)200);
|
|
|
|
test(pt::to_upper((wchar_t)255), (wchar_t)255);
|
|
|
|
|
|
|
|
test(pt::to_upper(L'a'), L'A');
|
|
|
|
test(pt::to_upper(L't'), L'T');
|
|
|
|
test(pt::to_upper(L'z'), L'Z');
|
|
|
|
test(pt::to_upper(L'0'), L'0');
|
|
|
|
test(pt::to_upper(L'A'), L'A');
|
|
|
|
test(pt::to_upper(L'C'), L'C');
|
|
|
|
test(pt::to_upper(L'X'), L'X');
|
|
|
|
test(pt::to_upper(L'Z'), L'Z');
|
|
|
|
test(pt::to_upper(L'@'), L'@');
|
|
|
|
test(pt::to_upper(L'['), L'[');
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text7()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_lower_emplace std::string");
|
|
|
|
std::string str1, str2;
|
|
|
|
|
|
|
|
str1 = "abcdefghijklm nopqrstuvwxyz";
|
|
|
|
str2 = str1;
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "A";
|
|
|
|
str2 += "a";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "B";
|
|
|
|
str2 += "b";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
str2 += "@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "0123456789";
|
|
|
|
str2 += "0123456789";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += "[];'\\!@#$%^&*()_+";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text8()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_lower_emplace std::wstring");
|
|
|
|
std::wstring str1, str2;
|
|
|
|
|
|
|
|
str1 = L"abcdefghijklm nopqrstuvwxyz";
|
|
|
|
str2 = str1;
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"A";
|
|
|
|
str2 += L"a";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"B";
|
|
|
|
str2 += L"b";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
str2 += L"@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"0123456789";
|
|
|
|
str2 += L"0123456789";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"\xabcd \xf000";
|
|
|
|
str2 += L"\xabcd \xf000";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"\x0000 \x1234";
|
|
|
|
str2 += L"\x0000 \x1234";
|
|
|
|
to_lower_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text9()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_upper_emplace std::string");
|
|
|
|
std::string str1, str2;
|
|
|
|
|
|
|
|
str1 = "ABCDEFGHIJKLM NOPQRSTUVWXYZ";
|
|
|
|
str2 = str1;
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "a";
|
|
|
|
str2 += "A";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "b";
|
|
|
|
str2 += "B";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
str2 += "@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "0123456789";
|
|
|
|
str2 += "0123456789";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += "[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += "[];'\\!@#$%^&*()_+";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text10()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_upper_emplace std::wstring");
|
|
|
|
std::wstring str1, str2;
|
|
|
|
|
|
|
|
str1 = L"ABCDEFGHIJKLM NOPQRSTUVWXYZ";
|
|
|
|
str2 = str1;
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"a";
|
|
|
|
str2 += L"A";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"b";
|
|
|
|
str2 += L"B";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
str2 += L"@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"0123456789";
|
|
|
|
str2 += L"0123456789";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
|
|
|
|
str1 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
to_upper_emplace(str1);
|
|
|
|
test(str1, str2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text11()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_lower std::string");
|
|
|
|
std::string str1, str2;
|
|
|
|
|
|
|
|
str1 = "abcdefghijklm nopqrstuvwxyz";
|
|
|
|
str2 = str1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "A";
|
|
|
|
str2 += "a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "B";
|
|
|
|
str2 += "b";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
str2 += "@[`{cdefghijklmnopqrstuvwxyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "0123456789";
|
|
|
|
str2 += "0123456789";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += "[];'\\!@#$%^&*()_+";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text12()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_lower std::wstring");
|
|
|
|
std::wstring str1, str2;
|
|
|
|
|
|
|
|
str1 = L"abcdefghijklm nopqrstuvwxyz";
|
|
|
|
str2 = str1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"A";
|
|
|
|
str2 += L"a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"B";
|
|
|
|
str2 += L"b";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
str2 += L"@[`{cdefghijklmnopqrstuvwxyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"0123456789";
|
|
|
|
str2 += L"0123456789";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += L"[];'\\!@#$%^&*()_+";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_lower(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text13()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_upper std::string");
|
|
|
|
std::string str1, str2;
|
|
|
|
|
|
|
|
str1 = "ABCDEFGHIJKLM NOPQRSTUVWXYZ";
|
|
|
|
str2 = str1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "a";
|
|
|
|
str2 += "A";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "b";
|
|
|
|
str2 += "B";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
str2 += "@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "0123456789";
|
|
|
|
str2 += "0123456789";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += "[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += "[];'\\!@#$%^&*()_+";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text14()
|
|
|
|
{
|
|
|
|
reset_test_counter("to_upper std::wstring");
|
|
|
|
std::wstring str1, str2;
|
|
|
|
|
|
|
|
str1 = L"ABCDEFGHIJKLM NOPQRSTUVWXYZ";
|
|
|
|
str2 = str1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"a";
|
|
|
|
str2 += L"A";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"b";
|
|
|
|
str2 += L"B";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"@[`{cdefghijklmnopqrstuvwxyz";
|
|
|
|
str2 += L"@[`{CDEFGHIJKLMNOPQRSTUVWXYZ";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"0123456789";
|
|
|
|
str2 += L"0123456789";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 += L"[];'\\!@#$%^&*()_+";
|
|
|
|
str2 += L"[];'\\!@#$%^&*()_+";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::to_upper(str1), str2);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text15()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare const char *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare("", "") == 0, true);
|
|
|
|
test(pt::compare("a", "a") == 0, true);
|
|
|
|
test(pt::compare("abc", "abc") == 0, true);
|
|
|
|
test(pt::compare("ABC", "ABC") == 0, true);
|
|
|
|
test(pt::compare("hello world", "hello world") == 0, true);
|
|
|
|
test(pt::compare("hello world", "HELLO WORLD") > 0, true);
|
|
|
|
test(pt::compare("HELLO WORLD", "hello world") < 0, true);
|
|
|
|
test(pt::compare("HEllo WOrld", "heLLO woRLD") < 0, true);
|
|
|
|
test(pt::compare("heLLO woRLD", "HEllo WOrld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare("a", "b") < 0, true);
|
|
|
|
test(pt::compare("b", "c") < 0, true);
|
|
|
|
test(pt::compare("x", "z") < 0, true);
|
|
|
|
test(pt::compare("hello world", "xhelloworld") < 0, true);
|
|
|
|
|
|
|
|
test(pt::compare("c", "b") > 0, true);
|
|
|
|
test(pt::compare("d", "c") > 0, true);
|
|
|
|
test(pt::compare("z", "x") > 0, true);
|
|
|
|
test(pt::compare("xhello world", "helloworld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare("abc8", "abc9") < 0, true);
|
|
|
|
test(pt::compare("abc9", "abc8") > 0, true);
|
|
|
|
test(pt::compare("abc8abc", "abc9abc") < 0, true);
|
|
|
|
test(pt::compare("abc9abc", "abc8abc") > 0, true);
|
|
|
|
test(pt::compare("abc9abc", "abc8") > 0, true);
|
|
|
|
test(pt::compare("abc8abc", "abc9") < 0, true);
|
|
|
|
test(pt::compare("abc8", "abc9abc") < 0, true);
|
|
|
|
test(pt::compare("abc9", "abc8abc") > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
char foo[] = {"abc"};
|
|
|
|
char bar[] = {"abc"};
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)127;
|
|
|
|
bar[0] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)128;
|
|
|
|
bar[0] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)1;
|
|
|
|
bar[0] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)255;
|
|
|
|
bar[0] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)0;
|
|
|
|
bar[0] = (char)(unsigned char)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)0;
|
|
|
|
bar[0] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)1;
|
|
|
|
bar[0] = (char)(unsigned char)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text16()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare const wchar_t *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(L"", L"") == 0, true);
|
|
|
|
test(pt::compare(L"a", L"a") == 0, true);
|
|
|
|
test(pt::compare(L"abc", L"abc") == 0, true);
|
|
|
|
test(pt::compare(L"ABC", L"ABC") == 0, true);
|
|
|
|
test(pt::compare(L"hello world", L"hello world") == 0, true);
|
|
|
|
test(pt::compare(L"hello world", L"HELLO WORLD") > 0, true);
|
|
|
|
test(pt::compare(L"HELLO WORLD", L"hello world") < 0, true);
|
|
|
|
test(pt::compare(L"HEllo WOrld", L"heLLO woRLD") < 0, true);
|
|
|
|
test(pt::compare(L"heLLO woRLD", L"HEllo WOrld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare(L"a", L"b") < 0, true);
|
|
|
|
test(pt::compare(L"b", L"c") < 0, true);
|
|
|
|
test(pt::compare(L"x", L"z") < 0, true);
|
|
|
|
test(pt::compare(L"hello world", L"xhelloworld") < 0, true);
|
|
|
|
|
|
|
|
test(pt::compare(L"c", L"b") > 0, true);
|
|
|
|
test(pt::compare(L"d", L"c") > 0, true);
|
|
|
|
test(pt::compare(L"z", L"x") > 0, true);
|
|
|
|
test(pt::compare(L"xhello world", L"helloworld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare(L"abc8", L"abc9") < 0, true);
|
|
|
|
test(pt::compare(L"abc9", L"abc8") > 0, true);
|
|
|
|
test(pt::compare(L"abc8abc", L"abc9abc") < 0, true);
|
|
|
|
test(pt::compare(L"abc9abc", L"abc8abc") > 0, true);
|
|
|
|
test(pt::compare(L"abc9abc", L"abc8") > 0, true);
|
|
|
|
test(pt::compare(L"abc8abc", L"abc9") < 0, true);
|
|
|
|
test(pt::compare(L"abc8", L"abc9abc") < 0, true);
|
|
|
|
test(pt::compare(L"abc9", L"abc8abc") > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
wchar_t foo[] = {L"abc"};
|
|
|
|
wchar_t bar[] = {L"abc"};
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)127;
|
|
|
|
bar[0] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)128;
|
|
|
|
bar[0] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)255;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0;
|
|
|
|
bar[0] = (wchar_t)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)127;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)128;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text17()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBc";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "aBc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "xyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc1";
|
|
|
|
str2 = "abc2";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc9";
|
|
|
|
str2 = "abc8";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text18()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBc";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"aBc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"xyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc1";
|
|
|
|
str2 = L"abc2";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc9";
|
|
|
|
str2 = L"abc8";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text19()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare const char* str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
char foo[] = {"abcdef"};
|
|
|
|
char bar[] = {"abcdef"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(char) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) == 0, true);
|
|
|
|
test(pt::compare(foo, foo + len - 1, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)127;
|
|
|
|
bar[len - 1] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)128;
|
|
|
|
bar[len - 1] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)1;
|
|
|
|
bar[len - 1] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)255;
|
|
|
|
bar[len - 1] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = 'f';
|
|
|
|
bar[len - 1] = 'f';
|
|
|
|
bar[3] = 'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = 'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text20()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare const wchar_t * str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
wchar_t foo[] = {L"abcdef"};
|
|
|
|
wchar_t bar[] = {L"abcdef"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(wchar_t) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) == 0, true);
|
|
|
|
test(pt::compare(foo, foo + len - 1, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)127;
|
|
|
|
bar[len - 1] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)128;
|
|
|
|
bar[len - 1] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)255;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)0xffff;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = L'f';
|
|
|
|
bar[len - 1] = L'f';
|
|
|
|
bar[3] = L'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = L'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text21()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc const char *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc("", "") == 0, true);
|
|
|
|
test(pt::compare_nc("a", "a") == 0, true);
|
|
|
|
test(pt::compare_nc("abc", "abc") == 0, true);
|
|
|
|
test(pt::compare_nc("ABC", "ABC") == 0, true);
|
|
|
|
test(pt::compare_nc("hello world", "hello world") == 0, true);
|
|
|
|
test(pt::compare_nc("hello world", "HELLO WORLD") == 0, true);
|
|
|
|
test(pt::compare_nc("HELLO WORLD", "hello world") == 0, true);
|
|
|
|
test(pt::compare_nc("HEllo WOrld", "heLLO woRLD") == 0, true);
|
|
|
|
test(pt::compare_nc("heLLO woRLD", "HEllo WOrld")== 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc("a", "b") < 0, true);
|
|
|
|
test(pt::compare_nc("b", "c") < 0, true);
|
|
|
|
test(pt::compare_nc("x", "z") < 0, true);
|
|
|
|
test(pt::compare_nc("hello world", "xhelloworld") < 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc("c", "b") > 0, true);
|
|
|
|
test(pt::compare_nc("d", "c") > 0, true);
|
|
|
|
test(pt::compare_nc("z", "x") > 0, true);
|
|
|
|
test(pt::compare_nc("xhello world", "helloworld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc("abc8", "abc9") < 0, true);
|
|
|
|
test(pt::compare_nc("abc9", "abc8") > 0, true);
|
|
|
|
test(pt::compare_nc("abc8abc", "abc9abc") < 0, true);
|
|
|
|
test(pt::compare_nc("abc9abc", "abc8abc") > 0, true);
|
|
|
|
test(pt::compare_nc("abc9abc", "abc8") > 0, true);
|
|
|
|
test(pt::compare_nc("abc8abc", "abc9") < 0, true);
|
|
|
|
test(pt::compare_nc("abc8", "abc9abc") < 0, true);
|
|
|
|
test(pt::compare_nc("abc9", "abc8abc") > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
char foo[] = {"abc"};
|
|
|
|
char bar[] = {"abc"};
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)127;
|
|
|
|
bar[0] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)128;
|
|
|
|
bar[0] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)1;
|
|
|
|
bar[0] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)255;
|
|
|
|
bar[0] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)0;
|
|
|
|
bar[0] = (char)(unsigned char)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)0;
|
|
|
|
bar[0] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (char)(unsigned char)1;
|
|
|
|
bar[0] = (char)(unsigned char)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text22()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc const wchar_t *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(L"", L"") == 0, true);
|
|
|
|
test(pt::compare_nc(L"a", L"a") == 0, true);
|
|
|
|
test(pt::compare_nc(L"abc", L"abc") == 0, true);
|
|
|
|
test(pt::compare_nc(L"ABC", L"ABC") == 0, true);
|
|
|
|
test(pt::compare_nc(L"hello world", L"hello world") == 0, true);
|
|
|
|
test(pt::compare_nc(L"hello world", L"HELLO WORLD") == 0, true);
|
|
|
|
test(pt::compare_nc(L"HELLO WORLD", L"hello world") == 0, true);
|
|
|
|
test(pt::compare_nc(L"HEllo WOrld", L"heLLO woRLD") == 0, true);
|
|
|
|
test(pt::compare_nc(L"heLLO woRLD", L"HEllo WOrld") == 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc(L"a", L"b") < 0, true);
|
|
|
|
test(pt::compare_nc(L"b", L"c") < 0, true);
|
|
|
|
test(pt::compare_nc(L"x", L"z") < 0, true);
|
|
|
|
test(pt::compare_nc(L"hello world", L"xhelloworld") < 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc(L"c", L"b") > 0, true);
|
|
|
|
test(pt::compare_nc(L"d", L"c") > 0, true);
|
|
|
|
test(pt::compare_nc(L"z", L"x") > 0, true);
|
|
|
|
test(pt::compare_nc(L"xhello world", L"helloworld") > 0, true);
|
|
|
|
|
|
|
|
test(pt::compare_nc(L"abc8", L"abc9") < 0, true);
|
|
|
|
test(pt::compare_nc(L"abc9", L"abc8") > 0, true);
|
|
|
|
test(pt::compare_nc(L"abc8abc", L"abc9abc") < 0, true);
|
|
|
|
test(pt::compare_nc(L"abc9abc", L"abc8abc") > 0, true);
|
|
|
|
test(pt::compare_nc(L"abc9abc", L"abc8") > 0, true);
|
|
|
|
test(pt::compare_nc(L"abc8abc", L"abc9") < 0, true);
|
|
|
|
test(pt::compare_nc(L"abc8", L"abc9abc") < 0, true);
|
|
|
|
test(pt::compare_nc(L"abc9", L"abc8abc") > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
wchar_t foo[] = {L"abc"};
|
|
|
|
wchar_t bar[] = {L"abc"};
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)127;
|
|
|
|
bar[0] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)128;
|
|
|
|
bar[0] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)255;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0;
|
|
|
|
bar[0] = (wchar_t)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)0;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)1;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)127;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)128;
|
|
|
|
bar[0] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[0] = (wchar_t)0xffff;
|
|
|
|
bar[0] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text23()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBc";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "aBc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "xyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc1";
|
|
|
|
str2 = "abc2";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abc9";
|
|
|
|
str2 = "abc8";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text24()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBc";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"aBc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) == 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"abc";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"xyz";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc1";
|
|
|
|
str2 = L"abc2";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abc9";
|
|
|
|
str2 = L"abc8";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(str1, str2) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text25()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc const char* str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
char foo[] = {"abcdef"};
|
|
|
|
char bar[] = {"abcdef"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(char) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) == 0, true);
|
|
|
|
test(pt::compare_nc(foo, foo + len - 1, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)127;
|
|
|
|
bar[len - 1] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)128;
|
|
|
|
bar[len - 1] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)1;
|
|
|
|
bar[len - 1] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)255;
|
|
|
|
bar[len - 1] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = 'f';
|
|
|
|
bar[len - 1] = 'f';
|
|
|
|
bar[3] = 'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = 'Z';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_text26()
|
|
|
|
{
|
|
|
|
reset_test_counter("compare_nc const wchar_t * str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
wchar_t foo[] = {L"abcdef"};
|
|
|
|
wchar_t bar[] = {L"abcdef"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(wchar_t) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) == 0, true);
|
|
|
|
test(pt::compare_nc(foo, foo + len - 1, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)127;
|
|
|
|
bar[len - 1] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)128;
|
|
|
|
bar[len - 1] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)255;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)0xffff;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)0xffff;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = L'f';
|
|
|
|
bar[len - 1] = L'f';
|
|
|
|
bar[3] = L'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) < 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = L'Z';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::compare_nc(foo, foo + len, bar) > 0, true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text27()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal char *");
|
|
|
|
|
|
|
|
test(is_equal("", ""), true);
|
|
|
|
test(is_equal("", "abc"), false);
|
|
|
|
test(is_equal("abc", ""), false);
|
|
|
|
test(is_equal("abc", "abc"), true);
|
|
|
|
test(is_equal("aBc", "aBc"), true);
|
|
|
|
test(is_equal("aBc", "abc"), false);
|
|
|
|
test(is_equal("abc", "aBc"), false);
|
|
|
|
test(is_equal("abc", "defgh"), false);
|
|
|
|
test(is_equal("defgh", "abc"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_text28()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal wchar_t *");
|
|
|
|
|
|
|
|
test(is_equal(L"", L""), true);
|
|
|
|
test(is_equal(L"", L"abc"), false);
|
|
|
|
test(is_equal(L"abc", L""), false);
|
|
|
|
test(is_equal(L"abc", L"abc"), true);
|
|
|
|
test(is_equal(L"aBc", L"aBc"), true);
|
|
|
|
test(is_equal(L"aBc", L"abc"), false);
|
|
|
|
test(is_equal(L"abc", L"aBc"), false);
|
|
|
|
test(is_equal(L"abc", L"defgh"), false);
|
|
|
|
test(is_equal(L"defgh", L"abc"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_text29()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
|
|
|
test(is_equal(str1, str2), true);
|
|
|
|
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "xYz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xYz";
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "abcxyz";
|
|
|
|
str2 = "abc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "abcxyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyzabc";
|
|
|
|
str2 = "abc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "xyzabc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal(str1, str2), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text30()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
|
|
|
test(is_equal(str1, str2), true);
|
|
|
|
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"xYz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xYz";
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"abcxyz";
|
|
|
|
str2 = L"abc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"abcxyz";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyzabc";
|
|
|
|
str2 = L"abc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"xyzabc";
|
|
|
|
test(is_equal(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal(str1, str2), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text31()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal const char*, str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
char foo[] = {"ABCDEF"};
|
|
|
|
char bar[] = {"ABCDEF"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(char) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), true);
|
|
|
|
test(pt::is_equal(foo, foo + len - 1, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)127;
|
|
|
|
bar[len - 1] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)128;
|
|
|
|
bar[len - 1] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)1;
|
|
|
|
bar[len - 1] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)255;
|
|
|
|
bar[len - 1] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = 'f';
|
|
|
|
bar[len - 1] = 'f';
|
|
|
|
bar[3] = 'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = 'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = '1';
|
|
|
|
bar[3] = '1';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text32()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal const wchar_t*, str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
wchar_t foo[] = {L"ABCDEF"};
|
|
|
|
wchar_t bar[] = {L"ABCDEF"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(wchar_t) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), true);
|
|
|
|
test(pt::is_equal(foo, foo + len - 1, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)127;
|
|
|
|
bar[len - 1] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)128;
|
|
|
|
bar[len - 1] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)255;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = L'f';
|
|
|
|
bar[len - 1] = L'f';
|
|
|
|
bar[3] = L'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = L'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = L'1';
|
|
|
|
bar[3] = L'1';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text33()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc char *");
|
|
|
|
|
|
|
|
test(is_equal_nc("", ""), true);
|
|
|
|
test(is_equal_nc("", "abc"), false);
|
|
|
|
test(is_equal_nc("abc", ""), false);
|
|
|
|
test(is_equal_nc("abc", "abc"), true);
|
|
|
|
test(is_equal_nc("aBc", "aBc"), true);
|
|
|
|
test(is_equal_nc("aBc", "abc"), true);
|
|
|
|
test(is_equal_nc("abc", "aBc"), true);
|
|
|
|
test(is_equal_nc("abc", "defgh"), false);
|
|
|
|
test(is_equal_nc("defgh", "abc"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_text34()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc wchar_t *");
|
|
|
|
|
|
|
|
test(is_equal_nc(L"", L""), true);
|
|
|
|
test(is_equal_nc(L"", L"abc"), false);
|
|
|
|
test(is_equal_nc(L"abc", L""), false);
|
|
|
|
test(is_equal_nc(L"abc", L"abc"), true);
|
|
|
|
test(is_equal_nc(L"aBc", L"aBc"), true);
|
|
|
|
test(is_equal_nc(L"aBc", L"abc"), true);
|
|
|
|
test(is_equal_nc(L"abc", L"aBc"), true);
|
|
|
|
test(is_equal_nc(L"abc", L"defgh"), false);
|
|
|
|
test(is_equal_nc(L"defgh", L"abc"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_text35()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "xYz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str1 = "xYz";
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str1 = "abcxyz";
|
|
|
|
str2 = "abc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "abcxyz";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyzabc";
|
|
|
|
str2 = "abc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "abc";
|
|
|
|
str2 = "xyzabc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = "xyz";
|
|
|
|
str2 = "xyz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text36()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"xYz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str1 = L"xYz";
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
|
|
|
|
str1 = L"abcxyz";
|
|
|
|
str2 = L"abc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"abcxyz";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyzabc";
|
|
|
|
str2 = L"abc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"abc";
|
|
|
|
str2 = L"xyzabc";
|
|
|
|
test(is_equal_nc(str1, str2), false);
|
|
|
|
|
|
|
|
str1 = L"xyz";
|
|
|
|
str2 = L"xyz";
|
|
|
|
test(is_equal_nc(str1, str2), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text37()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc const char*, str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
char foo[] = {"ABCDEF"};
|
|
|
|
char bar[] = {"ABCDEF"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(char) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
|
|
|
test(pt::is_equal_nc(foo, foo + len - 1, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)127;
|
|
|
|
bar[len - 1] = (char)(unsigned char)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)128;
|
|
|
|
bar[len - 1] = (char)(unsigned char)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)1;
|
|
|
|
bar[len - 1] = (char)(unsigned char)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (char)(unsigned char)255;
|
|
|
|
bar[len - 1] = (char)(unsigned char)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = 'f';
|
|
|
|
bar[len - 1] = 'f';
|
|
|
|
bar[3] = 'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = 'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = '1';
|
|
|
|
bar[3] = '1';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = 'h';
|
|
|
|
bar[3] = 'H';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = 'H';
|
|
|
|
bar[3] = 'h';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text38()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_equal_nc const wchar_t*, str1_begin, str1_end, str2");
|
|
|
|
|
|
|
|
wchar_t foo[] = {L"ABCDEF"};
|
|
|
|
wchar_t bar[] = {L"ABCDEF"};
|
|
|
|
size_t len = sizeof(foo) / sizeof(wchar_t) - 1; // minus terminating zero
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
|
|
|
test(pt::is_equal_nc(foo, foo + len - 1, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)127;
|
|
|
|
bar[len - 1] = (wchar_t)128;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)128;
|
|
|
|
bar[len - 1] = (wchar_t)127;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)1;
|
|
|
|
bar[len - 1] = (wchar_t)255;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = (wchar_t)255;
|
|
|
|
bar[len - 1] = (wchar_t)1;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[len - 1] = L'f';
|
|
|
|
bar[len - 1] = L'f';
|
|
|
|
bar[3] = L'X';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
foo[3] = L'A';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = L'1';
|
|
|
|
bar[3] = L'1';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = L'h';
|
|
|
|
bar[3] = L'H';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
foo[3] = L'H';
|
|
|
|
bar[3] = L'h';
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_equal_nc(foo, foo + len, bar), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text39()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr const char *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr("", ""), true);
|
|
|
|
test(pt::is_substr("", "a"), true);
|
|
|
|
test(pt::is_substr("a", ""), false);
|
|
|
|
test(pt::is_substr("a", "a"), true);
|
|
|
|
test(pt::is_substr("a", "ab"), true);
|
|
|
|
test(pt::is_substr("abc", "abb"), false);
|
|
|
|
test(pt::is_substr("abc", "abcd"), true);
|
|
|
|
test(pt::is_substr("XYZ", "XYZabc"), true);
|
|
|
|
test(pt::is_substr("XYZ", "xYz"), false);
|
|
|
|
test(pt::is_substr("hello world", "hello world"), true);
|
|
|
|
test(pt::is_substr("hello world", "abc hello world"), false);
|
|
|
|
test(pt::is_substr("hello world", "hello worldabc"), true);
|
|
|
|
test(pt::is_substr("Hello World", "hello world"), false);
|
|
|
|
test(pt::is_substr("hello world", "Hello World"), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text40()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr const wchar_t *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(L"", L""), true);
|
|
|
|
test(pt::is_substr(L"", L"a"), true);
|
|
|
|
test(pt::is_substr(L"a", L""), false);
|
|
|
|
test(pt::is_substr(L"a", L"a"), true);
|
|
|
|
test(pt::is_substr(L"a", L"ab"), true);
|
|
|
|
test(pt::is_substr(L"abc", L"abb"), false);
|
|
|
|
test(pt::is_substr(L"abc", L"abcd"), true);
|
|
|
|
test(pt::is_substr(L"XYZ", L"XYZabc"), true);
|
|
|
|
test(pt::is_substr(L"XYZ", L"xYz"), false);
|
|
|
|
test(pt::is_substr(L"hello world", L"hello world"), true);
|
|
|
|
test(pt::is_substr(L"hello world", L"abc hello world"), false);
|
|
|
|
test(pt::is_substr(L"hello world", L"hello worldabc"), true);
|
|
|
|
test(pt::is_substr(L"Hello World", L"hello world"), false);
|
|
|
|
test(pt::is_substr(L"hello world", L"Hello World"), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text41()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "";
|
|
|
|
str2 = "a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "a";
|
|
|
|
str2 = "a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "a";
|
|
|
|
str2 = "";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcdefg";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCd";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "aBCd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCdefg";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCd";
|
|
|
|
str2 = "abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "aBCdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text42()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"";
|
|
|
|
str2 = L"a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"a";
|
|
|
|
str2 = L"a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"a";
|
|
|
|
str2 = L"";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcdefg";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCd";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"aBCd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCdefg";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCd";
|
|
|
|
str2 = L"abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"aBCdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text43()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr_nc const char *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc("", ""), true);
|
|
|
|
test(pt::is_substr_nc("", "a"), true);
|
|
|
|
test(pt::is_substr_nc("a", ""), false);
|
|
|
|
test(pt::is_substr_nc("a", "a"), true);
|
|
|
|
test(pt::is_substr_nc("a", "ab"), true);
|
|
|
|
test(pt::is_substr_nc("abc", "abb"), false);
|
|
|
|
test(pt::is_substr_nc("abc", "abcd"), true);
|
|
|
|
test(pt::is_substr_nc("XYZ", "XYZabc"), true);
|
|
|
|
test(pt::is_substr_nc("XYZ", "xYz"), true);
|
|
|
|
test(pt::is_substr_nc("hello world", "hello world"), true);
|
|
|
|
test(pt::is_substr_nc("hello world", "abc hello world"), false);
|
|
|
|
test(pt::is_substr_nc("hello world", "hello worldabc"), true);
|
|
|
|
test(pt::is_substr_nc("Hello World", "hello world"), true);
|
|
|
|
test(pt::is_substr_nc("hello world", "Hello World"), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_text44()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr_nc const wchar_t *");
|
|
|
|
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(L"", L""), true);
|
|
|
|
test(pt::is_substr_nc(L"", L"a"), true);
|
|
|
|
test(pt::is_substr_nc(L"a", L""), false);
|
|
|
|
test(pt::is_substr_nc(L"a", L"a"), true);
|
|
|
|
test(pt::is_substr_nc(L"a", L"ab"), true);
|
|
|
|
test(pt::is_substr_nc(L"abc", L"abb"), false);
|
|
|
|
test(pt::is_substr_nc(L"abc", L"abcd"), true);
|
|
|
|
test(pt::is_substr_nc(L"XYZ", L"XYZabc"), true);
|
|
|
|
test(pt::is_substr_nc(L"XYZ", L"xYz"), true);
|
|
|
|
test(pt::is_substr_nc(L"hello world", L"hello world"), true);
|
|
|
|
test(pt::is_substr_nc(L"hello world", L"abc hello world"), false);
|
|
|
|
test(pt::is_substr_nc(L"hello world", L"hello worldabc"), true);
|
|
|
|
test(pt::is_substr_nc(L"Hello World", L"hello world"), true);
|
|
|
|
test(pt::is_substr_nc(L"hello world", L"Hello World"), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text45()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr_nc std::string");
|
|
|
|
|
|
|
|
std::string str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "";
|
|
|
|
str2 = "a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "a";
|
|
|
|
str2 = "a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "a";
|
|
|
|
str2 = "";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcdefg";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCd";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "aBCd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCdefg";
|
|
|
|
str2 = "abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "aBCd";
|
|
|
|
str2 = "abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = "abcd";
|
|
|
|
str2 = "aBCdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_text46()
|
|
|
|
{
|
|
|
|
reset_test_counter("is_substr_nc std::wstring");
|
|
|
|
|
|
|
|
std::wstring str1, str2;
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"";
|
|
|
|
str2 = L"a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"a";
|
|
|
|
str2 = L"a";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"a";
|
|
|
|
str2 = L"";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcdefg";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCd";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"aBCd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCdefg";
|
|
|
|
str2 = L"abcd";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), false);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"aBCd";
|
|
|
|
str2 = L"abcdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
|
|
|
|
str1 = L"abcd";
|
|
|
|
str2 = L"aBCdefg";
|
2021-05-20 16:11:12 +02:00
|
|
|
test(pt::is_substr_nc(str1, str2), true);
|
2021-05-10 20:08:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void make_tests()
|
|
|
|
{
|
|
|
|
test_text1();
|
|
|
|
test_text2();
|
|
|
|
test_text3();
|
|
|
|
test_text4();
|
|
|
|
test_text5();
|
|
|
|
test_text6();
|
|
|
|
test_text7();
|
|
|
|
test_text8();
|
|
|
|
test_text9();
|
|
|
|
test_text10();
|
|
|
|
test_text11();
|
|
|
|
test_text12();
|
|
|
|
test_text13();
|
|
|
|
test_text14();
|
|
|
|
test_text15();
|
|
|
|
test_text16();
|
|
|
|
test_text17();
|
|
|
|
test_text18();
|
|
|
|
test_text19();
|
|
|
|
test_text20();
|
|
|
|
test_text21();
|
|
|
|
test_text22();
|
|
|
|
test_text23();
|
|
|
|
test_text24();
|
|
|
|
test_text25();
|
|
|
|
test_text26();
|
|
|
|
test_text27();
|
|
|
|
test_text28();
|
|
|
|
test_text29();
|
|
|
|
test_text30();
|
|
|
|
test_text31();
|
|
|
|
test_text32();
|
|
|
|
test_text33();
|
|
|
|
test_text34();
|
|
|
|
test_text35();
|
|
|
|
test_text36();
|
|
|
|
test_text37();
|
|
|
|
test_text38();
|
|
|
|
test_text39();
|
|
|
|
test_text40();
|
|
|
|
test_text41();
|
|
|
|
test_text42();
|
|
|
|
test_text43();
|
|
|
|
test_text44();
|
|
|
|
test_text45();
|
|
|
|
test_text46();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|