Compare commits
2 Commits
31c624797f
...
82c3ed5b32
Author | SHA1 | Date | |
---|---|---|---|
82c3ed5b32 | |||
d6be8a11ac |
@ -2,13 +2,11 @@
|
||||
#include "../termcolor.hpp"
|
||||
#include "../../patch/stream.hpp"
|
||||
#include "../../patch/format.hpp"
|
||||
#include "../../string/op.hpp"
|
||||
|
||||
#define CLAP ::yycc::carton::clap
|
||||
#define TABULATE ::yycc::carton::tabulate
|
||||
#define TERMCOLOR ::yycc::carton::termcolor
|
||||
#define FORMAT ::yycc::patch::format
|
||||
#define OP ::yycc::carton::op
|
||||
|
||||
using namespace ::yycc::patch::stream;
|
||||
|
||||
|
@ -12,13 +12,19 @@ namespace yycc::string::op {
|
||||
|
||||
#pragma region Printf
|
||||
|
||||
// YYC MARK:
|
||||
// Shitty __attribute__((format(gnu_printf, (A), (B)))) force the type of format string is const char*.
|
||||
// My function signature will cause compile error which can not be removed by any switches.
|
||||
// I guess Clang may have same issue.
|
||||
// So I sadly disable format string check for printf in UTF8 char type.
|
||||
|
||||
/**
|
||||
* @brief Perform an UTF8 string formatting operation.
|
||||
* @param[in] format The format string.
|
||||
* @param[in] ... Argument list of format string.
|
||||
* @return The formatted result.
|
||||
*/
|
||||
std::u8string printf(YYCC_PRINTF_CHECK_FMTSTR const char8_t* format, ...) YYCC_PRINTF_CHECK_ATTR(1, 2);
|
||||
std::u8string printf(/*YYCC_PRINTF_CHECK_FMTSTR*/ const char8_t* format, ...) /*YYCC_PRINTF_CHECK_ATTR(1, 2)*/;
|
||||
/**
|
||||
* @brief Perform an UTF8 string formatting operation.
|
||||
* @param[in] format The format string.
|
||||
|
@ -11,25 +11,25 @@ namespace yycctest::patch::format {
|
||||
static constexpr std::u8string_view PROBE_STRING_VIEW(PROBE);
|
||||
|
||||
TEST(PatchFormat, OrdinaryFormat) {
|
||||
auto rv = FORMAT::format("{}{}{}{}{}{} world!",
|
||||
auto rv = FORMAT::format("{:c}{}{}{}{}{} world!",
|
||||
PROBE[0],
|
||||
PROBE_STRING.data(),
|
||||
PROBE_STRING.c_str(),
|
||||
PROBE,
|
||||
PROBE_STRING,
|
||||
PROBE_STRING_VIEW);
|
||||
EXPECT_EQ(rv, "104hellohellohellohellohello world!");
|
||||
EXPECT_EQ(rv, "hhellohellohellohellohello world!");
|
||||
}
|
||||
|
||||
TEST(PatchFormat, Utf8Format) {
|
||||
auto rv = FORMAT::format(u8"{}{}{}{}{}{} world!",
|
||||
auto rv = FORMAT::format(u8"{:c}{}{}{}{}{} world!",
|
||||
PROBE[0],
|
||||
PROBE_STRING.data(),
|
||||
PROBE_STRING.c_str(),
|
||||
PROBE,
|
||||
PROBE_STRING,
|
||||
PROBE_STRING_VIEW);
|
||||
EXPECT_EQ(rv, u8"104hellohellohellohellohello world!");
|
||||
EXPECT_EQ(rv, u8"hhellohellohellohellohello world!");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user