mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
upd: ut
This commit is contained in:
parent
d258e00710
commit
c39b0fc18c
@ -4,7 +4,7 @@
|
|||||||
#include <iomanip> // std::put_time
|
#include <iomanip> // std::put_time
|
||||||
#include <sstream> // std::ostringstream
|
#include <sstream> // std::ostringstream
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring> // std::memcpy, std::strncat
|
#include <cstring> // std::memcpy
|
||||||
#include <algorithm> // std::min
|
#include <algorithm> // std::min
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "libimp/fmt.h"
|
#include "libimp/fmt.h"
|
||||||
|
|
||||||
TEST(fmt, operator) {
|
TEST(fmt, spec) {
|
||||||
EXPECT_STREQ(imp::spec("hello")(123).fstr.data(), "hello");
|
EXPECT_STREQ(imp::spec("hello")(123).fstr.data(), "hello");
|
||||||
EXPECT_EQ(imp::spec("hello")(123).param , 123);
|
EXPECT_EQ(imp::spec("hello")(123).param , 123);
|
||||||
EXPECT_STREQ(imp::spec("hello")("world").fstr.data(), "hello");
|
EXPECT_STREQ(imp::spec("hello")("world").fstr.data(), "hello");
|
||||||
@ -81,4 +81,19 @@ TEST(fmt, fmt) {
|
|||||||
auto s = imp::fmt("hello", " ", "world", ".");
|
auto s = imp::fmt("hello", " ", "world", ".");
|
||||||
EXPECT_EQ(s, "hello world.");
|
EXPECT_EQ(s, "hello world.");
|
||||||
std::cout << imp::fmt('[', std::chrono::system_clock::now(), "] ", s) << "\n";
|
std::cout << imp::fmt('[', std::chrono::system_clock::now(), "] ", s) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class foo {};
|
||||||
|
|
||||||
|
std::string tag_invoke(decltype(imp::fmt_to_string), foo arg) noexcept(false) {
|
||||||
|
throw arg;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
TEST(fmt, throw) {
|
||||||
|
EXPECT_THROW(imp::fmt(foo{}), foo);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user