Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/utilities/format/format.functions/format_tests.h
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef TEST_STD_UTILITIES_FORMAT_FORMAT_FUNCTIONS_FORMAT_TESTS_H | #ifndef TEST_STD_UTILITIES_FORMAT_FORMAT_FUNCTIONS_FORMAT_TESTS_H | ||||
#define TEST_STD_UTILITIES_FORMAT_FORMAT_FUNCTIONS_FORMAT_TESTS_H | #define TEST_STD_UTILITIES_FORMAT_FORMAT_FUNCTIONS_FORMAT_TESTS_H | ||||
#include <format> | |||||
#include "make_string.h" | #include "make_string.h" | ||||
// In this file the following template types are used: | // In this file the following template types are used: | ||||
// TestFunction must be callable as check(expected-result, string-to-format, args-to-format...) | // TestFunction must be callable as check(expected-result, string-to-format, args-to-format...) | ||||
// ExceptionTest must be callable as check_exception(expected-exception, string-to-format, args-to-format...) | // ExceptionTest must be callable as check_exception(expected-exception, string-to-format, args-to-format...) | ||||
#define STR(S) MAKE_STRING(CharT, S) | #define STR(S) MAKE_STRING(CharT, S) | ||||
#define CSTR(S) MAKE_CSTRING(CharT, S) | #define CSTR(S) MAKE_CSTRING(CharT, S) | ||||
template <class T> | |||||
struct context {}; | |||||
template <> | |||||
struct context<char> { | |||||
using type = std::format_context; | |||||
}; | |||||
template <> | |||||
struct context<wchar_t> { | |||||
using type = std::wformat_context; | |||||
}; | |||||
template <class T> | |||||
using context_t = typename context<T>::type; | |||||
template <class CharT> | template <class CharT> | ||||
std::vector<std::basic_string<CharT>> invalid_types(std::string valid) { | std::vector<std::basic_string<CharT>> invalid_types(std::string valid) { | ||||
std::vector<std::basic_string<CharT>> result; | std::vector<std::basic_string<CharT>> result; | ||||
#define CASE(T) \ | #define CASE(T) \ | ||||
case #T[0]: \ | case #T[0]: \ | ||||
result.push_back(STR("Invalid formatter type {:" #T "}")); \ | result.push_back(STR("Invalid formatter type {:" #T "}")); \ | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,082 Lines • Show Last 20 Lines |