You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// double stod(const string& str, size_t *idx = 0);
|
||||
// double stod(const wstring& str, size_t *idx = 0);
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
// char
|
||||
{
|
||||
assert(std::stod("0") == 0);
|
||||
assert(std::stod("-0") == 0);
|
||||
assert(std::stod("-10") == -10);
|
||||
assert(std::stod(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod("10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod("1.e60", &idx) == 1.e60);
|
||||
assert(idx == 5);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod("INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stod("NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stod("1.e360", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
}
|
||||
|
||||
// wchar_t
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
assert(std::stod(L"0") == 0);
|
||||
assert(std::stod(L"-0") == 0);
|
||||
assert(std::stod(L"-10.5") == -10.5);
|
||||
assert(std::stod(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod(L"10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod(L"1.e60", &idx) == 1.e60);
|
||||
assert(idx == 5);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stod(L"INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stod(L"NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stod(L"1.e360", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stod(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
}
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// float stof(const string& str, size_t *idx = 0);
|
||||
// float stof(const wstring& str, size_t *idx = 0);
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stof("0") == 0);
|
||||
assert(std::stof("-0") == 0);
|
||||
assert(std::stof("-10") == -10);
|
||||
assert(std::stof(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stof("10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stof("INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stof("NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stof("1.e60", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stof("1.e360", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stof(L"0") == 0);
|
||||
assert(std::stof(L"-0") == 0);
|
||||
assert(std::stof(L"-10.5") == -10.5);
|
||||
assert(std::stof(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stof(L"10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stof(L"INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stof(L"NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stof(L"1.e60", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stof(L"1.e360", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stof(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// int stoi(const string& str, size_t *idx = 0, int base = 10);
|
||||
// int stoi(const wstring& str, size_t *idx = 0, int base = 10);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stoi("0") == 0);
|
||||
assert(std::stoi("-0") == 0);
|
||||
assert(std::stoi("-10") == -10);
|
||||
assert(std::stoi(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoi("10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) {
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi("0x100000000", &idx, 16);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stoi(L"0") == 0);
|
||||
assert(std::stoi(L"-0") == 0);
|
||||
assert(std::stoi(L"-10") == -10);
|
||||
assert(std::stoi(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoi(L"10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) {
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi(L"0x100000000", &idx, 16);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoi(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// long stol(const string& str, size_t *idx = 0, int base = 10);
|
||||
// long stol(const wstring& str, size_t *idx = 0, int base = 10);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stol("0") == 0);
|
||||
assert(std::stol("-0") == 0);
|
||||
assert(std::stol("-10") == -10);
|
||||
assert(std::stol(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stol("10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stol("9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stol(L"0") == 0);
|
||||
assert(std::stol(L"-0") == 0);
|
||||
assert(std::stol(L"-10") == -10);
|
||||
assert(std::stol(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stol(L"10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stol(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// long double stold(const string& str, size_t *idx = 0);
|
||||
// long double stold(const wstring& str, size_t *idx = 0);
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stold("0") == 0);
|
||||
assert(std::stold("-0") == 0);
|
||||
assert(std::stold("-10") == -10);
|
||||
assert(std::stold(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold("10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold("1.e60", &idx) == 1.e60L);
|
||||
assert(idx == 5);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold("INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stold("NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stold("1.e6000", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stold(L"0") == 0);
|
||||
assert(std::stold(L"-0") == 0);
|
||||
assert(std::stold(L"-10.5") == -10.5);
|
||||
assert(std::stold(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold(L"10g", &idx) == 10);
|
||||
assert(idx == 2);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold(L"1.e60", &idx) == 1.e60L);
|
||||
assert(idx == 5);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stold(L"INF", &idx) == INFINITY);
|
||||
assert(idx == 3);
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::isnan(std::stold(L"NAN", &idx)));
|
||||
assert(idx == 3);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stold(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
assert(std::stold(L"1.e6000", &idx) == INFINITY);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// long long stoll(const string& str, size_t *idx = 0, int base = 10);
|
||||
// long long stoll(const wstring& str, size_t *idx = 0, int base = 10);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stoll("0") == 0);
|
||||
assert(std::stoll("-0") == 0);
|
||||
assert(std::stoll("-10") == -10);
|
||||
assert(std::stoll(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoll("10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoll("99999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stoll(L"0") == 0);
|
||||
assert(std::stoll(L"-0") == 0);
|
||||
assert(std::stoll(L"-10") == -10);
|
||||
assert(std::stoll(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoll(L"10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoll(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoll(L"99999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
|
||||
// unsigned long stoul(const wstring& str, size_t *idx = 0, int base = 10);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stoul("0") == 0);
|
||||
assert(std::stoul("-0") == 0);
|
||||
assert(std::stoul(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoul("10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoul("9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stoul(L"0") == 0);
|
||||
assert(std::stoul(L"-0") == 0);
|
||||
assert(std::stoul(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoul(L"10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoul(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoul(L"9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
|
||||
// unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
assert(std::stoull("0") == 0);
|
||||
assert(std::stoull("-0") == 0);
|
||||
assert(std::stoull(" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoull("10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull("", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull(" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull("a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoull("9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
assert(std::stoull(L"0") == 0);
|
||||
assert(std::stoull(L"-0") == 0);
|
||||
assert(std::stoull(L" 10") == 10);
|
||||
{
|
||||
size_t idx = 0;
|
||||
assert(std::stoull(L"10g", &idx, 16) == 16);
|
||||
assert(idx == 2);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull(L"", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull(L" - 8", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
(void)std::stoull(L"a1", &idx);
|
||||
assert(false);
|
||||
} catch (const std::invalid_argument&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
size_t idx = 0;
|
||||
try {
|
||||
// LWG#2009 and PR14919
|
||||
(void)std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
|
||||
assert(false);
|
||||
} catch (const std::out_of_range&) {
|
||||
assert(idx == 0);
|
||||
}
|
||||
}
|
||||
#endif // TEST_HAS_NO_EXCEPTIONS
|
||||
#endif // TEST_HAS_NO_WIDE_CHARACTERS
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// string to_string(int val);
|
||||
// string to_string(unsigned val);
|
||||
// string to_string(long val);
|
||||
// string to_string(unsigned long val);
|
||||
// string to_string(long long val);
|
||||
// string to_string(unsigned long long val);
|
||||
// string to_string(float val);
|
||||
// string to_string(double val);
|
||||
// string to_string(long double val);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
#include "parse_integer.h"
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_signed()
|
||||
{
|
||||
{
|
||||
std::string s = std::to_string(T(0));
|
||||
assert(s.size() == 1);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "0");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(T(12345));
|
||||
assert(s.size() == 5);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "12345");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(T(-12345));
|
||||
assert(s.size() == 6);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "-12345");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(std::numeric_limits<T>::max());
|
||||
assert(s.size() == std::numeric_limits<T>::digits10 + 1);
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::max());
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(std::numeric_limits<T>::min());
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::min());
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_unsigned()
|
||||
{
|
||||
{
|
||||
std::string s = std::to_string(T(0));
|
||||
assert(s.size() == 1);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "0");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(T(12345));
|
||||
assert(s.size() == 5);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "12345");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(std::numeric_limits<T>::max());
|
||||
assert(s.size() == std::numeric_limits<T>::digits10 + 1);
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::max());
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_float()
|
||||
{
|
||||
{
|
||||
std::string s = std::to_string(T(0));
|
||||
assert(s.size() == 8);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "0.000000");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(T(12345));
|
||||
assert(s.size() == 12);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "12345.000000");
|
||||
}
|
||||
{
|
||||
std::string s = std::to_string(T(-12345));
|
||||
assert(s.size() == 13);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == "-12345.000000");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test_signed<int>();
|
||||
test_signed<long>();
|
||||
test_signed<long long>();
|
||||
test_unsigned<unsigned>();
|
||||
test_unsigned<unsigned long>();
|
||||
test_unsigned<unsigned long long>();
|
||||
test_float<float>();
|
||||
test_float<double>();
|
||||
test_float<long double>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: no-wide-characters
|
||||
|
||||
// <string>
|
||||
|
||||
// wstring to_wstring(int val);
|
||||
// wstring to_wstring(unsigned val);
|
||||
// wstring to_wstring(long val);
|
||||
// wstring to_wstring(unsigned long val);
|
||||
// wstring to_wstring(long long val);
|
||||
// wstring to_wstring(unsigned long long val);
|
||||
// wstring to_wstring(float val);
|
||||
// wstring to_wstring(double val);
|
||||
// wstring to_wstring(long double val);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
#include "parse_integer.h"
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_signed()
|
||||
{
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(0));
|
||||
assert(s.size() == 1);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"0");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(12345));
|
||||
assert(s.size() == 5);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"12345");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(-12345));
|
||||
assert(s.size() == 6);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"-12345");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
|
||||
assert(s.size() == std::numeric_limits<T>::digits10 + 1);
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::max());
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(std::numeric_limits<T>::min());
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::min());
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_unsigned()
|
||||
{
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(0));
|
||||
assert(s.size() == 1);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"0");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(12345));
|
||||
assert(s.size() == 5);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"12345");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
|
||||
assert(s.size() == std::numeric_limits<T>::digits10 + 1);
|
||||
T t = parse_integer<T>(s);
|
||||
assert(t == std::numeric_limits<T>::max());
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_float()
|
||||
{
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(0));
|
||||
assert(s.size() == 8);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"0.000000");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(12345));
|
||||
assert(s.size() == 12);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"12345.000000");
|
||||
}
|
||||
{
|
||||
std::wstring s = std::to_wstring(T(-12345));
|
||||
assert(s.size() == 13);
|
||||
assert(s[s.size()] == 0);
|
||||
assert(s == L"-12345.000000");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test_signed<int>();
|
||||
test_signed<long>();
|
||||
test_signed<long long>();
|
||||
test_unsigned<unsigned>();
|
||||
test_unsigned<unsigned long>();
|
||||
test_unsigned<unsigned long long>();
|
||||
test_float<float>();
|
||||
test_float<double>();
|
||||
test_float<long double>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user