• Home
  • Raw
  • Download

Lines Matching full:fmt

12 #include "fmt/chrono.h"
57 fmt::format("The date is {:%Y-%m-%d}.", tm)); in TEST()
65 fmt::format(s, *std::localtime(&t)); in TEST()
72 fmt::format_to(std::back_inserter(s), "{:%S}", time); in TEST()
76 TEST(TimeTest, EmptyResult) { EXPECT_EQ("", fmt::format("{}", std::tm())); } in TEST()
89 EXPECT_TRUE(EqualTime(tm, fmt::localtime(t))); in TEST()
95 EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t))); in TEST()
106 EXPECT_EQ(strftime_output, fmt::format("It is {:%Y-%m-%d %H:%M:%S}", point)); in TEST()
113 fmt::format(loc, "{:" spec "}", duration)); \
119 EXPECT_EQ("42s", fmt::format("{}", std::chrono::seconds(42))); in TEST()
121 fmt::format("{}", std::chrono::duration<int, std::atto>(42))); in TEST()
123 fmt::format("{}", std::chrono::duration<int, std::femto>(42))); in TEST()
125 fmt::format("{}", std::chrono::duration<int, std::pico>(42))); in TEST()
126 EXPECT_EQ("42ns", fmt::format("{}", std::chrono::nanoseconds(42))); in TEST()
127 EXPECT_EQ("42µs", fmt::format("{}", std::chrono::microseconds(42))); in TEST()
128 EXPECT_EQ("42ms", fmt::format("{}", std::chrono::milliseconds(42))); in TEST()
130 fmt::format("{}", std::chrono::duration<int, std::centi>(42))); in TEST()
132 fmt::format("{}", std::chrono::duration<int, std::deci>(42))); in TEST()
133 EXPECT_EQ("42s", fmt::format("{}", std::chrono::seconds(42))); in TEST()
135 fmt::format("{}", std::chrono::duration<int, std::deca>(42))); in TEST()
137 fmt::format("{}", std::chrono::duration<int, std::hecto>(42))); in TEST()
139 fmt::format("{}", std::chrono::duration<int, std::kilo>(42))); in TEST()
141 fmt::format("{}", std::chrono::duration<int, std::mega>(42))); in TEST()
143 fmt::format("{}", std::chrono::duration<int, std::giga>(42))); in TEST()
145 fmt::format("{}", std::chrono::duration<int, std::tera>(42))); in TEST()
147 fmt::format("{}", std::chrono::duration<int, std::peta>(42))); in TEST()
149 fmt::format("{}", std::chrono::duration<int, std::exa>(42))); in TEST()
150 EXPECT_EQ("42m", fmt::format("{}", std::chrono::minutes(42))); in TEST()
151 EXPECT_EQ("42h", fmt::format("{}", std::chrono::hours(42))); in TEST()
154 fmt::format("{}", std::chrono::duration<int, std::ratio<15, 1>>(42))); in TEST()
157 fmt::format("{}", std::chrono::duration<int, std::ratio<15, 4>>(42))); in TEST()
161 EXPECT_EQ(L"42s", fmt::format(L"{}", std::chrono::seconds(42))); in TEST()
163 fmt::format(L"{}", std::chrono::duration<int, std::atto>(42))); in TEST()
165 fmt::format(L"{}", std::chrono::duration<int, std::femto>(42))); in TEST()
167 fmt::format(L"{}", std::chrono::duration<int, std::pico>(42))); in TEST()
168 EXPECT_EQ(L"42ns", fmt::format(L"{}", std::chrono::nanoseconds(42))); in TEST()
169 EXPECT_EQ(L"42\u00B5s", fmt::format(L"{}", std::chrono::microseconds(42))); in TEST()
170 EXPECT_EQ(L"42ms", fmt::format(L"{}", std::chrono::milliseconds(42))); in TEST()
172 fmt::format(L"{}", std::chrono::duration<int, std::centi>(42))); in TEST()
174 fmt::format(L"{}", std::chrono::duration<int, std::deci>(42))); in TEST()
175 EXPECT_EQ(L"42s", fmt::format(L"{}", std::chrono::seconds(42))); in TEST()
177 fmt::format(L"{}", std::chrono::duration<int, std::deca>(42))); in TEST()
179 fmt::format(L"{}", std::chrono::duration<int, std::hecto>(42))); in TEST()
181 fmt::format(L"{}", std::chrono::duration<int, std::kilo>(42))); in TEST()
183 fmt::format(L"{}", std::chrono::duration<int, std::mega>(42))); in TEST()
185 fmt::format(L"{}", std::chrono::duration<int, std::giga>(42))); in TEST()
187 fmt::format(L"{}", std::chrono::duration<int, std::tera>(42))); in TEST()
189 fmt::format(L"{}", std::chrono::duration<int, std::peta>(42))); in TEST()
191 fmt::format(L"{}", std::chrono::duration<int, std::exa>(42))); in TEST()
192 EXPECT_EQ(L"42m", fmt::format(L"{}", std::chrono::minutes(42))); in TEST()
193 EXPECT_EQ(L"42h", fmt::format(L"{}", std::chrono::hours(42))); in TEST()
196 fmt::format(L"{}", std::chrono::duration<int, std::ratio<15, 1>>(42))); in TEST()
199 fmt::format(L"{}", std::chrono::duration<int, std::ratio<15, 4>>(42))); in TEST()
204 EXPECT_EQ("42s ", fmt::format("{:5}", s)); in TEST()
205 EXPECT_EQ("42s ", fmt::format("{:{}}", s, 5)); in TEST()
206 EXPECT_EQ(" 42s", fmt::format("{:>5}", s)); in TEST()
207 EXPECT_EQ("**42s**", fmt::format("{:*^7}", s)); in TEST()
209 fmt::format("{:12%H:%M:%S}", std::chrono::seconds(12345))); in TEST()
211 fmt::format("{:>12%H:%M:%S}", std::chrono::seconds(12345))); in TEST()
213 fmt::format("{:~^12%H:%M:%S}", std::chrono::seconds(12345))); in TEST()
215 fmt::format("{:{}%H:%M:%S}", std::chrono::seconds(12345), 12)); in TEST()
219 EXPECT_EQ("%", fmt::format("{:%%}", std::chrono::seconds(0))); in TEST()
220 EXPECT_EQ("\n", fmt::format("{:%n}", std::chrono::seconds(0))); in TEST()
221 EXPECT_EQ("\t", fmt::format("{:%t}", std::chrono::seconds(0))); in TEST()
222 EXPECT_EQ("00", fmt::format("{:%S}", std::chrono::seconds(0))); in TEST()
223 EXPECT_EQ("00", fmt::format("{:%S}", std::chrono::seconds(60))); in TEST()
224 EXPECT_EQ("42", fmt::format("{:%S}", std::chrono::seconds(42))); in TEST()
225 EXPECT_EQ("01.234", fmt::format("{:%S}", std::chrono::milliseconds(1234))); in TEST()
226 EXPECT_EQ("00", fmt::format("{:%M}", std::chrono::minutes(0))); in TEST()
227 EXPECT_EQ("00", fmt::format("{:%M}", std::chrono::minutes(60))); in TEST()
228 EXPECT_EQ("42", fmt::format("{:%M}", std::chrono::minutes(42))); in TEST()
229 EXPECT_EQ("01", fmt::format("{:%M}", std::chrono::seconds(61))); in TEST()
230 EXPECT_EQ("00", fmt::format("{:%H}", std::chrono::hours(0))); in TEST()
231 EXPECT_EQ("00", fmt::format("{:%H}", std::chrono::hours(24))); in TEST()
232 EXPECT_EQ("14", fmt::format("{:%H}", std::chrono::hours(14))); in TEST()
233 EXPECT_EQ("01", fmt::format("{:%H}", std::chrono::minutes(61))); in TEST()
234 EXPECT_EQ("12", fmt::format("{:%I}", std::chrono::hours(0))); in TEST()
235 EXPECT_EQ("12", fmt::format("{:%I}", std::chrono::hours(12))); in TEST()
236 EXPECT_EQ("12", fmt::format("{:%I}", std::chrono::hours(24))); in TEST()
237 EXPECT_EQ("04", fmt::format("{:%I}", std::chrono::hours(4))); in TEST()
238 EXPECT_EQ("02", fmt::format("{:%I}", std::chrono::hours(14))); in TEST()
240 fmt::format("{:%H:%M:%S}", std::chrono::seconds(12345))); in TEST()
241 EXPECT_EQ("03:25", fmt::format("{:%R}", std::chrono::seconds(12345))); in TEST()
242 EXPECT_EQ("03:25:45", fmt::format("{:%T}", std::chrono::seconds(12345))); in TEST()
243 EXPECT_EQ("12345", fmt::format("{:%Q}", std::chrono::seconds(12345))); in TEST()
244 EXPECT_EQ("s", fmt::format("{:%q}", std::chrono::seconds(12345))); in TEST()
249 EXPECT_THROW_MSG(fmt::format("{:%a}", sec), fmt::format_error, "no date"); in TEST()
250 EXPECT_THROW_MSG(fmt::format("{:%A}", sec), fmt::format_error, "no date"); in TEST()
251 EXPECT_THROW_MSG(fmt::format("{:%c}", sec), fmt::format_error, "no date"); in TEST()
252 EXPECT_THROW_MSG(fmt::format("{:%x}", sec), fmt::format_error, "no date"); in TEST()
253 EXPECT_THROW_MSG(fmt::format("{:%Ex}", sec), fmt::format_error, "no date"); in TEST()
254 EXPECT_THROW_MSG(fmt::format("{:%X}", sec), fmt::format_error, "no date"); in TEST()
255 EXPECT_THROW_MSG(fmt::format("{:%EX}", sec), fmt::format_error, "no date"); in TEST()
256 EXPECT_THROW_MSG(fmt::format("{:%D}", sec), fmt::format_error, "no date"); in TEST()
257 EXPECT_THROW_MSG(fmt::format("{:%F}", sec), fmt::format_error, "no date"); in TEST()
258 EXPECT_THROW_MSG(fmt::format("{:%Ec}", sec), fmt::format_error, "no date"); in TEST()
259 EXPECT_THROW_MSG(fmt::format("{:%w}", sec), fmt::format_error, "no date"); in TEST()
260 EXPECT_THROW_MSG(fmt::format("{:%u}", sec), fmt::format_error, "no date"); in TEST()
261 EXPECT_THROW_MSG(fmt::format("{:%b}", sec), fmt::format_error, "no date"); in TEST()
262 EXPECT_THROW_MSG(fmt::format("{:%B}", sec), fmt::format_error, "no date"); in TEST()
263 EXPECT_THROW_MSG(fmt::format("{:%z}", sec), fmt::format_error, "no date"); in TEST()
264 EXPECT_THROW_MSG(fmt::format("{:%Z}", sec), fmt::format_error, "no date"); in TEST()
265 EXPECT_THROW_MSG(fmt::format("{:%Eq}", sec), fmt::format_error, in TEST()
267 EXPECT_THROW_MSG(fmt::format("{:%Oq}", sec), fmt::format_error, in TEST()
281 fmt::print("{} locale is missing.\n", loc_name); in TEST()
301 EXPECT_EQ("1.234s", fmt::format("{}", fs(1.234))); in TEST()
303 EXPECT_EQ("1.234ms", fmt::format("{}", fms(1.234))); in TEST()
305 EXPECT_EQ("1.234s", fmt::format("{}", ds(1.234))); in TEST()
306 EXPECT_EQ("1.234ms", fmt::format("{}", dms(1.234))); in TEST()
310 EXPECT_THROW_MSG(fmt::format("{:.2}", std::chrono::seconds(42)), in TEST()
311 fmt::format_error, in TEST()
313 EXPECT_EQ("1.2ms", fmt::format("{:.1}", dms(1.234))); in TEST()
314 EXPECT_EQ("1.23ms", fmt::format("{:.{}}", dms(1.234), 2)); in TEST()
318 EXPECT_EQ("1.2ms ", fmt::format("{:6.1}", dms(1.234))); in TEST()
319 EXPECT_EQ(" 1.23ms", fmt::format("{:>8.{}}", dms(1.234), 2)); in TEST()
320 EXPECT_EQ(" 1.2ms ", fmt::format("{:^{}.{}}", dms(1.234), 7, 1)); in TEST()
321 EXPECT_EQ(" 1.23ms ", fmt::format("{0:^{2}.{1}}", dms(1.234), 2, 8)); in TEST()
322 EXPECT_EQ("=1.234ms=", fmt::format("{:=^{}.{}}", dms(1.234), 9, 3)); in TEST()
323 EXPECT_EQ("*1.2340ms*", fmt::format("{:*^10.4}", dms(1.234))); in TEST()
328 EXPECT_EQ("1.234 s", fmt::format("{:%Q %q}", fs(1.234))); in TEST()
330 EXPECT_EQ("1.234 ms", fmt::format("{:%Q %q}", fms(1.234))); in TEST()
332 EXPECT_EQ("1.234 s", fmt::format("{:%Q %q}", ds(1.234))); in TEST()
333 EXPECT_EQ("1.234 ms", fmt::format("{:%Q %q}", dms(1.234))); in TEST()
337 EXPECT_THROW_MSG(fmt::format("{:.2%Q %q}", std::chrono::seconds(42)), in TEST()
338 fmt::format_error, in TEST()
340 EXPECT_EQ("1.2 ms", fmt::format("{:.1%Q %q}", dms(1.234))); in TEST()
341 EXPECT_EQ("1.23 ms", fmt::format("{:.{}%Q %q}", dms(1.234), 2)); in TEST()
345 EXPECT_EQ("1.2 ms ", fmt::format("{:7.1%Q %q}", dms(1.234))); in TEST()
346 EXPECT_EQ(" 1.23 ms", fmt::format("{:>8.{}%Q %q}", dms(1.234), 2)); in TEST()
347 EXPECT_EQ(" 1.2 ms ", fmt::format("{:^{}.{}%Q %q}", dms(1.234), 8, 1)); in TEST()
348 EXPECT_EQ(" 1.23 ms ", fmt::format("{0:^{2}.{1}%Q %q}", dms(1.234), 2, 9)); in TEST()
349 EXPECT_EQ("=1.234 ms=", fmt::format("{:=^{}.{}%Q %q}", dms(1.234), 10, 3)); in TEST()
350 EXPECT_EQ("*1.2340 ms*", fmt::format("{:*^11.4%Q %q}", dms(1.234))); in TEST()
354 EXPECT_THROW(fmt::format("{:{o}", std::chrono::seconds(0)), in TEST()
355 fmt::format_error); in TEST()
359 EXPECT_THROW(fmt::format("{0}=:{0::", std::chrono::seconds(0)), in TEST()
360 fmt::format_error); in TEST()
364 EXPECT_EQ("-12345", fmt::format("{:%Q}", std::chrono::seconds(-12345))); in TEST()
366 fmt::format("{:%H:%M:%S}", std::chrono::seconds(-12345))); in TEST()
368 fmt::format("{:%M:%S}", std::chrono::duration<double>(-1))); in TEST()
369 EXPECT_EQ("s", fmt::format("{:%q}", std::chrono::seconds(-12345))); in TEST()
371 fmt::format("{:%S}", in TEST()
374 EXPECT_EQ(fmt::format("{}", min), in TEST()
375 fmt::format("{:%Q}", std::chrono::duration<int>(min))); in TEST()
381 fmt::format("{:%S}", std::chrono::duration<double>(1e20)).substr(0, 3)); in TEST()
385 fmt::format("{:%I %H %M %S %R %r}", std::chrono::duration<double>(nan))); in TEST()
386 fmt::format("{:%S}", in TEST()
388 EXPECT_EQ(fmt::format("{}", std::chrono::duration<float, std::exa>(1)), in TEST()
390 EXPECT_EQ(fmt::format("{}", std::chrono::duration<float, std::atto>(1)), in TEST()
392 EXPECT_EQ(fmt::format("{:%R}", std::chrono::duration<char, std::mega>{2}), in TEST()
394 EXPECT_EQ(fmt::format("{:%T}", std::chrono::duration<char, std::mega>{2}), in TEST()