2015-09-29 13:40:12 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Martin Storsjo
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include <stdio.h>
|
2019-01-28 12:08:27 +01:00
|
|
|
#include <locale.h>
|
2020-03-18 18:44:41 +01:00
|
|
|
#include <mbctype.h>
|
|
|
|
#include <mbstring.h>
|
2015-09-29 13:40:12 +02:00
|
|
|
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
2017-11-08 10:26:16 +01:00
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
|
|
|
expect_ ## func = TRUE
|
|
|
|
|
|
|
|
#define CHECK_EXPECT2(func) \
|
|
|
|
do { \
|
2017-11-26 12:49:36 +01:00
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
2017-11-08 10:26:16 +01:00
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
|
|
|
do { \
|
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
|
|
|
do { \
|
2017-11-26 12:49:36 +01:00
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
2017-11-08 10:26:16 +01:00
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
DEFINE_EXPECT(invalid_parameter_handler);
|
|
|
|
|
|
|
|
static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
|
|
|
|
const wchar_t *function, const wchar_t *file,
|
|
|
|
unsigned line, uintptr_t arg)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(invalid_parameter_handler);
|
|
|
|
ok(expression == NULL, "expression is not NULL\n");
|
|
|
|
ok(function == NULL, "function is not NULL\n");
|
|
|
|
ok(file == NULL, "file is not NULL\n");
|
|
|
|
ok(line == 0, "line = %u\n", line);
|
|
|
|
ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
|
|
|
|
}
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
_ACRTIMP int __cdecl _o_tolower(int);
|
|
|
|
_ACRTIMP int __cdecl _o_toupper(int);
|
2015-09-29 13:40:12 +02:00
|
|
|
|
|
|
|
static BOOL local_isnan(double d)
|
|
|
|
{
|
|
|
|
return d != d;
|
|
|
|
}
|
|
|
|
|
2019-12-30 13:23:47 +01:00
|
|
|
#define test_strtod_str(string, value, length) _test_strtod_str(__LINE__, string, value, length, FALSE)
|
|
|
|
#define test_strtod_str_todo(string, value, length) _test_strtod_str(__LINE__, string, value, length, TRUE)
|
|
|
|
static void _test_strtod_str(int line, const char* string, double value, int length, BOOL todo)
|
2015-09-29 13:40:12 +02:00
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
double d;
|
2020-03-18 18:44:41 +01:00
|
|
|
d = strtod(string, &end);
|
2019-12-30 13:23:47 +01:00
|
|
|
todo_wine_if(todo) {
|
|
|
|
if (local_isnan(value))
|
|
|
|
ok_(__FILE__, line)(local_isnan(d), "d = %.16le (\"%s\")\n", d, string);
|
|
|
|
else
|
|
|
|
ok_(__FILE__, line)(d == value, "d = %.16le (\"%s\")\n", d, string);
|
|
|
|
}
|
2015-09-29 13:40:12 +02:00
|
|
|
ok_(__FILE__, line)(end == string + length, "incorrect end (%d, \"%s\")\n", (int)(end - string), string);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_strtod(void)
|
|
|
|
{
|
|
|
|
test_strtod_str("infinity", INFINITY, 8);
|
|
|
|
test_strtod_str("INFINITY", INFINITY, 8);
|
|
|
|
test_strtod_str("InFiNiTy", INFINITY, 8);
|
|
|
|
test_strtod_str("INF", INFINITY, 3);
|
|
|
|
test_strtod_str("-inf", -INFINITY, 4);
|
|
|
|
test_strtod_str("inf42", INFINITY, 3);
|
|
|
|
test_strtod_str("inffoo", INFINITY, 3);
|
|
|
|
test_strtod_str("infini", INFINITY, 3);
|
2020-01-07 15:35:52 +01:00
|
|
|
test_strtod_str("input", 0, 0);
|
|
|
|
test_strtod_str("-input", 0, 0);
|
2015-09-29 13:40:12 +02:00
|
|
|
|
|
|
|
test_strtod_str("NAN", NAN, 3);
|
|
|
|
test_strtod_str("nan", NAN, 3);
|
|
|
|
test_strtod_str("NaN", NAN, 3);
|
|
|
|
|
|
|
|
test_strtod_str("0x42", 66, 4);
|
|
|
|
test_strtod_str("0X42", 66, 4);
|
|
|
|
test_strtod_str("-0x42", -66, 5);
|
|
|
|
test_strtod_str("0x1p1", 2, 5);
|
|
|
|
test_strtod_str("0x1P1", 2, 5);
|
|
|
|
test_strtod_str("0x1p+1", 2, 6);
|
|
|
|
test_strtod_str("0x2p-1", 1, 6);
|
|
|
|
test_strtod_str("0xA", 10, 3);
|
|
|
|
test_strtod_str("0xa", 10, 3);
|
|
|
|
test_strtod_str("0xABCDEF", 11259375, 8);
|
|
|
|
test_strtod_str("0Xabcdef", 11259375, 8);
|
|
|
|
|
|
|
|
test_strtod_str("0x1.1", 1.0625, 5);
|
|
|
|
test_strtod_str("0x1.1p1", 2.125, 7);
|
|
|
|
test_strtod_str("0x1.A", 1.625, 5);
|
|
|
|
test_strtod_str("0x1p1a", 2, 5);
|
2019-11-22 16:41:30 +01:00
|
|
|
test_strtod_str("0xp3", 0, 1);
|
|
|
|
test_strtod_str("0x.", 0, 1);
|
|
|
|
test_strtod_str("0x.8", 0.5, 4);
|
|
|
|
test_strtod_str("0x.8p", 0.5, 4);
|
|
|
|
test_strtod_str("0x0p10000000000000000000000000", 0, 30);
|
|
|
|
test_strtod_str("0x1p-1026", 1.3906711615670009e-309, 9);
|
|
|
|
|
|
|
|
test_strtod_str("0x1ffffffffffffe.80000000000000000000", 9007199254740990.0, 37);
|
|
|
|
test_strtod_str("0x1ffffffffffffe.80000000000000000001", 9007199254740991.0, 37);
|
|
|
|
test_strtod_str("0x1fffffffffffff.80000000000000000000", 9007199254740992.0, 37);
|
|
|
|
test_strtod_str("0x1fffffffffffff.80000000000000000001", 9007199254740992.0, 37);
|
2019-12-30 13:23:47 +01:00
|
|
|
|
|
|
|
test_strtod_str("4.0621786324484881721115322e-53", 4.0621786324484881721115322e-53, 31);
|
|
|
|
test_strtod_str_todo("1.8905590910042396899370942", 1.8905590910042396899370942, 27);
|
|
|
|
test_strtod_str("2.2250738585072014e-308", 2.2250738585072014e-308, 23);
|
|
|
|
test_strtod_str("4.9406564584124654e-324", 4.9406564584124654e-324, 23);
|
2015-09-29 13:40:12 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 10:26:16 +01:00
|
|
|
static void test__memicmp(void)
|
|
|
|
{
|
|
|
|
static const char *s1 = "abc";
|
|
|
|
static const char *s2 = "aBd";
|
|
|
|
int ret;
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(NULL, NULL, 0);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(NULL, NULL, 1);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(s1, NULL, 1);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(NULL, s2, 1);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(s1, s2, 2);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp(s1, s2, 3);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == -1, "got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test__memicmp_l(void)
|
|
|
|
{
|
|
|
|
static const char *s1 = "abc";
|
|
|
|
static const char *s2 = "aBd";
|
|
|
|
int ret;
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(NULL, NULL, 0, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(NULL, NULL, 1, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(s1, NULL, 1, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(NULL, s2, 1, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == _NLSCMPERROR, "got %d\n", ret);
|
2020-03-12 17:21:24 +01:00
|
|
|
ok(errno == EINVAL, "Unexpected errno = %d\n", errno);
|
2017-11-08 10:26:16 +01:00
|
|
|
CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(s1, s2, 2, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _memicmp_l(s1, s2, 3, NULL);
|
2017-11-08 10:26:16 +01:00
|
|
|
ok(ret == -1, "got %d\n", ret);
|
|
|
|
}
|
2018-10-30 14:01:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
static void test___strncnt(void)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
size_t size;
|
|
|
|
size_t ret;
|
|
|
|
}
|
|
|
|
strncnt_tests[] =
|
|
|
|
{
|
|
|
|
{ "a", 0, 0 },
|
|
|
|
{ "a", 1, 1 },
|
|
|
|
{ "a", 10, 1 },
|
|
|
|
{ "abc", 1, 1 },
|
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
size_t ret;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(strncnt_tests); ++i)
|
|
|
|
{
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = __strncnt(strncnt_tests[i].str, strncnt_tests[i].size);
|
2018-10-30 14:01:09 +01:00
|
|
|
ok(ret == strncnt_tests[i].ret, "%u: unexpected return value %u.\n", i, (int)ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0) /* crashes */
|
|
|
|
{
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = __strncnt(NULL, 0);
|
|
|
|
ret = __strncnt(NULL, 1);
|
2018-10-30 14:01:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 12:08:27 +01:00
|
|
|
static void test_C_locale(void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
wint_t ret, exp;
|
|
|
|
_locale_t locale;
|
|
|
|
static const char *locales[] = { NULL, "C" };
|
|
|
|
|
|
|
|
/* C locale only converts case for [a-zA-Z] */
|
2020-03-18 18:44:41 +01:00
|
|
|
setlocale(LC_ALL, "C");
|
2019-01-28 12:08:27 +01:00
|
|
|
for (i = 0; i <= 0xffff; i++)
|
|
|
|
{
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = tolower(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
if (i >= 'A' && i <= 'Z')
|
|
|
|
{
|
|
|
|
exp = i + 'a' - 'A';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _tolower(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
exp = i + 'a' - 'A';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _o_tolower(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
if (i >= 'A' && i <= 'Z')
|
|
|
|
{
|
|
|
|
exp = i + 'a' - 'A';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = towlower(i);
|
2019-01-28 12:08:27 +01:00
|
|
|
if (i >= 'A' && i <= 'Z')
|
|
|
|
{
|
|
|
|
exp = i + 'a' - 'A';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = toupper(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
if (i >= 'a' && i <= 'z')
|
|
|
|
{
|
|
|
|
exp = i + 'A' - 'a';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _toupper(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
exp = i + 'A' - 'a';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _o_toupper(i);
|
2020-01-09 23:03:17 +01:00
|
|
|
if (i >= 'a' && i <= 'z')
|
|
|
|
{
|
|
|
|
exp = i + 'A' - 'a';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = towupper(i);
|
2019-01-28 12:08:27 +01:00
|
|
|
if (i >= 'a' && i <= 'z')
|
|
|
|
{
|
|
|
|
exp = i + 'A' - 'a';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == i, "expected self %x, got %x for C locale\n", i, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(locales); i++) {
|
2020-03-18 18:44:41 +01:00
|
|
|
locale = locales[i] ? _create_locale(LC_ALL, locales[i]) : NULL;
|
2019-01-28 12:08:27 +01:00
|
|
|
|
|
|
|
for (j = 0; j <= 0xffff; j++) {
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _towlower_l(j, locale);
|
2019-01-28 12:08:27 +01:00
|
|
|
if (j >= 'A' && j <= 'Z')
|
|
|
|
{
|
|
|
|
exp = j + 'a' - 'A';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _towupper_l(j, locale);
|
2019-01-28 12:08:27 +01:00
|
|
|
if (j >= 'a' && j <= 'z')
|
|
|
|
{
|
|
|
|
exp = j + 'A' - 'a';
|
|
|
|
ok(ret == exp, "expected %x, got %x for C locale\n", exp, ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok(ret == j, "expected self %x, got %x for C locale\n", j, ret);
|
|
|
|
}
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
_free_locale(locale);
|
2019-01-28 12:08:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-02 19:50:37 +02:00
|
|
|
static void test_mbsspn( void)
|
|
|
|
{
|
|
|
|
unsigned char str1[] = "cabernet";
|
|
|
|
unsigned char str2[] = "shiraz";
|
|
|
|
unsigned char set[] = "abc";
|
|
|
|
unsigned char empty[] = "";
|
|
|
|
unsigned char mbstr[] = " 2019\x94\x4e" "6\x8c\x8e" "29\x93\xfa";
|
|
|
|
unsigned char mbset1[] = "0123456789 \x94\x4e";
|
|
|
|
unsigned char mbset2[] = " \x94\x4e\x8c\x8e";
|
|
|
|
unsigned char mbset3[] = "\x8e";
|
2020-03-18 18:44:41 +01:00
|
|
|
int ret, cp = _getmbcp();
|
2019-09-02 19:50:37 +02:00
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(str1, set);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 3, "_mbsspn returns %d should be 3\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(str2, set);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 0, "_mbsspn returns %d should be 0\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(str1, empty);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 0, "_mbsspn returns %d should be 0\n", ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
_setmbcp(932);
|
|
|
|
ret = _mbsspn(mbstr, mbset1);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 8, "_mbsspn returns %d should be 8\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(mbstr, mbset2);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 1, "_mbsspn returns %d should be 1\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(mbstr+8, mbset1);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 0, "_mbsspn returns %d should be 0\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(mbstr+8, mbset2);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 2, "_mbsspn returns %d should be 2\n", ret);
|
2020-03-18 18:44:41 +01:00
|
|
|
ret = _mbsspn(mbstr, mbset3);
|
2019-09-02 19:50:37 +02:00
|
|
|
ok(ret == 14, "_mbsspn returns %d should be 14\n", ret);
|
|
|
|
|
2020-03-18 18:44:41 +01:00
|
|
|
_setmbcp(cp);
|
2019-09-02 19:50:37 +02:00
|
|
|
}
|
|
|
|
|
2020-01-24 06:51:22 +01:00
|
|
|
static void test_wcstok(void)
|
|
|
|
{
|
|
|
|
static const wchar_t *input = L"two words";
|
|
|
|
wchar_t buffer[16];
|
|
|
|
wchar_t *token;
|
|
|
|
wchar_t *next;
|
|
|
|
|
|
|
|
next = NULL;
|
|
|
|
wcscpy(buffer, input);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(buffer, L" ", &next);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!wcscmp(L"two", token), "expected \"two\", got \"%ls\"\n", token);
|
|
|
|
ok(next == token + 4, "expected %p, got %p\n", token + 4, next);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(NULL, L" ", &next);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!wcscmp(L"words", token), "expected \"words\", got \"%ls\"\n", token);
|
|
|
|
ok(next == token + 5, "expected %p, got %p\n", token + 5, next);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(NULL, L" ", &next);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!token, "expected NULL, got %p\n", token);
|
|
|
|
|
|
|
|
wcscpy(buffer, input);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(buffer, L" ", NULL);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!wcscmp(L"two", token), "expected \"two\", got \"%ls\"\n", token);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(NULL, L" ", NULL);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!wcscmp(L"words", token), "expected \"words\", got \"%ls\"\n", token);
|
2020-03-18 18:44:41 +01:00
|
|
|
token = wcstok(NULL, L" ", NULL);
|
2020-01-24 06:51:22 +01:00
|
|
|
ok(!token, "expected NULL, got %p\n", token);
|
|
|
|
}
|
|
|
|
|
2020-03-25 19:15:24 +01:00
|
|
|
static void test__strnicmp(void)
|
|
|
|
{
|
|
|
|
static const char str1[] = "TEST";
|
|
|
|
static const char str2[] = "test";
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
SET_EXPECT(invalid_parameter_handler);
|
|
|
|
errno = 0xdeadbeef;
|
|
|
|
ret = _strnicmp(str1, str2, -1);
|
|
|
|
todo_wine CHECK_CALLED(invalid_parameter_handler);
|
|
|
|
todo_wine ok(ret == _NLSCMPERROR, "got %d.\n", ret);
|
|
|
|
todo_wine ok(errno == EINVAL, "Unexpected errno %d.\n", errno);
|
|
|
|
|
|
|
|
ret = _strnicmp(str1, str2, 0x7fffffff);
|
|
|
|
ok(!ret, "got %d.\n", ret);
|
|
|
|
}
|
|
|
|
|
2015-09-29 13:40:12 +02:00
|
|
|
START_TEST(string)
|
|
|
|
{
|
2020-03-26 11:42:00 +01:00
|
|
|
ok(_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
|
|
|
|
"Invalid parameter handler was already set\n");
|
|
|
|
|
2015-09-29 13:40:12 +02:00
|
|
|
test_strtod();
|
2017-11-08 10:26:16 +01:00
|
|
|
test__memicmp();
|
|
|
|
test__memicmp_l();
|
2018-10-30 14:01:09 +01:00
|
|
|
test___strncnt();
|
2019-01-28 12:08:27 +01:00
|
|
|
test_C_locale();
|
2019-09-02 19:50:37 +02:00
|
|
|
test_mbsspn();
|
2020-01-24 06:51:22 +01:00
|
|
|
test_wcstok();
|
2020-03-25 19:15:24 +01:00
|
|
|
test__strnicmp();
|
2015-09-29 13:40:12 +02:00
|
|
|
}
|