Compare commits

...

6563 Commits

Author SHA1 Message Date
8303d140a1 Update version 2025-01-12 08:15:44 -08:00
b0b3dc5ff9 Bump version 2025-01-12 08:13:56 -08:00
586ea06f02 Rename set_fill to copy_fill_from 2025-01-11 09:22:15 -08:00
5750f434fa Update changelog 2025-01-11 09:06:00 -08:00
bfbdc2be9a Add parameter to the fallback to_sys function. 2025-01-11 08:48:20 -08:00
87e0072673 Update changelog 2025-01-11 07:21:28 -08:00
d57040f949 Prefix components 2025-01-10 19:51:55 -08:00
21aa0956d4 Restore ABI compatibility 2025-01-10 17:36:09 -08:00
3f864a4505 Address MSVC C4127 warning when formatting non unicode tm (#4299)
Use `const_check` to silence visual studio's W4 level diagnostic regarding conditional expressions being constants, addresses https://github.com/fmtlib/fmt/issues/4294
2025-01-08 14:21:48 -08:00
093b39ca5e Update docs for meson (#4291) 2025-01-06 10:52:57 -08:00
2c3a5698ef Simplify a copying the fill from basic_specs
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2025-01-05 09:33:05 -08:00
fc1b0f3486 Clarify use of FMT_THROW in a comment 2025-01-05 07:31:19 -10:00
1d066890c7 Resolve C4702 unreachable code warnings 2025-01-03 16:39:11 -08:00
dad3237514 Fix a bug when copying the fill from basic_specs
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2025-01-03 09:16:21 -08:00
880e1494dc Improve xchar support for std::bitset formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2025-01-03 09:16:21 -08:00
e3ddede6c4 Update version 2024-12-27 08:41:16 -08:00
e9ec4fdc88 Bump version 2024-12-27 08:41:06 -08:00
feb72126b4 Readd FMT_NO_UNIQUE_ADDRESS 2024-12-26 13:54:06 -08:00
8d517e54c9 Update changelog 2024-12-26 13:50:13 -08:00
563fc74ae4 Update changelog 2024-12-26 10:59:56 -08:00
3e04222d53 Restore ABI compatibility with 11.0.2 2024-12-26 10:45:15 -08:00
853df39d0a Mention compile-time formatting 2024-12-26 09:48:10 -08:00
11742a09c7 Clarify that format_string should be used instead of fstring 2024-12-26 09:39:01 -08:00
da24fac101 Document fstring 2024-12-26 09:19:31 -08:00
5fa4bdd758 Define CMake components to allow docs to be installed separately (#4276)
Define two components, core and doc, which can be installed separately.
This facilitates packagers who want to package docs in a separate
package.

After this change it's possible to install only core files with:

     cmake --install build --component core

And only install documentation with:

     cmake --install build --component doc

When no component is specified, the behaviour is unchanged, i.e. if
documentation was built, it will be installed.
2024-12-26 07:13:01 -08:00
3c8aad8df7 Update the release script 2024-12-26 07:03:15 -08:00
0e8aad961d Update version 2024-12-25 08:46:43 -08:00
debe784aab Update changelog 2024-12-25 08:44:54 -08:00
f6d1125676 Update changelog 2024-12-25 08:40:19 -08:00
73d0d3f75d Fix github API call 2024-12-25 08:27:59 -08:00
08f60f1efc Update changelog 2024-12-25 08:27:33 -08:00
faf3f84085 Bump version 2024-12-25 08:18:51 -08:00
f3a41441df Replace requests with urllib 2024-12-25 08:16:09 -08:00
3f33cb21d2 Update changelog 2024-12-25 07:54:45 -08:00
b07a90386e Update changelog 2024-12-25 07:52:52 -08:00
a6fba51773 Update changelog 2024-12-25 07:49:56 -08:00
25e2929988 Update changelog 2024-12-25 07:44:58 -08:00
00ab2e98b5 Update changelog 2024-12-25 07:38:42 -08:00
a3ef285aec Always inline const_check to improve debug codegen in clang 2024-12-24 12:54:44 -08:00
28d1abc9d2 Update changelog 2024-12-24 09:12:32 -08:00
90704b9efd Update changelog 2024-12-23 14:55:33 -08:00
86dae01c23 Fix compatibility with older versions of VS (#4271) 2024-12-23 07:26:11 -08:00
d8a79eafdc Document formatting of bit-fields and fields of packed structs 2024-12-21 11:06:11 -08:00
7c3d0152e5 Use the _MSVC_STL_UPDATE macro to detect STL (#4267) 2024-12-19 06:47:13 -08:00
7c50da5385 Allow getting size of dynamic format arg store (#4270) 2024-12-18 19:54:35 -08:00
873670ba3f Make parameter basic_memory_buffer<char, SIZE>& buf of to_string const 2024-12-11 12:19:20 -08:00
735d4cc05e Update changelog 2024-12-11 12:17:40 -08:00
141380172f Allow disabling <filesystem> by define FMT_CPP_LIB_FILESYSTEM=0 (#4259)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-12-09 07:13:24 -08:00
4302d74293 Update changelog 2024-12-08 07:20:31 -08:00
0f51ea79d3 Update changelog 2024-12-07 11:05:40 -08:00
9600fee020 Include <filesystem> only if FMT_CPP_LIB_FILESYSTEM is set (#4258)
This change results out of necessity since the Nintendo Switch console
SDK does not support `std::filesystem`. The SDK still provides the
`<filesystem>` header, but with an `#error` directive, effectively
breaking any build that includes `<filesystem>`

Because `<filesystem>` is present, `FMT_HAS_INCLUDE` is insufficient
here. With this change and `FMT_CPP_LIB_FILESYSTEM` in place, one can
define `FMT_CPP_LIB_FILESYSTEM=0` to work around this issue.

This assumes that `<filesystem>` can be included (without warnings) if
`FMT_CPP_LIB_FILESYSTEM` is set. If this is not the case, fmt would be
broken even before this change as `std::filesystem::path` is used
without the accompanying header.
2024-12-07 06:45:54 -08:00
47a66c5ecc Bump msys2/setup-msys2 from 2.24.0 to 2.25.0 (#4250)
Bumps [msys2/setup-msys2](https://github.com/msys2/setup-msys2) from 2.24.0 to 2.25.0.
- [Release notes](https://github.com/msys2/setup-msys2/releases)
- [Changelog](https://github.com/msys2/setup-msys2/blob/main/CHANGELOG.md)
- [Commits](5df0ca6cbf...c52d1fa9c7)

---
updated-dependencies:
- dependency-name: msys2/setup-msys2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-02 09:24:57 -08:00
385c01dc7b Allow bit_cast to work for 80bit long double (#4246) 2024-11-29 01:25:21 -08:00
df249d8ad3 Remove an old workaround 2024-11-19 14:28:39 +01:00
dfad80d1c5 Remove an old workaround 2024-11-19 14:22:44 +01:00
536cabd562 Export all range join overloads (#4239) 2024-11-15 13:01:59 -08:00
b1a054706e Remove more MSVC 2015 workarounds and fix string_view checks 2024-11-15 08:33:30 -08:00
bfd95392c7 Remove MSVC 2015 workaround 2024-11-15 08:19:01 -08:00
9ced61bca4 Replace std::forward for clang-tidy (#4236)
Should fix #4231
2024-11-14 09:06:30 -08:00
75e5be6adc Sort specifiers 2024-11-13 13:01:13 -08:00
a169d7fa46 Fix chrono formatting syntax doc (#4235) 2024-11-13 12:57:22 -08:00
a6c45dfea8 Fix modular build 2024-11-10 09:06:50 -08:00
a35389b3c2 Corrently handle buffer flush 2024-11-09 10:56:31 -08:00
5a3576acc8 Implement fmt::join for tuple-like objects (#4230)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-11-09 08:28:46 -08:00
542600013f Suppress MSVC warnings "C4127: conditional expression is constant" by used const_check (#4233)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-11-09 07:43:46 -08:00
720da57bab Remove reference to unused intrinsic 2024-11-03 17:18:33 -08:00
680db66c3a Explicitly export symbols from detail 2024-11-03 09:13:17 -08:00
56ce41ef63 Remove initializer_list dependency 2024-11-03 08:26:25 -08:00
cf50e4d6a4 Fix const[expr] in context API 2024-11-03 07:25:52 -08:00
6580d7b808 Cleanup the format API 2024-11-03 06:57:36 -08:00
7e73566ce7 Minor cleanup 2024-11-02 11:24:24 -07:00
8523dba2dc Make constexpr precede explicit consistently 2024-11-02 11:03:03 -07:00
e3d3b24fc1 Minor cleanup 2024-11-02 10:46:58 -07:00
1521bba701 Use consistent types for argument count 2024-11-02 08:08:36 -07:00
00649552a8 Bump github/codeql-action from 3.26.6 to 3.27.0 (#4223)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.6 to 3.27.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4dd16135b6...662472033e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-01 09:13:46 -07:00
4b8e2838f0 More cleanup 2024-10-27 10:56:52 -07:00
7d4662f7ab Remove FMT_BUILTIN_CTZ 2024-10-27 10:22:43 -07:00
27110bc474 Minor cleanup 2024-10-27 09:44:25 -07:00
68f3153762 Fix narrowing conversion warning in struct fstring (#4210)
Warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data.
2024-10-27 06:41:20 -07:00
168df9a064 Implement fmt::format_to into std::vector<char> (#4211)
* Implement fmt::format_to into std::vector<char>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Move get_container to the trait

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

---------

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-10-26 09:23:59 -07:00
4daa3d591f Fix error: cannot use 'try' with exceptions disabled in Win LLVM Clang (#4208)
Fixes #4207.

LLVM Clang on Windows does not define `__GNUC__`. The preprocessor falls
to `#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS` with `_HAS_EXCEPTIONS 1`
defined in vcruntime.h:104.
2024-10-23 10:43:55 -07:00
e9eaa27e5a Add std::exception to the docs 2024-10-20 09:42:29 -07:00
2b6a786e35 Use standard context in print 2024-10-20 09:08:24 -07:00
a16ff5787b Add support for code units > 0xFFFF in fill 2024-10-20 07:59:58 -07:00
601be1cbe7 Add support for code units > 0xFFFF in fill 2024-10-19 08:15:50 -07:00
58c185b634 Changing type of data_ to size_t to avoid compilation warnings (#4200)
Changing type data_ to size_t because
1. If lib is cross-compiled for win32 using MXE environment it cause
   compilation warning -Wconversion on line 730 as sizeof(unsigned long)
   = 4 and sizeof(size_t) = 8
2. When lib is compiled on Unix like compiler generate warning
   -Wuseless-cast if static_cast is used to fix issue in 1
2024-10-19 06:59:21 -07:00
a0a9ba2afc Fix hashes 2024-10-18 12:33:42 -07:00
cc2ba8f9ed Cleanup cifuzz action 2024-10-13 11:16:31 -07:00
a18d42b208 Simplify lint (#4197) 2024-10-13 09:28:38 -07:00
4046f97278 Fix -Wmissing-noreturn warning (#4194)
Fixes warning reported by top of trunk Clang:

include/fmt/chrono.h:447:36: error: function 'throw_duration_error' could be declared with attribute 'noreturn'
2024-10-10 08:59:56 -07:00
6bdc12a199 detail_exported -> detail 2024-10-09 11:04:55 -07:00
786a4b0968 Cleanup fixed_string 2024-10-09 08:42:49 -07:00
2cb3b7c64b Update README.md 2024-10-06 07:39:03 -07:00
e9cba69057 Update README.md 2024-10-06 07:38:41 -07:00
02537548f3 Cleanup an example 2024-10-04 17:15:07 -07:00
c68c5fa7c7 Test FMT_BUILTIN_TYPES 2024-10-04 16:08:46 -07:00
22701d5f63 Address build failures when using Tip-of-Tree clang. (#4187)
When using ToT clang to build fmtlib, it complains 'sv' is not
initialized by a constant expression. This patch addresses this
issue.
2024-10-04 06:45:29 -07:00
e62c41ffb0 Conform std::iterator_traits<fmt::appender> to [iterator.traits]/1 (#4185)
* Conform `std::iterator_traits<fmt::appender>` to [iterator.traits]/1

> In addition, the types
> ```c++
> iterator_traits<I>::pointer
> iterator_traits<I>::reference
> ```
> shall be defined as the iterator’s pointer and reference types; that is, for an iterator object `a` of class type, the same type as `decltype(a.operator->())` and `decltype(*a)`, respectively. The type `iterator_traits<I>::pointer` shall be void for an iterator of class type `I` that does not support `operator->`. Additionally, in the case of an output iterator, the types
> ```c++
> iterator_traits<I>::value_type
> iterator_traits<I>::difference_type
> iterator_traits<I>::reference
> ```
> may be defined as `void`.

* Remove unnecessary member types from basic_appender

This reverts commit 1accf6c0a0.

* Address clang-format issue
2024-10-03 09:05:14 -07:00
18792893d8 Silencing Wextra-semi warning (#4188) 2024-10-03 09:00:55 -07:00
c90bc91862 Bump actions/checkout from 4.1.6 to 4.2.0 (#4182)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](a5ac7e51b4...d632683dd7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-01 13:39:00 -07:00
c95722ad62 Improve naming consistency 2024-09-29 18:17:44 -07:00
db06b0df87 Use countl_zero in bigint 2024-09-29 17:11:22 -07:00
b9ec48d9ca Cleanup bigint 2024-09-29 12:03:07 -07:00
3faf6f181e Add min_of/max_of 2024-09-29 10:24:39 -07:00
d64b100a30 Relax constexpr 2024-09-29 10:04:57 -07:00
ff9ee0461a Fix handling FMT_BUILTIN_TYPES 2024-09-28 09:23:48 -07:00
1c5883bef0 Test nondeterministic conversion to format string 2024-09-28 09:16:28 -07:00
cacc3108c5 Don't assume repeated evaluation of string literal produce the same pointer
Patch by @zygoloid (#4177).
2024-09-28 08:09:33 -07:00
fade652ade Require clang >=15 for _BitInt support (#4176)
For appleclang, fixes issue #4173
2024-09-26 16:10:51 -07:00
96dca569a1 Module linkage fixes for shared build (#4169)
* Mark some in-class defined member functions as explicitly inline/constexpr, to avoid missing external symbols when using fmt module with shared build due to modules not defaulting to implicit inline.

* Switch constexpr to inline for context::arg(string_view).
NOTE: Looks as if basic_format_args::get(string_view) could probably be made constexpr instead, but sticking with minimal change approach.

* Work around apparent non-conformance of older MSVC compilers.

* Switch format_int::str() from constexpr to inline to satisfy libstdc++ std::string constexpr limitations.

* Replace usages of macros for constexpr/inline with keywords.

* Fix for locations requiring C++14 constexpr.

* Further minor constexpr tweaks.

* Apply clang format
2024-09-26 07:53:55 -07:00
891c9a73ae Cleanup format API 2024-09-22 15:52:55 -07:00
9282222b7d Export more 2024-09-22 15:10:58 -07:00
e5b20ff0d0 Deprecate detail::locale_ref 2024-09-22 10:44:38 -07:00
ff92223549 Simplify locale handling 2024-09-22 10:21:19 -07:00
80c4d42c66 Cleanup format.h 2024-09-22 08:20:26 -07:00
3b70966df5 Add width and alignment support to error_code 2024-09-21 07:58:03 -07:00
05226c4bd9 Remove type_identity 2024-09-20 19:13:09 -07:00
c283b458a5 Cleanup format.h 2024-09-20 19:00:23 -07:00
fe79932c26 Fix conversion warning on chrono.h (#4170)
* Fix conversion warning on chrono.h

warning: conversion from 'time_t' {aka 'long long int'} to 'long int' may change value [-Wconversion]

* Changing write_utc_offset to accept a long long instead of the static_cast as requested..
2024-09-20 16:47:27 -07:00
23fcf1942a Apply clang-format 2024-09-20 09:34:10 -07:00
3f296e3d4a Workaround clang-format nonsense 2024-09-20 09:05:59 -07:00
a197a994c5 Add member format_as for std 2024-09-20 08:49:49 -07:00
6d43c755bc Fix a typo 2024-09-19 10:49:11 -07:00
1f87b1c58d Use fmt::formatter specialization for std::reference_wrapper to avoid undefined behavior (#4164)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-19 10:34:33 -07:00
ed8f8be70d More chrono padding (#4161)
* Add padding modifier to day of year, duration's remains unpadded
* Add padding modifier for %m, %Y
2024-09-18 09:27:45 -07:00
55a0a9cd62 Cleanup pragma detection 2024-09-17 19:46:30 -07:00
5c926d9ff9 Remove FMT_UNCHECKED_ITERATOR 2024-09-17 19:40:29 -07:00
8b024662d4 Remove unnecessary inheritance 2024-09-17 19:31:55 -07:00
2f1424be90 Simplify handling of arrays 2024-09-17 19:05:43 -07:00
239aa6911b Remove unwrap_named_arg 2024-09-16 20:46:47 -07:00
497df6db61 Remove formattable 2024-09-16 20:32:27 -07:00
a25e594f6a Remove range_mapper 2024-09-16 20:24:30 -07:00
503dff93ec Simplify has_formatter 2024-09-16 20:15:54 -07:00
3374a95b50 Simplify has_formatter 2024-09-16 20:08:52 -07:00
0e62e5dc7c Simplify has_formatter 2024-09-16 19:53:31 -07:00
7ce013971b Sync value ctors and type mapper 2024-09-16 19:23:08 -07:00
07e70151d5 format std::reference_wrapper 2024-09-16 19:05:18 -07:00
4197727712 Improve handling of unformattable args 2024-09-16 18:52:18 -07:00
527e98e3f8 Remove unformattable 2024-09-15 17:28:27 -07:00
8a19b2db77 arg_mapper -> type_mapper 2024-09-15 17:09:49 -07:00
e97df46ae1 Cleanup type mapping 2024-09-15 16:18:21 -07:00
39f1e0903a Remove FMT_MAP_API 2024-09-15 10:52:36 -07:00
d832830f60 Cleanup type mapping 2024-09-15 09:58:09 -07:00
b329ff194f Always detect encoding on Windows 2024-09-15 08:52:33 -07:00
2af403ce64 Simplify type mapping 2024-09-14 21:21:49 -07:00
b7513b1d00 Simplify type mapping 2024-09-14 20:23:42 -07:00
761d35f763 Cleanup format_as handling 2024-09-14 19:34:58 -07:00
545dc4148a Add value ctor taking name_arg 2024-09-14 10:33:15 -07:00
3f5e45dd33 Simplify handling of _BitInt 2024-09-14 10:15:36 -07:00
2e3b6fbd9f Remove redundant check 2024-09-14 09:48:33 -07:00
a0328e1f9f Improve error reporting 2024-09-14 09:39:41 -07:00
de28ef5f86 Remove make_arg 2024-09-14 09:18:47 -07:00
2d5e561a6b Cleanup argument handling 2024-09-14 08:56:04 -07:00
6537fb439c Update changelog 2024-09-14 08:14:22 -07:00
50aac2ac92 Add reference to iterator_traits 2024-09-14 08:07:39 -07:00
538d8777e5 Workaround a bug in libstdc++ 2024-09-14 07:49:10 -07:00
0335312320 Demacrify UTF-8 check 2024-09-13 18:41:10 -07:00
463fe65f17 Cleanup FMT_COMPILE_STRING 2024-09-12 19:57:50 -07:00
1782a6eac0 Rename pragma macros 2024-09-12 19:20:32 -07:00
b52fb98846 Fix no locale build 2024-09-11 20:37:44 -07:00
b6a6ec7f1c FMT_EXCEPTIONS -> FMT_USE_EXCEPTIONS 2024-09-11 19:34:12 -07:00
89999f1672 Simplify pragma 2024-09-11 18:52:56 -07:00
b90b4bc981 Remove FMT_STATIC_THOUSANDS_SEPARATOR in favor of FMT_USE_LOCALE 2024-09-11 18:30:05 -07:00
a1d6f9a973 Minor cleanup 2024-09-11 17:20:20 -07:00
689ec7a087 Cleanup 2024-09-11 16:05:34 -07:00
28143dc99d Cleanup chrono 2024-09-11 15:41:51 -07:00
1bde49e545 Remove FMT_USE_USER_LITERALS 2024-09-11 11:27:27 -07:00
f924d16e47 fix: pass /utf-8 only if the compiler is MSVC at build time 2024-09-11 08:21:07 -07:00
ab8f9d5b08 Cleanup format API 2024-09-11 07:52:19 -07:00
6f62db098a Cleanup format API 2024-09-11 07:26:11 -07:00
ab44ee7521 Avoid shadowing 2024-09-11 07:05:45 -07:00
0d4e7e3fee Remove old workaround 2024-09-11 06:17:47 -07:00
8ee89546ff Remove old workaround 2024-09-10 21:06:25 -07:00
a5deb96bf5 Update gcc version 2024-09-10 20:52:35 -07:00
61a241f03f Cleanup 2024-09-10 20:24:57 -07:00
ff82d8d2b5 Cleanup visit 2024-09-10 20:09:44 -07:00
0cc20f5639 Remove iterator_t 2024-09-10 19:51:57 -07:00
2ba6785d8f Remove unused type 2024-09-10 19:00:08 -07:00
5644e7507c Remove unnecessary forwarding 2024-09-10 18:35:32 -07:00
5345cfe6b3 Adjust clang-format 2024-09-10 18:24:35 -07:00
3e9fdb3a1f Cleanup 2024-09-10 17:27:49 -07:00
3ada4aed20 Optionally exclude Unicode data 2024-09-08 16:52:01 -07:00
b37be85bf1 Optionally disable named arguments 2024-09-08 16:25:33 -07:00
70643b2511 Don't use format_error if exceptions disabled 2024-09-08 15:56:36 -07:00
967e2d177d Cleanup 2024-09-08 15:43:11 -07:00
02c5d637c5 Cleanup 2024-09-08 11:13:44 -07:00
047bf75c24 Cleanup 2024-09-08 10:00:25 -07:00
2d3ba32e79 Improve debug codegen 2024-09-08 09:17:59 -07:00
6c90b31fbd Improve debug codegen 2024-09-08 07:49:02 -07:00
9408c2ae8c Readd support for FMT_BUILTIN_TYPES 2024-09-07 08:12:03 -07:00
cc3ff1529d Cleanup 2024-09-06 17:05:48 -07:00
158893b384 Cleanup 2024-09-06 13:39:03 -07:00
f5a16a484b Cleanup 2024-09-06 12:41:53 -07:00
cad876be4c Switch to vargs 2024-09-06 12:12:39 -07:00
debf6f8285 Switch to vargs 2024-09-06 09:10:39 -07:00
35f4fab4c4 Simplify value ctor 2024-09-06 08:59:43 -07:00
ff8f324786 Minor cleanup 2024-09-06 08:47:24 -07:00
bd48715d81 Simplify make_format_args 2024-09-06 08:15:33 -07:00
57d6df62f7 Simplify make_format_args 2024-09-06 08:07:22 -07:00
8ed4a9dcc1 Improve debug codegen 2024-09-06 07:51:22 -07:00
f288f45e46 Prepare for arg_store unification 2024-09-05 19:17:18 -07:00
5bf577ca58 Backport from GoogleTest: "Work around a maybe-uninitialized warning under GCC 12" (0320f517fd)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-05 09:40:55 -07:00
b6de66819e Backport from GoogleTest: "Always initialize fields in MatcherBase constructors" (https://github.com/google/googletest/pull/3797)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-05 09:40:55 -07:00
6870e4b06b Workaround for GCC regression: false positive null-dereference in vector.resize
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-05 09:40:55 -07:00
5cdef76034 Switch to gcc-13 for C++23 tests
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-05 09:40:55 -07:00
a2c290bc34 Suppress a bogus MSVC warning 2024-09-04 17:20:30 -07:00
f1e3016c13 Optimize debug codegen 2024-09-04 17:10:52 -07:00
106dc8fd64 Reduce usage of type_identity 2024-09-04 16:23:51 -07:00
c3344e21e2 Cleanup base API 2024-09-04 15:50:53 -07:00
5f438c967e Remove make_arg 2024-09-04 14:52:14 -07:00
2a257798d4 Reenable FMT_BUILTIN_TYPES 2024-09-04 14:10:40 -07:00
22d50c1a9c Add support formatting std::expected<void, E>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-04 12:31:44 -07:00
1cc10ab68f Make is_formattable work with const/volatile void
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-04 12:31:44 -07:00
6aaf7f4b79 Suppress a gcc 13 warning 2024-09-04 11:43:12 -07:00
b4d1d7f8e6 Improve debug codegen 2024-09-04 08:56:25 -07:00
1e0771c70a Fix broken CI for shared library on macos and linux (#4151)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-09-04 08:53:50 -07:00
3df47a4677 Make is_formattable work with void 2024-09-04 07:33:56 -07:00
b4aea98b55 Small fixes for some issues with modules builds (#4152)
* Avoid module export of member function definitions.

* Do not #include intrinsics header into module purview.
2024-09-04 07:29:41 -07:00
565461a0d3 Update MSVC workaround in compile-test 2024-09-04 06:43:05 -07:00
e2b7238707 Cleanup format string API 2024-09-03 21:30:57 -07:00
1e0c6cdc3b Make symbol sizes shorter 2024-09-03 20:44:37 -07:00
a8bcf81f72 Minor cleanup 2024-09-03 18:39:46 -07:00
15694c9a84 Workaround an MSVC bug 2024-09-03 16:12:29 -07:00
4cae2da0d0 Workaround a clang 17 bug 2024-09-03 15:58:33 -07:00
79e5ae919c Fix locale tests on FreeBSD 2024-09-03 12:50:03 -07:00
894b71da85 Fix handling of _BitInt 2024-09-03 11:32:31 -07:00
7a6a2a79ed Improve debug codegen 2024-09-02 20:29:24 -07:00
387395fc7c Cleanup base API 2024-09-02 15:15:38 -07:00
6a88415499 Add FMT_APPLY_VARIADIC 2024-09-02 13:59:41 -07:00
9a2aae37d4 Cleanup base API 2024-09-02 10:01:14 -07:00
8803768363 Cleanup base API 2024-09-02 09:11:33 -07:00
4fa533c70e Cleanup base API 2024-09-02 09:00:44 -07:00
d980dd7171 Cleanup base API 2024-09-02 07:50:46 -07:00
4eed488c66 Cleanup base API 2024-09-02 07:17:21 -07:00
a6ecd25b80 Improve debug codegen 2024-09-02 06:54:45 -07:00
9f29345ea0 Simplify mapped_type_constant 2024-09-02 06:41:44 -07:00
4986b4c0ef Simplify arg_mapper 2024-09-01 21:59:39 -07:00
a5f4d9820c Simplify arg_mapper 2024-09-01 21:47:41 -07:00
bc3af51272 Reduce the number of instantiations 2024-09-01 19:54:09 -07:00
60740b7c24 Cleanup base API 2024-09-01 19:35:00 -07:00
9ef160d309 Cleanup base API 2024-09-01 19:02:47 -07:00
0b80978c27 Cleanup base API 2024-09-01 18:31:41 -07:00
4f39d88650 Cleanup base API 2024-09-01 18:24:24 -07:00
a86b1acf6a Add mapped_t 2024-09-01 17:48:29 -07:00
c9ef07bc4e Minor cleanup 2024-09-01 17:34:47 -07:00
8c4cfab57a Detemplatize parse 2024-09-01 14:32:55 -07:00
7e3aa6d982 Minor cleanup 2024-09-01 14:17:38 -07:00
7c66216008 Minor cleanup 2024-09-01 12:53:09 -07:00
1416edabbb Cleanup base API 2024-09-01 12:06:40 -07:00
d4aeca9922 Bump actions/upload-artifact from 4.3.3 to 4.4.0 (#4141)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.3 to 4.4.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](65462800fd...50769540e7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-01 11:15:43 -07:00
eee93ddffa Bump github/codeql-action from 3.25.11 to 3.26.6 (#4142)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.11 to 3.26.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b611370bb5...4dd16135b6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-01 11:15:36 -07:00
b310a0d48b Simplify parse_format_string 2024-09-01 11:09:26 -07:00
985c3399d1 Make map static 2024-09-01 09:18:47 -07:00
4a55b0d5fd Remove duplicate error in compile-time checks 2024-09-01 09:03:34 -07:00
64a6c84592 basic_format_parse_context -> parse_context 2024-09-01 08:09:37 -07:00
66920feeee Improve compile-time checks 2024-09-01 07:49:35 -07:00
f4dad85c3a Improve handling of named arguments in compile-time checks 2024-09-01 07:07:14 -07:00
db4becabed Reduce template instantiations 2024-08-31 20:29:58 -07:00
fec2cc7af1 Improve handling of named arguments 2024-08-31 19:55:04 -07:00
621e9c17c5 Clarify why we have TYPE in native_formatter 2024-08-31 17:50:21 -07:00
bca7040556 Simplify compile-time checks 2024-08-31 15:01:25 -07:00
8c4b17fe64 Simplify compile-time checks 2024-08-31 14:49:59 -07:00
516a2e2049 Cleanup FMT_STRING 2024-08-31 14:13:57 -07:00
6797f0c39a Cleanup compile-time checks 2024-08-31 11:26:27 -07:00
db496b47c1 Remove old gcc hack 2024-08-31 09:22:49 -07:00
8eda3c8e90 Cleanup compile-time check 2024-08-31 08:38:53 -07:00
53316903e6 Move string_literal to format.h 2024-08-31 07:08:35 -07:00
8a484ad577 Minor cleanup 2024-08-30 20:53:54 -07:00
b446cc9e67 fwrite_fully -> fwrite_all 2024-08-30 18:43:56 -07:00
0204dd359d Fix _BitInt formatter 2024-08-30 18:30:20 -07:00
d8876b7787 Minor cleanup 2024-08-30 16:17:07 -07:00
c0fab5e2f7 Reject modernity, embrace tradition 2024-08-30 11:26:29 -07:00
64313e915c Move redundant initialization to compile time 2024-08-30 10:51:35 -07:00
8e3da9da2c Improve binary size 2024-08-30 10:27:03 -07:00
2a2f73f7c1 Improve binary size 2024-08-29 19:16:54 -07:00
6dd9194abd Simplify format_to_result 2024-08-29 18:35:42 -07:00
a017bba062 Minor cleanup 2024-08-29 18:22:09 -07:00
5eb023cd56 Improve binary size 2024-08-29 17:31:30 -07:00
f213d83306 Disable locale more 2024-08-29 16:35:15 -07:00
b3ccc2d210 Disable locale more 2024-08-29 15:08:43 -07:00
7477dda28d Simplify is_utf8_enabled 2024-08-29 14:39:26 -07:00
e582d377c2 Simplify locale handling 2024-08-29 14:19:33 -07:00
cd8d01d8cd Minor cleanup 2024-08-29 11:41:43 -07:00
377cf203e3 Add opt out for built-in types 2024-08-29 11:21:29 -07:00
5a0a37340c Add support for _BitInt on clang (#4072)
Issue #4007
Make _BitInt up to 128bits formattable
Note, libstdc++ is_signed doesn't work with _BitInt (so use own)
2024-08-28 18:57:52 -07:00
bbf8b3bd01 insert else branch to avoid unreachable code warning (#4130)
at least MSC caused warning C4702: unreachable code
2024-08-28 16:43:12 -07:00
a3f3f2ec9a Fix gcc 8.1 - 8.3 bug and compilation (#4131)
Fixes issue #4129
2024-08-28 11:25:39 -07:00
e3676ca309 Change std::copy to detail::copy in chrono to fix MSVC compile errors (#4132) 2024-08-28 08:25:40 -07:00
0379bf3a5d Workaround -Wstringop-overflow 2024-08-24 07:56:09 -07:00
c59ee969f3 Improve compile-time formatting (#4127) 2024-08-21 12:02:47 -07:00
1a79bbfa83 Cleanup chrono formatting 2024-08-18 12:17:45 -07:00
89af1ad77d Cleanup chrono formatting 2024-08-18 11:55:33 -07:00
0e741e0daa Minor cleanup 2024-08-18 10:35:01 -07:00
d1acc667c1 Minor cleanup 2024-08-18 09:33:29 -07:00
4fb7008c90 Cleanup duration cast 2024-08-18 08:33:26 -07:00
589898e28b Fix %S doc 2024-08-18 07:40:28 -07:00
62382e3650 Test full exponent range 2024-08-18 06:47:04 -07:00
94b8bc8eae Add an experimental writer API 2024-08-17 09:54:09 -07:00
020af729dd Simplify ostream 2024-08-17 08:38:10 -07:00
fb07b37c5b Prioritize using the header files of self (#4116) 2024-08-13 10:50:49 -07:00
3135421257 Minor cleanup 2024-08-12 07:59:42 -07:00
993f56cff6 Make sign a proper enum class 2024-08-11 13:49:57 -07:00
c6c830e203 Make align a proper enum class 2024-08-11 11:07:18 -07:00
b906c321f0 Get rid of bit fields 2024-08-11 10:28:09 -07:00
f8c0c8ee78 Cleanup public API 2024-08-11 07:29:17 -07:00
c71d03fcb0 Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant (2 of 2) (#4115)
* Change indents to 4 spaces.

* Run isort.

* Remove one extra space on the left hand side of each assignment at p.communicate's input.

* Remove 'from __future__ import annotations'.
This requires changing a 'list[]' into a 'List[]'.

We had previously added this import because the code was making use of operator '|'.
But that is no longer true, so the import shouldn't be needed.
2024-08-11 07:24:50 -07:00
50a8c3e9bf Reduce format specs size 2024-08-10 09:34:35 -07:00
98314319ad Fix ambiguous overload 2024-08-09 15:01:40 -07:00
0ce49aeb4a Add a test case 2024-08-09 10:18:11 -07:00
bf870ae3d1 Fix back_inserter lookup for non-std containers 2024-08-09 07:10:15 -07:00
c98518351e Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant (1 of 2) (#4110)
* Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP compliant.

* Rollback minor change in __init__ signature.

* Rollback minor change in __init__ signature.

* Fix previous commit.

* Add 'from __future__ import annotations' to fix Python 3.8 error when using operator '|'.

* Change doxyxml2html([n]) to doxyxml2html(list(n)) as suggested by Victor.
Change convert_type return type to Optional[str].
2024-08-08 15:22:41 -07:00
9f0c0c468b Add 'n' specifier for tuple and pair (#4107) 2024-08-05 14:56:44 -07:00
9f269062a7 Simplify default formatter 2024-08-05 14:24:07 -07:00
15f939c3de Improve handling of dynamic specs 2024-08-04 09:25:50 -07:00
928a07bb04 Simplify handling of dynamic specs 2024-08-04 09:09:01 -07:00
7891699737 Simplify handling of dynamic specs 2024-08-04 08:47:07 -07:00
58aba5a3de Deprecate append instantiation 2024-08-03 11:55:25 -07:00
5ee14d3508 Reintroduce constexpr fmt::formatted_size for C++20 (#4103)
* Reintroduce constexpr fmt::formatted_size for C++20

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Disable constexpr fmt::formatted_size on Visual Studio 2019

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

---------

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-08-03 07:13:32 -07:00
b9c0e4dd82 Improve spec parsing 2024-08-02 11:57:02 -07:00
8445327c84 Simplify spec handling 2024-08-01 19:59:21 -07:00
8a06cee826 Optimize shortest float formatting 2024-08-01 18:54:56 -07:00
1db2274966 Use us if Unicode is disabled 2024-08-01 10:24:43 -07:00
34ead4b39e Bump msys2/setup-msys2 from 2.23.0 to 2.24.0 (#4098)
Bumps [msys2/setup-msys2](https://github.com/msys2/setup-msys2) from 2.23.0 to 2.24.0.
- [Release notes](https://github.com/msys2/setup-msys2/releases)
- [Changelog](https://github.com/msys2/setup-msys2/blob/main/CHANGELOG.md)
- [Commits](d0e80f58df...5df0ca6cbf)

---
updated-dependencies:
- dependency-name: msys2/setup-msys2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-01 08:32:46 -07:00
3bf26009e4 Bump ossf/scorecard-action from 2.3.3 to 2.4.0 (#4099)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.3 to 2.4.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](dc50aa9510...62b2cac7ed)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-01 08:32:20 -07:00
d326c7298a Fix conversion a surrogate pair (#4095)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-07-30 07:27:11 -07:00
6e462b89aa Get rid of std::copy 2024-07-29 15:58:05 -07:00
aff640c32f Make fmt::appender implement std::output_iterator concept (#4093)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-07-29 09:18:20 -07:00
e23fb6a8b4 Apply clang-format 2024-07-29 08:20:58 -07:00
16b3542f7e Remove float_specs 2024-07-27 12:28:21 -07:00
29d7e58059 Remove float_format 2024-07-27 12:07:19 -07:00
919f7c5e7f Reduce float_specs usage 2024-07-27 11:38:55 -07:00
a80d668a52 Diagnose invalid precision 2024-07-27 10:41:54 -07:00
707d7d923a Apply coding conventions 2024-07-27 09:00:25 -07:00
de6ed8df8b Test alignment 2024-07-26 12:09:47 -07:00
ffdc3fdbd9 Align digits table 2024-07-24 18:43:37 -07:00
0c02813791 Fix doc build 2024-07-24 13:40:54 -07:00
f8581bcecf Add redirect page 2024-07-24 12:21:44 -07:00
31b3c325f6 Mark namespace scope constexpr variable 'buffer_size' inline. (#4084)
* Mark namespace scope constexpr variable 'buffer_size' inline.

* Use provided macro for inline variable.
2024-07-24 09:58:38 -07:00
52b32081f9 Wrap private module fragment content within conditional extern "C++", to match declarations. (#4083) 2024-07-24 06:25:23 -07:00
0b0b09f401 Constrain format_uint 2024-07-23 06:30:35 -07:00
4173a6315a Improve format_decimal 2024-07-22 17:24:56 -07:00
4239dfe081 Simplify format_decimal 2024-07-22 17:00:16 -07:00
ba36a04811 Remove counting_iterator 2024-07-22 16:24:13 -07:00
f6b4a23b83 Unbloat chrono 2024-07-22 15:46:58 -07:00
42d3d703b5 Remove the commenting attempt 2024-07-22 13:48:56 -07:00
9fcd9c4c12 Remove all warning suppressions 2024-07-22 12:41:12 -07:00
7f157dca0a Workaround gcc stringop-overflow bug 2024-07-22 11:31:35 -07:00
524ca1c715 Improve parsing 2024-07-21 09:57:18 -07:00
bdc45eef76 Simplify on_text 2024-07-21 08:31:03 -07:00
439b6d7212 Reenable print optimization 2024-07-21 08:05:07 -07:00
3cc32fdc8b Mark more formatters nonlocking 2024-07-21 08:00:34 -07:00
0c9fce2ffe Update version 2024-07-20 07:17:38 -07:00
b47d662e71 Update changelog 2024-07-20 07:14:03 -07:00
e84297f255 Bump version 2024-07-20 07:00:12 -07:00
0ad234ad13 Update changelog 2024-07-20 06:57:55 -07:00
de684ef776 Make appender compatible with fill 2024-07-19 15:21:57 -07:00
447c6cbf44 Update changelog 2024-07-19 13:38:27 -07:00
bc8d32e964 Update changelog 2024-07-18 06:37:02 -07:00
0f87d6ffa6 Improve sign processing 2024-07-17 16:13:27 -07:00
808ea0191a Cleanup test 2024-07-17 06:59:24 -07:00
55e76e6c20 Update check-commits script 2024-07-17 06:58:37 -07:00
8757f1f8d6 Add a script to test multiple commits 2024-07-16 06:27:01 -07:00
9228f349a5 Inline visit 2024-07-14 15:34:53 -07:00
e10643add2 Add a perf-sanity test 2024-07-14 14:17:39 -07:00
f29a7e7970 Don't use memcpy in append 2024-07-14 13:02:21 -07:00
f97deb0d7d Minor cleanup 2024-07-14 11:14:49 -07:00
3541353512 Apply minor optimization 2024-07-14 09:52:44 -07:00
5ef93a9f80 Expand FMT_FORMAT_AS to include implicit conversions (#4055)
Allows (for example) types convertible to std::string_view to inherit
from the fmt::formatter<fmt::string_view> to work etc.
2024-07-14 09:51:49 -07:00
c9102619da Avoid extra reserve 2024-07-14 08:41:35 -07:00
58d792b6d3 Apply minor optimizations 2024-07-14 07:05:18 -07:00
25adca5666 Remove redundant overload 2024-07-13 13:07:57 -07:00
1408f1824d Simplify iterator detection 2024-07-13 11:11:47 -07:00
3fe4641d3a Add 2 more constexprs to fix compile error (#4065) 2024-07-13 08:23:49 -07:00
33e7ed1eb5 Improve handling of back_insert_iterator that writes into a buffer 2024-07-13 07:56:11 -07:00
6a192f8d34 Fix broken links in README.md (#4066) 2024-07-12 11:21:35 -07:00
92cdbbae06 Update api.md 2024-07-10 15:50:10 -07:00
13038f37e8 Support printing (const) volatile void* (#4056)
Fixes #4049
2024-07-10 08:35:06 -07:00
6725225750 Update changelog 2024-07-09 13:22:56 -07:00
e60ff504ea Fix usage with std::generator (#4057)
Fixes #4053
2024-07-09 08:46:34 -07:00
ccea338070 Update lint.yml 2024-07-08 15:19:57 -07:00
92227c77a4 Improve support for non-POSIX platforms more 2024-07-08 14:00:00 -07:00
486838f26f Improve support for non-POSIX platforms 2024-07-08 11:18:44 -07:00
a43391199f Update changelog 2024-07-07 10:05:03 -07:00
7a8b54a0ef Don't confuse Glib::ustring with std::string 2024-07-06 13:27:06 -07:00
b50e685db9 Update version 2024-07-05 08:25:31 -07:00
e314776c2e Fix version check 2024-07-05 08:25:10 -07:00
2208143acc Update changelog 2024-07-05 08:20:52 -07:00
a96259701e Improve std::complex formatter (#4050)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-07-04 17:24:01 -07:00
232c6bc481 Update changelog 2024-07-04 08:02:45 -07:00
503e183b9e Bump version and add version validation 2024-07-04 07:49:58 -07:00
e50c8b6bd8 Fix disabling Unicode support 2024-07-04 07:27:22 -07:00
9d946a2fc4 Fix compilation errors due to make_format_args in gcc 14.1.1 with c++20 (#4042) 2024-07-03 12:41:08 -07:00
c4f6fa7135 fix: Make basic_format_arg::visit() const (#4043) 2024-07-01 14:43:52 -07:00
10f12fd3d2 Bump github/codeql-action from 3.25.3 to 3.25.11 (#4041)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.3 to 3.25.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](d39d31e687...b611370bb5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 12:16:55 -07:00
24c1f886af Remove double has_value check (#4040)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-07-01 09:24:33 -07:00
0041a40c13 Update version 2024-07-01 06:02:59 -07:00
686339f7c1 Minor cleanup 2024-06-30 10:29:50 -07:00
e355c116f9 Tweak wording in the changelog 2024-06-30 09:22:44 -07:00
707bb5b369 Fix grammar 2024-06-30 08:54:56 -07:00
6f68c62cb5 Ignore doxygen files 2024-06-30 08:42:34 -07:00
d059fe42a8 Ignore vagrant files 2024-06-30 08:33:37 -07:00
43c5b34749 Fix package build 2024-06-30 08:23:25 -07:00
e89568e6cb Update vagrant config 2024-06-30 07:56:35 -07:00
f5bf6f7781 Update build script 2024-06-30 07:55:57 -07:00
bd9af9a9f1 Update changelog 2024-06-30 07:49:55 -07:00
1652108905 Fix typo 2024-06-29 09:38:40 -07:00
84f6131825 Fix formatting of release notes 2024-06-29 09:36:35 -07:00
dedc17c1c9 Fix handling of tables, take 3 2024-06-29 09:31:32 -07:00
5d0adb6d74 Fix handling of tables, take 2 2024-06-29 09:29:06 -07:00
3f251fc9c9 Fix handling of tables 2024-06-29 09:23:02 -07:00
1930ed4bfa Fix release script 2024-06-29 09:09:55 -07:00
26d07e49b2 Fix formatting 2024-06-29 09:06:49 -07:00
949d5d1795 Fix build script 2024-06-29 08:59:54 -07:00
53186535d5 Bump version 2024-06-29 08:54:52 -07:00
602e3c3d11 Update build script 2024-06-29 08:54:03 -07:00
2952130cbc Fix doc build 2024-06-29 08:50:16 -07:00
1e94a463ed Create build dir 2024-06-29 08:49:01 -07:00
a34120329a Update doc script 2024-06-29 08:38:16 -07:00
0fae326c42 Update site dir 2024-06-29 08:32:24 -07:00
8b1fcf5cc1 Update doc dir 2024-06-29 08:18:24 -07:00
ec46c3de97 Update build script 2024-06-29 08:05:52 -07:00
2d9d32c62b Update build script 2024-06-29 07:25:35 -07:00
4703ade76d Update build script 2024-06-29 07:22:57 -07:00
52e7b25f95 Update changelog 2024-06-29 07:07:39 -07:00
b61c8c3d23 Change actions/github-script from e69ef54 -> 60a0d83 (#4038)
* Change actions/github-script from e69ef54 -> 60a0d83

* Change google/oss-fuzz action from 32f1d4d to 9218255
2024-06-27 12:34:07 -07:00
bbf44cc000 Defines are still needed for FMT_MODULE as well (#4027) 2024-06-24 07:11:35 -07:00
06948fa710 Pin deps 2024-06-23 07:27:58 -07:00
d9899492c1 Simplify deps 2024-06-23 07:22:45 -07:00
ff72f553e3 Update changelog 2024-06-23 06:58:05 -07:00
7f951f2502 Optimize range formatter 2024-06-23 06:51:46 -07:00
7ae102bd66 make format_int constexpr (#4032)
* make format_int constexpr

* format_int can only be constexpr in C++20

* apply clang-format

* drop constexpr for str()
2024-06-23 06:28:39 -07:00
edde973126 Update test names 2024-06-22 11:10:54 -07:00
b1efe8516e Prevent silent data loss 2024-06-22 07:46:16 -07:00
2c0d9e9409 Add a define to force the use of fallback_file 2024-06-21 09:42:02 -07:00
18a9676d95 Add an experimental path 2024-06-21 08:14:20 -07:00
af8cd4e404 Module purview can only contain direct preprocessor code (#4029)
Resolved MSVC Warning C5202: a global module fragment can only contain preprocessor directives
2024-06-19 13:00:29 -07:00
514b6955d2 Suppress a bogus warning in MSVC (#4023)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-06-19 08:49:43 -07:00
ac96773230 Added missing std::declval for non-default-constructible types (#4024) 2024-06-18 11:27:40 -07:00
c00149f5e2 Fix a typo 2024-06-17 06:58:33 -07:00
71244e07de Cleanup includes 2024-06-16 11:10:38 -07:00
a57b0194a6 Correct comments 2024-06-16 11:05:38 -07:00
febd8ed5fe Cleanup includes 2024-06-16 10:59:06 -07:00
0434026a95 Remove build-docs.py 2024-06-16 08:28:23 -07:00
0882bfef2a Don't deploy docs from a PR 2024-06-15 09:58:01 -07:00
2a2048a785 Don't pass seconds as a double in examples 2024-06-15 09:26:49 -07:00
ea1187f4c8 Generate doxyxml in build 2024-06-15 09:15:30 -07:00
1334eedaf5 Improve docs 2024-06-15 09:07:04 -07:00
709169a4d8 Set the anchors 2024-06-15 08:55:22 -07:00
2bf1b3004e Update changelog 2024-06-15 08:16:42 -07:00
8687315e86 Guard more system headers by FMT_MODULE (#4006)
* Guard more system headers by `FMT_MODULE`

* Merge FMT_MODULE and FMT_IMPORT_STD
2024-06-14 10:53:51 -07:00
98dd673cf8 Cleanup cmake 2024-06-14 08:04:11 -07:00
a245a8d4b9 Update changelog 2024-06-13 21:14:31 -07:00
e0b66e8f83 Remove dependency on <ranges> 2024-06-13 15:57:01 -07:00
794df69c8c Added range_format::(debug_)string formatter (#3973) 2024-06-13 15:43:29 -07:00
1d9df9ce1c Remove a redundant comment 2024-06-13 15:41:35 -07:00
c4ea903250 Only install FILE_SET when needed (#4013) 2024-06-13 12:17:46 -07:00
3e3062c13b Update msys2/setup-msys2 to v2.23.0 (#4012)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-06-13 06:14:27 -07:00
b998b47116 Update changelog 2024-06-12 20:27:27 -07:00
bff1de15e7 Fix deploy docs (#4010)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-06-12 10:27:12 -07:00
90932dd20d Update doc.yml 2024-06-11 15:31:05 -07:00
232c5e8547 Update doc.yml 2024-06-11 15:24:18 -07:00
26cdd1cb30 Update doc.yml 2024-06-11 15:15:56 -07:00
ad34d4df95 Update doc.yml 2024-06-11 15:12:47 -07:00
f796264449 Fix doc workflow 2024-06-11 13:43:31 -07:00
28673d9699 Update api.md 2024-06-11 12:27:12 -07:00
a5c1b5d440 Update changelog 2024-06-10 11:30:21 -07:00
cc4d1245b8 README.md: update to remove "not yet release" remarks on clang-tidy
clang v18 was released, see
https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.6
so let's drop the remarks of "not yet released", and encourage user
to the latest stable release of clang-tidy.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2024-06-10 23:18:02 +08:00
18a325f370 Disable footer 2024-06-09 19:02:34 -07:00
a1337aa8aa Merge literal-based API doc into the parent section 2024-06-09 18:16:56 -07:00
51a690ab15 Check if .cc exists in fmt.cc (#4005)
After installation, these files no longer exist and cause errors.
2024-06-09 18:01:44 -07:00
f332a81b72 Remove unnecessary build step 2024-06-09 17:32:13 -07:00
33a1de57af Deploy docs, take 3 2024-06-09 17:26:37 -07:00
c7252b3344 Deploy docs, take 2 2024-06-09 17:19:06 -07:00
3f71b60668 Deploy docs 2024-06-09 17:16:59 -07:00
215ce4d979 Fix error getting config 'user.email' 2024-06-09 17:07:23 -07:00
89f3a810ec Fix error getting config 'user.name' 2024-06-09 17:04:19 -07:00
1f170d3fe0 Install mike 2024-06-09 16:54:53 -07:00
d175db8f5b Fix doc CI and clean workflows 2024-06-09 16:51:19 -07:00
a8cfc0cc2c Deploy dev docs 2024-06-09 16:34:50 -07:00
65e278b286 Don't pollute the source directory 2024-06-09 16:20:54 -07:00
3620c174a6 Fix doc build 2024-06-09 16:10:26 -07:00
702b6f3788 Update docs 2024-06-09 15:59:35 -07:00
ed21034a10 Implement deployment 2024-06-09 15:53:16 -07:00
76d57f93db Remove old script 2024-06-09 13:40:33 -07:00
6ceef04dfe Merge branch 'master' of github.com:fmtlib/fmt 2024-06-09 13:17:31 -07:00
ab6b257a39 Implement doc building 2024-06-09 13:17:13 -07:00
077e4ae746 Added generator expression to /utf-8 compile option (#3995)
Do not pass the compile options in the project to other compilers such as nvcc
2024-06-09 13:05:17 -07:00
d4a8d26c55 Temporarily disable doc build in CI 2024-06-09 11:47:09 -07:00
b5c8fd783c Fix doc build 2024-06-09 11:37:18 -07:00
735a613821 Build docs 2024-06-09 11:26:25 -07:00
a6e6e9c3c9 Fix a link 2024-06-09 11:22:57 -07:00
e6d4f927cc Improve docs 2024-06-09 11:17:32 -07:00
8de3e87da1 Add a CMake option to control Unicode support 2024-06-09 11:16:13 -07:00
46d2acb3ba Don't add os.cc to sources with FMT_MODULE (#4004)
It will be included by `fmt.cc`
2024-06-09 11:00:12 -07:00
fad0222a0c Export compiled_string so that user can customize one (#3999) 2024-06-09 10:58:58 -07:00
d1cab6a9ae Drop parentheses 2024-06-09 10:58:02 -07:00
fcb6a452d6 Improve docs 2024-06-09 10:47:32 -07:00
72928661ed Improve docs 2024-06-09 10:33:34 -07:00
d6ec6b7e27 Update docs 2024-06-09 10:16:19 -07:00
e845fc572e Ignore old changelog 2024-06-09 07:40:02 -07:00
2bf811b1d9 Also allow compiled format for clang >= 12 (#4001) 2024-06-09 06:43:39 -07:00
9653eed8e7 Don't hide the navbar 2024-06-09 06:36:11 -07:00
9b5d1826d4 Update changelog 2024-06-08 18:45:18 -07:00
fe741daaab Mention namespace fmt::literals in the document (#4002) 2024-06-08 14:31:51 -07:00
0f6e716548 Fix missing includes in fmt.cc (#3994)
This causes duplicated std definitions in the fmt module
2024-06-08 13:50:29 -07:00
a3d95971be Update changelog 2024-06-08 08:52:16 -07:00
7bd11b5cdf Remove a redundant extension to reduce divergence from std::format 2024-06-08 08:29:34 -07:00
21372bc0b2 Update cmake config 2024-06-08 08:21:18 -07:00
a0495e3eb5 Update changelog 2024-06-08 08:17:15 -07:00
cba5e8615a Update changelog 2024-06-08 08:15:40 -07:00
e9609dec1a Update changelog 2024-06-08 08:13:08 -07:00
6ebbaf4b4d Split changelog 2024-06-08 08:11:19 -07:00
4e31d2dc61 Update changelog 2024-06-08 08:01:19 -07:00
fcc0b49978 Fix FMT_INSTALL with FMT_MODULE (#3998) 2024-06-08 07:26:53 -07:00
0560c334fb Fix build with FMT_MODULE=OFF (#3997) 2024-06-07 06:25:07 -07:00
db9365a11b Update lint.yml 2024-06-05 21:04:46 -07:00
5c445bc42c Reverting check to make shorter branch comes first 2024-06-05 21:01:42 -07:00
94f96d112d Fix undefined reference when compiling with FMT_STATIC_THOUSANDS_SEPARATOR and chrono.h 2024-06-05 21:01:42 -07:00
6abc1204f3 Check if the generator is ninja 2024-06-05 21:01:42 -07:00
a9b8517638 Use native c++ module support from CMake
also fix some clang compilation issues when using c++ modules
2024-06-05 21:01:42 -07:00
fba06f0ee1 Update changelog 2024-06-05 20:38:44 -07:00
598e518085 Remove redundant tests 2024-06-05 08:38:00 -07:00
0a555818d7 Usage -> Get Started 2024-06-05 07:59:06 -07:00
966a1b3d44 Update docs 2024-06-05 07:19:14 -07:00
adb8e27db0 Fix rendering of template parameters 2024-06-05 07:08:21 -07:00
2c84fa9ac9 Update docs 2024-06-05 06:19:40 -07:00
8da0240dbc Improve docs 2024-06-04 19:46:45 -07:00
83bf142378 Update changelog 2024-06-04 17:09:58 -07:00
595e54919b Cleanup docs 2024-06-04 17:01:04 -07:00
c636967c5c Improve docs 2024-06-04 15:26:38 -07:00
2392367efc Set primary color 2024-06-04 11:20:59 -07:00
06f8e02fb3 Remove rtd compat 2024-06-04 10:43:55 -07:00
c71d08fc22 github: update lint.yml to post details on formatting issue (#3988)
before this change, user need to click into the details for more
details on the formatting issue identified by the lint workflow.

after this change, the workflow pastes the details with a comment,
to provide more specific details on the formatting issue if any.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2024-06-03 06:34:44 -07:00
d9b90029bf Update docs 2024-06-03 06:25:14 -07:00
c0029b9847 Update docs 2024-06-02 21:16:04 -07:00
1ac9b317f2 New landing page 2024-06-02 20:46:16 -07:00
f68dee5351 Fix syntax highlighting 2024-06-02 15:10:10 -07:00
fb9ee2ed65 Simplify doxygen config 2024-06-02 14:27:12 -07:00
d29ceaf915 Update .gitignore 2024-06-02 14:21:46 -07:00
9b12491c19 Migrate docs 2024-06-02 14:20:41 -07:00
ab29ef37d9 Migrate docs and cleanup 2024-06-02 13:17:04 -07:00
97117cbb51 Migrate to mkdocs 2024-06-02 12:21:11 -07:00
886237ae7b Emit anchors 2024-06-02 10:32:53 -07:00
904f2a5c20 Remove a non-pinned dependency 2024-06-02 10:00:24 -07:00
dab1a65d2c Sort out directory URI config 2024-06-02 09:47:52 -07:00
509d018101 Fix a link 2024-06-02 09:29:33 -07:00
75ab3bc2a0 Add a script to invoke mkdocs 2024-06-02 09:29:07 -07:00
871538d3ab Fix install dir 2024-06-02 09:05:32 -07:00
250456d5a3 Migrate to mkdocs 2024-06-02 09:00:40 -07:00
38ba3d3993 Migrate to mkdocs 2024-06-02 08:26:56 -07:00
0714113974 Add macro support to api doc extraction 2024-06-02 08:06:52 -07:00
dd3b3f937b Merge branch 'master' of github.com:fmtlib/fmt 2024-06-02 07:02:05 -07:00
03d14c3beb Add support for multiple namespaces 2024-06-02 07:01:40 -07:00
416ac0fc7b Bump actions/checkout from 4.1.0 to 4.1.6 (#3986)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8ade135a41...a5ac7e51b4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-02 06:22:27 -07:00
596add8993 Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (#3984)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.1 to 2.3.3.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](0864cf1902...dc50aa9510)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-02 06:22:07 -07:00
a10e032148 Improve docs 2024-06-01 20:08:41 -07:00
febeb51bde Documentation improvements 2024-06-01 17:45:06 -07:00
f18c2b65c4 Fix rendering of aliases 2024-06-01 14:40:39 -07:00
e3910b8a9c Improve apidoc rendering 2024-06-01 10:24:46 -07:00
34b85678f9 Render members 2024-06-01 10:07:33 -07:00
e5c07c8356 Improve apidoc formatting 2024-06-01 09:37:32 -07:00
933d8ba352 Improve apidoc formatting 2024-06-01 09:24:32 -07:00
e7ba467e9b Improve apidoc formatting 2024-06-01 09:05:17 -07:00
91a859ee4a Switch to markdown 2024-06-01 08:56:26 -07:00
6180442ed8 Render template parameters 2024-06-01 08:30:25 -07:00
418c5d0949 Render template params 2024-06-01 08:25:14 -07:00
aafdde7ef8 Switch to JavaScript syntax highlighter 2024-06-01 08:04:55 -07:00
d2ecfcfc45 Fix rendering on github 2024-06-01 07:33:57 -07:00
26b249435e Improve doc presentation 2024-06-01 07:32:43 -07:00
4f330567e1 Improve apidoc generation 2024-06-01 07:02:45 -07:00
1992746249 Convert API doc to Markdown 2024-06-01 07:02:03 -07:00
a4d42c44f4 Cleanup comments 2024-06-01 07:00:56 -07:00
ddd8a54230 Add mkdocs config 2024-06-01 06:50:57 -07:00
fcd3e1e19c is_convertible_v -> is_convertible::value (#3983) 2024-05-31 10:02:59 -07:00
dc401b1c28 Move handlers outside of the docs 2024-05-31 07:22:22 -07:00
f7c5588c46 Cleanup syntax doc 2024-05-31 06:57:10 -07:00
a4e40677af Fix markdown 2024-05-30 21:14:06 -07:00
3479828e1d Fix markdown 2024-05-30 20:27:21 -07:00
191b0cb486 Fix markdown 2024-05-30 20:26:19 -07:00
e80f4a9b72 Cleanup syntax doc 2024-05-30 12:44:56 -07:00
022d8efec9 Update doc.yml
Temporarily disable doc build
2024-05-30 11:57:02 -07:00
ca8eeb09ee Add glibc ext for day of month and week of year (#3976) 2024-05-30 10:20:56 -07:00
cddb41f633 Fix markdown 2024-05-30 06:38:40 -07:00
0b0a05770f Remove old contents 2024-05-29 21:47:45 -07:00
caa97da1f5 Add a word joiner to prevent line break 2024-05-29 21:40:58 -07:00
cf9833f40b Cleanup apidoc comments 2024-05-29 20:30:19 -07:00
b6638f9c29 Convert usage to Markdown 2024-05-29 20:14:23 -07:00
d903460137 Fix markdown 2024-05-29 20:13:11 -07:00
ba2fbf6e1f Fix markdown 2024-05-29 19:43:52 -07:00
6e49bb887a Remove CSS 2024-05-29 19:10:27 -07:00
e0f3e85076 Fix markdown 2024-05-29 19:09:54 -07:00
4fc3fce9cb Improve syntax markdown 2024-05-29 19:01:09 -07:00
d6427ae7b2 Improve syntax markdown 2024-05-29 18:41:25 -07:00
3d6869065b Improve syntax markdown 2024-05-29 18:32:33 -07:00
551aa8d510 Add CSS 2024-05-29 18:10:55 -07:00
9e07045f50 Fix links 2024-05-29 17:29:41 -07:00
5735048b2d Improve mkdocstrings handler 2024-05-29 17:29:25 -07:00
33eba1049d Minor comment fix 2024-05-28 11:39:49 -07:00
43ab964c47 MSVC 17.10.0 + modules cannot find definition (#3972)
MSVC regressed since the new 17.10.0 compiler update. node<> cannot be found for detail::dynamic_arg_list::typed_node.
2024-05-28 11:34:44 -07:00
728f9bc388 Added std::type_info formatter (#3978)
* Added std::type_info formatter;
* Reused std::type_info formatter in std::exception formatters;
* Updated MSVC std::type_info outputting to exclude all class, struct and enum occurences.
2024-05-28 10:57:08 -07:00
e721046e27 Convert index to Markdown 2024-05-27 20:03:30 -07:00
552842c4ff Convert syntax to Markdown 2024-05-27 20:01:33 -07:00
2c38766fd5 Add a mkdocsstrings handler 2024-05-27 19:59:45 -07:00
c8f1b4e744 ci: Remove macos-11 runners, add macos-14 (#3980)
On June 28, 2024, macos-11 runners will be removed.
2024-05-27 10:58:57 -07:00
529dcd11fe Fix workflow, take 2 2024-05-27 08:08:07 -07:00
1441c660bf Fix workflow 2024-05-27 07:07:54 -07:00
ecd1559732 Improve styles 2024-05-27 07:05:53 -07:00
a57a63dc0f Fix styles 2024-05-27 06:39:54 -07:00
8691f21b45 Fix styles 2024-05-27 06:32:28 -07:00
7e4fac3f4f Improve styles 2024-05-26 20:08:42 -07:00
4a368625e8 Replace less with sass 2024-05-26 19:59:42 -07:00
f4e1ec81e2 Cleanup html 2024-05-26 19:23:26 -07:00
89c0d10105 Update description 2024-05-26 13:23:04 -07:00
12ef9e09d1 Fix class conflict 2024-05-26 13:18:43 -07:00
5afa681388 Remove redundant github button 2024-05-26 12:56:29 -07:00
cc13102031 Fix navbar style 2024-05-26 12:35:25 -07:00
8ee6c94014 Reintroduce GCC-11 C++20 into CI (#3979)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-05-26 10:58:26 -07:00
766300b3c6 Update html 2024-05-26 10:25:14 -07:00
4115219ede Fix CSS path 2024-05-26 09:17:33 -07:00
95076981f7 Update documentation deps 2024-05-26 09:11:43 -07:00
1752d7fbbb Added formattable concept (#3974) 2024-05-26 07:47:56 -07:00
1768bf9714 Added FMT_EXPORT for fmt::range_format and fmt::range_format_kind (#3970) 2024-05-24 07:08:07 -07:00
fc723fd6c7 Fix regression in #3710 (#3968)
Regression introduced in 11f2f30
Already have a test for this, but needed to make __cpp_lib_ranges
smaller to enable it
2024-05-23 12:39:11 -07:00
b81761068b Check range_begin is dereferenceable (#3964)
Fixes issue #3839
An Eigen 3.4 2x2 matrix has a begin member function that returns void
Be more strict checking that the result of calling *begin() is valid
See input_or_output_iterator concept notes about void
2024-05-20 16:11:07 -07:00
706eabd5e5 Resolved warning C4127: conditional expression is constant (#3967) 2024-05-20 11:59:19 -07:00
028bffa083 Update checks for dynamic_cast usage when compiled with no rtti (#3963)
* Rename FMT_USE_TYPEID to FMT_HAS_RTTI and use it as check to enable dynamic_cast usage

* FMT_HAS_RTTI->FMT_USE_RTTI
2024-05-19 11:21:55 -07:00
86741b3e1c Bazel support: Add missing platform dependency (#3965) 2024-05-19 06:33:50 -07:00
75e892420e Minor cleanup 2024-05-16 10:45:23 -07:00
0b5287f8b7 Remove unused function 2024-05-15 16:47:35 -07:00
a4715c48b4 Bazel support: Add utf-8 to Windows build (#3962) 2024-05-15 06:33:27 -07:00
8e728044f6 Fix format_as for non-const begin/end views (#3955)
base::format does not accept rvalues, using the result of format_as
directly means it is passed one. Doesn't matter for ranges with a const
begin and end, but filter_view caches, so it only has mutable begin/end.
Use auto&& to avoid copy if format_as returns const ref
2024-05-13 09:35:55 -07:00
1f436c646e Cleanup locking/buffering 2024-05-12 09:34:17 -07:00
db1ee420e0 Cleanup unicode check more 2024-05-11 20:02:22 -07:00
7d6ae972b9 Cleanup unicode checks 2024-05-11 19:43:46 -07:00
3460b30fd5 Improve utf-8 detection 2024-05-11 18:58:40 -07:00
b7809f91e2 Enable Unicode support by default 2024-05-11 15:11:23 -07:00
1dc71f21ea Enable Unicode by default 2024-05-10 18:27:45 -07:00
8db8f22490 Optimize join_view 2024-05-09 17:26:26 -07:00
d2473b7b73 Simplify join_view formatter 2024-05-08 15:42:49 -07:00
328d256c60 Apply coding conventions 2024-05-06 15:10:29 -07:00
57593a123b Simplify map formatter 2024-05-06 15:09:31 -07:00
10508a30ec Enable fmt::join for uncopyable iterators (#3946)
If iterator not copyable mutate the underlying iterator
Notably std::ranges::basic_istream_view::__iterator
Addresses issue (#3802)
2024-05-05 15:44:23 -07:00
16cec4f591 Make the map formatter correctly handle elements with custom formatters 2024-05-04 10:59:16 -07:00
77bfd8499a Split range and map formatters 2024-05-04 09:41:02 -07:00
3af8ac7a06 Privatize write_debug_string 2024-05-04 07:38:58 -07:00
ceb406d06c Remove range_default_formatter 2024-05-04 07:20:40 -07:00
19afc9c3bb Update README.md 2024-05-03 17:32:54 -07:00
6ff593b027 Update README.md 2024-05-03 09:30:44 -07:00
78420beddd Update README.md 2024-05-03 09:21:05 -07:00
a21bc7b869 Update doc.yml 2024-05-03 09:01:35 -07:00
97d0613ba9 Update doc.yml 2024-05-03 08:47:00 -07:00
04b0ae418b Update doc.yml 2024-05-03 08:32:02 -07:00
27dd1dcf08 Update lint.yml 2024-05-03 08:18:33 -07:00
3649c3954f Update lint.yml 2024-05-03 07:59:52 -07:00
7650ed04a3 Fix to_nonnegative_int 2024-05-03 07:49:16 -07:00
9234fe83f9 Add tests to check that isnan doesn't cause FP errors 2024-05-02 09:36:21 -07:00
8a8f4825a3 Fix: isnan() shouldn't cause FP exceptions
Fixes #3948.
2024-05-02 09:36:21 -07:00
17062a0c9b Bump actions/upload-artifact from 4.3.1 to 4.3.3 (#3950)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.1 to 4.3.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](5d5d22a312...65462800fd)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-01 11:39:32 -07:00
88d3997f5e Bump github/codeql-action from 3.24.9 to 3.25.3 (#3949)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.9 to 3.25.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](1b1aada464...d39d31e687)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-01 08:42:46 -07:00
48c908453d Fix CodeQL alert (#3945) 2024-04-30 12:41:29 -07:00
cf1f55f798 Specialize formatter for all std::basic_string types (#3943)
* Specialize `formatter` for all `std::basic_string` types

* mock-allocator: add member types to make GCC 4.8 happy
2024-04-23 08:44:41 -07:00
400f6a8ee2 Dedup ADL begin/end lookup 2024-04-22 16:09:07 -07:00
a3e0931ea2 Update signature in the doc 2024-04-22 15:26:09 -07:00
51eeccd0fb const void* is neither a fundamental nor string type 2024-04-22 13:59:26 -07:00
f30f1fd514 Document formatter specializations provided by base.h 2024-04-22 13:39:14 -07:00
f4b256c667 Fix warning C26439 2024-04-19 09:06:46 -07:00
f746a59a5c Cleanup FMT_ASSERT 2024-04-19 08:36:16 -07:00
ee0c3351a4 Fix format_to + FMT_STRING for wide character type (#3931)
Added overload that takes a wformat_string.
Fixes issue #3925.
2024-04-17 08:30:48 -07:00
99735764ea Fix FMT_USE_NONTYPE_TEMPLATE_ARGS define back (#3937)
Broken in refactor f1924d3
2024-04-16 13:29:30 -07:00
aa52eb765d Resolved warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _fileno. (#3930) 2024-04-11 11:13:57 -07:00
116a9ce488 Added FMT_IMPORT_STD feature macro (#3928) 2024-04-10 11:48:32 -07:00
5eb68c0ef2 Fix mix-up of 'FMT_BEGIN_EXPORT' and 'namespace detail'. (#3924) 2024-04-08 09:46:20 -07:00
550437b29e Resolved warning C4127: conditional expression is constant (#3923) 2024-04-07 11:01:26 -07:00
4e8640ed90 Fix: enable FMT_NORETURN without exception support too (#3917)
When building `format.cc` as such with GCC 13.2.1:

    $ g++ -c format.cc -DFMT_EXCEPTIONS=0 -Wmissing-noreturn -Werror

I get:

    In file included from format.cc:8:
    fmt/format-inl.h: In function ‘void fmt::v10::detail::assert_fail(const char*, int, const char*)’:
    fmt/format-inl.h:30:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
       30 | FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
          |               ^~~~~~~~~~~
    fmt/format-inl.h: In function ‘void fmt::v10::report_error(const char*)’:
    fmt/format-inl.h:129:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
      129 | FMT_FUNC void report_error(const char* message) {
          |               ^~~~~~~~~~~~
    cc1plus: all warnings being treated as errors

Note that, with `FMT_EXCEPTIONS` defined to 0:

‣ report_error(const char *) uses FMT_THROW() which expands to calling
  assert_fail().

‣ assert_fail() calls std::terminate() which has the `[[noreturn]]`
  attribute since C++11 [1].

Therefore, with `FMT_EXCEPTIONS` defined to 0, both assert_fail() and
report_error() need to have the `[[noreturn]]` attribute too (if
available). In other words, `FMT_NORETURN` doesn't depend on
`FMT_EXCEPTIONS`.

Also adding `FMT_NORETURN` to two on_error() functions which call
report_error(const char *).

Other report_error() overloads eventually return, therefore they don't
need `FMT_NORETURN`.

[1]: https://en.cppreference.com/w/cpp/error/terminate

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
2024-04-04 17:15:18 -07:00
c70e7b7473 Coding conventions and minor fixes 2024-04-05 08:36:45 +09:00
71144eeaff implement year_month_day (#3913)
* implement year_month_day, also changed weekday, day, month, year's formatter to use formatter<std::tm, Char> so they all support the format strings
* support ":L" for month and weekday
2024-04-03 15:35:53 -07:00
843e293564 Bump github/codeql-action from 3.24.6 to 3.24.9 (#3915)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.6 to 3.24.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](8a470fddaf...1b1aada464)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-03 15:21:30 -07:00
f5ec5ada2b Update syntax.rst 2024-03-30 15:54:39 -07:00
3b5f3de3b5 Make CMake version message less confusing (#3907) 2024-03-28 18:23:26 -07:00
ca9193983b Replace std::fill_n with fmt::detail::fill_n (#3909)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-28 17:26:18 -07:00
74a187288b Implemented fmt::day, fmt::month, fmt::year and related unit tests (#3906) 2024-03-27 17:10:30 -07:00
88620e53a4 Range formatting documentation (#3905) 2024-03-24 14:39:16 -07:00
5d63e87d23 Add a formatter for float128 2024-03-22 15:41:50 +09:00
aecec01b34 Initial support for extended FP types 2024-03-22 15:08:25 +09:00
5af88653eb Cleanup 2024-03-22 13:46:03 +09:00
45b772f85c Improve std::complex formatter to be compatible with P2197R0 (#3900)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-20 13:31:32 -07:00
53347891cf Make line buffering test less flaky 2024-03-20 16:45:50 +09:00
38881e5acf Fix handling of the fileno macro 2024-03-20 05:06:36 +09:00
6c7cc6a06f Fix group_digits for negative integers (#3901)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-19 13:03:57 -07:00
365c3fbd25 Bump timeout 2024-03-19 10:49:02 +09:00
c0dac83982 Use p2197 format for complex by default 2024-03-19 07:55:45 +09:00
bb882c03bc Simplify path formatting 2024-03-19 07:47:42 +09:00
12acd7988b Fix ambiguous call
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-17 17:16:53 -07:00
c710bfa10c Apply clang-format
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-17 15:26:18 -07:00
73f2b344b2 Add std::complex formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-17 15:26:18 -07:00
9f3fc6e38b Add XChar support into nested_formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-17 15:26:18 -07:00
c17816cb4a Fix invalid fmt::formatter<>::format return type (#3895)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-15 06:25:42 -07:00
df6e7b22f7 Fix relative path for cmake in usage doc (#3890) 2024-03-12 06:56:12 -07:00
c816fa6751 Fix a warning 2024-03-10 10:27:42 -07:00
e281749c5d Simplify range formatter 2024-03-10 08:19:26 -07:00
11f2f30f0b Simplify range formatter 2024-03-09 08:23:12 -08:00
13cfaa2ab0 Guard against usage of _isatty when header was not included (#3880)
* Guard against usage of _isatty when header was not included

* Rename FMT_WINDOWS_NO_WCHAR macro to FMT_USE_WRITE_CONSOLE
2024-03-08 13:34:46 -08:00
0861db500f Support character range formatting (#3863) 2024-03-07 10:51:46 -08:00
dfe5b12c08 Update os-test.cc (#3883)
uniq test file names for the os-test suite (#3878 issue).
2024-03-06 06:37:57 -08:00
09935d8239 Bump github/codeql-action from 3.23.2 to 3.24.6 (#3876)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.23.2 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b7bf0a3ed3...8a470fddaf)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-03 06:46:32 -08:00
3bc6cc1e63 Protect against locking formatters 2024-03-02 17:23:02 -08:00
4fcc317dc9 Bump actions/upload-artifact from 4.3.0 to 4.3.1 (#3875)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.0 to 4.3.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](26f96dfa69...5d5d22a312)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-01 12:20:00 -08:00
ae1e93d34d Fix warning C4702 emitted from format.h (MSVC) (#3866) 2024-02-28 07:47:13 -08:00
f68f452dea Workaround an ld warning on macOS 2024-02-25 11:41:52 -08:00
ebea5736a2 Fix chrono locale format bug for RHEL gcc (#3859) 2024-02-25 07:09:33 -08:00
ddf0b7d2b5 Fix warning C4365 emitted from printf.h (#3865) 2024-02-23 16:33:21 -08:00
0166f455f6 std.h c++23 build fix (#3856)
Add ::value to is_formattable<...> as per suggestion by @vitaut in
https://github.com/fmtlib/fmt/issues/3854
2024-02-19 10:19:39 -08:00
8e42eef495 Don't error on min time_point 2024-02-10 17:50:42 -08:00
91b30e5b4e More API details 2024-02-10 08:10:59 -08:00
7a63e233d2 Readd core.h to headers 2024-02-10 07:10:28 -08:00
44c3fe1ebb Fix handling of static separator 2024-02-09 15:58:56 -08:00
ae181cc93d C++23 compatibility: basic_string_view cannot be constructed from nullptr (#3846)
Co-authored-by: Anders Dalvander <anders.dalvander@sartorius.com>
2024-02-09 07:39:43 -08:00
3a6fb2fcaf Fix some typos. (#3843) 2024-02-08 10:59:52 -08:00
0879504796 Fix typo in typename. containter_type -> container_type. (#3844) 2024-02-08 06:24:55 -08:00
34f415b56e Fix %S formatting for chrono durations with leading zeroes (#3814) 2024-02-07 09:47:32 -08:00
e17bc67547 Make scan variadic 2024-02-04 08:07:00 -08:00
06311ed1ce Fix fixed rounding around zero in Dragon 2024-02-03 10:13:58 -08:00
e5bab8dab4 added formatter for std::expected (#3834) 2024-02-03 09:06:15 -08:00
9f5f39cb50 Bump actions/upload-artifact from 4.0.0 to 4.3.0 (#3837)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.0.0 to 4.3.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](c7d193f32e...26f96dfa69)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-01 09:05:12 -08:00
ea581437e5 Bump github/codeql-action from 2.22.5 to 3.23.2 (#3836)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.5 to 3.23.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](74483a38d3...b7bf0a3ed3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-01 09:04:58 -08:00
6321a97d6b Simplify color formatting 2024-01-31 18:30:23 -08:00
4b6b32f388 Deprecate wide stream function 2024-01-31 18:10:52 -08:00
1b54ba4b9d Fix UB in format_arg_store implementation. (#3833) 2024-01-31 10:08:29 -08:00
71a4a8d479 Really fix MSVC warning about <bit> only being available in C++20. (#3832)
* Really fix MSVC warning about <bit> only being available in C++20.

The warning states "The contents of <bit> are available only with C++20 or later.",
but the check was for C++17 and later.

* Change <bit> inclusion check per https://github.com/fmtlib/fmt/pull/3832#discussion_r1471144867
2024-01-30 10:42:35 -08:00
8e62172ab6 Fix a warning 2024-01-29 07:48:48 -08:00
28afff363c Improve buffering 2024-01-27 16:20:34 -08:00
af44c29744 Separate buffer initialization from flush 2024-01-27 15:39:36 -08:00
a1e1eedbb5 Minor cleanup 2024-01-27 14:00:13 -08:00
ffce3632b7 Add glibc stream support 2024-01-27 11:00:45 -08:00
b5669512b1 Don't hang on test failure 2024-01-27 09:41:33 -08:00
6435b169ec Add support for line buffering 2024-01-27 08:57:21 -08:00
6f260455aa Add scan_data::make_args 2024-01-23 08:17:06 -08:00
e1832bcf00 Consider ADL begin() and end() when joining ranges (#3824)
Closes #3813

Signed-off-by: Beat Bolli <dev@drbeat.li>
2024-01-22 07:39:33 -08:00
2caf1b3b91 scan more 2024-01-21 08:02:54 -08:00
668fe2653c doc: fix the chrono %C example value (#3822)
Assuming that the example date is always "Sat Nov 12 22:04:00 1955", the
result of the `%C` format string should be "19", not "55".

Signed-off-by: Beat Bolli <dev@drbeat.li>
2024-01-21 06:31:15 -08:00
06fc25f266 Don't always enable typeid usage under msvc (#3821) 2024-01-21 06:28:22 -08:00
11ba1270ab Fix flush 2024-01-20 07:58:56 -08:00
4c5b4af04d Improve name argument validation 2024-01-19 16:13:43 -08:00
2eb363297b Fix custom formatter example (#3820)
Add a return type declaration so the example builds when the formatter is used in a different compilation unit than it's implemented.
2024-01-19 08:14:48 -08:00
0147e08225 Document println 2024-01-18 19:42:33 -08:00
6b68dff901 Write directly to a stream buffer 2024-01-18 16:27:12 -08:00
b2cde48de5 Reduce usage of float_specs 2024-01-17 08:27:03 -08:00
8510838db1 Make format_specs not depend on code unit type 2024-01-17 07:50:52 -08:00
090ee13595 Pass char type to write 2024-01-17 06:07:29 -08:00
470c4e6ca8 Fix scope for glibc ext for sec, min, and hour (#3812)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-16 13:54:19 -08:00
13ec66bf78 🛠 Add basic array safety functions and backwards-compatible result type (#3805) 2024-01-16 07:01:15 -08:00
64091b7a25 Fix naming 2024-01-15 15:17:46 -08:00
e954823531 Make fill independent on code unit type 2024-01-15 15:00:28 -08:00
f80a2bee1c Update README.md 2024-01-15 11:40:20 -08:00
83652dfee7 Restrict always inlining to the top-level API 2024-01-15 10:09:01 -08:00
d249fd9f84 Workaround for gcc 6 (#3810)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-15 08:58:19 -08:00
73d91351b4 Mark iterator_buffer move constructors as noexcept. (#3808) 2024-01-15 08:46:35 -08:00
fe0d910a7d Replace multiple error reporting mechanisms with report_error 2024-01-15 07:23:06 -08:00
f9294f0e60 Improve handling of format specs 2024-01-15 06:31:24 -08:00
c98a5a599f Remove unnecessary checks 2024-01-14 17:41:49 -08:00
5f30d37102 Update README.md 2024-01-14 17:25:43 -08:00
3647feaad5 Improve scan 2024-01-14 09:30:45 -08:00
e420a58f24 Improve scan prototype 2024-01-14 08:51:33 -08:00
ca37503f93 scan -> scan_to 2024-01-14 08:30:42 -08:00
123e058eb3 Improve scan prototype 2024-01-14 08:11:13 -08:00
f924d20dbd core-test -> base-test 2024-01-14 06:57:01 -08:00
d70729215f Fix constness 2024-01-14 06:44:38 -08:00
362b40c1a3 Fix docs 2024-01-13 19:21:27 -08:00
56fa4d61f6 Fix docs 2024-01-13 19:03:23 -08:00
cacdf1439f Remove nonstandard alias 2024-01-13 15:56:16 -08:00
4d766b1670 Invert dependencies 2024-01-13 10:30:44 -08:00
c10859f15c Remove deprecated options 2024-01-13 10:25:11 -08:00
d0963d4823 Make ranges only depend on fmt/base.h 2024-01-13 09:54:19 -08:00
da0f84c42c Cleanup copy functions and move to base.h 2024-01-13 09:31:20 -08:00
59baac522e Remove unused functions 2024-01-13 09:03:35 -08:00
21b0458291 Use std::allocator_traits (#3804)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-13 08:48:37 -08:00
df6a3564b0 Fix MSVC warning: "The contents of <bit> are available only with C++20 or later." (#3807)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-13 08:26:44 -08:00
7c163acfda Fix conversion warning in filesystem::path formatter (#3806)
* Fix conversion warning in filesystem::path formatter

Use template character type to eliminate MSVC conversion warning when
formatting a wide chararacter path:

fmt\std.h(140,49): warning C4244: '=': conversion from 'const Char' to 'char', possible loss of data

* Review: use to_ascii instead

---------

Co-authored-by: Hans-Martin B. Jensen <haje@eposaudio.com>
2024-01-13 08:02:31 -08:00
1b55d10305 Update api.rst 2024-01-12 16:48:20 -08:00
5d9d376d49 Update api.rst 2024-01-12 15:17:52 -08:00
6064b85c10 Update api.rst 2024-01-12 13:57:44 -08:00
deb584c0e1 Update build.py 2024-01-12 13:56:00 -08:00
297b22f585 Remove <memory> dependency 2024-01-12 09:09:19 -08:00
3c9608416a Remove redundant detection of experimental string_view 2024-01-12 07:45:07 -08:00
0cdee904a4 Add a missing num_bits specialization 2024-01-12 07:20:12 -08:00
7e58af4eaf Fix an ICE on clang <= 15 2024-01-12 06:48:03 -08:00
f1924d3269 Cleanup macros 2024-01-12 06:35:25 -08:00
52174953bc Cleanup conseval detection 2024-01-12 05:59:22 -08:00
b71d98774b Reduce usage of FMT_COSTEXPR20 2024-01-11 21:27:00 -08:00
810d1750f1 Cleanup constexpr detection 2024-01-11 21:08:01 -08:00
170ffb1ff8 Simplify constexpr checks 2024-01-11 20:26:52 -08:00
e470ba8b7b Simplify exception detection 2024-01-11 19:42:06 -08:00
bf98e3e4c6 Cleanup macros 2024-01-11 19:16:35 -08:00
fd87a23d34 Reduce memory dependency 2024-01-10 20:00:15 -08:00
b71ef65b6e Remove iterator dependency 2024-01-10 18:52:53 -08:00
c5340539f9 Remove unnecessary trait specialization 2024-01-10 18:11:37 -08:00
971f7ae768 Minor cleanup 2024-01-10 16:43:00 -08:00
6159e2b0ab Bazel support: Switch to globbing to collect header files 2024-01-10 15:52:54 -08:00
da7a232b9e Cleanup contexts 2024-01-10 13:09:55 -08:00
2595bf57b3 Fix formatting of ranges with begin()&/end()&
C++20 allows ranges to have lvalue-qualified begin() and end() member functions. fmt correctly handles this if begin() and end() are additionally const-qualifed (i.e. begin() const&), but not in the non-const case. For example:

https://godbolt.org/z/YfxaYz5r7

This patch fixes fmt's range detection to handle this case by testing calls to detail::ranges_begin()/end() with an lvalue T&, matching the behaviour in the const case.
2024-01-10 12:22:53 -08:00
6f5d53ce08 Add fmt::is_contiguous<std::basic_string<Char, Traits, Allocator>>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-10 10:47:39 -08:00
961df829b9 Fix buffer overflow if output iterator is std::back_insert_iterator and value is escaped (debug format)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-10 09:15:16 -08:00
401f087394 Fix write_uintptr_fallback 2024-01-10 09:09:57 -08:00
725992928b Update build.py 2024-01-10 07:44:24 -08:00
3d84b45a22 Update core.h 2024-01-10 06:57:22 -08:00
4331abed26 Move fmt::format to fmt/format.h 2024-01-10 06:43:12 -08:00
fc8f6ba934 Separate compilation for println 2024-01-10 05:55:26 -08:00
58a6bd48a8 Add core.h for compatibility 2024-01-09 20:10:30 -08:00
79f1506fe3 Add base.h 2024-01-09 19:36:12 -08:00
4d616479b5 Simplify make_format_args 2024-01-09 19:18:35 -08:00
cf8426cf8c Sort links on fmt/std.h section 2024-01-09 15:43:18 -08:00
e915d52162 Update api.rst with support provided by std.h 2024-01-09 15:43:18 -08:00
7ba6420540 Optimize debug codegen 2024-01-09 11:44:57 -08:00
97867e279a Extend Bazel build support to bzlmod (#3792) 2024-01-09 11:27:44 -08:00
8875cf96c2 Fix spelling: othewise ==> otherwise (#3791) 2024-01-09 10:32:46 -08:00
f7ed65fa4a Simplify format_arg_store 2024-01-09 06:29:16 -08:00
f34f31b321 Move format_arg_store to detail 2024-01-08 21:44:56 -08:00
fb66131efa Improve arg storage 2024-01-08 21:25:41 -08:00
6af30d8f75 Remove legacy workaround 2024-01-08 20:13:50 -08:00
c177324ba9 Simplify basic_format_args 2024-01-08 18:42:53 -08:00
545d37a8b0 Remove extra level of indirection when building args 2024-01-08 17:58:07 -08:00
9f73e45ca0 Update README.md 2024-01-08 12:51:59 -08:00
a5ae9ae19d Split standard context into a separate class and optimize 2024-01-08 07:08:49 -08:00
23e8109d8d Remove buffer_appender 2024-01-07 22:03:02 -08:00
679af1f5cc Remove redundant get_container 2024-01-07 19:31:26 -08:00
48d7fb265b Merge back_insert_iterator and appender 2024-01-07 18:43:27 -08:00
f348d1a211 Reintroduce back_insert_iterator detection 2024-01-07 17:44:40 -08:00
df67df7b4c Add is_back_insert_iterator 2024-01-07 16:44:42 -08:00
17f79ac6cf Minor cleanup 2024-01-07 15:04:38 -08:00
dbdfc99fa1 Don't crash if flush fails during unwinding 2024-01-07 14:55:16 -08:00
c1d9e88402 Remove unnecessary final and apply clang-format 2024-01-07 13:08:17 -08:00
7d73ef85f7 Cleanup ranges 2024-01-06 19:37:14 -08:00
ae9b0b521b Disable transitive includes 2024-01-06 15:22:13 -08:00
f73388f1ad Update README.md 2024-01-06 13:26:17 -08:00
08878044c6 Update readme 2024-01-06 13:24:51 -08:00
1b7d9db0ce Remove string dependency 2024-01-06 06:25:34 -08:00
0641b844ac Cleanup string traits 2024-01-05 19:31:04 -08:00
1e938dda20 Simplify char_t 2024-01-05 15:32:59 -08:00
2e5b14bf60 Add compile-time checks to color formatting 2024-01-05 09:51:52 -08:00
e0b604beb1 Remove a redundant function 2024-01-04 15:59:33 -08:00
6c617c9670 Update documentation (#3789)
Add a note about the numerical zero being ignored when an alignment flag is
present in the format specifier.

This change was introduced in a585571e90 to
be compatible with std::format, but misses documentation.
2024-01-04 10:35:55 -08:00
bee495c97f Remove dead code 2024-01-04 09:40:30 -08:00
794e1b6145 Remove redundant overload 2024-01-04 09:21:19 -08:00
c7061776ab Bump version 2024-01-04 05:50:54 -08:00
dc52d176de Cleanup dependencies 2024-01-03 20:52:45 -08:00
0e3e61cc0a Remove limits dependency 2024-01-03 19:14:30 -08:00
800a0bb23f Remove dependency on string_view 2024-01-03 18:49:45 -08:00
f2e43f967c Remove char_traits dependency 2024-01-03 13:16:28 -08:00
c9287eb9f7 Reduce char_traits usage 2024-01-03 10:02:16 -08:00
61f144bd61 Move copy_str for format.h 2024-01-03 09:05:09 -08:00
4687f8e37e Remove dependency on <iterator> 2024-01-03 08:20:04 -08:00
f2c55f6bb8 Remove dependency on back_insert_iterator 2024-01-03 06:16:00 -08:00
c9d233c0a4 Decouple appender from back_insert_iterator 2024-01-03 06:16:00 -08:00
242bcaec04 Update README.md (#3784) 2024-01-03 05:35:38 -08:00
4e43a46993 Clarify why we can't have nice things 2024-01-02 19:14:32 -08:00
c36ed77ff0 Get rid of addressof 2024-01-02 18:44:27 -08:00
e2ab9ab22b Add FMT_GLIBCXX_RELEASE 2024-01-02 16:15:23 -08:00
0378d171f9 Replace remove_cvref_t with remove_const_t 2024-01-02 12:46:09 -08:00
baea8f6906 Update docs 2024-01-02 08:52:07 -08:00
eedfdb4c5c Fix docs 2024-01-02 08:44:15 -08:00
5dbd7fd770 Switch to bootstrap 4 because 5 breaks menus 2024-01-02 07:39:28 -08:00
7fd1802686 Fix FMT_OS definition (#3783)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-02 07:20:09 -08:00
63ce170853 Replace virtual dispatch with normal functions in buffers 2024-01-02 07:02:20 -08:00
74ffea0dcf Simplify to_ascii 2024-01-01 20:09:47 -08:00
6c3b2d491e Fix constness 2024-01-01 19:50:36 -08:00
4ec9c2906b Apply coding conventions 2024-01-01 19:04:25 -08:00
f4a7d40dca Dedup throw_format_error 2024-01-01 18:42:23 -08:00
9659f22d36 Don't include os.cc in the module if it is disabled via FMT_OS 2024-01-01 18:32:53 -08:00
068bf9bad8 Make visitation compatible with std::format 2024-01-01 17:31:36 -08:00
50565f9853 Move misplaced join overloads to fmt/ranges.h 2024-01-01 16:28:59 -08:00
0b39d67103 Remove detail::error_handler 2024-01-01 16:10:13 -08:00
c142385033 Improve the pipe API 2024-01-01 15:55:37 -08:00
398ddb8fec Don't include fmt/os.h in the module if it is disabled via FMT_OS 2024-01-01 12:21:28 -08:00
583729493c Remove duplicate version 2024-01-01 11:50:43 -08:00
6c5bcca819 Fix the release script 2024-01-01 11:26:19 -08:00
67c0c0c09c Update version 2024-01-01 11:10:16 -08:00
051b31531c Fix changelog update 2024-01-01 11:06:44 -08:00
b0569451a7 Bump version 2024-01-01 10:06:52 -08:00
ce3161887a Add overflow check 2024-01-01 09:17:10 -08:00
1a95e5d1b4 Update changelog 2024-01-01 09:03:46 -08:00
e1aac42663 Implement hex specifier 2024-01-01 09:03:46 -08:00
1705600be3 Remove optional 2024-01-01 09:03:46 -08:00
0c345dccd2 Bump actions/upload-artifact from 3.1.2 to 4.0.0 (#3782)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.2 to 4.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](0b7f8abb15...c7d193f32e)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-01 08:10:18 -08:00
d33731d202 Implement empty format specs 2024-01-01 07:54:02 -08:00
c068c7c622 Add sentinel support 2024-01-01 07:25:01 -08:00
13fa26745d Update changelog 2024-01-01 06:58:46 -08:00
ebd5c8f994 Consistently use fmt:: when invoking format_to. (#3779)
This has been done partially in previous commits:

* 2ac6c5ca8b
* 258000064d
* ba50c19e82
* 5ab9d39253

A patch that includes the `std::error_code` changes here is
upstream in vcpkg, so that will be able to be removed when
updating to the next release.
2024-01-01 06:57:03 -08:00
f5ca178c12 Complete scan_handler 2023-12-31 18:00:14 -08:00
138a64bfb1 Privatization 2023-12-31 15:06:17 -08:00
a5bacf3fef Remove custom_formatter 2023-12-31 12:34:18 -08:00
4aa24f54cd Implement visitor for scan 2023-12-31 09:53:24 -08:00
e33c1568c3 Implement scan argument access 2023-12-31 08:49:29 -08:00
23826669cf Cleanup error handling 2023-12-31 07:51:57 -08:00
8e6b2541a6 Apply coding conventions 2023-12-30 16:07:35 -08:00
4939d67a83 Cleanup scripts 2023-12-30 15:08:27 -08:00
bd3273021b Update release script 2023-12-30 14:29:31 -08:00
5f9058dbd4 Improve scripts 2023-12-30 11:23:08 -08:00
28576b0600 Workaround github markdown mess 2023-12-30 09:57:31 -08:00
5ddd0cad15 Add a visitor for scan arguments 2023-12-30 07:43:21 -08:00
41d31512b7 Remove unused import 2023-12-30 07:11:32 -08:00
44b76d88f4 Fix docs 2023-12-30 07:11:13 -08:00
3324152db4 Update the release script 2023-12-30 06:53:20 -08:00
55190dadb5 Cleanup chrono test 2023-12-29 16:34:42 -08:00
63e4b93cfc Update changelog 2023-12-29 15:54:50 -08:00
c64edcd325 Fix grammar 2023-12-29 15:51:16 -08:00
8c520b4fdc Fix comment 2023-12-29 15:48:25 -08:00
2e6bb706bf Update changelog 2023-12-29 15:48:09 -08:00
a13d1b12e5 Update changelog and docs 2023-12-29 13:00:12 -08:00
47a0eec2e8 Remove unnecessary alias 2023-12-29 09:59:55 -08:00
a8bed38952 Update changelog 2023-12-29 09:57:29 -08:00
e206043d2b Update changelog 2023-12-29 09:00:05 -08:00
4a6f0be5b6 Improve scan test 2023-12-29 08:32:38 -08:00
662d784157 Fix scan test 2023-12-29 08:21:10 -08:00
d5823aae36 Ceci n'est pas une pipe 2023-12-29 08:11:29 -08:00
d83c1b8d4a Add initial specifier support to scan 2023-12-29 07:30:56 -08:00
bfba2f9e92 Improve iterator handling in scan 2023-12-29 06:34:49 -08:00
a3bf40838f Initial range support in scan 2023-12-29 06:25:57 -08:00
ea1066bbe3 Cleanup test 2023-12-28 16:56:42 -08:00
be57ec7ec0 Fix chrono-test on platforms with 32-bit time_t 2023-12-28 16:36:18 -08:00
305747d440 Update changelog 2023-12-28 08:01:56 -08:00
47c8f63d02 Remove redundant specifier 2023-12-28 07:32:07 -08:00
76e8f10403 Update changelog 2023-12-28 07:23:56 -08:00
18ca2248df Document '?' 2023-12-28 06:39:00 -08:00
3a25a58482 Update README.md 2023-12-26 11:12:02 -08:00
4cbf6182ea Remove peek 2023-12-25 10:47:45 -08:00
88d19f5de9 Cleanup scan 2023-12-25 10:28:50 -08:00
62529aad19 Apply coding conventions 2023-12-25 10:20:00 -08:00
df62c86783 Mark grow as deprecated 2023-12-25 10:11:22 -08:00
eef6dbafbf Refactor file layer in scan 2023-12-25 09:32:29 -08:00
41c2433358 clang-format 2023-12-25 09:09:20 -08:00
0a9d08fefd Simplify fallback 2023-12-25 09:00:03 -08:00
e450b7aeb3 Implement locking 2023-12-25 08:48:45 -08:00
c5a85f8d7d Handle end of input in scan 2023-12-25 07:18:23 -08:00
1fd093add4 Update changelog 2023-12-25 06:41:37 -08:00
c4f2de4933 Improve scan 2023-12-25 06:34:15 -08:00
d06921d8d8 Update changelog 2023-12-23 15:30:26 -08:00
fc0f84d290 Move formatbuf to ostream.h 2023-12-23 15:00:28 -08:00
86f2ec5de7 Fix a warning 2023-12-23 14:51:43 -08:00
a537c39fdf Move conjunction to where it is used 2023-12-23 14:35:11 -08:00
7c240d52c3 Remove unused symbol 2023-12-23 13:20:55 -08:00
f64a6a2ecd Update changelog 2023-12-23 12:20:14 -08:00
6f9a816786 Enable test 2023-12-23 10:14:27 -08:00
e7875ae0fa Fix formatting of some nested ranges 2023-12-23 09:35:32 -08:00
3eb3aef575 Fix handling of set_debug_format 2023-12-23 08:32:36 -08:00
56d7a8c157 Simplify test 2023-12-23 07:02:58 -08:00
968fb9d166 Update changelog 2023-12-22 20:42:20 -08:00
b5f6b36b00 Update changelog 2023-12-22 16:55:02 -08:00
44dd6c0e09 Add glibc support to scan 2023-12-22 13:43:20 -08:00
3a0f4af4e9 Refactor file layer 2023-12-22 11:27:22 -08:00
1ca1a4a7a9 Update scan test 2023-12-22 08:22:00 -08:00
dbd9c89b3c Fix URI 2023-12-20 14:59:29 -08:00
9cd2b87e18 Fix wchar_t to char conversion warnings (#3764)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-20 08:59:26 -08:00
d5da9cc40e Apply clang-tidy 2023-12-19 17:52:50 -08:00
3a2c50d4ac Cleanup test 2023-12-19 15:28:10 -08:00
18c43a214c Cleanup test 2023-12-19 13:46:48 -08:00
6b07fff0d9 Make hex float test more stable on different libc (#3762)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-19 11:03:06 -08:00
9165434e5a Enable consteval in MSVC VS2019 version 16.10 (#3757)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-18 13:00:11 -08:00
b8f81dede5 [StepSecurity] ci: Harden GitHub Actions (#3759)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
2023-12-17 17:01:17 -08:00
923005bd4f Add stdlib version check for C++20 (#3754)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-17 08:33:17 -08:00
afa85e46c3 Apply clang-format 2023-12-17 07:32:22 -08:00
6025bd7c37 Add localized formatting to non-decimal presentation types of ints (#3750) 2023-12-15 07:51:25 -08:00
5471a2426c Update README.md 2023-12-13 09:32:00 -08:00
7d757cba5d CI: add lint github workflow for running clang-format (#3749)
so that we can identify changes which do not confirm to the
clang-format rules.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2023-12-13 07:20:23 -08:00
6855bd532b Apply clang-format
* use clang-format v17.0.6 to reformat the tree
* tweak some places so that clang-format does not mutate the layout
  of code too much

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2023-12-13 07:18:37 -08:00
bbee753579 Make clang-format happy 2023-12-13 06:54:51 -08:00
89860eb901 Use void(*)(void*) instead of decltype(&std::free) to satisfy clang in CUDA mode (#3751)
clang can't resolve &std::free in decltype(&std::free) because std::free
is overloaded (for host and device).
2023-12-11 09:44:02 -08:00
274ba2645b allow format_as() to format reference (#3739)
before this change, format_as() is unable to format a type which
has `auto format_as() -> const another_type&`, and `another_type`
is formattable. because `format_as_result` maps the result type
as it is, and the compiler refuses to compile
`static_cast<T*>(nullptr)`, where T is a reference type. but
it would be handy if we could use `format_as()` to format types
which, for instance, owns / inherit from a formattable type, and
delegate the formatter to these variables instead without creating
a copy of them.

in this change:

* instruct `format_as_result` to map the
  result type to the decayed type, so that `type` can be the decayed
  type of result type, and this also enables `type` to be formattable,
  as long as the decayed type is formattable.
* corresponding test is added to format-test.cc

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2023-12-10 08:49:53 -08:00
9048add999 Report out-of-range errors in chrono 2023-12-10 08:28:50 -08:00
640e0c02d4 Update README.md 2023-12-09 17:37:07 -08:00
6392dba21c Fix warning: identifier '_a' preceded by whitespace in a literal operator declaration is deprecated (#3748)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-09 08:16:57 -08:00
9a6fd11a56 Fix typo in gmock-gtest-all.cc (#3747)
syntetic -> synthetic
2023-12-09 08:13:20 -08:00
dee0dbf07f Update README.md 2023-12-08 14:24:11 -08:00
2fabb43b93 Fix README file table (#3744)
Co-authored-by: George Liontos <george.liontos@forallsecure.com>
2023-12-08 10:26:52 -08:00
9c3c107c8c Fix compile with GCC 6.3.0 (bug #3738) (#3743) 2023-12-08 09:36:33 -08:00
4497a2d09a fix cmake build 2023-12-08 08:33:16 -08:00
81629e425c Convert README to Markdown 2023-12-08 07:28:33 -08:00
6f95000b7a Update README.rst (#3737)
Fix Celestia URL
2023-12-07 06:21:06 -08:00
573d74395b error on bool arg w/ char pres_type (#3734) 2023-12-05 13:45:10 -08:00
5d55375a8a Experiment with scan buffering 2023-12-03 08:09:36 -08:00
71bd51e6c2 Implement %j specifier for std::chrono::duration (#3732)
This adds support for `%j` presentation type for duration types:

> "If the type being formatted is a specialization of duration, the decimal
number of days without padding."

Fixes #3643.
2023-12-03 07:29:58 -08:00
f575089243 Simplify test 2023-12-01 08:52:42 -08:00
99b9fbf8ef Add formatter for std::source_location (#3730) 2023-11-30 10:05:56 -08:00
8f83ee2ad1 Apply coding conventions 2023-11-30 08:24:02 -08:00
2a8a694466 Clarify that mixing code unit types is deprecated 2023-11-30 08:20:01 -08:00
04718008ab Minor cleanup 2023-11-30 07:43:31 -08:00
b87ea22e29 Add native and generic representation for filesystem::path format spec (#3729) 2023-11-29 14:49:36 -08:00
5cfd28d476 Experiment with FILE in scan 2023-11-26 10:01:42 -08:00
73fae91e64 Cleanup .gitignore 2023-11-25 09:45:38 -08:00
6988be3878 Bump version 2023-11-25 09:11:53 -08:00
2d1e4bb35e Remove a useless comment 2023-11-25 09:05:20 -08:00
7f8d419115 Fix overflow in time_point formatting with large dates (#3727)
* Fix #3725 and rename fmt_safe_duration_cast to fmt_duration_cast
The function is now more generic and will handle all casts. It also
takes care of toggling safe vs unsafe casts using
FMT_SAFE_DURATION_CAST.

* Refactor fmt_duration_cast to put #ifdef inside the function

* Fix compilation error with FMT_USE_LOCAL_TIME
2023-11-25 08:36:55 -08:00
ccc9ab7bf9 Include correct header 2023-11-25 08:23:41 -08:00
c4283ec471 Fix a libc++ warning and move the test to the right place 2023-11-25 08:20:53 -08:00
c3f9a73445 Apply coding conventions 2023-11-25 07:43:44 -08:00
06f1c0d725 Clarify that calling non-const format is deprecated 2023-11-24 10:21:57 -08:00
ffa5b14fe3 Make gtest-extra-test more portable 2023-11-24 10:09:21 -08:00
bea7ecc710 Disable locale-specific tests on OpenBSD 2023-11-24 09:45:56 -08:00
8a39388516 Fix the default locale in ostream_formatter 2023-11-24 09:24:43 -08:00
dd6f657a79 Remove this-> from decltype (#3723)
* Remove this-> from decltype

The latest version of MSVC doesn't like it, and removing it doesn't seem to harm anything.

* Add ifdef for GCC < 5
2023-11-22 09:46:04 -08:00
c13753a70c Fix handling of invalid Unicode in precision 2023-11-18 08:36:11 -10:00
864a8b5f38 fix: support optional<T> with format_as(T) (#3713)
Formatting a std::optional<T> where T had a custom format_as(T) function failed to compile with clang,
due to set_debug_format being hidden by private inheritance. This fix makes the function available through a using clause.
2023-11-16 15:02:33 -08:00
649fe0fc8b Fix handling of null strings with the s specifier 2023-11-15 17:03:01 -10:00
45e124ee43 Added workaround for old xcode compiler bug (#3716)
* Added macros to disable std::filesystem and std::variant as a workaround for old xcode bugs

* Change macro to positive logic
2023-11-15 09:19:08 -08:00
045b05d79e Revert CMake changes 2023-11-14 06:48:16 -10:00
ec628561c2 Fix formatting 2023-11-13 06:41:28 -10:00
cbb18c237a Add support for CMake 3.28 C++ modules (#3679) 2023-11-13 08:34:42 -08:00
6b0082e6c7 Improve OpenBSD workaround 2023-11-07 09:24:33 -10:00
52a99a67f7 Set PDB path for Visual Studio (#3702)
Ensure the PDB files are output into the same directory and with the same name
as the static library when using Visual Studio.

Resolves fmtlib#3701.
2023-11-07 08:22:52 -08:00
4548d1eae2 Make write_escaped_path more portable 2023-11-07 05:46:15 -10:00
050d41e857 Make get_path_string more portable 2023-11-06 14:34:53 -10:00
1c023c0087 Update bootstrap 2023-11-06 08:20:01 -10:00
b35d4e40fe fix: use FMT_HAS_INCLUDE instead of __has_include 2023-11-03 15:10:40 -07:00
acaf83f40f feat: enable building with gcc 4.8 2023-11-03 02:38:05 +09:00
05aa783779 feat: include xlocale.h only if exists 2023-11-03 02:38:05 +09:00
05dda9490d Bump ossf/scorecard-action from 2.2.0 to 2.3.1 (#3697)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.2.0 to 2.3.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](08b4669551...0864cf1902)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-01 12:38:06 -07:00
caf4fcb207 Bump github/codeql-action from 2.21.5 to 2.22.5 (#3696)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.5 to 2.22.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](00e563ead9...74483a38d3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-01 12:37:23 -07:00
e0d3e346d2 Wrap Char in array to avoid pointer arithmetic (#3695)
This resolves the following finding reported by Coverity Static Analysis
v2023.6.1 on line 1964 of fmt/include/fmt/format.h:

  ptr_arith: Using &v as an array. This might corrupt or misinterpret
             adjacent memory locations.
2023-10-31 14:05:46 -07:00
19276d7325 Fix an inconsistentcy between to_string and format 2023-10-28 08:05:11 -07:00
2a2c6e676f Fix flushing C++ iostreams before calling write_console() (#3689)
This change correctly implements https://wg21.link/P2539/ for both
C streams and C++ iostreams.

Fixes #3688.
2023-10-25 13:13:31 -07:00
3b7f58a8b3 add buffer flush before direct write 2023-10-24 16:02:37 -07:00
e9bbd4069e Update README.rst 2023-10-22 09:13:14 -07:00
857cce7a83 Update README.rst 2023-10-22 08:45:50 -07:00
081d5b0d8b Update README.rst 2023-10-22 08:30:04 -07:00
baae1ed658 add meson instructions to usage docs (#3677) 2023-10-18 11:53:47 -07:00
2ac6c5ca8b Fix error C2668 on Windows with option /std:c++latest (#3680)
* Namespace-qualify to avoid ambiguity with std::format_to for format-test.cc

When build fmt with MSVC under option /std:c++latest, it failed due to `error 2668: 'std::format_to': ambiguous call to overloaded function`, so add namespace to qualify the call to format_to to avoid this issue.
2023-10-16 09:54:02 -07:00
d9063baf22 Fix perf regression in ostream::print 2023-10-15 08:23:36 -07:00
f7542c5761 Apply clang-format 2023-10-14 06:52:43 -07:00
130cf54cbc Use a more sensible locale in tests 2023-10-08 10:49:21 -07:00
8e0ca0589f Use a more sensible locale in tests 2023-10-08 09:21:02 -07:00
bf497ac068 Cleanup test 2023-10-08 07:30:08 -07:00
bb8d50f04b add a suffix for days and fix the one for minutes (#3664) 2023-10-07 12:45:34 -07:00
f76603f21e fix: make std::bitset formattable again (#3660)
* fix: make std::bitset formattable again

It used to be formattable via operator<<(ostream&) implicitly. Make it
formattable again, but this time via formatter specialization.

* fix: make nested_formatter constexpr default constructible
2023-10-03 09:53:47 -07:00
f918289363 Bump actions/checkout from 4.0.0 to 4.1.0 (#3666)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](3df4ab11eb...8ade135a41)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-01 09:49:05 -07:00
72e883e163 Diagnose unsupported code unit types 2023-10-01 08:37:21 -07:00
b3bf23f3c4 Remove leftover usage of the __std_stream header (#3663)
2dd4fa8742 removed all usage of __std_stream because
it is no longer available with clang v17. That commit missed one place
where the header was still used (only used when building with -DFMT_MODULE=ON).
Remove it there too.

See #3654
2023-10-01 08:16:42 -07:00
349e1c48d1 Update README.rst (#3661)
Signed-off-by: Joyce <joycebrum@google.com>
2023-09-30 07:16:04 -07:00
79dbd3f192 feat: add security policy to readme (#3655)
Signed-off-by: Joyce <joycebrum@google.com>
2023-09-28 16:50:14 -07:00
2dd4fa8742 Remove an ostream hack incompatible with libc++ 17 2023-09-26 12:42:37 -07:00
44f3d8a77c README.rst: fix broken LICENSE link (#3653)
The `.rst` suffix was dropped for this file a while ago.
2023-09-22 15:54:40 -07:00
06b20387ae Optimize fractional_part_rounding_thresholds 2023-09-22 13:26:57 -07:00
649f2460db Apply clang-format 2023-09-22 09:07:43 -07:00
7529af8f99 Workaround intel bug (#3652)
* Workaround intel bug

Potential workaround / restructure for the intel bug that is the cause of #3645.

Make the variable in the external struct instead an embedded static constexpr variable in the only function that uses the variable.

* Finish the proposed change -- remove struct accessor

* Refactor proposed intel fix.

Moved variable out of function to avoid specialization on Float.  Made it a separate function that is called from format_float.

* Fix incorrect function name.

* Add missing inline.
2023-09-20 18:57:55 -07:00
a3a74fa7f3 fix: mark fmt::streamed() as constexpr (#3650)
Because it's just performing a very basic type conversion that can be
done at constexpr time.

My use case simultaneously creates a
`fmt::basic_format_string<some_type_conversion<Args...>>` instance and
performs `some_type_conversion<Args>(args)...`. `some_type_conversion`
optionally applies `fmt::streamed(arg)` to a subset of types. This needs
to be `constexpr` because `basic_format_string`'s constructor is
`consteval`.
2023-09-19 08:42:34 -07:00
8ef4db4b96 Use datatype of underlying data (#3647) 2023-09-19 07:31:36 -07:00
492a99c964 Fix error: 'char_traits<custom_char>' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it. [-Werror,-Wdeprecated-declarations] (#3634)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-09-18 15:46:17 -07:00
3baaa8d899 Update docs 2023-09-18 14:54:52 -07:00
0e01e46c11 Implement nested formatter 2023-09-18 14:21:21 -07:00
f6ca4ea199 Avoid a space in the UDL definition (#3610)
* Avoid a space in the UDL definition except on GCC before 4.9

Clang 18 has grown a warning about the space being deprecated which
is enabled by default in their nightly binaries. However GCC before 4.9
will reject the UDL definition unless there is a space there, so we need
to keep the space conditionally for it.

* Remove UDLs on GCC before 4.9 to simplify things

GCC before 4.9 rejects the syntax that is now
rejected on more modern compilers.

* Disable compile-error-test on GCC < 4.9

This avoids the UDL tests failing as GCC < 4.9 can not parse UDLs
without a space, but the space is malformed in modern compilers.
2023-09-18 08:09:42 -07:00
a8a73da7e4 Add an option to avoid wchar APIs on Windows (#3636)
With this, fmt can be used on Windows 98 and the Original Xbox with:

    set(FMT_OS OFF)

It is not exposed as a CMake option but one can define it manually
in the fmt subproject, e.g.:

    target_compile_definitions(fmt PUBLIC FMT_WINDOWS_NO_WCHAR)

Fixes #3631
2023-09-17 08:49:51 -07:00
aa3c5a4127 Clarify I/O error handling 2023-09-16 08:20:27 -07:00
bfdf50d183 Minor cleanup 2023-09-16 08:16:59 -07:00
571a9b7b26 Replace usage of C++17 library feature with C++11 (#3638) 2023-09-16 08:07:03 -07:00
6c088be8ec Cleanup handling of visibility 2023-09-16 07:40:08 -07:00
016b1faede Fix symbol leak (#3627)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-09-16 07:26:36 -07:00
e25370093a Remove unnecessary spaces (#3642) 2023-09-16 06:55:22 -07:00
d4987546a4 Add an experimental nested formatter 2023-09-10 11:56:55 -07:00
5bdce181f1 Mark styled_arg as a view to prevent lifetime issues 2023-09-09 08:16:45 -07:00
cyy
a4b7b24b7b fix redundant redeclaration of ‘constexpr’ static data member (#3630) 2023-09-08 16:20:32 -07:00
fac60bd4f5 Remove type cast as mxe(mingw32) compiler complains about useless-cast (#3624)
Remove type cast as mxe(mingw32) compiler complains about useless-cast
when FMT_PEDANTIC && FMT_WERROR options are enabled
"""
error: useless cast to type 'class fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >' [-Werror=useless-cast]
 1449 |                      basic_format_args<buffer_context<char>>(args));
"""
2023-09-05 07:37:27 -07:00
f5be4a8a9a Bump actions/checkout from 3.5.3 to 4.0.0 (#3623)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 4.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](c85c95e3d7...3df4ab11eb)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 11:24:28 -07:00
84e6661517 Workaround a gcc 6.4 issue 2023-09-04 11:23:14 -07:00
ac3240439c Update dependabot.yml 2023-09-04 10:23:00 -07:00
8894ae87fe Bump github/codeql-action from 2.21.4 to 2.21.5 (#3622)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.4 to 2.21.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](a09933a12a...00e563ead9)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 10:19:51 -07:00
ca608547e5 Workaround a C++11 issue 2023-09-04 10:07:14 -07:00
23cf4055a0 Simplify URLs 2023-09-04 10:00:13 -07:00
46c8301ee9 Remove rst2md 2023-09-04 09:38:06 -07:00
a79a979828 Cleanup ranges test 2023-09-04 09:19:40 -07:00
457bb6a98f Merge the copyright comment since there are many contributors 2023-09-04 09:09:01 -07:00
61aef41110 Cleanup changelog 2023-09-04 09:05:07 -07:00
2a45fd30fe Drop the rst suffix from the license file 2023-09-04 08:18:03 -07:00
24296cff1c Update ChangeLog.md 2023-09-04 08:16:16 -07:00
3d1d20a6ac Update ChangeLog.md 2023-09-04 08:10:34 -07:00
0302c527c6 Update ChangeLog.md 2023-09-04 07:59:30 -07:00
154eccfeb1 Convert changelog to markdown for compatibility with release notes 2023-09-04 07:15:18 -07:00
35dc5def30 Revert "Bump actions/checkout from 3.5.3 to 3.6.0 (#3615)"
This reverts commit e8259c5298.
2023-09-04 07:12:32 -07:00
e1fc481d65 Merge the copyright comment since there are many contributors 2023-09-04 06:54:07 -07:00
e8259c5298 Bump actions/checkout from 3.5.3 to 3.6.0 (#3615)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](c85c95e3d7...f43a0e5ff2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-28 13:55:28 -07:00
6379251554 Update version 2023-08-28 06:29:25 -07:00
951fd9e66f Update changelog 2023-08-28 06:28:15 -07:00
be89b9a41e Merge branch 'release' of github.com:fmtlib/fmt 2023-08-28 06:24:29 -07:00
28e2d3b640 Bump version 2023-08-26 08:29:50 -07:00
f5e54359df Update version 2023-08-26 08:20:41 -07:00
a003ab93cf Update changelog 2023-08-26 08:18:55 -07:00
9b74160817 atomic_flag formatting (#3594) 2023-08-25 08:06:10 -07:00
a21690bdfa Coding conventions 2023-08-25 07:46:32 -07:00
c9efd8968c Merge branch 'MathewBensonCode-master' 2023-08-25 07:44:44 -07:00
e786824053 Refactor Improvement on umul128 function
- Removal of direct access to members of uint128_fallback and instead
  create the values at the callsite and pass them via the constructor of
  uint128_fallback on the return statement.
2023-08-25 13:21:52 +03:00
2b20d7be6f Refactor To remove friend function private access
- Remove umul128 friend function from uint128_fallback class using
  non-const member access functions instead.
2023-08-24 00:55:43 +03:00
1f38ebbdb1 Add condition to include friend function in win32 2023-08-22 23:07:04 +03:00
e418179694 Fix for FMT_MODULE not compiling on GCC 2023-08-22 21:11:53 +03:00
0bffed8957 Bump actions/checkout from 3.1.0 to 3.5.3 (#3602)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.1.0...c85c95e3d7251135ab7dc9ce3241c5835cc595a9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-21 10:58:34 -07:00
cc077a5e3b Fix FMT_NO_UNIQUE_ADDRESS warning with clang-cl. (#3600)
See https://reviews.llvm.org/D110485 for info.
2023-08-20 10:21:50 -07:00
a992b3d1fc Fix for Compilation Error When Using FMT_MODULE (#3597)
* FMT_EXPORT reorganization to fix compile error

- When compiling with FMT_MODULE, an error was being generated due to
  use of FMT_EXPORT on a declaration within FMT_BEGIN_EXPORT and
  FMT_END_EXPORT on `include/core.h`

- On `include/format.h` had to exclude the function vformat_to by ending
  the export block just before it and beginning a new one after it.
2023-08-20 07:32:36 -07:00
af1b768cc7 Update changelog 2023-08-19 08:22:50 -07:00
2a7c45b54e Update changelog 2023-08-19 08:19:01 -07:00
bd868f3a51 Improve compatibility with GBK #3598 (#3599) 2023-08-19 08:13:20 -07:00
bbb784fb1b Fix a gcc error about partial specialization after instantiation 2023-08-19 07:22:40 -07:00
6c845f57e5 Fix formatted_size with FMT_COMPILE and format specs (#3588)
Addresses issue #3586
2023-08-15 06:45:48 -07:00
a379595c5f Bump actions/upload-artifact from 3.1.0 to 3.1.2 (#3593)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3.1.0...0b7f8abb1508181956e8e162db84b466c27e18ce)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 14:02:10 -07:00
9dfde78714 Bump ossf/scorecard-action from 2.1.2 to 2.2.0 (#3592)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.2 to 2.2.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](e38b1902ae...08b4669551)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 13:43:25 -07:00
e92a705bdc Bump github/codeql-action from 2.2.4 to 2.21.4 (#3591)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.4 to 2.21.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](17573ee1cc...a09933a12a)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 11:49:24 -07:00
5a866fe852 Add formatter for std::atomic (#3574) 2023-08-14 08:34:31 -07:00
e150ea0cc2 to_string supports types with format_as
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-08-13 08:39:52 -07:00
29ce2ff8a8 Update README.rst
Signed-off-by: Joyce <joycebrum@google.com>
2023-08-13 07:32:33 -07:00
2e1362addb Create scorecard.yml
Signed-off-by: Joyce <joycebrum@google.com>
2023-08-13 07:32:33 -07:00
e57ca2e368 Update version 2023-08-12 07:18:59 -07:00
4c56612c67 Update changelog 2023-08-12 07:18:12 -07:00
e1acd5f4d9 Bump version 2023-08-12 06:52:15 -07:00
6ffee2f752 Handle new rst nodes 2023-08-12 06:51:40 -07:00
ee475d6409 Update changelog 2023-08-07 15:12:34 -07:00
ecc9141259 Update changelog 2023-08-07 14:41:53 -07:00
d424862319 Fix fixed precision handling during rounding in long double 2023-08-07 13:56:53 -07:00
3c1b3337de Update changelog 2023-08-07 11:39:30 -07:00
35fb69ebe0 Update changelog 2023-08-07 10:30:52 -07:00
f92be35c09 Update changelog 2023-08-07 09:44:43 -07:00
7a2f6ac210 Fix a comment 2023-08-07 09:33:45 -07:00
744ff55549 Fix docs 2023-08-07 08:40:41 -07:00
70ae48b005 Update changelog 2023-08-07 08:38:17 -07:00
ebb10347c4 Merge branch 'master' of github.com:fmtlib/fmt 2023-08-07 08:18:13 -07:00
1005720169 Clarify that visit_format_arg is deprecated 2023-08-07 08:17:55 -07:00
aeb6ad4dd0 Added formatter for bit_reference-like types (#3570)
* Add test for std::vector<bool>::reference

Co-authored-by: Felix <felix-antoine.constantin@polymtl.ca>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Add test for std::bitset<N>::reference

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Add test for const std::bitset<N>::reference and const std::vector<bool>::reference

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Add bit_reference-like formatter

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Use std::addressof

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

---------

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
Co-authored-by: Felix <felix-antoine.constantin@polymtl.ca>
2023-08-06 11:36:30 -07:00
96d1fa22d4 Update changelog 2023-08-05 10:00:27 -07:00
8a4bec5cf5 fix ambiguous formatter lookup for flat_set (#3561) 2023-07-31 09:26:33 -07:00
eacd51c249 cmake: fix FMT_PKGCONFIG_DIR path (#3563) 2023-07-31 08:11:56 -07:00
757564f5cd add missing inline specifier (#3552) 2023-07-27 12:12:00 -07:00
f4214ae8dd Use the U literal for unsigned integer constants. (#3549)
Fix MSVC Error C2398 Element '1': conversion from 'int' to 'const uint32_t' requires a narrowing conversion.
2023-07-27 11:43:00 -07:00
aecf80d304 Update a comment 2023-07-26 15:10:12 -07:00
503d49286d expose detail::throw_format_error (#3551)
This enables to only #include <fmt/core.h> when defining formatters.
2023-07-26 13:21:38 -07:00
4f46cb82f3 Remove std::copy usage. (#3550) 2023-07-26 07:27:01 -07:00
3dec65b7fd Use replacement character in path 2023-07-22 09:07:28 -07:00
dbabb305c3 Turn off error-producing NVCC workaround when using c++20 (#3544) 2023-07-21 11:29:15 -07:00
ac0ab8eff3 Improve path formatter 2023-07-20 17:49:12 -07:00
40f35d6f04 Cleanup std formatters 2023-07-20 16:26:27 -07:00
31c2c5679e Cleanup formatters 2023-07-20 15:57:43 -07:00
b2728a3170 Improve path formatter 2023-07-20 15:25:35 -07:00
77e0b0e228 Cleanup chrono formatter 2023-07-20 15:00:59 -07:00
e475859042 Fix overspecified tests 2023-07-20 14:09:22 -07:00
436c131d4c Optimize compiled format_to_n 2023-07-20 12:35:01 -07:00
388bc296b7 Fix fixed formatting of small long doubles 2023-07-20 12:06:05 -07:00
95e1ea5737 Clarify requirement on compiled formatter 2023-07-20 10:24:02 -07:00
fb97cb2318 Suppress a bogus stringop-overflow warning 2023-07-20 09:53:54 -07:00
dd5a9691f9 Clarify that data is not null-terminated 2023-07-20 07:36:30 -07:00
72dc4491ea Fix format_string_checker initialisation order (#3542)
Linter (clang-tidy) complains about uninitialised fields in
format_string_checker since types_ is passed to context_ before being
initialised. Fixes #3541.
2023-07-20 07:30:45 -07:00
9bea6ec04a Don't use deprecated checked_array_iterator 2023-07-20 07:12:06 -07:00
661b23edeb Call parse on empty specs at compile time 2023-07-15 22:20:29 -07:00
8e87d3a8be Fix include 2023-07-15 09:02:19 -07:00
a474916560 Update CMakeLists.txt (#3523) 2023-07-05 06:38:38 -07:00
de4705f84d Trying to improve errors in the unformattable case (#3478) 2023-07-01 06:46:04 -07:00
e4c8cfe38e README: Add link to merged clang-tidy check (#3515)
A much-improved version of the main clang-tidy-fmt check for converting
printf and fprintf has landed in upstream LLVM. It converts to
std::print by default, but can be configured to convert to fmt::print
instead. It makes more sense for the README to point to that version
instead now.
2023-06-30 15:49:36 -07:00
606f85f8b2 Workaround brain-damaged conversions 2023-06-26 16:06:24 -07:00
a331dbfb65 Fix type in assert message. (#3508)
Reviewed all strings in the file and found no other typos.
2023-06-26 11:35:29 -07:00
13156e54bf Revert "add ability to build Apple framework using CMAKE_FRAMEWORK" (#3496)
This reverts commit ae25f7968e.

Co-authored-by: Petr Manek <1252039-petrmanek@users.noreply.gitlab.com>
2023-06-18 20:41:07 -07:00
9158bea1e1 Remove old grisu tests 2023-06-18 18:15:09 +03:00
dd17f89a16 Fix for issue #3492 (#3493)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-06-16 02:20:40 -07:00
1daae555b3 Optimize format string compilation 2023-06-15 10:28:23 +03:00
6ad301235f Optimize code unit output in compiled format 2023-06-14 21:13:26 +03:00
8732ad8773 Update docs 2023-06-13 19:24:18 +03:00
5afb1821a9 Update docs 2023-06-13 18:58:15 +03:00
a81135f2c8 Fix a link 2023-06-13 18:39:00 +03:00
dfc34821ad Update docs 2023-06-13 18:33:36 +03:00
0765e7284c Update docs 2023-06-13 18:12:27 +03:00
977d887a4e Suppress a bogus warning 2023-06-13 14:01:46 +03:00
c86fe0b8d3 Give basic_memory_buffer allocator [[no_unique_address]] (#3485)
This allows stateless allocators to take up no space while still avoiding the empty base class optimization.
2023-06-13 01:22:19 -07:00
5dbe0ff954 Bump actions/checkout from 3.5.2 to 3.5.3 (#3486)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8e5e7e5ab8...c85c95e3d7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-12 22:46:54 -07:00
de0757b578 Use FMT_TRY and FMT_CATCH in std.h (#3482)
This naked try-catch block prevents compilation when exceptions are disabled.
2023-06-10 21:28:13 -07:00
8fe893c0ac Update README.rst 2023-06-06 19:56:53 -07:00
0f823df46a Remove detail namespace hack 2023-06-04 15:19:50 -07:00
60fd9941c0 Use correct Char type in std::filesystem::path (#3476)
Godbolt repro:
https://godbolt.org/z/o4bjG6ddo

Co-authored-by: Hans-Martin B. Jensen <haje@eposaudio.com>
2023-06-02 14:12:57 -07:00
8abfc145be Fix MSVC warning in std::chrono::time_point formatter (#3475)
* Fix MSVC warning in std::chrono::time_point formatter

The condition is constexpr causing MSVC level 4 warning:
warning C4127: conditional expression is constant

Changed the code to eliminate the warning

* Use detail::const_check

* Review: revert else condition

---------

Co-authored-by: Hans-Martin B. Jensen <haje@eposaudio.com>
2023-06-02 08:40:34 -07:00
686b3353aa Simplify typeid check 2023-06-01 09:32:44 -07:00
b2106f3639 Tweak comments 2023-05-31 09:52:44 -07:00
35547d6003 Use const_check to silence MSVC warning
The condition is constexpr, so the compiler warns if a runtime check
is used as there's no need to generate code for it.
2023-05-31 09:25:53 -07:00
179c7e5a66 Use typeid() only if it's available
On MSVC it is always available, otherwise it depends on whether
RTTI is enabled.
2023-05-31 09:25:53 -07:00
61fb3a15ff Add VxWorks7 user space and kernel space support (#3467) 2023-05-31 06:35:07 -07:00
bd393456ed Remove FMT_*_DETAIL_NAMESPACE 2023-05-28 07:33:26 -07:00
6be36af0d4 Remove udl_formatter 2023-05-27 17:16:36 -07:00
2a35eeed8a Remove unused data 2023-05-27 10:47:17 -07:00
256a826d63 Consolidate formatters 2023-05-27 09:19:50 -07:00
6369af37d3 Simplify formatters 2023-05-27 09:19:50 -07:00
0b8404918e Remove get_cached_power 2023-05-27 09:19:50 -07:00
171a020c82 Pass correct Char to base format_as formatter (#3457) 2023-05-24 14:50:47 -07:00
d8f04e3995 Simplify ceil 2023-05-24 11:51:34 -07:00
5e988f8dfa Remove is_constant_evaluated() check
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-24 09:07:12 -07:00
19b17618a9 Make constexpr ceil
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-24 09:07:12 -07:00
c684a06d51 New CI: macOS 13, Xcode 14.3, C++ 20
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-24 09:07:12 -07:00
abdb7fdf88 Update api.rst 2023-05-24 06:30:48 -07:00
8b09fe2a0a Fix example for user-defined types in documentation for 10.0.0 (#3461)
* Fix example for user-defined types in documentation for 10.0.0

* Fix the fix
2023-05-24 06:25:51 -07:00
adad18a74d Update ChangeLog.rst 2023-05-23 12:46:26 -07:00
858e528abd Use dragon in constexpr 2023-05-23 06:30:09 -07:00
a54cb108d4 CMake: Do not fail on unknown compiler features (#3453)
If CMake does not know much about a compiler, `target_compile_features` will fail. Issue a warning instead.
2023-05-22 14:17:32 -07:00
ef55d4f52e Suppress a bogus gcc warning 2023-05-22 11:27:20 -07:00
70b6a6fa44 Update README.rst (#3454)
Fixed grammar and punctuation issues.
2023-05-22 10:35:24 -07:00
6fe895410d Remove invalid_arg_index 2023-05-21 19:57:17 -07:00
d0652d225f Create dependabot.yml (#3452)
Signed-off-by: Joyce <joycebrum@google.com>
2023-05-21 06:41:30 -07:00
de8d0171a2 Simplify FMT_FORMAT_AS 2023-05-20 18:28:01 -07:00
7401fe046a Hash pin Github Workflows (#3451)
* hash pin doc.yml

Signed-off-by: Joyce <joycebrum@google.com>

* hash pin linux.yml

Signed-off-by: Joyce <joycebrum@google.com>

* hash pin macos.yml

Signed-off-by: Joyce <joycebrum@google.com>

* hash pin windows.yml

Signed-off-by: Joyce <joycebrum@google.com>

* hash pin github owned cifuzz.yml

Signed-off-by: Joyce <joycebrum@google.com>

---------

Signed-off-by: Joyce <joycebrum@google.com>
2023-05-20 06:33:37 -07:00
08ef0d0842 fix formatter<char*> (#3432) 2023-05-20 06:32:21 -07:00
d60b907f87 Replace mod_inv_25 by explicit value (#3450) 2023-05-18 11:26:19 -07:00
4ce086f731 remove code duplication (#3448)
* remove code duplication

* new interface for remove_trailing_zeros(uint32_t& n, int s = 0)

---------

Co-authored-by: Florimond Collette <4939681+florimondcollette@users.noreply.github.com>
2023-05-18 08:27:57 -07:00
821f8cdb45 Detemplatize printf more 2023-05-17 12:34:12 -07:00
0bf6ed7e1d Cleanup printf 2023-05-17 10:53:25 -07:00
e40e04face Detemplatize printf_arg_formatter 2023-05-17 10:05:46 -07:00
0a1c27281a Detemplatize basic_printf_context 2023-05-17 09:29:20 -07:00
2f605cc896 Deprecate wide printf 2023-05-17 08:58:55 -07:00
1d54499ac0 Apply coding conventions 2023-05-17 08:21:13 -07:00
3c6053c535 Cleanup basic_printf_context 2023-05-17 07:57:53 -07:00
4a392adaa7 Remove basic_printf_parse_context 2023-05-17 07:47:42 -07:00
b14913fae5 FMT_MODULE_EXPORT -> FMT_EXPORT 2023-05-17 07:38:06 -07:00
2117df299c format-inl.h: address implicit int to bool conversion (#3446) 2023-05-17 06:39:20 -07:00
616a493786 Revert Char* formatter removal 2023-05-17 06:11:11 -07:00
9a034b0d55 Always assert in FMT_THROW (#3439) 2023-05-17 06:04:36 -07:00
e0fc0e85e3 Remove unneeded FMT_API 2023-05-16 17:25:20 -07:00
552c43aba9 Improve long formatters 2023-05-14 07:07:36 -07:00
d6846f4ac8 Clarify why byte formatter is in core 2023-05-13 08:04:53 -07:00
aeedac5884 Remove unneeded specialization 2023-05-13 07:46:47 -07:00
eaa6307691 Make hex float test more stable (#3434)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-13 06:34:33 -07:00
e82bf41a1a Update README.rst 2023-05-12 16:24:47 -07:00
e077396f5a Update docs 2023-05-12 16:10:38 -07:00
861facad0a Fix a typo 2023-05-12 16:08:55 -07:00
75bfe57614 Improve docs 2023-05-12 12:57:01 -07:00
697e76ba30 Don't call init_named_args unnecessarily 2023-05-12 11:53:22 -07:00
a425e0ff3b Cleanup xchar API 2023-05-12 07:05:14 -07:00
c36dd825ba Remove unnecessary forwarding 2023-05-12 06:45:49 -07:00
130b8fcdb9 Reduce template instantiations 2023-05-11 20:18:34 -07:00
a47e8419be Cleanup the core API 2023-05-11 19:07:56 -07:00
ea49c91cd1 Cleanup argument construction 2023-05-11 18:43:39 -07:00
d7592ad8bf Fix time_point formatting for durations with certain ratios (#3430)
* Fix time_point formatting

* Add timestamps_ratios tests
2023-05-11 15:25:21 -07:00
ebfb2e6779 Remove unused alias 2023-05-11 10:51:32 -07:00
5780269d57 Improve API safety 2023-05-11 10:19:56 -07:00
b471192160 Fix a comment 2023-05-11 09:39:53 -07:00
8f18e72df5 Improve API safety 2023-05-11 06:32:58 -07:00
93d7cb12f1 Fix formatting 2023-05-10 16:29:47 -07:00
0e4278717b Remove unused macro 2023-05-10 16:27:16 -07:00
93a30a0746 unicode_to_utf8 -> to_utf8 since both sides of conversion are Unicode 2023-05-10 16:26:02 -07:00
a08196b149 Update ChangeLog.rst 2023-05-10 09:49:39 -07:00
0398ba42ca Update ChangeLog.rst 2023-05-10 09:39:04 -07:00
a0b8a92e3d Update version 2023-05-09 15:55:39 -07:00
5cf2342aa2 Bump version 2023-05-09 15:37:01 -07:00
fe9d39d7cb Update changelog 2023-05-09 14:27:48 -07:00
4c98561979 Update changelog 2023-05-09 14:25:56 -07:00
403b271ed7 Update changelog 2023-05-09 14:20:59 -07:00
2c991e1af6 Update changelog 2023-05-08 14:43:16 -07:00
c984df9815 Remove an unused function from internal class 2023-05-08 13:35:23 -07:00
fbf21ed224 Update changelog 2023-05-08 13:34:29 -07:00
575583144e Update changelog 2023-05-08 11:37:33 -07:00
e7f6888c7a Update changelog 2023-05-08 09:49:39 -07:00
39db2dfd06 Update changelog 2023-05-08 09:41:57 -07:00
9b7829e264 Update changelog 2023-05-08 09:15:07 -07:00
1e0ce567ef Fix formatting of paths containing invalid Unicode 2023-05-07 10:05:15 -07:00
dde8cf3bb7 Unification utf16/utf32 to utf8 conversion
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-06 08:32:51 -07:00
e84b00e014 Workaround to error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-05-06 08:32:51 -07:00
b12ffea4fb Add filesystem_error test back 2023-05-06 07:49:46 -07:00
f61f15cc5b Suppress a false positive in gcc 2023-05-06 06:54:30 -07:00
192df93d7b modules missing pieces (#3399)
- don't export names from `detail`
- put more headers into the global module fragment
- support MSYS2 and Clang
2023-05-05 10:21:18 -07:00
d8973bf16b Add FMT_STRING for format_to() call (#3413) 2023-05-03 07:58:40 -07:00
d7a8e50cb5 Improve module testing (#3397)
* use the standard `test-main.cc` component instead of injected test infrastructure sources
 * undo now obsolete commit `00235d8a` from July 2021
 * Clang cannot import user-defined literals as it seems -> disable test
 * Clang emits duplicate, non-mergeable copies of `detail::buffer`'s vtable, causing linker errors -> disable test
2023-05-03 07:56:24 -07:00
02cae7e48a Improve handling of Unicode in paths 2023-04-30 09:58:59 -07:00
53162142b2 Remove .bazelrc mention from Bazel related readme (#3411) 2023-04-29 16:25:00 -07:00
5bcf0d7f97 Bazel support (#3406)
* Bazel support: Remove not needed .bazelrc file

* Bump tested Bazel version

* Apply buildifier to format Bazel build files

* Add note about Bzlmod
2023-04-29 07:45:49 -07:00
f8c9fabd94 Fix spelling (#3404) 2023-04-25 11:47:37 -07:00
62ff4e1dbd Remove foonathan from maintainer list (#3402) 2023-04-23 13:35:05 -07:00
f449ca0525 Name vfprintf clashes with the identically named declaration in 'stdio.h' if that happens to be #included into the same TU. Fix this by using qualified name lookup instead of unqualified lookup that also enables ADL. (#3400) 2023-04-23 07:10:57 -07:00
eafcd3c8e1 Optionally attach declarations to the global module rather than module fmt (#3387)
This allows coexistence with TUs that use {fmt} through #include without duplicating declarations, definitions, linker symbols, and object code.
2023-04-23 06:04:36 -07:00
18154cc903 Simplify print 2023-04-22 14:03:40 -07:00
0de789cf29 Update changelog 2023-04-22 09:20:28 -07:00
c039389223 export names only once (#3392)
names declared to be exported at the point of introduction into a namespace *must not* be (re-)declared as exported later in the TU, e.g. when they are redeclared, defined, or specialized. [module.export]/6

Drive-by fix found during module testing: add a missing `detail::` name qualification
2023-04-22 06:21:06 -07:00
93e81bb5d8 Fix C4365 (signed/unsigned mismatch) warning on 32-bit Windows (#3398) 2023-04-20 17:36:05 -07:00
e7d6eb6794 Update tests to use recommended MOCK_METHOD (#3395) 2023-04-20 13:16:21 -07:00
18e7a2532b Remove obsolete msvc workarounds (#3388)
This bug in the modules implementation is fixed since at least msvc 19.34, possibly even earlier like 19.32.
2023-04-19 17:09:51 -07:00
0489c19dcb fix and improve module (#3386)
* export public documented API
* don't export `namespace detail`
* add `std.h` into module
* add missing namespace qualification in `xchar.h`
* fix call to `detail::get_iterator` in `xchar.h`
* fix ambiguous overload of `detail::isfinite` in `chrono.h`
2023-04-18 06:47:01 -07:00
8ec94ac6a5 Use full path to pcm 2023-04-14 11:57:17 -07:00
d97d8cea67 Push module check to test 2023-04-14 11:42:01 -07:00
d8a2698e6c Fix compilation as a C++20 module with gcc 13 2023-04-14 09:49:07 -07:00
d9c19940a3 Update add_module_library 2023-04-13 17:13:52 -07:00
4b5ae0b0ef Remove unnecessary module support check 2023-04-13 16:53:45 -07:00
75f3b1c094 Use add_module_library 2023-04-12 09:10:34 -07:00
faf83406a9 Workaround cmake issue 2023-04-11 15:59:08 -07:00
165814d57a Add module support to CMake 2023-04-11 14:38:34 -07:00
33f7150778 Fix error C2668 on msvc (#3378) 2023-04-11 06:27:28 -07:00
c98e5a08a4 Fix modular build on clang 2023-04-10 12:07:25 -07:00
119c6bd16f Move the modules check 2023-04-10 09:28:00 -07:00
77eeb71830 Remove unused headers 2023-04-10 09:08:19 -07:00
13bf99f9db Enable modules in clang 16 2023-04-10 08:44:43 -07:00
1d0257e4c0 FMT_MODULE_EXPORT_* -> FMT_EXPORT_* 2023-04-10 08:33:39 -07:00
4613d48fd3 FMT_EXPORT -> FMT_LIB_EXPORT 2023-04-10 08:24:23 -07:00
4a4a2a2bd6 Fix diagnostics 2023-04-09 09:30:20 -07:00
fce74caa15 Disable problematic implicit conversions 2023-04-09 09:08:46 -07:00
02bf4d1c1c Disable to_string_view ADL 2023-04-09 08:49:05 -07:00
466e0650ec Remove problematic workaround 2023-04-09 08:04:11 -07:00
029caa8ea2 Update changelog 2023-04-09 07:01:06 -07:00
e406ddbfaf Remove broken part of the config 2023-04-08 08:46:43 -07:00
9095679536 Update changelog 2023-04-08 08:39:17 -07:00
7f46cb75b8 ranges: Fix extra semi (#3374) 2023-04-06 08:31:07 -07:00
4e3f381058 Update changelog 2023-04-02 07:13:42 -07:00
d3c10f5167 fix compilation for MSDOS (#3369) 2023-04-01 13:40:53 -07:00
ab956f600f Update changelog 2023-04-01 08:04:47 -07:00
97aedeab48 Workaround a double-double hexfloat format (#3366)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-04-01 07:19:23 -07:00
bce8d4ed08 Remove stray comment 2023-03-27 11:04:00 -07:00
a91c7b286d Cleanup the core API 2023-03-26 21:07:26 -07:00
19c074e477 Remove deprecated fallback formatter 2023-03-26 08:45:06 -07:00
41cfc739fe Generalize format_as 2023-03-26 07:37:51 -07:00
f6276a2c2b Force use a signed char (On ARM char is unsigned by default) (#3362)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-03-22 11:34:59 -07:00
6002ddf825 Remove a deprecated option 2023-03-19 12:17:43 -07:00
6549ffde8e Improve format_as safety 2023-03-19 12:09:54 -07:00
d9bc5f1320 Fix code causing spurious Wstringop-overflow warning
See #2989, #3054, and others
2023-03-18 09:29:54 -07:00
9c5cd998d1 Remove unused functions 2023-03-18 08:40:16 -07:00
93bfa05382 %T is %H:%M:%S (#3349) 2023-03-18 07:16:22 -07:00
d8e1c4265a fix case of variant which is valueless by exception (#3347)
Co-authored-by: theomegacarrot <theomegacarrot@gmail.com>
2023-03-18 07:07:06 -07:00
e1720c0e51 Fix CUDA nvcc warning fmt/include/fmt/core.h(295): warning #1675-D: unrecognized GCC pragma (#3352) 2023-03-17 11:35:35 -07:00
7f882918eb write_floating_seconds: Fall back to ::round (#3343)
On some toolchains, `std::round` is not available.

Fixes #3342
2023-03-12 09:34:19 -07:00
cbc7b8d5c1 Cleanup dead variable (#3338) 2023-03-10 09:17:43 -08:00
050293646f Path is not escaped twice in the debug mode (#3321)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-03-05 08:01:06 -08:00
3daf33837c Enable consteval for Xcode 14.0.1 and later (#3331)
Co-authored-by: Cloyce D. Spradling <cloyce_spradling@apple.com>
2023-03-04 09:22:43 -08:00
e0748e61dd Fix recursion check in range formatting 2023-03-04 08:20:32 -08:00
b94e1016fa chore: set permission to cifuzz.yml (#3328)
Signed-off-by: Joyce <joycebrum@google.com>
2023-03-01 07:58:59 -08:00
98699719f8 Make # handling consistent with std::format 2023-02-26 10:15:16 -08:00
48dfbcaa95 Improve license and PR template wording 2023-02-26 09:08:53 -08:00
c644c753d7 Add '🐙 userver framework' to the projects 2023-02-26 08:42:55 -08:00
73b7cee7fb Fix for issue #3325 (#3326)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-02-26 06:59:41 -08:00
5b8302079d Add optional support (#3303) 2023-02-25 06:45:56 -08:00
3a69529e8b Fix various typos (#3312)
Found via `codespell -q 3 -S ./test/gtest -L "fo,pres,seh,wronly"`
2023-02-21 15:14:41 -08:00
76f520835f Call element parse in tuple parse 2023-02-20 12:54:20 -08:00
507c3042d8 class -> typename 2023-02-18 10:23:42 -08:00
1741e90dec Always call parse in range formatter 2023-02-18 09:58:37 -08:00
d646fd0daf Minor cleanup 2023-02-16 11:21:08 -08:00
b5c2f74f45 change sopen_s to wsopen_s (fmtlib#3234) (#3293) 2023-02-16 11:17:55 -08:00
e03753c4ac Add ubuntu mirrors (#3302)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-02-12 07:46:50 -08:00
6e6eb63770 [msvc] fix warning about non-inline variable 2023-02-11 09:45:13 -08:00
3c5464ba1c Fix OpenBSD build error (#3295) 2023-02-11 08:46:28 -08:00
655046d24f Fix container adaptor formatting 2023-02-10 09:45:37 -08:00
581c6292c9 Add formatters for container adapters (#3279) 2023-02-08 17:25:41 -08:00
7718eeeacc Implement glibc ext for sec, min, and hour (#3271) 2023-02-08 09:22:58 -08:00
44e0eea94e Use FMT_HAS_INCLUDE and apply clang-format 2023-02-08 07:19:10 -08:00
99070899b7 Fix errors setting of FMT_USE_FLOAT128 (#3259) 2023-02-08 07:15:02 -08:00
05e3a9233a Allowing formatting non-copyable ranges. (#3290) 2023-01-27 12:29:57 -08:00
70db193f09 Visual Studio 2022: fmt/format-inl.h(1145,60): warning C4310: cast truncates constant value #3287 (#3288) 2023-01-26 11:46:30 -08:00
a2c05a10ec Workaround a bug in MSVC <= 19.22 2023-01-25 10:34:28 +13:00
cae9bf45b9 Simplify apidoc comments 2023-01-25 09:32:03 +13:00
87c066a35b Implement println (#3267) 2023-01-24 12:30:00 -08:00
9409b2e4d8 Workaround for incompatibility between libstdc++ consteval-based std::is_constant_evaluated() implementation and clang-14 (#3281)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-01-22 11:29:34 -08:00
f89cd276f7 Refactor countl_zero fallback (#3276) 2023-01-17 15:04:34 -08:00
240b728d81 Report an error on overflow 2023-01-18 11:52:33 +13:00
dfbb952b2c Fix empty spec for time point (#3275) 2023-01-16 11:48:00 -08:00
39971eb336 Fix localized format for float-point numbers (#3272) 2023-01-15 11:47:24 -08:00
0f42c17d85 Implement a new formatting algorithm for small given precision (#3269)
Implement the formatting algorithm for small given precision discussed in https://github.com/fmtlib/fmt/issues/3262 and https://github.com/fmtlib/fmt/pull/2750
2023-01-14 11:30:20 -08:00
bfc0924eac Bugfix for fmt::printf on Power9 architecture with the XL compiler (#3256) 2023-01-13 11:36:00 -08:00
676c2a107e Fix negative subsec for time_point (#3261) 2023-01-11 11:36:50 -08:00
2c80cedc39 Fix standard default installation target presence (#3264) 2023-01-10 17:56:00 -08:00
dda53082be Support fill, align & width for time point (#3260) 2023-01-09 11:25:31 -08:00
2622cd23e6 Simplify arg_mapper 2023-01-03 16:35:21 -08:00
9e4a54fa6e Disable remaining implicit conversions 2023-01-03 12:08:42 -08:00
9ce6480676 Disble deprecated implicit enum conversions 2023-01-03 10:24:31 -08:00
9121f9b1d3 Enable format_as for classes 2023-01-03 08:58:23 -08:00
b7535365b2 Enable format_as for non-integral types 2023-01-02 13:37:13 -08:00
09ed1ddb9c Cleanup tests 2023-01-02 09:58:12 -08:00
0ec65d99aa Merge parse_presentation_type into parse_format_specs 2023-01-02 09:19:32 -08:00
71e4e02722 Cleanup vprintf 2023-01-02 08:37:00 -08:00
aad546baa5 Simplify presentation type parsing 2023-01-01 16:14:17 -08:00
14a69fcc54 Use parse_align 2023-01-01 10:44:55 -08:00
bf34ffd33f Refactor format string parsing 2023-01-01 10:21:47 -08:00
6056e07125 Simplify symbols 2022-12-30 19:35:05 -08:00
aa99b86409 Minor cleanup 2022-12-30 18:51:15 -08:00
6ade2eb4e5 Inline all_int_set 2022-12-30 17:05:08 -08:00
caa6974942 Simplify parse functions 2022-12-30 16:34:36 -08:00
a73a9b6a84 Refactor format string checks 2022-12-30 16:03:41 -08:00
72785a3aba Cleanup write 2022-12-30 13:53:55 -08:00
0c3dd5ddd7 Remove redundant check 2022-12-30 12:55:19 -08:00
739b600f40 Remove iterator shenanigans 2022-12-30 12:37:22 -08:00
3710c4d38f Link to dragonbox 2022-12-30 12:07:55 -08:00
a05ba44df8 Simplify format string parsing 2022-12-30 11:23:42 -08:00
ffb9b1d13c Improve handling of signed types 2022-12-30 10:31:39 -08:00
32190859ec Fix handling of char 2022-12-30 09:11:42 -08:00
8fe4d97d5e Reduce template instantiations 2022-12-30 08:44:23 -08:00
7e5a959564 Fix build with MSVC C++20 modules (#3254)
When using fmt with C++20 modules under MSVC, it can end up requiring certain things to have storage that would not otherwise have needed to. Since I didn't see anything that was already doing detection for `inline constexpr` variable support, I've just moved the entire thing into the only function where it's used.
2022-12-28 19:58:57 -08:00
9e60304869 Clarify that unused args are allowed 2022-12-28 06:58:04 -08:00
7ad48c1f65 Cleanup core.h 2022-12-26 09:14:15 -08:00
a921a596e7 Cleanup core.h 2022-12-26 07:46:31 -08:00
3e762fdf5c Use ignore_unused 2022-12-26 06:57:21 -08:00
79981a2528 Cleanup ranges formatting 2022-12-25 20:05:20 -08:00
bd12aaa98e Simplify format string parsing 2022-12-25 12:31:38 -08:00
b8f36207c9 Simplify format string parsing 2022-12-25 11:47:43 -08:00
d907786f04 Move anchor to where it belongs 2022-12-25 10:58:54 -08:00
f2355bbe5e Fix docs 2022-12-25 10:25:35 -08:00
f398c94761 Fix docs 2022-12-25 10:24:36 -08:00
4841784e82 Simplify C99 strftime detection conditions
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-25 10:16:19 -08:00
cb72c23e9e Improve timezone tests
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-25 10:16:19 -08:00
583f2d8209 Set timezone for chrono tests
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-25 10:16:19 -08:00
32c4390704 Minor cleanup 2022-12-25 08:59:25 -08:00
3a5e19fbf5 Minor cleanup 2022-12-25 08:42:16 -08:00
dfb857ebef Refactor format spec parsing 2022-12-25 07:25:32 -08:00
9ea9b6bcb1 Cleanup arg id parsing 2022-12-24 16:33:57 -08:00
2b0ff62a7f Remove unused template arg from format_string_checker 2022-12-24 15:46:34 -08:00
d1745084e0 Simplify parse context 2022-12-24 15:20:24 -08:00
407e7b7b6d basic_format_specs -> format_specs 2022-12-24 14:34:50 -08:00
3cf9794755 Cleanup format string parsing 2022-12-24 13:47:20 -08:00
934c8e5f76 Refactor precision parsing 2022-12-24 13:29:23 -08:00
fc96938345 Remove empty semicolon 2022-12-24 09:54:55 -08:00
f0ab112c34 Cleanup parsing 2022-12-24 09:40:35 -08:00
9660e5b956 Remove redundant tests 2022-12-24 07:28:13 -08:00
a585571e90 Ignore 0 character with align 2022-12-23 19:36:05 -08:00
840ec8569d Cleanup width handlers 2022-12-23 19:18:35 -08:00
1dadeb8a33 Refactor width parsing 2022-12-23 18:29:59 -08:00
275b4b3417 Remove obsolete parse-benchmark 2022-12-23 12:50:08 -08:00
e004f1d699 Fix for issue #3241
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-23 12:26:20 -08:00
bde1a6070d Simplify fill and alignment parsing 2022-12-23 10:52:56 -08:00
040dc2a5d4 small typo in syntax.rst
0x1e was misread as 0x13, it looks like
2022-12-23 10:29:14 -08:00
6a186bcd66 Localize FMT_USE_LOCAL_TIME 2022-12-21 14:52:52 -08:00
8c56919bd2 Check chrono spec starts with % 2022-12-21 14:40:30 -08:00
115001a3b1 Formatting of system clocks ought to be to UTC, not to local time.
This improves standards conformance of fmt.
2022-12-21 14:23:02 -08:00
b90895412f Fix formatting of named arguments with locale 2022-12-15 09:59:40 -08:00
d072f1dc69 Fix for issue #3228
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-14 13:49:36 -08:00
3999fd193a Workaround an ADL issue 2022-12-11 09:32:17 -08:00
c06e0b4ede Extract timezone offset from timezone conversion functions
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-10 10:13:53 -08:00
1bf302a4ea Implement %Ez, %Oz for chrono formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-10 10:13:53 -08:00
f1733afd49 Pin godbolt example to specific version 2022-12-10 09:35:55 -08:00
f61dcccc6e Update README.rst 2022-12-06 11:52:37 -08:00
f9bcbdcbcf Update README.rst 2022-12-06 11:51:59 -08:00
1a854b4aa5 Clarify what mod_inv_5 is 2022-12-04 08:36:03 -08:00
62ceb181b1 fix #3105 - Compile-time error when mixing named argument with automatic indexing 2022-12-04 08:13:26 -08:00
b0c8263cb2 include/fmt/core.h: copy constructors removal 2022-11-30 16:44:42 -08:00
d24be2e95c Add countl_zero function
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-30 12:25:01 -08:00
8d50d814db Fix a chrono formatting issue found by fuzzing 2022-11-30 11:04:51 -08:00
115ca96e0e Bump tested CMake version to 3.25
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-30 08:09:32 -08:00
886491625d Remove workaround for GTest bug
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-30 07:16:37 -08:00
74c51ff37e Skip only strptime dependent test in scan-test
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-27 08:59:30 -08:00
69ffedfe52 Use target_compile_features to specify C++ standard requirement 2022-11-26 11:03:17 -08:00
fae6f7e081 Optimize range formatter 2022-11-26 08:50:46 -08:00
a69e43c9d7 Update benchmark results 2022-11-25 09:52:02 -08:00
91c024ed33 Rename leading_v -> leading_xdigit
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-25 09:08:40 -08:00
649aa102d6 CI linux: add CIFuzz Github action
Signed-off-by: David Korczynski <david@adalogics.com>
2022-11-24 08:22:51 -08:00
31364732dc Replace snprintf-based hex float formatter with internal implementation
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-24 07:15:46 -08:00
74d55a4938 Add missing operators
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-24 07:15:46 -08:00
8276f1a204 Fix warning: the implicit by-copy capture of "this" is deprecated (EDG frontend)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-22 10:51:00 -08:00
81ebe70b9b Fix warning: a class type that is not trivially copyable passed through ellipsis (EDG frontend)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-22 10:51:00 -08:00
3160847ebd Enable C++17 tests on macOS
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-18 08:22:07 -08:00
6a95f8c7eb Add missing env CTEST_OUTPUT_ON_FAILURE
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-18 08:22:07 -08:00
c7980542d3 Skip the scan-test if strptime isn't defined (#3184)
cygwin and embedded systems. By default newlib doesn't provide strptime
in time.h because it was added in a later X/Open versions. Issue: #3178
2022-11-16 09:42:01 -08:00
7df30f91ae Format unique_ptr with custom deleter (#3177)
* Format unique_ptr with custom deleter

Added deleter type to fmt::ptr unique_ptr overload. Deleter type is
part of the unique_ptr type.

* Review: apply clang-format

Co-authored-by: Hans-Martin B. Jensen <haje@eposaudio.com>
2022-11-13 21:54:32 -08:00
d2e89c8b08 Document more chrono specs 2022-11-08 19:35:34 -10:00
bd19593204 Document more chrono specs 2022-11-08 16:22:23 -10:00
fd0d0ec8df Document more chrono specs 2022-11-08 14:57:57 -10:00
8e93434edd Update README.rst 2022-11-08 11:21:16 -08:00
fc07217d85 Make utf-8 detection compatible with gbk 2022-11-02 15:42:47 -07:00
cb7373b469 Replace format with FMT_STRING. (#3162)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-11-02 13:17:16 -07:00
795ed8abf5 Add precision modifier for seconds in chrono format (#3148)
Co-authored-by: Stepan Ponomarev <stepan.ponomarev@itiviti.com>
2022-11-02 11:58:51 -07:00
66d71a1b35 Fixing formatting of range of range of char. (#3158) 2022-11-02 11:04:54 -07:00
80f8d34427 fmt::ostream - aggregate buffer instead of inheriting it (#3139)
Some MSVC-specific behavior:
When class fmt::ostream inherits detail::buffer - the last gets implicitly exported when fmt is built as a shared library.
Unless os.h is included, the compiler assumes detail::buffer is not externally exported and instantiates a local copy of it, which causes ODR violation.
With aggregation - there is no extra exporting of detail::buffer symbols.
2022-10-23 07:21:36 -07:00
64965bdc96 Add locale getter in tm_writer (#3147)
* Add locale getter in tm_writer

* Apply clang-format

Co-authored-by: Stepan Ponomarev <stepan.ponomarev@itiviti.com>
2022-10-20 10:22:03 -07:00
e1ffa7655d Fix warning: conditional expression is constant. (#3150)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-20 07:49:53 -07:00
8c19bf3f2f Mention MariaDB amongst the projects that use fmt (#3145) 2022-10-17 13:33:05 -07:00
f67dbc9811 Remove duplicate implementation (#3144)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-17 11:15:28 -07:00
cd7202e039 Fix overflow error (#3143)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-16 14:04:55 -07:00
51d3685efe Remove duplicate template parameter. (#3142)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-14 16:34:24 -07:00
9254cfa6f0 Support formatting of subseconds (#3115)
* Timestamp formatting shall print also subseconds, fixed a bug for fractional durations
2022-10-12 14:33:53 -07:00
cfb34a0607 Avoid using uint as a type name (#3137)
Sometime `uint` is defined as a global type by the project's code directly or by some 3rdparty libraries (e.g. Qt or OpenCV).
Some versions of MSVC (e.g. v16.11.15) gives a type shadowing warning:
```
3rdparty\fmtlib\fmt\include\fmt/format.h(3251): warning C4459: declaration of 'uint' hides global declaration
opencv2/core/hal/interface.h(45): note: see declaration of 'uint'
```
This also causes a compilation failure when `/WX` is used.
2022-10-12 10:53:47 -07:00
5ad7b71381 Fix options for C++20 experimental module in CMake (#3134)
* Fix options for C++20 experimental module in CMake

* Replace `FMT_CAN_MODULE` by `FMT_MODULE` in test/CMakeLists.txt
2022-10-12 08:23:12 -07:00
d2c47c0df2 Fix broken condition (#3129)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-07 13:46:45 -07:00
491c32cbd9 Workaround gcc bug 103879 2022-10-05 21:12:38 -07:00
662adf4f33 Move formatter<std::error_code> from fmt/os.h to fmt/std.h (#3125)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-01 17:46:09 -07:00
ad91cab374 Normalization of stdlib inline namespace names (#3119)
* Normalization of stdlib inline namespace names

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

* Remove all subnamespaces with names matching "__*" mask

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-29 09:52:38 -07:00
0ccaed3a6c Set CMAKE_RUNTIME_OUTPUT_DIRECTORY relative to CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR (#3120)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-28 16:51:23 -07:00
ad719619cc Support formatting of std time_point with utc_clock (#3110) 2022-09-28 07:31:53 -07:00
6e0a5f7fba Update CI to Ubuntu 20.04 and to newer versions of actions 2022-09-27 15:06:12 -07:00
48f525d025 Add basic_format_string::get() 2022-09-22 19:50:04 -07:00
0b5cb18b71 Use buffering in to_string to avoid bloat 2022-09-21 17:11:43 -07:00
4c4f99a583 Update a godbolt link 2022-09-21 12:05:57 -07:00
3272a7a3ce Update an example 2022-09-21 12:03:18 -07:00
a48e3355a6 Improve docs 2022-09-18 08:44:04 -07:00
afcf424294 Update docs 2022-09-16 15:27:18 -07:00
ac85afaab6 Simplify format_error 2022-09-16 14:25:14 -07:00
3178bb9a26 Update docs 2022-09-16 10:29:53 -07:00
cf58f64c54 Update docs 2022-09-16 10:28:00 -07:00
e4e0ae3918 Use fmt/core.h in examples 2022-09-15 20:41:32 -07:00
d65acc4e6c Improve docs 2022-09-14 10:59:50 -07:00
c9f790b061 Update docs 2022-09-14 10:58:52 -07:00
6b8144a5ac Update locale docs 2022-09-14 06:38:29 -07:00
2d66ad5d33 Suppress -Wshadow
Solves:
/fmt/include/fmt/ostream.h:89:18: warning: declaration of 'fbuf' shadows a previous local [-Wshadow]
   89 |   else if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_filebuf<char>*>(rdbuf))
      |                  ^~~~
C:/GIT/ok-mimot/libs/3rdParty/fmt/include/fmt/ostream.h:87:13: note: shadowed declaration is here
   87 |   if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_sync_filebuf<char>*>(rdbuf))
      |             ^~~~
2022-09-13 11:14:30 -07:00
042af53324 Suppress -Wfloat-equal
Only NaN and Inf are not less than Inf and the check for NaN is done
before.

Solves:
.../fmt/include/fmt/format.h:2509:43: warning: comparing floating-point with '==' or '!=' is unsafe [-Wfloat-equal]
 2509 |     return !detail::isnan(value) && value != inf && value != -inf;
2022-09-13 11:14:30 -07:00
192859c2b5 Optimize writing to buffers via back_insert_iterator 2022-09-12 15:32:12 -07:00
e2f6d7665b fix gcc <= 7.1 compile errors 2022-09-12 10:43:16 -07:00
61844b6b67 Fix build error on GCC-9
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-12 07:02:29 -07:00
7a752e75ff New CI: GCC-9
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-12 07:02:29 -07:00
94ceb38a09 Improve locale API 2022-09-11 09:33:31 -07:00
58c4c012fa Disable slow windows build and simplify write_loc 2022-09-11 08:35:09 -07:00
c3494ae364 Refactor float localization 2022-09-11 07:47:27 -07:00
8ae56161c8 Fix compilation with FMT_ENFORCE_COMPILE_STRING and FMT_WERROR (#3091) 2022-09-10 18:05:10 -07:00
76705fc2ee Update doc 2022-09-10 15:06:09 -07:00
21c2137e77 Add class name output to formatter for std::exception (#3076)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-10 08:04:00 -07:00
ecffca6726 Don't parse '}' as fill 2022-09-07 17:33:31 -07:00
3176e0fad7 Add locale overload for formatted_size (#3084) (#3087)
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-09-07 14:15:12 -07:00
1feb430faa Fix intellisense on Windows (#3082)
__INTELLISENSE__ is 1 on vs2022 and clang, causing FMT_HAS_INCLUDE, FMT_USE_FCNTL, etc to be 0.
That results in VS and VSCode having a lot of linter errors while code compiles just fine.
2022-09-05 11:50:06 -07:00
b98ffb7dbd Improve locale handling 2022-09-04 21:07:30 -07:00
bac53951b8 Add starts_with to basic_string_view. (#3080)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-04 11:41:16 -07:00
d59b89e9cd More locale 2022-09-04 11:23:45 -07:00
58a5563a9f Implement grouping 2022-09-04 09:01:26 -07:00
1b94271ff6 Add support for UTF-8 digit separators 2022-09-03 11:01:05 -07:00
768d79a839 Implement format_facet 2022-09-03 09:42:36 -07:00
91ecb38a34 Localize negative integers 2022-09-03 07:01:11 -07:00
aec3bb5d0a Workaround C complex.h idiocy 2022-09-03 06:35:55 -07:00
29c6000137 Simplify is_variant_like_ check, fix compile error before GCC 11 (#3072)
Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>

Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-02 21:08:07 -07:00
fec5515c55 num_format_facet -> format_facet 2022-09-02 18:55:08 -07:00
f187274d36 Add loc_value 2022-09-02 13:45:23 -07:00
fc5e59fe4a Don't use stringstream 2022-09-02 13:05:26 -07:00
d6a8704605 Improve locale support 2022-09-02 11:52:19 -07:00
56c72a671c Reduce locale dependency 2022-09-02 10:22:11 -07:00
4191477b98 Add formatter for std::exception (#3062)
Co-authored-by: fekir <federico.kircheis@gmail.com>
Co-authored-by: Alexey Ochapov <alexez@alexez.com>
Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>

Co-authored-by: fekir <federico.kircheis@gmail.com>
Co-authored-by: Alexey Ochapov <alexez@alexez.com>
Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-09-02 08:33:37 -07:00
75383a87f9 Inline trivial functions 2022-09-01 18:25:23 -07:00
48327a82e3 Make format.h compile faster 2022-09-01 17:06:47 -07:00
b79ed4105a Remove unnecessary type_identity 2022-09-01 16:29:08 -07:00
64e29893cf Improve locale support 2022-09-01 14:48:43 -07:00
0b0f7cfbfc hip workaround 2022-09-01 09:18:53 -07:00
40e414d823 Fix compilation error with gcc-7.2.0
Without the added line, the gcc-7.2.0 compiler will give the following error:
```
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:1240:8: error: uninitialized variable 'buffer' in 'constexpr' function
   Char buffer[digits10<UInt>() + 1];
        ^~~~~~
```
See https://godbolt.org/z/fh7TMs9qs
2022-08-30 10:55:57 -07:00
33b4c33c5b Requires FMT_CONSTEXPR20 support
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-29 13:33:48 -07:00
a07411c2b9 Disable compile-time checks for dynamic width/precision test for LCC and compiler without std::is_constant_evaluated()
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-29 13:33:48 -07:00
797d82b21a Disable non-type template args for LCC
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-29 13:33:48 -07:00
a553521d6d Disable "GCC optimize" pragma for LCC
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-29 13:33:48 -07:00
a33701196a Update version 2022-08-27 08:57:10 -07:00
1f575fd5c9 Bump version 2022-08-27 08:55:39 -07:00
c7635288f7 Fix docs, take 2 2022-08-27 08:28:07 -07:00
c8ed78e315 Fix docs 2022-08-27 08:01:47 -07:00
e07cfb2068 Update changelog 2022-08-27 07:55:06 -07:00
1dc7af5693 Fix markup 2022-08-27 07:52:58 -07:00
f7d21c3a1a Update changelog 2022-08-27 07:51:24 -07:00
a55bcb24bd Update changelog 2022-08-27 07:13:36 -07:00
30cb2b3122 Remove appveyor config 2022-08-27 06:52:25 -07:00
cf8d3c3229 Update changelog 2022-08-26 16:17:42 -07:00
3c3cb6f6b1 Update changelog 2022-08-26 16:00:24 -07:00
91481f255c Detemplatize code_point_length_impl 2022-08-26 15:45:00 -07:00
f98048b621 Fix bugs in utf8 decoder (#3056)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-26 15:37:15 -07:00
4a8e2949bb Fix formatting of ranges of code unit types
Thanks Nicole Mazzuca.
2022-08-26 13:48:58 -07:00
3a3b0709e2 Disable bogus -Wstringop-overflow on GCC 11 (#3054)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-24 12:37:34 -07:00
e724bbea16 Fix wchar_t corner cases 2022-08-24 12:23:10 -07:00
665d9779ec Disable non-type template args for nvhpc (#3053) 2022-08-24 10:56:45 -07:00
13d07c6a3d Apply doc fixes retroactively 2022-08-24 09:16:12 -07:00
391f922acc Improve error reporting in format string compilation 2022-08-24 09:05:15 -07:00
dc59d3df3f Fix a warning in gtest 2022-08-24 07:18:14 -07:00
489dabbd31 Fix decoder on broken utf8 sequences. (#3044)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-24 07:13:27 -07:00
541cd21838 Fix locale name (thanks Mikhail Paulyshka) 2022-08-20 08:06:20 -07:00
1f95c34381 Fix sign handling with large code units 2022-08-20 07:46:58 -07:00
779449fd99 Belarusify test 2022-08-20 07:37:15 -07:00
fbb568bce0 nvhpc/22.3: workaround for c++17 mode. (#3043) 2022-08-18 11:30:40 -07:00
36c23bd5fd Prepare for deprecating FindPythonInterp module. (#3040)
* Prepare for deprecating FindPythonInterp module.

Since FindPythonInterp module is deprecated after CMake 3.12, it is better to start using the new FindPython module.

* Add the proper punctuation in comments.
2022-08-17 14:18:39 -07:00
9ff0f3a7d6 Fix docs 2022-08-16 11:31:11 -07:00
fd41110d38 Add MinGW to CI 2022-08-14 08:40:38 -07:00
fc23cfbf4e Fix testsuite on MinGW + MSVCRT
Fixes #2952. The testsuite indirectly called strftime() with conversion
specifiers defined only in C99. In MSVCRT this function conforms only to
C89. Only in the updated UCRT this functon provides the functionality of
C99.
2022-08-14 08:40:38 -07:00
fd93b633b8 Constexpr formatted_size (#3026)
* Constexpr formatted_size

* Add C++20 tests for gcc 9 and 10

* Adjust unit test to require __cpp_lib_bit_cast
2022-08-10 09:35:30 -07:00
7fb8d33f9d Fix compile-time width/precision type check 2022-08-09 16:10:02 -07:00
8bd02e93b2 Reduce conditional compilation 2022-08-09 09:05:01 -07:00
d9c1c7353a Use is_utf8() in print(std::ostream&, ...)
This patch concludes the Unicode support for print(ostream&, ...)
2022-08-09 09:05:01 -07:00
682e097bee Remove -Wl,--as-needed linker option
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-07 06:51:41 -07:00
b9087ee587 Suppress unused typedef warning 2022-08-05 15:27:01 -07:00
df56fdf883 Clarify docs for compile-time checks 2022-08-05 07:00:34 -07:00
90c48b8525 Remove double code execution
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
5a8b7cd742 Add comment
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
36a25d75b4 Reuse detail::string_literal in the chrono formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
6c9304b2c2 Replace ParseContext with basic_format_parse_context
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
24ab9dd19e Remove duplicate method
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
a95dc17017 Remove unused condition
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-05 06:15:59 -07:00
5f774c0aed I shouldn't be there 2022-08-02 16:35:50 -07:00
6567df7f24 Update README.rst 2022-08-02 06:50:09 -07:00
6c6b1fbf6e Workaround a bug in MSVC
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-08-02 06:46:02 -07:00
9beddd08f9 Improve CI on Windows 2022-08-02 06:46:02 -07:00
6452e3c9eb Fix a typo in example 2022-08-02 06:26:19 -07:00
756822ba39 Fix Unicode handling for ostream under Windows with libc++. (#3001)
Also replaces the SFIANE tricks applied in
ce7ecdb7af with conditional compilation.
The code was too complicated along with the other trick to access private
data members.
2022-07-30 06:49:21 -07:00
0b2862a1e4 Range formatter (#2983)
* Implement range_formatter and format_kind

* Attempted gcc 4.8 fix

* gcc 4.8 interprets inaccessible as a hard error (instead of... not available)

* Attempting to delete set_debug_format.

* clang-format

* Different implementation of FMT_STATICALLY_WIDEN

* Renaming copy_str_range to copy_str.

* I guess I need a definition

* Forgot to delete these.

* Other PR comments.
2022-07-29 13:55:16 -07:00
258000064d Add fmt:: namespace to doc (#3009)
Otherwise as-is the example does not compile on Visual Studio due to the conflict with std::format_to: 
https://gcc.godbolt.org/z/qe4jEvvqY
2022-07-29 13:10:09 -07:00
e9ca7ea472 Suppress a bogus warning 2022-07-28 07:12:49 -07:00
81f1cc74a7 Improve Unicode handling when writing to an ostream on Windows (#2994)
* Refactor detail::print() by splitting into two functions.

The part with SetConsoleW is a separate function, without fwrite().

* Make Unicode handing when writing to std::ostream more robust.

Calls to print(ostream&) in the special Unicode case on Windows fallback
to writing via ostream::write instead of fwrite().

* Fix Unicode handling when writing to an ostream on GCC on Windows

* Add TODO note about detail::is_utf8()

* Fix warning -Wundef

* Fix for non-Windows OSs

* Fix building as DLL on Windows

* Refactor

* Suppress warning
2022-07-23 08:03:31 -07:00
bbcb129e02 Reduce filesize of the tests on MinGW (#2995)
This patch removes the workaround applied here
1acfd07f1e.
MinGW is not tested on Appveyor anymore.
2022-07-22 20:11:33 -07:00
48e0a59222 Implement compile-time checks for dynamic width/precision type 2022-07-22 17:00:40 -07:00
bc5c7c50fd Fixes IBM XLC behavior with uint128 fallback (#2985)
* Fixes IBM XLC behavior with uint128 fallback

* Replace legacy xlc with clang-based xlc

* simplify xlc intrinsics handling

Co-authored-by: Federico Busato <fbusato@nvidia.com>
2022-07-22 13:49:17 -07:00
00adc7120d Add a regression test for here be dragons 2022-07-22 11:08:00 -07:00
c48be439f1 Add additional search paths for doxygen on Windows
`find_program(DOXYGEN doxygen)` didn't find the executable automatically even if I installed Doxygen on Windows. Therefore, I added some additional search paths.
2022-07-19 08:59:18 -07:00
371f9c71ca Fix even in format_dragon 2022-07-19 08:36:34 -07:00
91abfcd6cf Suppress an msvc warning 2022-07-16 08:57:09 -07:00
deeab54b40 Remove unused include 2022-07-15 20:11:35 -07:00
688a627d6c Remove unused constants. 2022-07-14 15:25:35 -07:00
9bb1605f10 Remove some branches 2022-07-14 15:25:35 -07:00
8061d9afbe Simplify Dragonbox implementation 2022-07-14 15:25:35 -07:00
d82e1a108d Make sure the correct fmod overload is called 2022-07-13 12:42:03 -07:00
defa04e730 Fix for EDG frontend (Intel, NVHPC compilers) (#2982)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-13 11:34:43 -07:00
92d36e82c4 The n specifier for ranges (#2981)
* The n specifier for ranges.

* Flipping flag polarity.
2022-07-12 10:08:38 -07:00
0db43cf7fe Pointless comparison warnings (#2971)
Co-authored-by: Federico Busato <fbusato@nvidia.com>
2022-07-11 12:29:39 -07:00
05be7a0764 Use FMT_USE_FLOAT128 instead of __SIZEOF_FLOAT128__ 2022-07-10 08:54:34 -07:00
2a1b3ac629 Fix large shift in uint128_fallback 2022-07-10 08:27:21 -07:00
e1d3d3a326 Exclude recursive ranges from the formatter specialization for ranges (#2974)
* 2954: Add test case

* Eliminate extra-test and merge it into existing std-test instead. Add conditionals for filesystem::path testing that does not run into the ambiguity problem.

* #2968: Introduce additional compile-time predicate to detect recursive ranges and reject them in formatter specialization for ranges. In addition, introduce additional wrapper traits for the individual logical operands of the complete range constraints

* #2968: Eliminate preprocessor condition that enables the formatter specialization for std::filesystem::path

* #2968: Eliminate preprocessor condition that enables the test for the formatter specialization for std::filesystem::path

* Use own bool_constant, which is available for all C++ versions

* Reintroduce previous workaround but restrict to VS 2015 for now

* Comma fix

* - Rename is_not_recursive_range to is_nonrecursive_range and add comment that explains it being depending on is_range being true
- Merge has_fallback_formatter_delayed into is_formattable_delayed and add comment that explains it being depending on is_not_recursive_range being true
- Replace disjunction in formatter specialization by has_fallback_formatter_delayed
- Get rid of unneeded detail:: prefixes within namespace detail
2022-07-10 06:26:23 -07:00
b761f1279e Improve forward using the idea from Jonathan Müller 2022-07-07 16:48:17 -07:00
cc1926942f Inline std::forward 2022-07-07 14:41:54 -07:00
d5e9166f54 Fixed typo in changelog example. 2022-07-05 19:07:39 -07:00
b31d1a75a0 Add xchar support for fmt::streamed().
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-05 19:07:06 -07:00
c4ee726532 Update version 2022-07-04 09:50:06 -07:00
fa2eb2d2e3 Bump version 2022-07-04 09:37:29 -07:00
35f72bf210 Bump version 2022-07-04 09:10:55 -07:00
d22f00d7e4 Update changelog 2022-07-04 09:01:56 -07:00
4e8d215606 Update changelog 2022-07-04 08:56:18 -07:00
84eecb6561 Prune CI configs 2022-07-04 08:51:35 -07:00
55727e3b21 More compile-time checks 2022-07-04 08:25:27 -07:00
1010b7f148 Update docs 2022-07-04 08:18:44 -07:00
2ac51fc448 Update changelog 2022-07-04 08:13:27 -07:00
831132293b Workaround for Microsoft Visual Studio 2022 Internal compiler error.
D:\a\fmt\fmt\test\compile-test.cc(362,3): fatal error C1001: Internal compiler error. [D:\a\fmt\build\test\compile-test.vcxproj]
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\constexpr\constexpr.cpp', line 8635)

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-04 07:18:21 -07:00
115e00e0b9 Replace __cplusplus with FMT_CPLUSPLUS.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-04 07:18:21 -07:00
94114b05ca New CI: Microsoft Visual Studio 2022.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-04 07:18:21 -07:00
d2a2320820 Fix partial specialization problem for filesystem for Visual Studio (#2957)
* #2954: Provide std::conjunction and std::disjunction substitutes

* #2954: Use conjunction and disjunction substitute to make formatter specializations for ranges and maps more robust (especially for Visual Studio compiler family)

* #2954: As workaround for older MSVC compilers split formatter<std::filesystem::path> partial template specialization into two explicit specialization.

* 2954: Add test case

* Provide simplified implementations of conjunction and disjunction

* Remove workaround explicit specializations if the partial specialization would cause an ambiguity error

* Eliminate extra-test and merge it into existing std-test instead. Add conditionals for filesystem::path testing that does not run into the ambiguity problem.
2022-07-03 11:06:54 -07:00
0c06c81da8 Deprecated implicit conversion of enums to ints for consistency with scoped enums 2022-07-03 09:02:22 -07:00
c12b4c0cf1 New CI: GCC-8 C++17, Clang-8 C++17.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-02 08:34:52 -07:00
99bb5b1d17 Fix std::variant, std::filesystem::path tests on GCC-8, Clang-7,8.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-07-02 08:34:52 -07:00
e29c2bc60e Update docs 2022-06-30 08:13:34 -07:00
c65e4286bf Update changelog 2022-06-29 09:02:08 -07:00
69c24e47e8 Update changelog 2022-06-28 11:00:56 -07:00
6a775e9560 Add support for 'std::variant' in C++17 (#2941)
Add support for 'std::variant' in C++17.

For C++17, if all the alternatives of a variant are formattable
the variant is now also formattable. In addition 'std::monostate'
is now formattable.

Moves implementation into 'std.h', and tests into 'std-test.cc'.

Avoid fold-expression since MSVC was crashing.

Add section for 'fmt/std.h' in API-docs.
2022-06-26 07:28:01 -07:00
51535866d0 Update docs 2022-06-25 09:13:29 -07:00
3ef5caa9fe Update docs 2022-06-25 09:11:10 -07:00
dccd3e6742 Fix docs 2022-06-25 09:04:31 -07:00
9cb02aaaad Fix UDLs 2022-06-25 08:52:10 -07:00
e6d478f8e8 Update changelog and docs 2022-06-25 08:33:57 -07:00
2d931b1497 Add fmt::streamed 2022-06-24 09:26:24 -07:00
0506a5733d Update changelog 2022-06-24 09:04:56 -07:00
e8bd2a804d Fix enable_ifs for map formatter (#2944) 2022-06-23 08:24:11 -07:00
7c56e11ecf Update changelog 2022-06-23 07:40:56 -07:00
69a20db081 Update changelog and fix an apidoc comment 2022-06-22 08:32:46 -07:00
7a2a97c882 Update changelog 2022-06-22 07:31:34 -07:00
5682338891 Fix is_formattable for tuple-like types. (#2940) 2022-06-19 08:25:58 -07:00
f0de128449 Remove /source-charset:utf-8 compile option.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-06-19 07:37:39 -07:00
eaa8efb950 Fix ofstream handling in msvc 2022-06-16 15:02:33 -07:00
fb991e9d3b Update changelog 2022-06-12 12:17:39 -07:00
8e47cfd1cd fix -Wsign-conversion warning 2022-06-11 12:31:33 -07:00
2471875867 Make the tests pass on a CHERI system. 2022-06-10 07:02:03 -07:00
b135f1c014 Refactor handling of argument types 2022-06-09 17:03:33 -07:00
f61a1e8132 Add format_arg_types 2022-06-09 15:50:30 -07:00
48b7e3dafb Added a FMT_STRING wrapper for system_error() call.
This enables the use of FMT_ENFORCE_COMPILE_STRING on MSVC 2019.
2022-06-07 07:00:57 -07:00
4bb3af7a6b Improve compile-time checks 2022-06-05 13:58:04 -07:00
d02c582b96 Fix 'duplicate symbol' error.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-06-05 07:17:25 -07:00
b59d8c3a23 Make std::filesystem::path formatter utf-8 compatible.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-06-04 10:10:21 -07:00
232e21d51f Add utf-8 test for std::filesystem::path formatter.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-06-04 10:10:21 -07:00
8644654190 Docs: add comment about empty format context range 2022-06-02 08:40:29 -07:00
ba50c19e82 use qualified call to avoid ADL conflict with std::format_to 2022-06-01 15:57:15 -07:00
9d60395953 Fix compilation on ppc64 2022-05-31 13:53:15 -07:00
a2681aabcb Debug ppc failure 2022-05-31 11:30:22 -07:00
bfc5767368 Add support for std.h in Bazel build 2022-05-30 16:52:25 -07:00
798d09bb70 Debug ppc failure 2022-05-30 13:06:34 -07:00
8c7cf51395 Cleanup 2022-05-30 08:21:01 -07:00
cdfacb4345 Cleanup parse_format_string 2022-05-30 07:30:11 -07:00
926ddd0631 Move compile string to detail 2022-05-30 07:06:36 -07:00
cb682f36f4 Move to_string_view to detail 2022-05-29 22:51:31 -07:00
156744ad47 Simplify fmt::runtime 2022-05-29 21:18:52 -07:00
d9c7166cf0 bi_iterator -> base 2022-05-29 21:01:57 -07:00
11316b29af chore: Set permissions for GitHub actions
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
2022-05-29 19:12:52 -07:00
fe6eb792d5 Cleanup check_format_string 2022-05-29 19:01:06 -07:00
054b1d9808 Remove unused include 2022-05-29 18:24:10 -07:00
e927149f8e Cleanup macros 2022-05-29 17:23:02 -07:00
1761e2666a Remove FMT_CONSTEXPR_DECL 2022-05-29 16:42:58 -07:00
d6b568a6cc Cleanup string_view checks 2022-05-29 16:30:39 -07:00
c83a5d42bb FMT_MSC_VER -> FMT_MSC_VERSION 2022-05-29 15:39:08 -07:00
27cd68c301 Cleanup macros 2022-05-29 14:45:59 -07:00
08be4abb30 Remove FMT_NVCOMPILER_VERSION 2022-05-29 13:54:31 -07:00
661b192545 Remove FMT_HEADER_ONLY_CONSTEXPR20 2022-05-29 13:22:45 -07:00
d1026fa5d2 Remove extern format_float 2022-05-29 13:11:19 -07:00
7e63b600b6 Make to_string work with __float128 2022-05-29 12:23:57 -07:00
b2ea212cd1 Update README.rst 2022-05-29 11:44:09 -07:00
c2fcdc54e2 Move format_float to format.h for __float128 2022-05-29 11:30:33 -07:00
2b9037a190 Move basic_fp to format.h for compile-time formatting 2022-05-29 07:32:52 -07:00
542785ccbf Get rid of detail::bits 2022-05-29 07:10:36 -07:00
65dd2ea52c Use write_escaped_string to std::filesystem::path.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-05-28 07:48:02 -07:00
9860f67cde Improve xchar support for std formatters.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-05-28 07:48:02 -07:00
03b1b2838e Improve std::filesystem::path formatter.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-05-28 07:48:02 -07:00
4f9311e689 Fix definition of error_handler::on_error 2022-05-27 10:49:19 -07:00
652fea45a9 Visual Studio 2022: fmt/format.h(1526,27): warning C4127: conditional expression is constant #2908 2022-05-27 10:38:13 -07:00
1f9eae7e31 Add xchar support for write_escaped_string.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-05-27 08:36:38 -07:00
90b68783ff Skip cmake targets inclusion if fmt::fmt already exists (#2907) 2022-05-27 08:35:40 -07:00
ce246aaf74 Remove deprecated APIs 2022-05-22 07:10:09 -07:00
edeb3d8091 Remove deprecated APIs 2022-05-21 19:57:38 -07:00
496aff7c33 Remove deprecated APIs 2022-05-21 15:12:38 -07:00
f5cdf7cb04 Simplify snprintf_float 2022-05-21 12:34:21 -07:00
440512f08d Remove deprecated APIs 2022-05-21 12:20:31 -07:00
621eb80bbb Remove deprecated APIs 2022-05-21 11:34:07 -07:00
5c7d315ded Remove locale.h 2022-05-21 08:19:09 -07:00
c6324009ba Add initial double-double support 2022-05-21 07:32:54 -07:00
147e8ca580 Fix Windows max mix-up (#2903) 2022-05-18 16:35:26 -07:00
6bf039d750 Add std:🧵:id formatter 2022-05-17 16:37:19 -07:00
9730fb0156 Fix path formatter 2022-05-17 14:29:49 -07:00
f0903ad9df Add a path formatter 2022-05-16 17:32:25 -07:00
8833f386e4 Merge branch 'master' of github.com:fmtlib/fmt 2022-05-15 09:51:38 -07:00
5ab9d39253 Namespace-qualify format_to to avoid conflict with std::format_to 2022-05-15 09:51:20 -07:00
af5644c274 Update README.rst 2022-05-15 06:29:15 -07:00
3e28dc021c VS2022 17.2: C4189: 'zero': local variable is initialized but not referenced #2891 (#2892)
VS2022 17.2: C4189: 'zero': local variable is initialized but not referenced #2891

Co-authored-by: Ivan Shynkarenka <Ivan_Shynkarenka@epam.com>
2022-05-13 07:04:34 -07:00
f6f920a1a8 Tweak a comment and apply clang-format 2022-05-11 14:40:26 -07:00
ae963e444f Implement constexpr isfinite to avoid producing NaN 2022-05-11 08:43:22 -07:00
358f5a7e50 Make precision computation consistent with width 2022-05-11 06:34:51 -07:00
f63afd161f Fixed all clang -Wsigned-enum-bitfield warnings (#2882)
Made enums involved in bitfields unsigned by specifying their underlying type as unsigned char.

Due to a bug, when specifying an underlying type, gcc < 9.3 warns about bitfields not being big enough to hold the enum, even though they are. So keep the plain enum for old gcc.

An example of the bug is here:

https://godbolt.org/z/58aEv8zEq
2022-05-09 11:03:51 -07:00
7e4ad40171 Add initial support for double-double 2022-04-24 07:43:02 -07:00
ffb5e6a732 Suppress a -Wliteral-range warning on Apple M1 (#2861) 2022-04-19 11:10:18 -07:00
5d804ee7fe Fix handling of subnormals in exotic FP 2022-04-17 08:56:35 -07:00
86e27ccb41 Suppress a warning 2022-04-12 09:30:29 -07:00
192f79aaae Fix handling of locale separators in FP formatting 2022-04-12 08:00:17 -07:00
395cf0f03e Fix detection of unformattable pointers 2022-04-12 06:45:46 -07:00
fc429d18b6 Avoid overhead on sensible platforms 2022-04-11 16:52:34 -07:00
ce7ecdb7af Replace conditional compilation with SFINAE 2022-04-11 12:16:05 -07:00
8751a03a04 Fix Unicode handling when writing to an ostream 2022-04-10 09:46:01 -07:00
c55175a589 Add an issue template 2022-04-08 07:53:42 -07:00
a935ac3e60 MSVC CMake generation optimization (#2852) 2022-04-08 06:27:23 -07:00
22d31b31f0 Add a __float128 test 2022-04-03 14:56:29 -07:00
f607e3e970 Add __float128 support 2022-04-03 12:58:06 -07:00
686de58886 Implement 128-bit constant mul in bigint 2022-04-03 07:24:18 -07:00
02eb215f2f Replace uint128_wrapper with uint128_fallback 2022-04-02 18:01:41 -07:00
b4dc7a1d34 Add 128-bit operations to bigint 2022-04-02 09:29:13 -07:00
ef54f9aa38 Suppress -Wfloat-equal 2022-04-01 12:18:22 -07:00
288c3b928b Remove dead code in ostream.h format_value 2022-03-29 10:21:19 -07:00
96930161f9 Implement 128-bit operator+= for uint128_fallback 2022-03-27 08:07:54 -07:00
b41890c1e5 Make arg_mapper SFINAE-friendly again 2022-03-27 07:10:15 -07:00
e2408f37c8 Check if formatter is not defined if there is format_as 2022-03-26 09:44:49 -07:00
db5b8993ac Fix formatting of std::byte via format_as 2022-03-26 09:01:30 -07:00
1c83eaf75e Fix incompatible between Jinja2 >= 3.1 and sphinx 3.3.0 2022-03-26 07:30:17 -07:00
5379063b54 Fixed clang -Wreserved-identifier warings
Created FMT_UNCHECKED_TYPE that resolves to special identifier _Unchecked_type for Microsoft, but to a dummy string otherwise. Using
_Unchecked_type is invalid because underscore + uppercase is a reserved identifier.
2022-03-24 07:33:43 -07:00
b591fc87dc Fixed all clang -Wreserved-id-macro warnings (on macOS at least)
Avoid defining various reserved identifiers (starting with underscore and capital letter).  Fortunately, they were all Windows-only, so it was easy to conditionalize them in Window-only preprocessor checks.
2022-03-24 07:33:43 -07:00
17dda58391 constexpr -> const for portability 2022-03-23 21:14:22 -07:00
7ffe87c0bc Fix docs 2022-03-22 19:13:01 -07:00
3c4273dd09 Simplify UDL 2022-03-22 17:43:37 -07:00
36d95c9fcc Fix docs 2022-03-22 17:31:31 -07:00
44abd1f483 Update signatures in docs and ostream.h 2022-03-22 16:05:30 -07:00
db745986f2 Workaround broken std::numeric_limits 2022-03-20 08:50:52 -07:00
8271e43e5e Improve __float128 support and use constexpr 2022-03-20 07:20:41 -07:00
3f9b7433a3 Improve __float128 support 2022-03-19 09:44:14 -07:00
71778e8b90 Specialize float_info for __float128 2022-03-19 08:39:16 -07:00
f024565c3f Improve exponent handling in Dragon 2022-03-19 08:23:32 -07:00
e7f31f5cdb Cleanup format_dragon 2022-03-18 16:03:19 -07:00
3c61799fbf Cleanup fuzzing mode 2022-03-18 12:01:52 -07:00
4e39e13085 Remove xchar.h include from ostream.h 2022-03-18 10:53:15 -07:00
ac0d9d5fe2 Issue #2816: also strip named-arg for the fallback formatter 2022-03-18 10:11:14 -07:00
4ad90578f7 Fix #2818: diagnose unformattable arguments in unpacked case 2022-03-18 10:11:14 -07:00
17ba99c1d2 Fix #2817: add compile-time checking to ostream overloads of fmt::print 2022-03-18 10:11:14 -07:00
3d19be282a Fix #2816: strip named argument wrappers for compile-time checking 2022-03-18 10:11:14 -07:00
c076a54a4d Move snprintf_float to format.h 2022-03-18 08:31:31 -07:00
0419d23882 Add FMT_USE_FLOAT128 2022-03-18 07:43:51 -07:00
cre
69396347af Update color.h (#2815)
fixed typo in comment
2022-03-17 10:55:02 -07:00
c51604a0e1 Reduce the number of configs 2022-03-15 18:20:59 -07:00
587dc9946d Remove windows-2016 env no longer suppported by GA 2022-03-15 18:16:13 -07:00
1f3d44b859 Update std::tm/chrono docs 2022-03-15 16:53:51 -07:00
bc654faf82 Add is_floating_point that works with __float128 2022-03-15 08:26:05 -07:00
26bffce66d Simplify basic_memory_buffer 2022-03-15 07:15:52 -07:00
ed18ca3eae Implement isnan 2022-03-14 20:37:46 -07:00
a204b8dde7 Add initial __float128 support 2022-03-14 19:34:41 -07:00
b6b003b073 Cleanup test 2022-03-14 15:48:38 -07:00
f2543b0a98 Add initial support for 128-bit floats 2022-03-14 14:00:15 -07:00
72f487562d Simplify float_info 2022-03-14 13:37:03 -07:00
f91f61cd13 Reuse num_significand_bits 2022-03-14 11:34:24 -07:00
9a1beab574 Workaround Windows API garbage 2022-03-11 17:31:39 -08:00
a8fe8becf4 Fix compilation error for ranges with ADL begin/end (#2807)
* Use `range_begin`/`end` to get formatted range iterators

* Add test for adl `begin`/`end`

* Apply clang-format

* Simplify tests
2022-03-11 11:36:39 -08:00
f6bcb25e16 Remove extra dot 2022-03-10 16:26:17 -08:00
b4a4189d0c Fix handling of implicit bit 2022-03-10 15:34:56 -08:00
32d477e5f1 Add styled in documentation (#2805) 2022-03-10 12:24:47 -08:00
0b7c045a2f Simplify _cf 2022-03-08 15:31:51 -08:00
c10fffecdc Make _cf visible in the doc build 2022-03-08 11:00:04 -08:00
dcfbe4a77a Document output_file default behavior correctly (#2803)
The documentation for output_file incorrectly says that opening an output file happens with `file::WRONLY | file::CREATE` by default, but this includes `file::TRUNC` is also included since 119f7dc3d.
2022-03-08 10:02:22 -08:00
8c9bc070f5 Implement styled arguments (#2793)
* Implement styled arguments

* Inherit from formatter<Arg> to get the underlying `parse` and `format`

* Move styled_arg definition into the previous detail block

* Change styled_arg ctor parameters names to avoid shadowing members

* Move const before auto

* Remove redundant constructor for styled_arg

* Use the iterator instead of the buffer in styled_arg::format

* Remove unnecessary `styled` overloads

* Remove defaulted text_style parameter in styled function
2022-03-08 09:50:14 -08:00
5bc39d363a Eliminate intel compiler warnings (#2802)
The intel compiler emits  `declaration hides parameter "loc" ..."  and similar warnings for "out" and "args" since the function arguments are the same as other visible symbols.  This is for intel-2021.3.0 20210609.
2022-03-07 15:34:33 -08:00
e3d688e79a Fix warning C4251: class fmt::v8::file needs to have dll-interface (#2797)
* Fix warning C4251: class fmt::v8::file needs to have dll-interface

* Add CMake target dependency between test-main and fmt
2022-03-07 12:09:48 -08:00
8d4f3e91b2 Update docs 2022-03-06 10:12:40 -08:00
0cef1f819e Fixing formatting of certain kinds of ranges of ranges. (#2787)
* Fixing formatting of certain kinds of ranges of ranges.

* Renaming const_range to range_type.
2022-03-04 16:21:00 -08:00
5c0d656401 Fix apt install 2022-03-03 15:50:25 -08:00
d416a995ea Update README.rst 2022-03-01 13:53:02 -08:00
3f67a12477 Update README.rst 2022-03-01 13:48:54 -08:00
cc57e35974 Update godbolt link in the readme (#2789) 2022-02-25 13:47:23 -08:00
86477f7ecc Fix size computation 2022-02-22 17:21:07 -08:00
0742606f19 Fix Conversion Warning (#2782)
With -Wconversion and 32 Bit I get a warning here with unsigned long
long converted to unsigned long.
2022-02-22 08:16:36 -08:00
1ba69fb5a1 Remove snprintf FP fallback 2022-02-21 08:01:55 -08:00
ea6f0bf0e5 Minor cleanup 2022-02-21 07:29:36 -08:00
1a18a2f3dd Fixing "C4127: conditional expression is constant" Visual Studio 2022 warning in pedantic mode (#2783) 2022-02-21 07:26:16 -08:00
4fcacea354 Parameterized fp on significand type 2022-02-21 07:25:13 -08:00
cf940ae82e Simplify to_decimal 2022-02-20 19:38:02 -08:00
70dc3de053 Update format.h
To prevent the following compiler message:
[...]/include/fmt/format.h:392:20: warning: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
  392 |     unsigned value[size];
      |                    ^~~~
2022-02-20 11:38:03 -08:00
cbc59ca893 Clear moved from memory buffer 2022-02-20 08:12:59 -08:00
ea3d326c63 Fix clang -Wliteral-range warning (#2779) 2022-02-19 10:52:33 -08:00
aad44f2839 Add fmt::enums::format_as 2022-02-19 08:03:42 -08:00
1319719a5e Add underlying_t 2022-02-19 07:57:43 -08:00
af5d8004fc Limit Dragonbox to supported FP formats 2022-02-19 07:14:18 -08:00
7b96420961 Remove unused include 2022-02-18 18:56:51 -08:00
a0b43bfae2 Add support for 96-bit long double 2022-02-18 18:01:49 -08:00
2c8cd2db34 Fix handling of zero precision 2022-02-18 12:38:30 -08:00
b6d56170fc Remove unnecessary inline 2022-02-18 07:41:55 -08:00
05432e570e Use consistent indentation 2022-02-18 07:38:42 -08:00
47da218cc3 Remove uintptr_fallback 2022-02-18 07:03:33 -08:00
4ddab8901c Merge accumulator into int128_fallback 2022-02-18 06:17:28 -08:00
d38f72aff2 Refactor fallback ints 2022-02-17 20:24:42 -08:00
15c2a3bacc int128_t -> int128_opt 2022-02-17 20:03:25 -08:00
532a69a639 Fix handling of 96-bit long double with -m32 2022-02-17 15:51:59 -08:00
d8e1dd4ab2 improve installing headers 2022-02-17 08:13:26 -08:00
ae25f7968e add ability to build Apple framework using CMAKE_FRAMEWORK 2022-02-17 08:13:26 -08:00
ce93a66dfb Implement a fallback uint128_t 2022-02-17 07:37:09 -08:00
6a13464059 Include 128-bit with other signed integers in specifier check 2022-02-16 16:57:06 -08:00
70de324aa8 Apply 2746 fix for NVidia compiler also (#2770) 2022-02-16 12:04:16 -08:00
a1ea3e015b Move built-in formatter specialization to core 2022-02-16 07:37:00 -08:00
161059dd98 Add support for extended precision FP 2022-02-16 06:07:04 -08:00
c4c6b42de7 Bump version 2022-02-15 13:36:59 -08:00
21785040c7 Fix markup 2022-02-15 13:28:53 -08:00
2b6f7fc7a3 Add partial support for extended precision FP 2022-02-15 07:22:41 -08:00
0a24a0714e Clz builtin may be not constexpr (Issue #2761) (#2762) 2022-02-14 18:19:06 -08:00
ba6f89c76e Update .bazelversion (#2766) 2022-02-14 06:08:46 -08:00
5594edaf67 Address https://github.com/fmtlib/fmt/issues/2763 (#2765) 2022-02-13 20:14:28 -08:00
10e3b83a75 Replace `make_args_checked with make_format_args` (#2760)
* Replace make_args_checked to make_format_args

* Deprecate legacy make_args_checked
2022-02-13 20:13:35 -08:00
c48353cb75 Update docs 2022-02-13 07:41:15 -08:00
083510f0f0 Add FMT_CONSTEXPR to rotr instead 2022-02-13 06:15:17 -08:00
dba99bc860 Revert adding constexpr to rotr to satisfy C++11 compilers 2022-02-13 06:15:17 -08:00
c04af4bfc7 Simplify remove_trailing_zeros 2022-02-13 06:15:17 -08:00
b348caa9e9 Remove some C-style casts for consistency 2022-02-13 06:15:17 -08:00
c8bd1e646e Simplify remove_trailing_zeros 2022-02-13 06:15:17 -08:00
9b23e9dcb8 Fix wrong comment/refer to a correct reference 2022-02-13 06:15:17 -08:00
69f2c550ab Remove std:: infront of uint32_t/64_t & add constexpr to rotr 2022-02-13 06:15:17 -08:00
9b62310f03 Fix some conversion issues 2022-02-13 06:15:17 -08:00
08d12f31d1 Fix typo 2022-02-13 06:15:17 -08:00
dbddb1d066 Remove literal separator to satisfy some compilers 2022-02-13 06:15:17 -08:00
7dbe3dcded Recover log10_2_significand 2022-02-13 06:15:17 -08:00
10642e6082 Optimize remove_trailing_zeros 2022-02-13 06:15:17 -08:00
7b4323e1e0 Add rotr 2022-02-13 06:15:17 -08:00
f1bd6f7731 Check r < deltai first, because that is the major branch chosen for short inputs 2022-02-13 06:15:17 -08:00
5d8eb6a1a0 Reflect the new paper
- Change constants appearing in log & division computations
  - Rename beta_minus_1 to beta
2022-02-13 06:15:17 -08:00
8e2e4d4034 Suppress a gcc warning 2022-02-12 09:26:48 -08:00
a44716f58e Workaround to Intel compiler (#2758) 2022-02-11 06:25:42 -08:00
c71b070168 Add missing const qualifier (#2755) 2022-02-10 10:51:32 -08:00
ecd6022c24 Update docs 2022-02-08 06:28:22 -08:00
afbcf1e8ea Remove legacy C locale wrapper 2022-02-05 12:37:21 -08:00
90325d0970 Fix stored type detection 2022-02-05 10:44:34 -08:00
e2ba01fcb0 Fix overload ambiguity in print 2022-02-05 08:35:19 -08:00
17b362f78c Simplify ostream opt-in API 2022-02-04 18:33:59 -08:00
a5a7e3a261 Update docs 2022-02-04 15:42:22 -08:00
f055ebbd25 Make ostream operators opt in to reduce the risk of ODR violations 2022-02-04 15:06:45 -08:00
8a21e328b8 Remove problematic constructibility check 2022-02-04 12:20:02 -08:00
31e743d06e Don't use ostream for types convertible to string_view 2022-02-04 11:00:00 -08:00
35c0286cd8 Simplify byte handling 2022-02-02 16:13:24 -08:00
c7173a36a1 Drop :: and fix formatting 2022-02-02 07:00:33 -08:00
3e8372b96e qualify unqualified calls to format in compile.h (#2742) 2022-02-01 18:41:19 -08:00
a34a97cc1d Supporting ? as a string presentation type (#2674)
* Supporting ? as a string presentation type.

* Supporting ? as a char presentation type.

* Adding iterator_category to counting_iterator.
2022-01-30 08:55:28 -08:00
ae1aaaee5f Fix access mode of files created (#2530) (#2733)
The previous fix for this in 4a85db1 was incomplete. The intent was to
mimic what `fopen()` is doing. As per standard[1] `fopen()` also sets
`S_IWGRP` and `S_IWOTH` and lets the umask handle the rest.

[1] https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/fopen.html
2022-01-28 17:12:49 -08:00
1557ab7644 Add format_as for enums 2022-01-28 06:38:02 -08:00
b00a1eac75 Fixes NVIDIA HPC compiler and Intel ICC compatibility (#2732)
* Fixes NVIDIA HPC compiler and Intel ICC compatibility

* Fixes NVIDIA HPC compiler and Intel ICC compatibility

* Rename FMT_NVHPC_VERSION to FMT_NVCOMPILER_VERSION

Co-authored-by: Federico Busato <fbusato@nvidia.com>
2022-01-26 15:53:04 -08:00
a7aecbfcaa Remove an old mingw workaround 2022-01-23 09:44:53 -08:00
dfcc730cbd Making target_compile_options PRIVATE, fix #2726, fix #2507 2022-01-23 09:36:11 -08:00
f7a809be6e Clarify the choice of magic numbers and compute the most magic one
https://github.com/fmtlib/fmt/pull/2713#discussion_r788349826
2022-01-23 08:58:58 -08:00
09fde7f4b8 Add fmt::underlying for enum classes 2022-01-22 08:06:22 -08:00
0014024a2c Don't rely on transitive includes 2022-01-21 15:03:28 -08:00
c28500556a FMT_NOEXCEPT -> noexcept 2022-01-20 16:55:47 -08:00
6240d02011 Improve comments 2022-01-19 17:03:44 -08:00
925b744ae8 Improve comments 2022-01-19 17:03:44 -08:00
22b14ff252 Simplify cache recovery 2022-01-19 17:03:44 -08:00
3dc26b44d3 Make a fallback path more compiler-friendly 2022-01-19 17:03:44 -08:00
2e4038bf51 Simplify lines with __builtin_addcll and friends 2022-01-19 17:03:44 -08:00
76336b4f63 Replace noexcept with FMT_NOEXCEPT 2022-01-19 17:03:44 -08:00
9181983483 Fix syntax errors 2022-01-19 17:03:44 -08:00
74097a149b Remove now-unused stuffs 2022-01-19 17:03:44 -08:00
21a1c53381 Fix typo 2022-01-19 17:03:44 -08:00
04eea0f0a8 Remove now-unused stuffs 2022-01-19 17:03:44 -08:00
35a468ed38 Simplify integer checks 2022-01-19 17:03:44 -08:00
1882a7a2c1 Replace Dragonbox cache which allows simpler cache recovery & integer checks 2022-01-19 17:03:44 -08:00
f4dd1b1b8b Simplify Dragonbox Step 3. 2022-01-19 17:03:44 -08:00
70561ed13e Minimize the usage of built-in 128-bit ints
It usually generates slower code than manual handling.
2022-01-19 17:03:44 -08:00
cdf1a3b530 Fix codecvt warning (#2408) (#2725) 2022-01-19 10:26:09 -08:00
b8b037e930 Fix -Wconversion warning (#2724)
* - try fixing the warning "chrono.h:1217:37: warning: conversion from 'std::make_unsigned<long long int>::type' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]" by casting int to size_t (occurs when cross-compiling to Raspberry Pi ARMv7)

* - remove call to to_unsigned() because using static_cast<size_t> is enough
2022-01-19 06:31:33 -08:00
5985f0a7d2 Fix overflow for chrono durations (#2722) 2022-01-17 12:14:59 -08:00
8f8a1a02d5 Fix handling of formattable types implicitly convertible to pointers 2022-01-14 13:42:01 -08:00
b02e5af52c fmt::join support FMT_COMPILE (#2720) 2022-01-14 09:58:49 -08:00
58fb782396 Improve docs 2022-01-13 14:57:17 -08:00
4fe6129d6c Fix FMT_NOEXCEPT definition 2022-01-13 10:20:32 -08:00
c056a009de Docs: Fix link to "Compile-time Format String Checks" section (#2712) 2022-01-12 16:07:56 -08:00
7c12118c19 Deprecate buffered_file::fileno 2022-01-12 10:54:44 -08:00
2a09d468da Use noexcept unconditionally 2022-01-12 09:42:29 -08:00
a126b4d888 Check if right shift is arithmetic 2022-01-11 08:23:30 -08:00
9ff91b18cd Simplify write_fractional_seconds 2022-01-09 15:08:46 -08:00
d9f045fba1 Fix a UB in chrono 2022-01-09 14:06:13 -08:00
c06bef7273 Adding comments for range formatting. (#2706)
* Adding comments for range formatting.

* Adding missing quotes
2022-01-08 16:37:21 -08:00
3c98f1a4cd Comment style 2022-01-08 09:52:39 -08:00
6e0f1399d7 Supporting nested format specs for ranges. (#2673)
* Supporting nested format specs for ranges.

* I dedicate this commit to Eric Niebler.

* clang-format

* PR comments.

* throw -> FMT_THROW

* Need to map every element too.

* Clarifying uncvref_type

* Trying to add a workaround for MSVC.
2022-01-08 09:48:26 -08:00
0102101acc Make colored print handle UTF-8 (#2701)
* Fix #2681 - Make detail::print handle UTF-8

* Okay, let's do this Windows-only

* drop extra \0

* yay we can throw!
2022-01-06 16:10:53 -08:00
4ac5269b4f Update ChangeLog.rst 2022-01-06 15:03:01 -08:00
b6f4ceaed0 Update version 2022-01-06 14:35:15 -08:00
15f812dae8 Update changelog 2022-01-06 14:13:01 -08:00
6884aab49b Update changelog 2022-01-06 12:38:33 -08:00
88ec4e7061 Bump version 2022-01-06 12:32:43 -08:00
dd3d2490ed Update changelog 2022-01-06 12:07:13 -08:00
739055ae7b Fix apidocs 2022-01-06 11:06:39 -08:00
dbbd711f46 Suppress a warning 2022-01-05 09:41:35 -08:00
98cbb6a43c Fix ABI compatiblity issue 2022-01-05 08:08:38 -08:00
214cf13f17 Fix endianness bug in write_digit2_separated (#2699)
* Fix endianness bug in write_digit2_separated

* Move endianness check to compile time if it possible

* Turn 8 into a constant
2022-01-04 14:23:42 -08:00
17a5c808da Restore FMT_API on error_handler::on_error() (#2696)
this fixes a breaking ABI change that was introduce in the upgrade from
8.0.1 to 8.1.0.

Fixes #2695.
2022-01-04 10:53:44 -08:00
fc1783fcc6 Avoid undefined symbols with mingw-w64 (#2692)
Fixes issue #2691
2022-01-03 15:29:29 -08:00
1b193e7b37 Deprecate more 2022-01-03 11:13:09 -08:00
8e59744b8d Switch to new github auth mechanism 2022-01-02 09:29:42 -08:00
7081a6aa34 Update version 2022-01-02 09:01:32 -08:00
64dc8fbada Bump version 2022-01-02 08:34:01 -08:00
fc8e3de7db Fix manage.py script 2022-01-02 08:22:25 -08:00
57bee9fcdd Fix formating 2022-01-02 08:09:55 -08:00
dce52e491e Update changelog 2022-01-02 08:02:45 -08:00
9405a47245 Update changelog 2022-01-02 07:57:36 -08:00
495b8bf12e Update changelog 2022-01-01 13:56:31 -08:00
e221166fab Update changelog 2022-01-01 11:34:04 -08:00
035cab8da3 Update changelog 2022-01-01 09:36:40 -08:00
89c6ed12bf Clarify in comments (for now) deprecated map functions 2022-01-01 09:29:50 -08:00
e462da828d Add some noexcept (#2684)
I got warnings from -Wnoexcept, fixed them.
2022-01-01 08:44:00 -08:00
79c66d66bd Update changelog 2021-12-29 15:33:30 -08:00
5d37f705f4 Update changelog 2021-12-29 15:31:03 -08:00
6bb370cec1 Update changelog 2021-12-29 15:26:11 -08:00
bb69201578 Fix tuple join 2021-12-29 14:46:45 -08:00
4fac7daaef Cleanup bit_cast 2021-12-29 12:14:51 -08:00
3617c2795a Update changelog 2021-12-29 08:25:12 -08:00
9c0c1bcdbd Simplify tuple formatting 2021-12-29 08:03:12 -08:00
187e8db1be Update changelog 2021-12-28 08:11:03 -08:00
c7f88180f6 add tests for format string compile-time checks 2021-12-27 20:55:06 -08:00
8a2c3fb88f add reverse tests to compile-error-test
to make sure that error tests do not fail because they become outdated
2021-12-27 20:55:06 -08:00
1164eda5af disable compile-error-test on Windows
since it takes too much time to complete, similar to other tests with additional
CMake invocation
2021-12-27 20:55:06 -08:00
4482f6f1f0 rewrite compile-error-test to use non-header-only library 2021-12-27 20:55:06 -08:00
796662a612 Escape range items convertible to std::string_view 2021-12-27 09:38:06 -08:00
33ee4cc516 Improve noexception test 2021-12-26 16:28:41 -08:00
3bbf2c673c Fix throw with exceptions disabled 2021-12-26 16:28:41 -08:00
074c9c52ef Update changelog 2021-12-26 08:36:29 -08:00
3110ec5a23 Update changelog 2021-12-26 08:19:32 -08:00
3014b3d770 Clarify that C strings must be null-terminated 2021-12-26 07:23:43 -08:00
eab2ea9fc2 Replace an assert with an exception 2021-12-26 07:05:45 -08:00
21ed92a6e9 Update changelog 2021-12-24 07:25:23 -08:00
04111dd1e4 Fix issue #2670 (#2671) 2021-12-23 12:38:48 -08:00
817788fbf0 remove incorrect C++20 check from test/CMakeLists.txt (#2663)
It disables entire branch of tests declaration unconditionally because CXX_STANDARD
is not defined there. But even we use CMAKE_CXX_STANDARD here, these tests should
not be disabled with standard >= C++20.
2021-12-23 12:32:03 -08:00
4511030af2 Minor code style tweaks for consistency 2021-12-23 11:55:58 -08:00
7812813a32 Don't explicitly delete copy ctor of dynamic_format_arg_store (#2664)
* Don't explicitly delete copy ctor of dynamic_format_arg_store

Explicitly deleting the copy ctor causes the move constructor to not be
implicitly generated. This behaviour is different than what was in
v8.0.1 and causes code that relied on the move ctor of
dynamic_format_arg_store to break.

* Add test for dynamic_format_arg_store's move ctor

* include <memory>, don't use make_unique
2021-12-23 11:34:16 -08:00
664cd6067d Remove std-format-test 2021-12-23 10:58:02 -08:00
784e2a7b42 Fix an overflow when formatting very large durations 2021-12-23 10:34:32 -08:00
fc2a376d8e Remove two expressions which had no effect (reported by LGTM)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-12-22 16:29:16 -08:00
c5aafd8f90 expose headers as SYSTEM depending on special configuration option 2021-12-19 08:29:51 -08:00
eaddd1e3cd Fix handling of byte 2021-12-19 06:46:24 -08:00
2d44577586 Try fixing byte regression 2021-12-18 08:51:21 -08:00
e46392ea2c deprecate _format UDL in code using FMT_DEPRECATED 2021-12-18 08:33:20 -08:00
c882790a2e Add a set formatter 2021-12-18 07:35:40 -08:00
121002d700 Add a map formatter 2021-12-18 07:12:53 -08:00
be51ee1ceb Disable broken copy ctor of dynamic_format_arg_store 2021-12-17 17:18:18 -08:00
659de779e6 Fix a UB in parse_format_specs when begin is null 2021-12-17 16:51:24 -08:00
51b14b6c0c remove commented out lines 2021-12-17 16:05:56 -08:00
223a0fa55d move gtest-specific check into gtest/CMakeLists.txt 2021-12-17 16:05:56 -08:00
ef72b471fc enable named arguments check in compile-time checks (#2649)
works only if all named arguments are UDL-based
2021-12-17 15:53:05 -08:00
82246b8766 fix throw with exceptions disabled (#2647) 2021-12-17 13:44:36 -08:00
35f60377aa Update ChangeLog.rst 2021-12-17 06:49:29 -08:00
3a951a66cb Avoid qualifying by inline namespace. Fixes #2642. (#2643) 2021-12-10 08:28:25 -08:00
e0136fc8bd Qualify calls to make_wformat_args. Fixes #2639. (#2641) 2021-12-10 06:36:42 -08:00
ac1b5f3da5 Refactor problematic trailing returns in arg_mapper 2021-12-09 18:08:30 -08:00
fd62fba985 Don't convert scoped enums to integers 2021-12-09 12:09:33 -08:00
c652f8243a Make header guard consistent with header name 2021-12-09 10:49:47 -08:00
a9c7b9b8f7 Clarify that _format is deprecated 2021-12-09 10:34:27 -08:00
e4f0564aa6 Disable is_streamable for string[_view] 2021-12-09 10:02:18 -08:00
91533d3c33 Minor tweaks to chrono subsecond formatting 2021-12-09 06:55:31 -08:00
0bbc9708f9 Implement c++20 std::chrono::duration subsecond formatting (#2623)
* Add support for subsecond printing for std::chrono::duration according to the c++20 standard

* Remove assert test that overflows intmax_t

* * Hopefully fix int64_t to int32_t conversion errors.
* Allow proper Duration::rep type to propagate via template argument deduction

* * Hopefully fix int64_t to int32_t conversion errors.
* Allow proper Duration::rep type to propagate via template argument deduction

* Fix sign conversion (-Wsign-conversion) warning treated as error in num_digits()

* Format chrono.h with clang-format

* Remove extra forward slash in doxygen style comment

Co-authored-by: Victor Zverovich <victor.zverovich@gmail.com>

* Apply all suggestions from GitHub, except for replacing the utility subsecond_helper class with a function

* * Move logic of handling subseconds from utility class to function with name write_fractional_seconds()
* Revert write(Rep value, int width) function to previous state

* Fix -Wshadow warning

* Remove unsued get_subseconds() function, its logic has been moved to write_fractional_seconds()

* Change comment from lowercase int to uppercase Int

* Simplify test check

* Integrate suggested changes

* Remove static from detail functions, they are no longer member functions of a class and static is unnecessary.
* Change comment from "amount" to "number"

Co-authored-by: Victor Zverovich <victor.zverovich@gmail.com>
2021-12-09 06:45:13 -08:00
9d5b9defde Enable tzset only on Windows desktop app (#2633) 2021-12-07 15:22:36 -08:00
215f21a038 Detect overflow on large precision 2021-12-05 07:26:58 -08:00
c240d98ffd Optimize tm formatting (Non C-locales and %Z) (#2617)
* Move fmt::detail::formatbuf to format.h

* Replace std::basic_ostringstream to std::basic_ostream with custom formatbuf

* Use tm.tm_zone
2021-12-04 11:02:31 -08:00
6ab73113fc Mark grow as FMT_CONSTEXPR20 (#2630)
resolves https://github.com/fmtlib/fmt/issues/2627
2021-12-03 07:13:30 -08:00
713c7c7c62 Cleanup os.cc 2021-12-01 06:47:41 -08:00
9b1807a8a2 fix int -> uint warning (#2611)
* fix int -> uint warning

* change unsigned int to mode_t

* undef + warn uint -> ushort loss presision

* fix mode_t

* mode_t in detail

Co-authored-by: Acretock <George.Goncharov@finch-xr.com>
2021-12-01 06:40:17 -08:00
ec3b097cb9 [doc] FMT_STRING supports C++14 and no-op in C++11 (#2620)
* FMT_STRING supports C++14 and no-op in C++11

* Move requirement to the end. Modify description.
2021-11-28 07:02:15 -08:00
c472a27818 Fix handling of very large precision in fixed format 2021-11-27 08:23:05 -08:00
201971e293 Make MSVC use [[nodiscard]] (#2615)
* Make MSVC use [[nodiscard]]
* Uniformly detect attributes for __cplusplus and _MSVC_LANG
2021-11-26 07:32:50 -08:00
acad8cfab1 Reformat all source code; no functional changes
Before adding the format checker, the mainline should be clean, to
avoid false failures.
2021-11-25 09:15:25 -08:00
491ba2dda5 Annotate fmt::format and fmt::formatted_size as [[nodiscard]]
This prevents accidentally writing fmt::format when fmt::print was
intended. Other than running tests, there's not a good use case for
discarding the formatted output.
2021-11-25 07:30:30 -08:00
5abe9e8266 Add platform-specific 'z' formatter 2021-11-25 06:52:39 -08:00
be3a3a5aed Use predefined formats for C-locale 2021-11-25 06:52:39 -08:00
a3ab36c803 Formatting of function pointers, member function pointers, member object pointers... (#2610) 2021-11-23 12:55:22 -08:00
19cac63fe4 Broken link in README.rst
Added src directory to link
2021-11-19 09:24:38 -08:00
43419a4ada Workaround a bug in gcc 2021-11-19 07:32:42 -08:00
c089f7d497 Simplify std::tm formatter 2021-11-14 07:16:22 -08:00
aa5517f6b9 Reuse tm_writer in chrono_formatter 2021-11-14 07:16:22 -08:00
50140be7ae Reuse tm_writer in weekday formatter 2021-11-14 07:16:22 -08:00
8b89454994 Improve consistency 2021-11-13 08:59:56 -08:00
5380ff4d88 Detect types convertible to unformattable pointers 2021-11-13 08:26:27 -08:00
094b66e81d changed locale retrieval way to a fancy one 2021-11-12 12:46:38 -08:00
b69ae4854c Reorder classes (#2591) 2021-11-10 17:09:23 -08:00
0b843af56b sped up chrono.h formatting for cases without providing locale (#2576) 2021-11-07 08:52:57 -08:00
12b1d8b14a Fix precision 0 with std::chrono::duration and added additional tests. (#2588) 2021-11-06 08:57:22 -07:00
e67f92c55c Cleanup warnings with nvhpc/21.9. (#2582)
* Cleanup warnings with nvhpc/21.9.

* Move __NVCOMPILER check.

* Be more explicit.

* Immediately executed lambda.

* Fix shadowing warning.
2021-11-05 12:17:11 -07:00
812733cc96 const qualify format function for systen_clock 2021-10-31 09:41:16 -07:00
028f227752 Handle implicit conversions in write 2021-10-31 08:58:54 -07:00
5b0aa638cf Minor grammar fix 2021-10-30 09:14:13 -07:00
6eaceb5f73 Fix incompatible between docutils 1.18.0 and sphinx 3.3.0 (#2575) 2021-10-30 09:12:36 -07:00
0697c5edb6 FMT_USE_FCNTL can be predefined (#2573)
'os.h' accepts a predefined FMT_USE_FCNTL override so using FMT with e.g. the NXP toolchain for ARM (e.g. for FreeRTOS) does not have a fcntl() call, but the detection routine does not detect this correctly.
2021-10-30 08:35:48 -07:00
1031eedf27 Replacing strftime with std::time_put (#2550)
* Fix unicode test

* Add xchar support to chrono formatter

* Replace strftime with std::time_put

* Add std::locale support to std::tm formatter

* Use predefined names and formats for C-locale

* Performance improvement

* Make locale-independent and C locale formats consistent among platforms
2021-10-30 08:25:45 -07:00
90034e4c4b Add FMT_ASSERT and validation of values of struct tm members (#2564)
Switch internal year calculations to long long
2021-10-27 13:29:07 -07:00
df40e94673 Upgrade module-test to msvc 16.11.5 and 17.0-pre5 (#2558) 2021-10-24 08:12:39 -07:00
e6d5059cbb Simplify js tag in basic-bootstrap theme (#2562)
When build the docs for debian package, it uses a sphinx building
helper, which does a sanity check for the output.

The sanity check complains missing data-url_root attribute in the
js tag. So this patch changes the js tag to use the same function like
the origin basic theme, which adds additional information like
data-url_root.

Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=997437
2021-10-24 06:36:10 -07:00
3b6e409cd8 Enable consteval for msvc 17.0-pre5 (#2559) 2021-10-23 07:19:57 -07:00
249f03bbb7 do not detect LLVM based IBMXL compiler (on ppc) as clang (#2555) 2021-10-20 06:21:49 -07:00
7463c83205 Fix overflow for very bigger years (>2*10^9) (#2551) 2021-10-19 07:04:55 -07:00
1266c2b600 Fix handling of exotic character types 2021-10-17 09:07:48 -07:00
684e2fdc94 Minor cleanup 2021-10-17 06:33:27 -07:00
a1d586302f Minor cleanup 2021-10-17 06:07:03 -07:00
7a604cdd98 Cleanup 2021-10-16 15:03:57 -07:00
aeb54b0dd9 Fix bug on '%Y' and '%C' formats with negative years
Requested changes
2021-10-16 15:03:57 -07:00
f88c020fc0 Generalization of strftime/wcsftime function calls in tests 2021-10-16 15:03:57 -07:00
2eeddba756 Renaming, splitting of functions 2021-10-16 15:03:57 -07:00
2754546080 Fix errors in ISO week-base-year formatter 2021-10-16 15:03:57 -07:00
218cecb6d1 Fix error in test 2021-10-16 15:03:57 -07:00
e9f4453b0e Fix Microsoft Visual Studio 14.0 build 2021-10-16 15:03:57 -07:00
27c3674ce1 Improve performance 2021-10-16 15:03:57 -07:00
5dc3dd3d4a New tests 2021-10-16 15:03:57 -07:00
f8542cd988 Unified formatters for std::chrono::time_point<std::chrono::system_clock, Duration> and std::tm 2021-10-16 15:03:57 -07:00
4707373d33 Fix year formatter 2021-10-16 15:03:57 -07:00
79c00ad8f2 Improve ISO week-base-year formatter 2021-10-16 15:03:57 -07:00
fbaaa5906b Improve week of the year formatter 2021-10-16 15:03:57 -07:00
cde44ddb72 Improve year formatter 2021-10-16 15:03:57 -07:00
b04601b918 Switch from std::strftime/std::wcsftime to internal implementation for locale independent formats 2021-10-16 15:03:57 -07:00
d3d30a46f0 New tests 2021-10-16 15:03:57 -07:00
7911d8d3f5 Add format spec checker 2021-10-16 15:03:57 -07:00
fbbfc3b03c Reorder formatters 2021-10-16 15:03:57 -07:00
509eac9575 Workarounds for implementation-defined std::strftime behavior 2021-10-16 15:03:57 -07:00
85b38190d1 New tests for all C++11 std::strftime format specifiers 2021-10-16 15:03:57 -07:00
7aca36bca4 Extending fmt::join to support C++20-only ranges. (#2549) 2021-10-16 10:02:03 -07:00
f5371a75f4 locale.h -> format.h 2021-10-14 15:57:10 -07:00
febdef43f5 fix: add workaround for intel parameter pack bug 2021-10-14 10:44:24 -07:00
f56756986b fix: check to make sure both 'if constexpr' and return type deduction are available
fix: remaining ifdefs
2021-10-14 10:44:24 -07:00
dcd282bb26 Namespace qualify calls to get 2021-10-09 07:15:14 -07:00
9c14474d30 Include <bit> when using std::bit_cast 2021-10-09 06:11:36 -07:00
1e96e01766 Fix compiler flag check (#2540) 2021-10-09 06:05:05 -07:00
7e4bc94510 Speeding up write_significand() (#2499) 2021-10-09 05:27:38 -07:00
26c1ca4c3e Replaced default spec with equivalent one, which is potentially more optimizable (#2537) 2021-10-08 07:09:54 -07:00
1e865b3539 Fix docs 2021-10-03 07:05:31 -07:00
4a85db1ce1 Change default open mode to -rw-r--r-- (#2530) 2021-10-03 06:36:40 -07:00
0a985fd4c6 Move size_ initialization to initializer list (#2529) 2021-10-02 17:20:33 -07:00
012cc709d0 Workaround gcc _Pragma bug 59884 2021-10-02 15:41:47 -07:00
d6590e3bd2 Fix compiler check 2021-10-02 08:46:18 -07:00
134aec40f0 Fix search in docs 2021-10-02 07:58:08 -07:00
48a476ae0f Update example (#2522) 2021-10-02 07:33:33 -07:00
023c2018f7 Don't use strlen in constexpr 2021-10-02 07:17:05 -07:00
800d4c8ac8 Refactor Windows workarounds 2021-10-02 06:06:08 -07:00
32865aeaab changed detection of Intel Compiler Classic to distinguish MS-Windows (#2510)
* changed detection of Intel Compiler Classic to distinguish MS-Windows

* replaced !FMT_ICC_ON_WINDOWS by FMT_ICC_POSIX
removed #pragma manged

* replaced FMT_ICC_POSIX with FMT_ICC_INTRINSIC_BUG to be crystal clear about the macro's purpose
2021-10-02 05:43:41 -07:00
7b339795a1 Describe a better approach of how to use {fmt} as a depency in a Bazel project (#2516) 2021-10-02 05:36:43 -07:00
ae9bbe1169 Suppress warning C4127 in chrono.h (conditional expression is constant) (#2518) 2021-09-30 09:14:38 -07:00
927dbd134d Misplaced comma in README.rst (#2515) 2021-09-28 09:53:37 -07:00
2a9a77dd8c Remove misplaced comment 2021-09-26 18:01:39 -07:00
1aee4bc90a Refactor FP formatting 2021-09-26 14:37:33 -07:00
e1bd6cc913 Refactor FP formatting 2021-09-26 10:25:46 -07:00
027fcaf05e Replace use_grisu with fallback since Grisu is only one of multiple implemented algorithms 2021-09-26 08:44:05 -07:00
716d69f27e Refactor FP formatting 2021-09-26 08:27:18 -07:00
ff7e73af66 Always run grisu_gen_digits before fallback_format 2021-09-26 07:54:25 -07:00
2976e31ac9 Refactor format_float 2021-09-25 11:20:56 -07:00
807ee5ec31 Disable consteval in Apple clang 2021-09-25 05:55:05 -07:00
d9a731d486 Add basic support for Bazel (#2505) 2021-09-24 13:17:26 -07:00
9c57357e05 Add static to a table (#2509) 2021-09-24 06:25:08 -07:00
2742611cad Fix formatting 2021-09-18 11:09:24 -07:00
5092b198bc Document group_digits 2021-09-18 10:50:30 -07:00
b4d9d82e1d make FP formatting available to be used at compile-time (#2426)
* works only with FMT_HEADER_ONLY
* works only with float and double types (not long double)
2021-09-18 08:03:23 -07:00
d9fd695ac7 Fix wchar_t tm formatting 2021-09-15 07:33:24 -07:00
92614ecbf9 Optimize %T in tm formatting 2021-09-15 07:33:24 -07:00
aaeca12d89 Move FMT_MAYBE_UNUSED to format.h where it is used 2021-09-13 07:51:36 -07:00
3d0c7ae385 Move data to format.cc 2021-09-13 06:23:57 -07:00
04e3a79f76 Use memcpy in more cases in copy2 2021-09-12 12:23:45 -07:00
e47e99bb09 Simplify format_decimal (#2498)
* Add copy2() constexpr

* Removed redundant format_decimal implementation for constexpr context
2021-09-12 10:36:06 -07:00
9b6b0e403c Remove data 2021-09-12 09:46:00 -07:00
4d1c6034eb Deprecate basic_data 2021-09-12 09:37:23 -07:00
a3348eccdd Deprecate most of basic_data 2021-09-12 08:59:39 -07:00
3a04481485 Remove data::hex_digits 2021-09-11 17:54:40 -07:00
ad77331c04 Move log10_2_significand to format-inl.h 2021-09-11 09:36:23 -07:00
d9ebc4e821 Add a function to get sign char 2021-09-11 09:17:59 -07:00
c00eb4f4c6 Add missing inline 2021-09-10 09:01:18 -07:00
25af02f21a positive -> nonnegative (#2493) 2021-09-10 08:52:54 -07:00
67cb2dad37 Optimize %F in tm formatting 2021-09-10 07:48:50 -07:00
1aa98f8b93 Eliminate double copying in vformat_to_n (#2489) 2021-09-09 08:10:29 -07:00
a58c133821 Improve code_point_length codegen on older gcc 2021-09-07 19:34:13 -07:00
aeee70a815 Remove unnecessary cast 2021-09-07 10:53:43 -07:00
c771ba361c Fix build for the clang-10 / libstdc++-9 couple (#2491) 2021-09-07 08:52:34 -07:00
ab6e2272cc Clarify shifts encoding 2021-09-06 18:45:34 -07:00
e4728409e7 Use throw_format_error in more places to reduce bloat 2021-09-06 16:42:17 -07:00
e3ebf366a6 Inline padding shifts 2021-09-06 16:26:50 -07:00
894faf3fed Refactor presentation types 2021-09-06 13:32:33 -07:00
4eb97fa4e3 Reduce code bloat 2021-09-05 16:24:20 -07:00
6b55c83252 is_const_formattable -> has_const_formatter 2021-09-05 08:35:08 -07:00
2fe94ad7e3 Make specifiers support in tuple_join an opt-in 2021-09-05 07:34:06 -07:00
3940de5952 thousands -> group_digits 2021-09-05 06:47:18 -07:00
c4d0f96a6d Implement format specs in fmt::thousands 2021-09-04 06:56:51 -07:00
3b9c442689 Implement thousands separators without locales 2021-09-04 06:32:46 -07:00
08f98c7fac Simplify get_arg_index_by_name 2021-09-03 21:17:36 -07:00
a151f955a0 Remove FMT_OVERRIDE 2021-09-03 18:15:17 -07:00
42a225cbd9 Remove redundand final 2021-09-03 17:33:26 -07:00
bf20d19901 Simplify the core API 2021-09-03 16:57:33 -07:00
fc0884037e Move FMT_GCC_VISIBILITY_HIDDEN to format.h 2021-09-03 16:34:42 -07:00
1aeed2dbca Require inline namespaces 2021-09-03 15:59:23 -07:00
799bea4730 Remove FMT_HAS_GXX_CXX11 2021-09-03 15:49:40 -07:00
60cd5ea3f2 Add support for more formattable types in ranges 2021-09-03 14:55:41 -07:00
4fd9a00f35 Simplify ostream interface 2021-09-03 13:07:54 -07:00
5681563898 Cleanup ostream interface 2021-09-03 10:35:19 -07:00
20931baf1d Disable fallback_formatter for arrays 2021-09-03 08:59:36 -07:00
d58d19ba32 Fix an odr violation in ranges.h (#2483)
* Add a testcase demonstrating ODR violation in ranges.h

* Fix ODR violation in ranges.h

* Fix comments

Co-authored-by: Pierre-Antoine Lacaze <pa.lacaze@gmail.com>
2021-09-02 08:47:44 -07:00
ee0659f8b6 Fix formatting of abstract classes via ostream 2021-09-02 08:19:12 -07:00
8029bf955c Fix copy_str performance (#2477) 2021-09-02 07:25:26 -07:00
Max
2520f410c8 Workaround for #2478 (#2482)
_MSC_VER 1911 (Visual Studio 2017 15.3)
2021-09-02 07:13:30 -07:00
ee63f5f04e Workaround to MSVC bug (#2474) (#2476) 2021-08-31 07:54:42 -07:00
1aaf72fb6d Add an example to fmt::runtime 2021-08-29 12:10:40 -07:00
c1313c2057 Clarify that format_to[_n] do not append a terminating null 2021-08-29 12:07:35 -07:00
cb0f177c35 Improve docs 2021-08-29 11:30:35 -07:00
71677e5204 Improve docs 2021-08-29 11:21:38 -07:00
4db5723525 add fuzzers for chrono timepoint and localtime,gmtime (#2469)
* add fuzzers for chrono timepoint and localtime,gmtime

* reorder cases to improve throughput

mutating the first byte of the input now always results in picking
on of the two paths. Before, two of the four possible outcomes resulted
in doit() not being invoked.

* drop the localtime fuzzer

* inline aliases

* only fuzz std::chrono::system_clock
2021-08-29 06:58:23 -07:00
dc7f3ef2bb Fix header name 2021-08-28 20:34:45 -07:00
419ba86a91 Improve docs 2021-08-28 16:54:58 -07:00
6a5b4d5faf Document format_string 2021-08-28 16:51:48 -07:00
2599163b8a Document format_string 2021-08-28 15:20:56 -07:00
8ef22f7740 Update docs 2021-08-28 12:05:30 -07:00
c0c4d1adab Update docs 2021-08-28 11:52:13 -07:00
729a44e67d Depreate strtod and remove problematic tests 2021-08-28 09:20:36 -07:00
74c1118964 Apply force inline 2021-08-26 21:17:35 -07:00
596508a928 Cleanup 2021-08-26 20:56:28 -07:00
043e3b3429 Remove static_assert from arg_mapper 2021-08-26 20:45:01 -07:00
8b0cb944da Fix error reporting when mixing character types 2021-08-26 18:16:05 -07:00
117fc67077 CI: replace g++ C++20 build to test FP formatting at compile-time 2021-08-26 17:16:45 -07:00
c79a3841e8 make detail::fp and detail::bigit constexpr 2021-08-26 17:16:45 -07:00
5888de9f34 make detail::make_checked() constexpr 2021-08-26 17:16:45 -07:00
04b4b69b11 make detail::bit_cast() constexpr with C++20 2021-08-26 17:16:45 -07:00
fd34a3d246 make detail::basic_memory_buffer constexpr with C++20 2021-08-26 17:16:45 -07:00
6d597e39c3 Fix overload ambiguity in arg_mapper 2021-08-26 16:54:27 -07:00
b9ce56d936 Improve comments 2021-08-26 16:30:58 -07:00
f889e52a15 Improve error reporting 2021-08-26 15:47:44 -07:00
34caecd6b6 Use consistent initialization style 2021-08-23 10:10:56 -07:00
a44c8f651b reimplement formatter<tuple_join_view> (#2457)
* reimplement `formatter<tuple_join_view>`

1. completely reimplement `formatter<tuple_join_view<Char, T...>, Char>`
2. Add some tests

* use FMT_THROW
2021-08-23 09:51:19 -07:00
4b8bda25c0 Fix 2462
Signed-off-by: owent <admin@owent.net>
2021-08-23 06:31:10 -07:00
6b5e6119ee set clang in one place 2021-08-22 17:52:45 -07:00
7af1dc1d27 fix UB in fuzzer common (memcpy on nullptr) 2021-08-22 17:52:45 -07:00
e77686f7a8 clang format
using clang format 11
2021-08-22 17:52:45 -07:00
2207ea0b36 More escaping 2021-08-22 16:54:26 -07:00
a212ff757f Escape invalid code points 2021-08-22 15:51:33 -07:00
a76031e11d check -> is_printable 2021-08-22 13:23:38 -07:00
a7f280765c Improve naming 2021-08-22 12:44:00 -07:00
07d033ecb4 Fix is_printable 2021-08-22 10:37:18 -07:00
cdb4299acb Add Unicode support to is_printable 2021-08-22 09:11:35 -07:00
7df2c82a8a Rewrite printable.py codegen to emit C++ 2021-08-22 09:10:10 -07:00
6cf90d7cee Add script license and fix python version 2021-08-22 08:17:58 -07:00
2f1ad8ed3c Add printable codegen from Rust 2021-08-22 08:15:34 -07:00
371d8e2ee0 Escape Unicode 2021-08-22 07:55:59 -07:00
6397095ca4 More escaping 2021-08-21 16:36:25 -07:00
f69a572538 Don't overescape wide strings 2021-08-19 17:25:16 -07:00
11b07a56b2 We should escape 2021-08-19 14:50:59 -07:00
b559cfd4c0 Implement basic escaping 2021-08-19 14:12:26 -07:00
11d49491cb Handle global locale 2021-08-14 09:38:41 -07:00
6ea6cf9464 Add decimal separator support to float 2021-08-14 09:16:26 -07:00
9730a2af0a Update ChangeLog.rst 2021-08-13 10:07:48 -07:00
c2ed5f6863 Update ChangeLog.rst 2021-08-13 10:07:20 -07:00
7b66e72e2c Use builtin intrinsics on intel (#2450) 2021-08-11 06:22:02 -07:00
d57b2a6525 Suppress a warning 2021-08-08 09:18:46 -07:00
bdfbd794e3 Cleanup begin/end usage 2021-08-07 08:55:01 -07:00
111de881fa Don't copy non-const-iterable ranges 2021-08-07 07:34:02 -07:00
d6e882ed84 Undo the move because the doc is not a GH template 2021-08-06 11:22:33 -07:00
f488eed101 Resolve default constructor error in Xcode 7.2.1 and 8.2.1
Fix issue that produces the error 'default initialization of an object
of const type 'const detail::buffer_size' without a user-provided
default constructor'
2021-08-06 11:17:02 -07:00
652c3653bb Move CONTRIBUTING.md to .github 2021-08-06 10:56:05 -07:00
fb19faa31b Improves README with svg badge (#2446)
Looks much better now!
2021-08-05 06:50:15 -07:00
07211701f4 Disable the -Wstringop-overflow warning from GCC 7 (#2442) 2021-08-02 14:20:18 -07:00
bba0a9d962 Make flush public 2021-07-30 07:02:49 -07:00
f1794a8853 Switch to threadsafe death test style 2021-07-29 06:56:38 -07:00
brm
0544a2279b Exclude fallback functions when FMT_BUILTIN_CLZ(LL) is not defined (#2434) 2021-07-25 10:37:18 -07:00
5c222f0561 Add support for nonconst formattable types 2021-07-24 09:53:53 -07:00
3def950b84 Set FMT_CAN_MODULE=OFF for MSVC 19.29.30035+ 2021-07-23 09:35:09 -07:00
63fe2d5bd2 Add copy constructor for dynamic_format_arg_store, and test 2021-07-23 09:35:09 -07:00
561834650a Improve digit count 2021-07-18 09:14:56 -07:00
f20f50368f Replace throw with FMT_THROW (#2427)
Using `throw` results in compile errors with `-fno-exceptions`. gcc seems fine with it, but arm-gcc and clang would complain.
2021-07-18 07:08:24 -07:00
00235d8a99 fix module test odr violations (#2414) 2021-07-17 09:16:49 -07:00
2038bf6183 Update format_to usage 2021-07-13 07:56:24 -07:00
e41ac1f875 Don't use deprecated API in docs 2021-07-10 13:42:51 -07:00
8465869d7b Move ignore_unused to detail 2021-07-09 08:24:11 -07:00
3d53d1539d Warning removals in test code (#2399)
* Warning removals in test code.

Mostly 0 to nullptr and adding override to virtual function implementations.

* Fix module-test.
2021-07-09 08:05:02 -07:00
20e4ef8b4c Pass significand_size by value 2021-07-05 08:51:43 -07:00
c4a3c2342a Refactor locale handling 2021-07-05 08:25:12 -07:00
7a0d301753 Update README.rst 2021-07-04 07:03:20 -07:00
f2b03facd9 Include test sources to pick up functions and classes from the module rather than from the non-modular library which is baked into the test-main library. (#2356)
This averts linker problems:
 - strong ownership model: missing linker symbols
 - weak ownership model: duplicate linker symbols

Simplify `gtest-extra.cc` while at it.
2021-07-03 07:21:54 -07:00
02ad5e11da Add faint, blink, reverse and conceal to the emphases (#2394) 2021-07-02 20:03:55 -07:00
d141cdbeb0 Update version 2021-07-02 16:14:33 -07:00
cfc05e05f0 Bump version 2021-07-02 14:43:31 -07:00
8ea312633b Update changelog 2021-07-02 14:43:00 -07:00
e461f3dbbe Minor consitency and comment tweaks 2021-07-02 13:56:37 -07:00
54014e42e3 silence warning C4100 on MSVC 2019 when exceptions are disabled (#2397) 2021-07-02 13:51:49 -07:00
3e7a29cc92 Workaround clang/gcc incompatibility 2021-07-02 13:29:22 -07:00
00a57a9f8f Update changelog 2021-07-02 08:07:48 -07:00
1d7384530e Add missing presentation type checks for std::string (#2402) 2021-07-02 07:51:04 -07:00
889bbf27a2 Fix missing std::get overload in MSVC (#2407)
This replaces the `std::get` call with an unqualified equivalent to allow
it to be treated as a dependent call.

ranges.h needs std::get overloads from `<tuple>` but does not directly
include it. This causes compilation failures in MSVC with /permissive-.
On other platforms `<tuple>` is included as a dependency from other headers
(specifically from `<memory>`), but there is no such implicit dependency in
MSVC's STL.

Fixes #2401
2021-07-01 10:55:46 -07:00
5f8473914c Remove outdated apidoc 2021-07-01 07:56:53 -07:00
785908ee37 Fix warnings 2021-06-30 06:42:29 -07:00
fbb70eec5c suppress unused variable warnings (#2381)
* suppress unused variable warnings

An arguably better method for suppressing unused variable warnings.   The `(void)var` method does not work on many intel compiilers.
This is from Herb Sutter's blog post https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/

* Format to eliminate long lines

* Run clang-format
2021-06-30 06:33:30 -07:00
002bb759ff Remove unneeded num_result_bigits decrement
For what I see this seems unused?
2021-06-29 06:23:02 -07:00
a3f762c5aa [doc] Minor: fix `code`. 2021-06-29 06:21:15 -07:00
c3c27e5ab5 Fix MSVC warning C4819 2021-06-28 06:14:53 -07:00
c6b1f181aa Fix docs 2021-06-27 09:06:21 -07:00
94564b058e Fix docs 2021-06-27 08:55:16 -07:00
0fc73a2a85 Merge branch 'master' of github.com:fmtlib/fmt 2021-06-27 08:10:49 -07:00
3156fcf5f4 Switch to older breathe version 2021-06-27 08:10:37 -07:00
f85fb9fdff Adjust definition for FMT_HAS_INCLUDE
Adjust definition for FMT_HAS_INCLUDE

Remove check for `!FMT_MSC_VER`
2021-06-27 07:08:29 -07:00
0bc3d664e3 Fix docs 2021-06-27 06:41:54 -07:00
e5c46e13e8 Fix docs: breathe 18 and earlier corrupts trailing return type 2021-06-26 09:55:27 -07:00
49a3b58c8b Specify size for static data arrays 2021-06-26 06:55:24 -07:00
d0c8d45a2e apt update before install 2021-06-26 06:29:53 -07:00
c9a10631cb format: do not use udl_{arg,formatter} return types when UDL is not in use
The udl_{arg,formatter} structs are only defined when
FMT_USE_USER_DEFINED_LITERALS is set, so don't try to define things that
return that struct when it's not defined.
2021-06-26 06:25:16 -07:00
3bd806f12f Eliminate intel compiler warning
The intel compiler defines `__GNUC__`, but does not support the gcc `_Pragma`.  This PR filters out the intel compiler to avoid warnings about an unrecognized function.
2021-06-26 06:16:12 -07:00
fd16bcb20c Fix bug in cmake join function 2021-06-24 09:10:53 -07:00
5221242f6e Instruct msvc to report the _true_ value in __cplusplus and force _full_ C++ conformance
* do this  in _some_ tests to improve test coverage and catch possible problems due to that
 * fix invalid export of `static constexpr` constant
 * fix msvc warnings about unreachable code in high warning levels
2021-06-24 09:10:08 -07:00
31a5f0d399 Bump version in inline namespace 2021-06-22 14:47:59 -07:00
102a4d492a Bump version in inline namespace 2021-06-22 07:04:02 -07:00
f68508b6ce Update ChangeLog.rst 2021-06-21 18:37:56 -07:00
9e8b86fd2d Update version 2021-06-21 05:59:17 -07:00
92fec0f050 Bump version 2021-06-21 05:57:50 -07:00
4749cc930a Update changelog 2021-06-19 08:16:43 -07:00
78a0ba0a6a Improve conversion of paragraphs 2021-06-19 08:02:52 -07:00
7a39837d96 Use a working breathe version 2021-06-19 07:35:09 -07:00
55b6e92db5 Fix docs 2021-06-19 06:31:19 -07:00
69dc3a8535 Fix docs 2021-06-18 12:51:48 -07:00
27f4cdd586 Update changelog 2021-06-18 12:23:16 -07:00
70d61a0ae3 Update changelog 2021-06-18 08:32:43 -07:00
427b534054 Add no_value state to value 2021-06-15 07:53:28 -07:00
e421d52713 Simplify error handling in parse_nonnegative_int 2021-06-14 16:05:37 -07:00
a59678f376 Fix chrono_test.locale
UTF-8: https://datatracker.ietf.org/doc/html/rfc3629
2021-06-14 09:41:08 -07:00
c98254c3d7 Install locales into CI 2021-06-14 09:41:08 -07:00
c123a72844 Fix set locale error in chrono formatter 2021-06-14 09:41:08 -07:00
3c8fad126c Optimize parse_nonnegative_int 2021-06-13 19:20:44 -07:00
f28cf3302d adding a default format for std::chrono::time_point<std::chrono::syst… (#2345) 2021-06-11 10:52:39 -07:00
55010a9d3a Support non-char overloads (module) 2021-06-11 09:38:53 -07:00
0193e7c428 Support compile-time strings and compile-time format string compilation in module
Make just the necessary parts available for lookup from client context.
2021-06-11 09:38:53 -07:00
3423d75475 Remove the msvc workaround (#2351) 2021-06-11 06:20:25 -07:00
f6b5cc9f84 Fix chrono_test.weekday on legacy glibc 2021-06-10 16:17:10 -07:00
59a298f124 Enable enforce-checks-test for MSVC, too 2021-06-10 12:54:54 -07:00
36c2948225 Update docs 2021-06-08 08:25:50 -07:00
c9fe1fa5ba Remove unused flag 2021-06-08 08:00:37 -07:00
dccddc2bdb Apply clang-format 2021-06-07 08:49:47 -07:00
0e36681b8e Cleanup digit count 2021-06-07 07:42:22 -07:00
1de80f5b22 Workaround lack of static constexpr in constexpr functions 2021-06-07 07:27:56 -07:00
2039dce75f Detect consteval 2021-06-07 06:57:43 -07:00
d551b88a6d Move is_char specializations to xchar.h 2021-06-06 15:32:30 -07:00
16c3514d01 wchar-test -> xchar-test 2021-06-06 07:59:18 -07:00
206000a017 Workaround pathological conversion (#2343) 2021-06-06 07:18:44 -07:00
76ee490468 Move wchar/custom char overloads to xchar.h 2021-06-05 22:57:45 -07:00
e77b22d6da Deprecate memory buffer overload of format_to 2021-06-05 14:58:36 -07:00
07039f4b19 Update README.rst 2021-06-05 06:32:22 -07:00
4678192c88 Remove bsr2log10 2021-06-04 21:33:05 -07:00
7c3d3dfa29 Update thousands_sep_impl signature 2021-06-04 21:12:47 -07:00
ef826b86cb Fix docs 2021-06-04 20:34:58 -07:00
5223f552c8 Remove FMT_ALWAYS_INLINE 2021-06-04 20:29:54 -07:00
cfde93afe0 Add FMT_STATIC_CONSTEXPR 2021-06-04 16:50:09 -07:00
986a5a6c2c Fixed join_view formatter for wchar_t 2021-06-04 14:50:45 -07:00
7c8b35ff32 fix MSVC Win32 count_digits 2021-06-04 11:06:25 -07:00
3eeb084e71 Optimize count_digits 2021-06-04 09:14:58 -07:00
2ac0bfe59e Improve handling of thousands separator 2021-06-04 06:12:44 -07:00
024741b476 CI: set up multi-thread build for all platforms 2021-06-04 05:56:55 -07:00
f4c95f6dd9 Improve handling of thousands separator 2021-06-03 18:25:08 -07:00
d4fbeacc33 Fix docs build 2021-06-03 18:25:08 -07:00
0eef389ddb Code style 2021-06-03 18:25:08 -07:00
e27b1ce50c Fix docs 2021-06-03 09:32:12 -07:00
9f8b6daca2 Fix wheel installation 2021-06-03 09:10:07 -07:00
6060bcfc8a Fix docs 2021-06-03 09:03:00 -07:00
ff9673463c Fix docs 2021-06-03 08:43:41 -07:00
1085cc2178 Fix docs 2021-06-03 08:28:02 -07:00
11addaa16e Update docs 2021-06-03 06:24:17 -07:00
760ca5ccc0 Update docs 2021-06-02 19:45:42 -07:00
290d3f8b61 Cleanup ranges API 2021-06-02 17:06:02 -07:00
aa09e0f5dd Update docs 2021-06-02 16:25:21 -07:00
d142579e97 Cleanup the format API 2021-06-02 16:25:21 -07:00
f286139d22 Fix "undefined reference to `fmt::v7::detail::basic_data<void>::digits'"
Remove unused FMT_EXTERN_TEMPLATE_API
2021-06-02 14:33:17 -07:00
7b9d69b827 Add xchar.h to docs 2021-06-02 08:19:54 -07:00
cbd861f188 Update docs 2021-06-02 08:06:52 -07:00
faf972f039 Update docs 2021-06-02 07:46:26 -07:00
622d1c0423 Update changelog 2021-06-02 07:36:27 -07:00
634c948769 Update changelog 2021-06-02 07:13:06 -07:00
a04e3a2dc8 Comment 2021-06-01 20:47:16 -07:00
87876d5474 Cleanup the printf implementation 2021-06-01 20:32:56 -07:00
d338d66324 Cleanup the printf implementation 2021-06-01 19:30:46 -07:00
272660e704 Remove deprecated printf functions 2021-06-01 18:08:31 -07:00
5a95c5ae2c Update changelog 2021-06-01 17:47:23 -07:00
70e67ae018 Re-enable module testing
Prepare for compilation with gcc (modules branch).
2021-06-01 14:49:56 -07:00
ad97258915 Merge branch 'master' of github.com:fmtlib/fmt 2021-06-01 13:38:26 -07:00
ed2a6377e7 Workaround msvc constexpr issues 2021-06-01 13:32:44 -07:00
9976869549 fix custom types formatting at compile-time, add test 2021-06-01 11:16:05 -07:00
8c1b22ba6d Workaround a gcc 9.1 bug (#2334) 2021-06-01 06:43:30 -07:00
2dba1cfac1 Update changelog 2021-05-31 19:19:09 -07:00
d7ba6c3ea8 Use qualified name-lookup in module. (#2324)
Allow lookup of non-exported names from local classes in function templates.
2021-05-31 09:11:24 -07:00
bf9904ee4d Workaround msvc bugs 2021-05-31 08:25:05 -07:00
577bce9029 Apply clang-format 2021-05-31 08:09:10 -07:00
ba4c7f193b Swap parameter order to match #2327 (#2329) 2021-05-31 07:44:33 -07:00
e9e89b355b Update ChangeLog.rst 2021-05-31 07:43:29 -07:00
9bb406d78d Update changelog 2021-05-31 07:37:10 -07:00
11a14db286 Update format_to taking a buffer and remove undocumented vformat_to overload 2021-05-30 07:57:51 -07:00
832ec098fc Fix argument order in locale overload of vformat_to (#2327) 2021-05-30 06:42:09 -07:00
486a80e8ef Move wchar_t overloads to xchar.h 2021-05-30 06:41:39 -07:00
19d45f4b31 Update changelog 2021-05-29 16:56:33 -07:00
5a2b88f6e9 Reduce binary size 2021-05-29 16:45:43 -07:00
00a39ad5f8 Enable Char types other than char (#2323) 2021-05-29 11:42:16 -07:00
ff37e41625 wchar.h -> xchar.h because it handles other code unit types too 2021-05-29 09:37:17 -07:00
0901176fe4 arg_join -> join_view 2021-05-29 08:47:16 -07:00
a9a9018191 Move wmemory_buffer to wchar.h 2021-05-29 08:26:04 -07:00
4a7801c3ec Update changelog 2021-05-29 08:14:25 -07:00
517578f80e Update changelog 2021-05-29 07:48:59 -07:00
85442ed045 Update changelog 2021-05-29 07:43:21 -07:00
6a12b13a85 Update changelog 2021-05-29 07:39:35 -07:00
1cfe3c7382 Update ChangeLog.rst 2021-05-29 07:30:47 -07:00
c06014792b Update changelog 2021-05-29 07:30:07 -07:00
6fe04871f4 Update changelog 2021-05-29 07:20:29 -07:00
9d67988aed FMT_DEPRECATED_WCHAR -> FMT_DEPRECATED_INCLUDE_WCHAR 2021-05-29 06:41:07 -07:00
765b451edd Update changelog 2021-05-29 06:15:49 -07:00
17c993c753 Fixed compilation with CMake < 3.7 (#2321) 2021-05-28 20:24:31 -07:00
dde6937319 Update changelog 2021-05-28 16:20:46 -07:00
272b0f36b3 More module tests (#2309)
core.h, format.h, args.h, chrono.h, color.h, printf.h, os.h
2021-05-28 15:49:39 -07:00
126c8cb46b Export os.h API, too (#2318) 2021-05-28 09:27:45 -07:00
98b9ff47a1 Align hex floats right as default (#2317) 2021-05-28 09:21:01 -07:00
ece4b4b33a Update changelog 2021-05-28 06:53:33 -07:00
a70a4ae053 Ignore zero-padding for non-finite floating points (#2310)
* Ignore zero-padding for non-finite floating points

* keep width for non-finite formatting with 0-padding

* clang-format

* preserve alignment

* align code-style
2021-05-27 14:13:05 -07:00
7612f18dc8 Update changelog 2021-05-27 07:06:13 -07:00
b9f2c27661 Update changelog 2021-05-26 21:12:03 -07:00
4e21baff43 Simplify get_units 2021-05-26 18:26:00 -07:00
683ef11ab9 Update changelog 2021-05-26 18:25:21 -07:00
ca466374bd qualify make_format_args (#2315)
Co-authored-by: John Melas <john@jmelas.gr>
2021-05-26 06:42:02 -07:00
5a2a185682 Make buffers non-movable 2021-05-25 17:30:17 -07:00
ee52a6dc40 add fmt::print() overload to support compiled format (#2304) 2021-05-25 14:54:56 -07:00
82607efb57 Fixed int conversion warning (#2313)
* Fixed int conversion warning

Compiler warns about conversion from int to size_t, thus added explicit cast.

* now using detail::to_unsigned for the cast
2021-05-25 08:13:39 -07:00
35a2c2a743 Refactor chrono formatting 2021-05-25 06:57:47 -07:00
b955e7a6b2 Refactor chrono formatting 2021-05-24 15:33:33 -07:00
883d9595c5 Support alternative locale names in tests 2021-05-24 14:09:19 -07:00
1f308a3cea Update integer presentation types documentation.
Documents that the 'c' type is a valid type for integer types. Since
boolean uses the same types as integer its documentation is
automatically updated.
2021-05-24 10:55:08 -07:00
1cd9899cf3 Add initial support for weekday formatting 2021-05-24 10:21:34 -07:00
069131dc25 Add unicode-test 2021-05-24 06:20:51 -07:00
dd8f38fcbb Cleanup printf API 2021-05-23 20:30:26 -07:00
a216f2562d Remove undocumented and obsolete vprintf overload 2021-05-23 20:15:02 -07:00
0c0926395d Add is_exotic_char trait 2021-05-23 19:50:17 -07:00
bc13c6de39 Update README.rst 2021-05-23 07:45:33 -07:00
8ec0b9e33b Do *not* export namespace detail 2021-05-23 06:49:07 -07:00
b99c2bd345 Remove deprecated locale.h from module interface unit 2021-05-23 06:17:25 -07:00
c04a24399a Update changelog 2021-05-22 20:55:56 -07:00
b099a56f9f Update changelog 2021-05-22 16:12:38 -07:00
703005c8ba Deprecate locale.h 2021-05-22 10:21:17 -07:00
51f0178625 Cleanup the format API 2021-05-22 07:09:09 -07:00
5d59dcf66e Remove deprecated aliases / undeprecate has_formatter 2021-05-22 06:53:34 -07:00
c242dd402c Move cerrno include to where it is used 2021-05-22 06:18:40 -07:00
2216e0b779 Update changelog 2021-05-22 06:04:33 -07:00
1c83a49be9 Simplify buffer extraction 2021-05-21 20:15:56 -07:00
2617384d8e Improve buffer extraction 2021-05-21 19:44:49 -07:00
34b8acaef7 More wchar_t-specific API to wchar.h 2021-05-21 18:24:39 -07:00
6326c18906 Improve code style consistency 2021-05-21 17:29:15 -07:00
5c4b0c86fb Add missing Allocator template argument for basic_memory_buffer in format_to
Remove deduced default template arguments in format_to and moves the
SFINAE check to a non-deduced template parameter.
2021-05-21 12:13:46 -07:00
00149c0b6a Move detail::null to chrono where it is used 2021-05-21 09:16:45 -07:00
c5c968cb22 Improve binary size 2021-05-21 08:50:35 -07:00
128cbdeb2f cmake: hide private symbols by default 2021-05-21 08:25:08 -07:00
18af1dc460 Fix binary size regression caused by b268f88 2021-05-20 18:33:45 -07:00
d1e6f0f8c6 Fix binary size regression caused by b268f88 2021-05-20 18:00:19 -07:00
5a0d99fa0b Add a test for the module 2021-05-20 10:26:31 -07:00
6e2e6b796f Restore support for wchar_t overloads in module 2021-05-20 10:03:58 -07:00
24b677d053 Improve symbol sizes 2021-05-20 07:21:20 -07:00
63271a51c4 Fix ADL issues 2021-05-20 06:31:43 -07:00
61b4c923d7 Reduce code bloat 2021-05-20 05:51:45 -07:00
2a2e4c5801 addressing nits. 2021-05-19 16:09:49 -07:00
be48f4d657 Avoid unwanted sign extensions from MSVC in is_utf8.
Microsoft's constexpr evaluator treats the type of micro[0] and micro[1] as
plain char, and so sign extends before comparing them to ints.
The normal compiler, including the optimizer, does not fail in this way,
so this is merely a "future proof" change in case someone uses is_utf8()
in a constant expression.
2021-05-19 16:09:49 -07:00
13e652939b export missed symbols
Enable `-fvisibility=hidden` and `-fvisibility-inlines-hidden` by default in CI builds to ensure all public symbols are exported correctly.
2021-05-19 16:03:45 -07:00
71fb113818 fix compile error on msvc preview 4 (16.10) involving lookup clash /w STL 2021-05-19 13:17:20 -07:00
08d22503bb Remove outdated comments 2021-05-19 11:47:21 -07:00
56f518a98f Update signatures 2021-05-19 09:45:33 -07:00
b7f2933744 Update signatures 2021-05-19 09:39:32 -07:00
7483dfc652 Update signatures 2021-05-19 09:36:12 -07:00
95c358f721 Improve separation between code unit types 2021-05-19 09:06:57 -07:00
39c3c4ec22 Simplify the core API 2021-05-19 08:32:57 -07:00
e9c1c415b8 Improve compile-time checks 2021-05-19 07:57:57 -07:00
21d93bfd33 Move generic format functions to format.h 2021-05-18 19:01:43 -07:00
9a92eb4158 Move more wchar overloads to wchar.h 2021-05-18 05:53:25 -07:00
0dd91e20d5 Add wchar.h for wide char overloads 2021-05-17 21:59:10 -07:00
ce14eafc24 Simplify format string checks 2021-05-17 19:25:50 -07:00
8d70c0edab Refactor the format API 2021-05-17 18:25:36 -07:00
813ac49543 More API cleanups 2021-05-17 07:58:13 -07:00
4ab01fb198 Cleanup printf API 2021-05-17 07:19:50 -07:00
d5036b11b1 Remove deprecated APIs 2021-05-17 06:59:46 -07:00
2581946231 Cleanup the core API 2021-05-16 13:02:01 -07:00
b35db4e006 Improve handling of 128-bit ints 2021-05-16 11:43:44 -07:00
d35f1ad5c1 Cleanup core 2021-05-16 10:02:33 -07:00
8f1902c05a Move format string checks to core.h 2021-05-16 07:08:49 -07:00
6469b9037c Silence msvc warning about an unused named parameter
Warning C4100 may cause compile failures under strict warning regimes.
2021-05-16 06:14:30 -07:00
7d4c92fb00 Update ChangeLog.rst 2021-05-15 17:19:27 -07:00
0763d8cadf Fix Visual Studio warning 2021-05-15 17:13:15 -07:00
5466373a11 Do *not* export namespace detail
Introduce `FMT_BEGIN_DETAIL_NAMESPACE` and `FMT_END_DETAIL_NAMESPACE` for `namespace detail` sections embedded in that part of the code that contains all declarations that are exported from the module, i.e. which is enclosed by `FMT_MODULE_EXPORT_BEGIN` and `FMT_MODULE_EXPORT_END`. Given a correct implementation of C++20 modules, neither the name `fmt::detail` nor any of its contents will become visible outside of the module.
2021-05-15 12:08:42 -07:00
588bdb5404 Simplify get_arg_index_by_name 2021-05-15 06:47:43 -07:00
54f22a3eef add support for statically named arguments with FMT_STRING 2021-05-14 16:31:10 -07:00
ea94d6d93c Prevent ambiguity in name lookup
Unqualified calls to 'make_format_args' may find the same name by ADL in <format> if this C++20 header happens to be directly or indirectly included in a translation unit. Do a qualified lookup instead.
2021-05-14 07:10:02 -07:00
57280762b6 Move specs checker to core.h 2021-05-13 19:33:09 -07:00
ced3037523 Move dynamic specs to core.h 2021-05-13 19:01:21 -07:00
dd2bc998ab Move specs to core.h 2021-05-13 18:48:15 -07:00
08da1adcf6 Remove unused headers 2021-05-13 17:58:15 -07:00
3be0cc2087 Fix handling of 128-bit ints 2021-05-13 17:53:23 -07:00
9648bdce30 add missing header 2021-05-13 05:39:18 -07:00
d1aebdbde0 Inline format_to 2021-05-12 18:07:59 -07:00
8f0fadfaaa Cleanup docs 2021-05-11 20:20:03 -07:00
02896dabee Avoid use after move (#2278) 2021-05-11 16:58:07 -07:00
0036a1d195 Fix issue #2274. 2021-05-10 15:57:23 -07:00
2a9b314627 Replace fmt::error_code to std::error_code 2021-05-09 12:26:19 -07:00
2165bef4ca Update README.rst 2021-05-09 09:35:44 -07:00
4862930845 Optimize format string compilation 2021-05-09 09:15:55 -07:00
3207a8bbbf Get rid of unnecessary recursion to enable inlining 2021-05-09 07:54:13 -07:00
6214f15a0c Optimize standard formatter specialization 2021-05-09 07:11:35 -07:00
cd2c78fb8a Use write directly in formatter specializations 2021-05-09 07:07:51 -07:00
4211d86539 Add a formatter specialization for std::error_code. 2021-05-09 06:29:39 -07:00
39f28424ca Cleanup tests 2021-05-07 21:27:58 -07:00
84feeb0f36 Remove redundant comments and put common case check first 2021-05-07 17:14:29 -07:00
2665afb515 Cleanup add-subdirectory-test 2021-05-07 16:42:02 -07:00
d0abe7c246 Make chrono formatting locale-independent by default 2021-05-07 16:14:10 -07:00
50fb0b5eae Fix formatting 2021-05-07 08:52:49 -07:00
16f2ef91ab Replace fmt::system_error with std::system_error 2021-05-07 08:33:39 -07:00
4b885c8633 Replace windows_error with system_error 2021-05-07 06:19:03 -07:00
5238055f40 Move esoteric char type support to format.h 2021-05-06 09:02:00 -07:00
9ac088f376 Add fmtlog to projects 2021-05-06 08:39:36 -07:00
849c9f6168 Move is_name_start to core 2021-05-06 08:12:24 -07:00
23892caf53 Move more parsing to core 2021-05-06 07:37:40 -07:00
8e6390c32c Move FMT_STRING to core 2021-05-06 07:19:41 -07:00
51a33713fc Move parsing to core 2021-05-06 07:01:29 -07:00
9c3af11a92 Cleanup tests 2021-05-05 18:31:41 -07:00
9d7b53cb9b Remove redundant formatter specialization for byte 2021-05-05 08:14:12 -07:00
f0095ccd34 Add support for ranges of types without formatters to join (#2262) 2021-05-05 07:43:46 -07:00
4f0eadfce4 Exclude fallback from is_formattable 2021-05-05 06:29:51 -07:00
400b953fbb Use [] instead of {} in ranges for consistency with Python format 2021-05-04 21:04:21 -07:00
38bcc04a11 Drop range limit and cleanup tests 2021-05-04 20:53:56 -07:00
c738c3431f Cleanup tests 2021-05-04 17:23:13 -07:00
ed7c4320f6 Cleanup tests 2021-05-02 09:28:38 -07:00
9155e2de4c Cleanup tests 2021-05-01 17:11:45 -07:00
38127d9ec0 Cleanup tests 2021-04-30 15:50:03 -07:00
c9c0e5077d Cleanup tests 2021-04-30 06:42:38 -07:00
ccf4ccde23 Cleanup tests and format string compilation 2021-04-29 19:50:04 -07:00
e96a92f869 Cleanup tests and format string compilation 2021-04-29 16:21:08 -07:00
fd43e4dcbc gtest: fix std::is_trivially_copy_constructible for GCC 4.8 & 4.9 properly
`std::is_pod<T>` was deprecated in C++20

original (pre `is_pod`) error on GCC 4.8:
```
/fmt/test/gtest/gtest.h: In static member function 'static constexpr bool testing::internal::MatcherBase<T>::IsInlined()':
/fmt/test/gtest/gtest.h:6512:12: error: 'is_trivially_copy_constructible' was not declared in this scope
            std::is_trivially_copy_constructible<M>::value &&
            ^
/fmt/test/gtest/gtest.h:6512:45: error: expected primary-expression before '>' token
            std::is_trivially_copy_constructible<M>::value &&
                                                  ^
/fmt/test/gtest/gtest.h:6512:46: error: '::value' has not been declared
            std::is_trivially_copy_constructible<M>::value &&
                                                   ^
```
2021-04-29 07:11:49 -07:00
3d51ccdaae gtest: remove obsolete GTEST_LANG_CXX11 compile definition setting 2021-04-29 07:11:49 -07:00
833377ff1e gtest: add .clang-format file into test/gtest directory to prevent formatting there 2021-04-29 07:11:49 -07:00
53ca0cbe75 gtest: move GTest/GMock files to separate directory, update GTest/GMock usages
* all GTest/GMock files moved to `test/gtest` directory
* `CMakeLists.txt` created in `test/gtest` from `CMakeLists.txt` in `test`
* GTest/GMock target in CMake renamed to `gtest` (was `gmock`)
* CMake `gtest` target updated to export includes as "gtest/gtest.h" or "gmock/gmock.h" only
* includes in tests updated: "gtest.h" -> "gtest/gtest.h", "gmock.h" -> "gmock/gmock.h"
* removed duplications of `target_include_directories` for GTest/GMock directories (CMake manages them)
2021-04-29 07:11:49 -07:00
342973b349 Make wchar_t overloads usable in module
Bring ''detail::find()' into scope.
2021-04-28 09:37:57 -07:00
355be4b13f Make FMT_COMPILE fallback on runtime without if constexpr (#2261) 2021-04-28 09:11:47 -07:00
0cd0fb9184 C++17: std::char_traits<>::{compare,length} is constexpr - v2 2021-04-28 07:05:32 -07:00
d1a6e5603f Keep defaulted destructors inline
applies to exception classes in case of msvc only
2021-04-28 06:17:26 -07:00
84a36b99bf Move data to functions 2021-04-27 17:21:32 -07:00
ab7c33ede0 Suppress checked iterator warnings 2021-04-27 13:54:39 -07:00
77258f6069 fix FMT_CONSTEXPR_CHAR_TRAITS check for MSVC 2021-04-26 16:35:32 -07:00
d23e315ea2 CI windows: add MSVC C++20 build 2021-04-26 16:35:32 -07:00
f085c3d7a0 use proper check for non-type template parameters 2021-04-26 16:35:32 -07:00
69bdc20a3c Workaround missing std::system on iOS, take 2 2021-04-26 06:21:44 -07:00
847aac4315 Follow naming conventions in tests 2021-04-25 21:26:30 -07:00
39818e7979 Cleanup core-test 2021-04-25 17:59:23 -07:00
0e6f989b0d __THROW warning fix for e2k (#2253) 2021-04-25 08:51:37 -07:00
1678ed6235 simplify field::format() and spec_field::format(), fix typo 2021-04-25 07:53:49 -07:00
ca821982ee use named arg with static name in compile-time API
to get arg index by name at compile-time
2021-04-25 07:53:49 -07:00
ce6e7d8620 use fixed_string to create named arg class with static name for _a literal 2021-04-25 07:53:49 -07:00
fc56af14c2 move fixed_string from compile.h to format.h 2021-04-25 07:53:49 -07:00
bb006f9735 Replace TYPED_TEST_CASE with TYPED_TEST_SUITE 2021-04-24 17:46:49 -07:00
6956b10b2d Fix gcc 4.8 build 2021-04-24 11:04:34 -07:00
b4f9a05894 Update gtest 2021-04-24 11:03:40 -07:00
8f9ddf452d Remove deprecated posix.h 2021-04-24 07:03:11 -07:00
dacd1356e4 Add module interface unit 2021-04-24 06:39:57 -07:00
d3c523e0d2 Export printf-related contexts from printf.h 2021-04-24 06:39:57 -07:00
2c25df089f Export replacement type_traits, too 2021-04-24 06:39:57 -07:00
553022dc56 Don't use std::system on iOS (#2248) 2021-04-24 06:17:05 -07:00
8a040d187a Cleanup core-test 2021-04-23 20:07:48 -07:00
064cac2bf9 Bump version 2021-04-23 16:05:03 -07:00
5b2c740ad8 Remove deprecated APIs 2021-04-23 15:27:25 -07:00
b9ab5c8836 Remove printf.h dependency on ostream.h 2021-04-23 10:42:57 -07:00
c47f211296 Simplify data handling 2021-04-23 06:52:10 -07:00
54d3b1710e Move more data out of basic_data 2021-04-23 06:45:23 -07:00
128f007b25 C++17: std::char_traits<>::{compare,length} is constexpr. (#2246) 2021-04-23 06:11:34 -07:00
841aad95b4 Move data out of basic_data 2021-04-22 15:29:42 -07:00
1d4199f46b fix udl_compiled_string with non-byte chars (e.g. wchar) (#2242) 2021-04-19 08:29:35 -07:00
c5d4fcb119 Appending a space to guarantee non-empty strftime() result. (#2244) 2021-04-18 19:13:51 -07:00
6271406233 Fix a warning (#2233) 2021-04-16 15:58:17 -07:00
52bd62c72f Create separate dllexport marking points for clang and msvc. (#2229)
* add FMT_INSTANTIATION_DEF_API for msvc

This should fix https://github.com/fmtlib/fmt/issues/2228

To fix difference dllexport requirements
msvc:  dllexport at template instantiation definition in format.cc
clang: dllexport at template instantiation declaration (extern template) in format.h
2021-04-16 12:34:18 -07:00
f4bbc54cc4 Tag official API for module export (#2235)
* functions
 * classes
 * UDLs
 * other declarations

Export everything in namespace 'fmt' from core.h and format.h
2021-04-16 11:04:55 -07:00
d8910af80d Use qualified name lookup rather than ADL. (#2239)
Name lookup within exported templates cannot find non-exported entities by ADL when instantiation takes place outside the module.
2021-04-16 09:38:25 -07:00
9260114162 Ranges wide strings support (#2236)
* Ranges copy wchar_t

* arg_join formatter not working for wide strings

* Added ranges wide string tests

Co-authored-by: Cristi <cristi@emailaddressmanager.com>
2021-04-16 06:25:35 -07:00
24c9751558 Try to suppress MVSC warn of narrowing (#2230) 2021-04-13 07:30:43 -07:00
a1c6bfd77b Add a link to llvm diff 2021-04-12 10:05:14 -07:00
42eccac454 Fix clang warning about ignoring __declspec(dllexport) on basic_data<void> template instantitation definition (#2220) 2021-04-12 09:31:44 -07:00
aec504344a Update README.rst 2021-04-10 08:48:11 -07:00
0b41145443 Update README.rst 2021-04-10 08:31:47 -07:00
00f3d16b12 Update docs 2021-04-10 08:07:16 -07:00
99c2f7a349 Allow including fmt/core.h in the header-only mode 2021-04-10 07:44:36 -07:00
b441532396 CI linux: add clang++-11 C++20 (with LLVM libc++) build
* find-package-test fixed by passing CXX_FLAGS, i.e. -stdlib=libc++
 * std::array usage in compile-test.cc replaced with plain array, because
   <array> header was not included
2021-04-10 07:20:05 -07:00
1dbadb6527 CI linux: add clang++-11 C++20 build 2021-04-10 07:20:05 -07:00
09dbad47e1 CI linux: add missing build_type
for g++-8 C++14, g++10 C++17, g++10 C++20
2021-04-10 07:20:05 -07:00
e2facffe4d CI linux: remove excessive clang++-9 include 2021-04-10 07:20:05 -07:00
273d8865e3 Suppress redef warning of _CRT_SECURE_NO_WARNINGS if any. (#2218) 2021-04-08 11:56:35 -07:00
5a8bf1f6a3 Workaround hexfloat inconsistency on windows (#2205) 2021-04-07 11:20:08 -07:00
78776ee4e2 Fix a conditional expression is constant warning #2210 (#2211) 2021-04-07 10:42:11 -07:00
266107f57c constexpr uint128_wrapper (#2215)
* constexpr uint128_wrapper

* change FMT_CONSTEXPR to constexpr

* clang format

Co-authored-by: Jake Staahl <jstaahl@snapchat.com>
2021-04-06 22:07:01 -07:00
2e0d64cf2f specify size for prefixes static data 2021-04-06 17:07:14 -07:00
95da484727 Fix a link 2021-04-03 09:14:52 -07:00
06b3a1000c Add support for time points with arbitrary durations (#2208) 2021-04-02 11:17:14 -07:00
dac42f52b2 Inline fallback is_constant_evaluated 2021-04-01 10:42:09 -07:00
7c43f8b896 Don't use strlen at compile time (#2205) 2021-04-01 10:04:21 -07:00
c62e4c30f4 Make buffer_appender default-constructible when back_insert_iterator is 2021-04-01 09:52:44 -07:00
0d6b70d96b Install gcc 8 2021-04-01 09:19:36 -07:00
15c10b0c66 Add speech synthesis support 2021-04-01 09:19:36 -07:00
308510eb4f "Use" fwrite result (workaround for warn_unused_result)
Fixes #2185
2021-03-31 08:31:35 -07:00
afe23e7f10 Don't call fileno on NULL file in tests (#2196) 2021-03-30 10:41:12 -07:00
b49af043d7 Remove noexcept from file's move assignment 2021-03-30 09:51:25 -07:00
14848875bf Fix: fmt::ostream cannot be moved while holding buffered data #2197 (#2198)
* Add a test case: move ostream while holding data

* Fix moving ostream while holding data

Co-authored-by: Junliang HU <jlhu@cse.cuhk.edu.hk>
2021-03-30 08:43:26 -07:00
7d8c34018e Update pull_request_template.md 2021-03-30 08:42:11 -07:00
b966afcc7a Remove formattable 2021-03-28 14:21:12 -07:00
ec5315a987 Use strlen when possible in fallback basic_string_view 2021-03-28 08:01:55 -07:00
4f8778bab9 Inline basic_format_args's ctor 2021-03-28 07:32:17 -07:00
e2d87548f8 user-defined constructor
user-defined constructor added to prevent Intel compilers
warnings. According to the standard, objects need to have a
user-defined constructor if instances are delcared const.
2021-03-28 06:56:14 -07:00
f7151d384b Extra flag to prevent Intel compiler with Clang front-end warning of 'unknown attribute no_sanitize' 2021-03-28 06:56:14 -07:00
0fb8ef8f79 Inline trivial argument handling functions 2021-03-27 19:05:39 -07:00
1b23e25f95 Simplify formattability check 2021-03-27 18:57:18 -07:00
35c71ff536 Only use -Og with optimizations disabled 2021-03-27 11:35:01 -07:00
243d8bebd1 Enable minimal optimizations in debug mode 2021-03-27 08:40:07 -07:00
9b34681d97 Work around xl compiler bug when nvcc preprocesses this file (#2190) 2021-03-27 06:05:49 -07:00
4dc7170d21 Fix C++17 builds: (#2192)
- Fix C++17 Visual Studio builds.
- Use C++17 for `windows-2019` builds.
- Removed options for unsupported compiler (MSVC11).
- Removed options, not needed after enabling C++11+ features in gmock/gtest.
2021-03-26 06:19:43 -07:00
9cb347b4b2 Simplify argument formatters 2021-03-21 09:31:46 -07:00
0f85a4683a add default cases (#2186)
Adding default case for switch statements where the compilation
flag -Wswitch-default is present on the command line when spdlog
is included in external projects.

Signed-off-by: Ryan Sherlock <ryan.m.sherlock@gmail.com>
2021-03-19 16:56:52 -07:00
417e1cee9e Stop using deprecated UDL templates 2021-03-19 08:34:55 -07:00
f7e900e12e Simplify UDL definitions 2021-03-19 08:10:58 -07:00
d9661c8f3b Mark grouping as deprecated 2021-03-19 07:54:57 -07:00
14a2a64df4 Fix handling of formattable types with to_string_view (#2181) 2021-03-19 06:43:38 -07:00
6ae402fd0b Fix handling of types with to_string_view and formatter specialization (#2180) 2021-03-18 11:25:43 -07:00
a6408a3b09 Add args-test 2021-03-18 09:04:17 -07:00
1147782c79 Fix an ambiguous call to check caused by ADL (#2184) 2021-03-17 20:59:36 -07:00
VZ
2f3f3862fa Fix harmless MSVS warning about using undefined _MANAGED symbol (#2183)
Since the changes of 1305cbeb (Fix MSVC2019 error C2049 when compiling
with /clr (#1897), 2020-09-23), compiling fmt with MSVS 2019 resulted in

fmt\include\fmt\core.h(180,32): warning C4668: '_MANAGED' is not defined
as a preprocessor macro, replacing with '0' for '#if/#elif'.

when the (disabled by default) warning C4668 was enabled.

Fix this simply by checking if _MANAGED is defined before testing it.
2021-03-17 11:21:50 -07:00
d0bded5988 Fix MSVC /clr builds (#2179) 2021-03-15 08:17:28 -07:00
8308f52c2a Fix dynamic_format_arg_store::push_back comment 2021-03-15 07:10:28 -07:00
6151d0dc1e Fix the comment 2021-03-14 09:26:18 -07:00
5a1127b726 Don't wrap named arg in cref and clarify docs 2021-03-14 09:08:08 -07:00
b8ff3c1820 optimize append (#2164) 2021-03-13 07:21:23 -08:00
c8d8b88223 fix GCC 7,8,9 warning about unused but set parameter (#2177) 2021-03-13 06:36:53 -08:00
d28101878a Document ostream support limitation 2021-03-12 15:49:22 -08:00
bac14ef985 Simplify integer spec checking 2021-03-12 15:02:01 -08:00
8f9db3fcb8 Make ubsan happy on empty format specs (#2175) 2021-03-12 09:13:47 -08:00
af567538a0 Bitpack integral prefixes 2021-03-11 21:22:33 -08:00
cdf877d4b1 Workaround missed optimization opportunity 2021-03-11 16:44:59 -08:00
eef4ba9c02 Optimize integer formatting without padding 2021-03-11 15:47:58 -08:00
a1ea8a82c3 Unbloat my heart 2021-03-11 08:27:53 -08:00
a457e16360 Simplify integer formatter 2021-03-11 08:14:03 -08:00
05bc87a66f Optimize padding 2021-03-10 17:59:36 -08:00
605b603735 Optimize count_digits for powers of 2 2021-03-10 14:48:07 -08:00
85ba271639 Implement 128-bit count_digits in terms of count_digits_fallback 2021-03-10 12:57:46 -08:00
d9835737f0 spec -> specs 2021-03-10 12:51:03 -08:00
f9e0e90441 Apply clang-format 2021-03-10 12:08:02 -08:00
60f5d24411 Simplify arg_formatter 2021-03-10 09:35:48 -08:00
30e1302e73 Simplify on_format_specs 2021-03-10 08:46:16 -08:00
87c5cd46ac Optimize parsing of argument ids 2021-03-10 07:04:04 -08:00
6a9016ea60 fix formatted_size with "compiled format" as argument (#2161) 2021-03-07 06:44:36 -08:00
6e1fc01752 Move detail::truncating_iterator to fmt/compile.h 2021-03-06 08:35:36 -08:00
e718ec3e93 Make truncating_iterator an output_iterator (#2158) 2021-03-04 15:53:08 -08:00
772aeca338 Don't include <cassert>. (#2148) (#2152)
* Don't include <cassert>. (#2148)

This commit replaces use of the assert() macro in format-inl.h with
FMT_ASSERT(). This allows us to drop the cassert include.

* FMT_GCC_VERSION is not defined when we include test-assert.h, use __GCC__ instead.

* Don't explicitly suppress GCC's -Wterminate in tests' FMT_ASSERT.

Throwing from a separate function is enough to silence the warning, no need to
explicitly suppress it.

* Remove messages from assertions added in 2f699d2.

* Correct formatting around throw_assertion_failure().
2021-03-04 07:28:04 -08:00
684b5b0e40 Fix fallback to runtime API from compile-time API (#2143)
* fix fallback to the runtime API, add FMT_ENABLE_FALLBACK_TO_RUNTIME_API define, add test

* remove `FMT_ENABLE_FALLBACK_TO_RUNTIME_API`

* pass format string to format_to() inside format_to_n() in compile-time API

instead of compiling it inside format_to_n(), to eliminate code duplication
2021-03-04 07:20:57 -08:00
d8b9254301 use simplified void_t for all compilers other than gcc 4.x (#2160) 2021-03-02 14:42:27 -08:00
835b910e7d Add an is_formattable trait 2021-02-28 15:25:33 -08:00
578874033a Revert "Optimize handling of integer constants" (#2147)
This reverts commit 2797588be1.
2021-02-25 05:58:58 -08:00
640acba850 Print x.what() of FMT_THROW when exception is disabled (#2145)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2021-02-24 06:29:04 -08:00
d8e1c9f175 fix fmt::get for some GCC versions and legacy Clang (#2144)
fixes https://github.com/fmtlib/fmt/issues/2140

- some GCC versions decay function pointers to `const void*`, exactly like
  MSVC does
- legacy Clang (prior to 7.0) treats function pointers also as `const T*`
  pointers, but unable to convert them
2021-02-23 07:18:30 -08:00
2797588be1 Optimize handling of integer constants 2021-02-21 11:11:57 -08:00
e8eff3b8fd Fix FMT_STATIC_THOUSANDS_SEPARATOR (#2142) 2021-02-21 07:42:12 -08:00
ab0f7d7fdc use const& for arguments 2021-02-20 11:50:12 -08:00
29cc8282b1 update chrono duration formatter (constness), use it in compile-test for specs checks 2021-02-20 11:50:12 -08:00
3f69af3aaf update wording in the error inside arg_id_handler, use FMT_ASSERT instead of throw 2021-02-20 11:50:12 -08:00
499047e132 fix incorrect indexing mode for named args, update tests 2021-02-20 11:50:12 -08:00
78c67157c1 prepare tests, fix incorrect handling of named args with simple {} replacement fields 2021-02-20 11:50:12 -08:00
b31bc2dc9f simplify try_format_argument(), make manual_indexing_id() a variable 2021-02-20 11:50:12 -08:00
95e1aa2dc5 add support for manual indexing and named fields, add tests 2021-02-20 11:50:12 -08:00
7e72673d87 Improve width estimation (#2033) 2021-02-13 09:30:29 -08:00
13b117b5bc Improve code point computation 2021-02-13 08:46:19 -08:00
ee0fed639c Fix handling of the + flag with locales (#2133) 2021-02-13 07:08:01 -08:00
c5979d564e Fix fmt::localtime formatting not working in wide-char string contexts 2021-02-13 06:53:30 -08:00
e6ef927e6b fmt::ptr: Support function pointers (#2131)
Passing a function pointer to fmt::ptr results in:

 In file included from /home/mac/git/fmt/test/gmock/gmock.h:238,
                  from /home/mac/git/fmt/test/format-test.cc:31:
 .../fmt/test/format-test.cc: In member function ‘virtual void FormatterTest_FormatPointer_Test::TestBody()’:
 .../fmt/test/format-test.cc:1486:56: error: no matching function for call to ‘ptr(void (&)(int, double, std::__cxx11::string))’
              format("{}", fmt::ptr(function_pointer_test)));

with GCC and Clang. Let's add an overload to support that usage.

Unfortunately, MSVC would
consider the overload to be ambiguous for unknown reasons:

 D:\a\fmt\fmt\test\format-test.cc(1485,1): error C2668: 'fmt::v7::ptr': ambiguous call to overloaded function [D:\a\fmt\build\test\format-test.vcxproj]
 D:\a\fmt\fmt\include\fmt/format.h(3742,60): message : could be 'const void *fmt::v7::ptr<void,int,double,std::string>(T (__cdecl *)(int,double,std::string))' [D:\a\fmt\build\test\format-test.vcxproj]
           with
           [
               T=void
           ]
 D:\a\fmt\fmt\include\fmt/format.h(3735,42): message : or       'const void *fmt::v7::ptr<void(int,double,std::string)>(T (__cdecl *))' [D:\a\fmt\build\test\format-test.vcxproj]
           with
           [
               T=void (int,double,std::string)
           ]
 D:\a\fmt\fmt\test\format-test.cc(1486,1): message : while trying to match the argument list '(overloaded-function)' [D:\a\fmt\build\test\format-test.vcxproj]

but luckily this means that the overload is unnecessary in that case
anyway, so we can just make it conditional.
2021-02-09 07:35:16 -08:00
58aa04573f Fix ordering of install commands for CMake (#2122)
the library itself needs to be installed before
the fmt-targets.cmake file is installed,
otherwise the installed targets file doesn't
actually point to the library using
IMPORTED_LOCATION
2021-01-30 09:03:55 -08:00
1980ca8c4e fix #2118: FMT_COMPILE did not work with tm formatter (#2119)
Co-authored-by: summivox <summivox@github.com>
2021-01-30 08:44:49 -08:00
2a25e2bf4d Make ranges-test available with C++11 (#2114)
* make ranges-test available with C++11, fix problem with some gcc versions

* potentially fix build for MSVC 19.10, a bit reorganizing in test
2021-01-30 07:42:58 -08:00
b0b56b4379 fix #2116 (FMT_COMPILE requires exceptions enabled) (#2117)
Co-authored-by: summivox <summivox@github.com>
2021-01-28 06:58:49 -08:00
373262f9fb Update docs 2021-01-24 09:11:44 -08:00
ce519e939b Fix exception propagation from iterators (#2097) 2021-01-23 17:27:24 -08:00
acef0bb51a use gcc-10.2 instead of gcc-10.1 on CI, also fix one problem (#2110)
the problem was not detected by test because of wrong gcc-10 minor version on CI
2021-01-23 07:52:41 -08:00
8bf28e6bb1 Add support for s format specifier to bool (#2094) (#2109) 2021-01-23 07:32:41 -08:00
9c418bc468 Update README.rst 2021-01-21 07:45:34 -08:00
456efa4666 add missing detail namespace (#2107)
Co-authored-by: Walter Gray <walter.gray@getcruise.com>
2021-01-19 17:44:15 -08:00
80dc7cceb8 Fixed format.h(1465): warning C4702: unreachable code (#2106)
* Fixed format.h(1465): warning C4702: unreachable code

* Fixed format.h(1416): warning C4702: unreachable code
2021-01-19 17:13:10 -08:00
7fd535c6ae Cleanup 'L' handling 2021-01-18 07:57:38 -08:00
b4b8917caf Update docs 2021-01-17 09:36:06 -08:00
e4f2cf455e Make 'L' a modifier 2021-01-17 09:28:46 -08:00
6972b5f3d2 Add build variable: FMT_MASTER_PROJECT (#2100) 2021-01-16 16:56:49 -08:00
ac35208115 Install fmt/args.h (#2096) 2021-01-16 08:13:38 -08:00
532e846b86 Fix width computation in float formatter 2021-01-15 11:07:55 -08:00
f8c2f8480a Fix handling of width when formatting int as char 2021-01-14 08:41:17 -08:00
0fe0b15e71 Fix handling of # in width computation 2021-01-13 16:48:07 -08:00
061e364b25 Document output_file 2021-01-09 07:18:56 -08:00
018688da2a Correct a typo on syntax.rst (documentation) (#2081) 2020-12-31 16:23:42 -08:00
9ec5592bb5 Fix writing to stdout when redirected to NUL on Windows (#2080) 2020-12-30 13:23:37 -08:00
cdc5ef6710 Remove fallback to inline specifier from FMT_CONSTEXPR(20) macro (#2075) 2020-12-30 06:23:20 -08:00
c9dd1eb97d Don't change charset 2020-12-27 07:44:02 -08:00
d09b5c1453 Fix std::byte formatting with compile-time API (#2072)
* add test for byte formatting with `FMT_COMPILE`

* fix byte formatting with `FMT_COMPILE`, use `__cpp_lib_byte` macro

* use is not custom mapped type check

* workaround MSVC bug
2020-12-27 07:23:28 -08:00
bbd6ed5bc5 Add support of most format_specs for formatting at compile-time (#2056) 2020-12-25 06:40:03 -08:00
a750bf3ac6 Update api.rst 2020-12-24 07:09:49 -08:00
1256541d7a Fix formatting 2020-12-24 07:07:15 -08:00
4fa4c9248f Add tests for FMT_ENFORCE_COMPILE_STRING, fix several errors (#2038) 2020-12-24 06:40:46 -08:00
aa89e380d9 add cwchar to format.h for std::fputws (#2073) 2020-12-23 07:02:25 -08:00
5a37e182de Disable warning about format string (#2067)
Reported by MinGW/GCC 10
2020-12-21 08:43:30 -08:00
fa43fd1444 Forward arguments to work with views (#2068) 2020-12-20 07:14:54 -08:00
3551f5d118 Workaround a gcc 10 -Warray-bounds bug (#2065) 2020-12-19 09:34:43 -08:00
e737672614 Remove an old mingw workaround (#2059) 2020-12-10 06:36:04 -08:00
25a41b80fc Fix a link to Android.mk (#2057) 2020-12-09 08:04:58 -08:00
9293f7072e Suppress gcc warning on privates-only class (#2053)
Since gcc 9 it warns about is_streamable to have only private methods.
Add explicit default ctor instead of suppression
2020-12-09 06:55:17 -08:00
c20874c28f Reenable support for fallback formatter in join (#2040) (#2050) 2020-12-08 08:56:53 -08:00
5de0bc1d4f Add UDL as replacement for FMT_COMPILE (#2043) 2020-12-07 15:53:11 -08:00
a6fafe2f01 docs: use https for some links (#2051) 2020-12-05 06:41:38 -08:00
33f9a6d360 Fix handling of enums in to_string (#2036) 2020-12-03 15:18:33 -08:00
aabe0a8473 simplify tests by reordering arguments of EXPECT_EQ (#2044) 2020-12-03 14:21:23 -08:00
1f4a76d2c8 Add a missing include (#2047) 2020-12-03 14:17:09 -08:00
4a6eadbde0 Make std::byte formattabe (#1981) 2020-12-03 08:59:07 -08:00
683a74501f fix formatting with empty compiled format string (#2042) 2020-12-02 07:14:57 -08:00
f43416e1d7 Add a link to contents from index 2020-12-02 06:30:09 -08:00
5a493560f5 Move some code from core.h to format.h where it is used 2020-11-29 09:45:15 -08:00
9ed0a98178 Fix docs build 2020-11-29 09:33:09 -08:00
dac753b81e Basics of formatting at compile-time based on compile-time API (#2019) 2020-11-29 08:59:11 -08:00
119f7dc3d6 Truncate file by default 2020-11-27 08:15:14 -08:00
22a68d1613 Don't emit trailing zeros by default 2020-11-27 07:45:54 -08:00
d0110b7e35 Update README.rst 2020-11-26 19:51:31 -08:00
3f4839ce3d Merge branch 'release' of github.com:fmtlib/fmt 2020-11-25 06:41:05 -08:00
7bdf0628b1 Update version 2020-11-24 17:15:02 -08:00
fc1355114d Update changelog 2020-11-24 17:14:00 -08:00
926233bde8 Fix test 2020-11-24 14:54:15 -08:00
0683fa7d1d Bump version 2020-11-24 08:36:21 -08:00
6ce207b9a5 Fix formatting 2020-11-24 08:29:17 -08:00
07b1c1a15f Update changelog 2020-11-24 08:24:14 -08:00
58992761cf Reintroduce ostream support to range formatters (#2014) 2020-11-24 08:22:29 -08:00
b8957f50c3 Fix an overflow in format_to_n (#2029) 2020-11-24 08:22:12 -08:00
df66516ed3 Workaround an issue with mixing std versions in gcc (#2017) 2020-11-24 08:21:10 -08:00
a57baa69a5 Fix more linkage errors (#2011) 2020-11-24 08:17:31 -08:00
85534a1397 Fix linkage errors when linking with a shared library (#2011) 2020-11-24 08:15:59 -08:00
a2fa5d6288 Update changelog 2020-11-23 10:35:07 -08:00
cd3003683d Fix more linkage errors (#2011) 2020-11-23 10:34:27 -08:00
d1ef29d679 Fix initialization of iterator_buffer (#1996) 2020-11-23 10:28:35 -08:00
5f41bb0f77 clang-format 2020-11-23 10:23:54 -08:00
a58a6b27c3 Add a newline 2020-11-21 16:52:40 -08:00
a036cc97b7 Reintroduce ostream support to range formatters (#2014) 2020-11-21 16:31:22 -08:00
38c7def47a Update clang version to 3.4 since there are ICEs on earlier ones 2020-11-19 10:37:43 -08:00
5533641319 🆕 [CI] Test with C++14 in Windows 2019 (#2020)
Problem:
- Both Windows builds test C++14

Solution:
- Use C++11 for `windows-2016` builds and C++14 for `windows-2019`
  builds.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-19 06:04:16 -08:00
55dfdd9299 Update README.rst 2020-11-18 07:33:38 -08:00
2c734c9bca Fix an overflow in format_to_n (#2029) 2020-11-18 06:50:43 -08:00
6cdd1be93e Update build.gradle for latest AGP (#2026)
* update build.gradle for latest AGP

* bump Android Gradle Plugin version to 4.1.1
* ignore .cxx which was externalNativeBuild in old versions

Use variable 'rootDir' instead of using relative path.

* build.gradle copies AAR files to libs/
2020-11-17 06:31:06 -08:00
bcc20b29df Implement compile-time checks by default 2020-11-15 17:24:36 -08:00
befd7d4a2f Always use FMT_STRING internally where possible [Issue #2002] (#2006)
Co-authored-by: Walter Gray <walter.gray@getcruise.com>
2020-11-15 05:19:06 -08:00
f8640d4050 Add more standards 2020-11-14 12:02:46 -08:00
f81c14aa1e Workaround an issue with mixing std versions in gcc (#2017) 2020-11-14 11:41:51 -08:00
5555651ce0 Fix more linkage errors (#2011) 2020-11-14 06:06:10 -08:00
b268f8815d detail::write in one more place relevant to printf with long argument… (#2016) 2020-11-13 12:14:16 -08:00
aa9b09a9e3 🐛 Cannot call non-constexpr function in constexpr context (#2010)
Problem:
- gcc-8 gives the following error when compiling this function on all
  standards:
    test/std-format-test.cc: In member function 'constexpr auto std::formatter<S>::parse(std::format_parse_context&)':
    test/std-format-test.cc:112:17: error: call to non-'constexpr' function 'int isdigit(int)'
        if (!isdigit(c) || (++iter, get_char()) != '}')
         ~~~~~~~^~~

Solution:
- Write a `constexpr` version of `isdigit` for use in this function.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-12 10:10:52 -08:00
986fa00406 Printf get container (#1982)
* eliminate one case where basic_print_context would copy a string into a fmt::basic_memory_buffer character by character instead of using fmt::basic_memory_buffer::append

* use detail::write instead of re-implementing it

* use to_unsigned to avoid signedness conversion warnings
2020-11-12 08:37:04 -08:00
7abc3c01e0 Suppress a useless warning (#2004) 2020-11-12 08:18:28 -08:00
6d14f78115 Fix linkage errors when linking with a shared library (#2011) 2020-11-12 06:11:17 -08:00
9534b9fe69 Refactor warning suppression 2020-11-12 05:45:36 -08:00
60dc273513 Simplify on_text 2020-11-11 15:13:44 -08:00
b5dac0f0f8 Reduce <algorithm> usage (#1998) 2020-11-11 09:12:15 -08:00
a07627b1f8 🐛 Implicit sign conversion warning in clang in c++17 and 20 modes (#2009)
Problem:
- On Apple clang version 11.0.3 (clang-1103.0.32.62) in C++17 and C++20
  mode, clang 11.0.0 in C++17 and C++20 mode, and clang 9.0.1 in C++17
  mode, the following error is generated:

    In file included from test/compile-test.cc:16:
    include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
      return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
                     ~  ~~~~^~~~~~~~~~~~
    include/fmt/compile.h:538:31: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_specs<int, char>' requested here
          constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
                                  ^
    include/fmt/compile.h:569:17: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int>, 0, 0, FMT_COMPILE_STRING>' requested here
            detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
                    ^
    include/fmt/compile.h:648:37: note: in instantiation of function template specialization
          'fmt::v7::detail::compile<int, FMT_COMPILE_STRING, 0>' requested here
      constexpr auto compiled = detail::compile<Args...>(S());
                                        ^
    test/compile-test.cc:140:24: note: in instantiation of function template specialization
          'fmt::v7::format<FMT_COMPILE_STRING, int, 0>' requested here
      EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42));
                           ^
    In file included from test/compile-test.cc:16:
    include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
      return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
                     ~  ~~~~^~~~~~~~~~~~
    include/fmt/compile.h:538:31: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_specs<char [4], char>' requested here
          constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
                                  ^
    include/fmt/compile.h:494:27: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, FMT_COMPILE_STRING>'
          requested here
        constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
                              ^
    include/fmt/compile.h:539:14: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_tail<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, fmt::v7::detail::spec_field<char, int, 0>, FMT_COMPILE_STRING>' requested here
          return parse_tail<Args, result.end, result.next_arg_id>(
                 ^
    include/fmt/compile.h:569:17: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 0, 0, FMT_COMPILE_STRING>'
          requested here
            detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
                    ^
    include/fmt/compile.h:648:37: note: in instantiation of function template specialization
          'fmt::v7::detail::compile<int, int, char const (&)[4], int, FMT_COMPILE_STRING, 0>' requested here
      constexpr auto compiled = detail::compile<Args...>(S());
                                        ^
    test/compile-test.cc:145:18: note: in instantiation of function template specialization
          'fmt::v7::format<FMT_COMPILE_STRING, int, int, char const (&)[4], int, 0>' requested here
                fmt::format(FMT_COMPILE("{:{}}{:{}}"), 42, 4, "foo", 5));
                     ^
    2 errors generated.

Solution:
- Explicitly cast the result of the subtraction to the (unsigned) outer
  type.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-11 07:57:52 -08:00
1b8f499ee1 🔧 Silence useless cast warnings (#2008)
Problem:
- gcc-10 is generating the following warning at all standards:

    test/format-test.cc: In member function 'virtual void UtilTest_BitCast_Test::TestBody()':
    test/format-test.cc:108:42: error: useless cast to type 'uint64_t' {aka 'long long unsigned int'} [-Werror=useless-cast]
      108 |   s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
          |                                          ^~~~~~~~~~~~~~~
- gcc-8 is generating the following warning at all standards:
    test/format-test.cc: In member function 'virtual void UtilTest_BitCast_Test::TestBody()':
    test/format-test.cc:108:56: error: useless cast to type 'uint64_t' {aka 'long long unsigned int'} [-Werror=useless-cast]
       s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
                                                        ^
Solution:
- Cast 0 to a 64 unsigned bit int and then invert.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-11 07:56:59 -08:00
f428d286a1 Update README.rst 2020-11-11 07:11:43 -08:00
beb248b6ac Optimize handling of large format strings 2020-11-11 06:11:05 -08:00
1936dddc3c fix gcc warning of missing override (#2001)
Co-authored-by: Lieven de Cock <killerbot@linux-2x3u.suse>
2020-11-10 07:57:21 -08:00
14f6bd0f4e Move one more headers to args.h 2020-11-09 20:35:03 -08:00
e01d26e1a4 Optimize includes 2020-11-09 16:34:54 -08:00
e528d919a8 Merge branch 'master' of github.com:fmtlib/fmt 2020-11-08 12:45:15 -08:00
4881677268 Update signatures 2020-11-08 12:29:26 -08:00
3302fd1088 use memchr for searching for '%' in printf format string (#1984) 2020-11-08 10:36:00 -08:00
4c2d637203 Update signatures 2020-11-08 10:10:44 -08:00
beaff39618 Update signatures 2020-11-08 10:00:08 -08:00
ffa0a0834a Use newer versions of Sphinx and Breathe 2020-11-08 09:46:27 -08:00
038057eb3e Document contexts 2020-11-08 08:16:23 -08:00
5bedcb665b Fix initialization of iterator_buffer (#1996) 2020-11-08 08:08:55 -08:00
2435ea4113 Workaround MSVC mess 2020-11-08 07:48:03 -08:00
8c6215f5de Fix fmt/color.h 2020-11-08 07:24:07 -08:00
10ebe6cb48 Document color 2020-11-08 07:18:01 -08:00
1ac50fcb5a Suppress more bogus warnings 2020-11-08 07:04:42 -08:00
e098be8e88 Fix warning filtering 2020-11-08 06:58:41 -08:00
8cf0afaf1c Improve docs 2020-11-08 06:48:34 -08:00
e29f93e8a8 Suppress more bogus warnings 2020-11-08 06:33:42 -08:00
4e8d000f76 Suppress more bogus warnings 2020-11-08 06:29:50 -08:00
7787792e8d Fix re usage 2020-11-08 06:20:53 -08:00
6ee5e507c7 Fix imports 2020-11-08 06:16:49 -08:00
06ee32d1b5 Filter useless doxygen warnings 2020-11-08 06:13:56 -08:00
86bb7fe614 Add a missing import 2020-11-08 05:55:49 -08:00
959a9f5cad Merge branch 'master' of github.com:fmtlib/fmt 2020-11-08 05:50:48 -08:00
4f7df299ea Improve docs 2020-11-08 05:40:39 -08:00
b3ab0bc7e3 🎨 [CI] Specify the exact version of clang to use (#1991)
Problem:
- The version of clang to use is specified only as `clang++`. This is
  inconsistent with the specifications for gcc and exposed to unexpected
  failure if the default changes.

Solution:
- Specify the exact version of clang to use. I chose `clang++-9` as that
  is the version that `clang++` is currently resolving to.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-08 05:18:24 -08:00
701ed6c874 Install deps in github actions instead of script 2020-11-07 11:16:38 -08:00
8f2131cf2d Document chrono 2020-11-07 10:51:08 -08:00
32c4af8f0d Document chrono 2020-11-07 10:38:51 -08:00
295a60ec8d Document chrono 2020-11-07 10:30:23 -08:00
a4fae96c96 Document chrono 2020-11-07 10:24:27 -08:00
263bb0e68d Document chrono 2020-11-07 10:19:40 -08:00
0506b328b5 Document chrono 2020-11-07 09:59:57 -08:00
4e426c19d0 Document chrono 2020-11-07 09:47:56 -08:00
9795d87348 Update docs 2020-11-07 09:27:06 -08:00
2eb0be0b73 Remove debug code and fix bot contact 2020-11-07 09:16:55 -08:00
cd95579834 Move less installation to actions 2020-11-07 09:12:54 -08:00
98639d0f6f Debug doc build 2020-11-07 09:04:07 -08:00
ab5e0632fe Debug doc build 2020-11-07 08:54:58 -08:00
b123129f4e Dump the content of html dir 2020-11-07 08:42:13 -08:00
81d2b986af Print less command 2020-11-07 08:24:58 -08:00
7a0b1d5781 Add key 2020-11-07 08:09:01 -08:00
9f0617cbfb Fix branch ref 2020-11-07 08:04:01 -08:00
75b07598fe Chrono docs 2020-11-07 07:56:53 -08:00
dfbb6975b3 Remove travis config 2020-11-07 07:38:20 -08:00
5b3052f999 Switch doc build to github actions 2020-11-07 07:31:15 -08:00
506ff320f2 Fix build failure when not using fcntl with -Werror (#1990) 2020-11-06 15:39:59 -08:00
a30b279bad Apply clang-format and tweak comments 2020-11-04 17:17:23 -08:00
6a2495c840 -Wattributes visibility warning with some GCC versions (#1975) 2020-11-04 17:11:31 -08:00
cba5970cd8 Remove migrated build configs 2020-11-04 10:03:00 -08:00
689081d832 Merge branch 'release' of github.com:fmtlib/fmt 2020-11-04 07:46:02 -08:00
cc09f1a679 Update version 2020-11-04 06:50:09 -08:00
e4eb242ce8 Update changelog and bump version 2020-11-03 21:20:53 -08:00
ce98e0c6a0 Fix fallback float formatter at assymetric bounds (#1976) 2020-11-03 21:18:04 -08:00
49544ea943 Fuzz fallback formatter 2020-11-03 19:34:35 -08:00
6b7bfed40c Fix fallback float formatter at assymetric bounds (#1976) 2020-11-03 19:19:10 -08:00
bcab36da3f Update CI config 2020-11-03 16:01:26 -08:00
1689e73e90 Move PR template 2020-11-03 14:52:47 -08:00
0103408a5c Update CI config 2020-11-03 14:39:43 -08:00
38a16ecba2 Move build config to github actions 2020-11-03 13:35:37 -08:00
205eb3a8f2 Update CI config 2020-11-03 13:27:15 -08:00
fe61b8c630 Update CI config 2020-11-03 11:59:59 -08:00
867b15d77c Update CI config 2020-11-03 11:48:20 -08:00
98cb9f9931 Update CI config 2020-11-03 11:43:00 -08:00
95077d60c9 Update CI config 2020-11-03 11:41:25 -08:00
bc49f094e7 Update CI config 2020-11-03 11:02:49 -08:00
cef6dfb422 Update CI config 2020-11-03 10:46:03 -08:00
c8703ba40b Update CI config 2020-11-03 10:45:16 -08:00
ab4405bea5 Update README.rst 2020-11-03 10:42:06 -08:00
78a55e2898 Update CI config 2020-11-03 10:37:30 -08:00
d0a2494a99 Update cmake.yml 2020-11-03 10:17:38 -08:00
89d009ba6e Update cmake.yml 2020-11-03 10:14:38 -08:00
1f4ff47b41 Create cmake.yml 2020-11-03 10:04:28 -08:00
eb52ac7a35 🆕 Enable -Wshadow in pedantic mode
Problem:
- All `-Wshadow` warnings are fixed but there is nothing stopping them
  from being reintroduced.

Solution:
- Fail pedantic builds on `-Wshadow` warnings. This allows CI to prevent
  reoccurrence of the warning.

Notes:
- Not enabling `-Wshadow` for gcc versions 4 or lower because the
  warning is much more aggressive there to the point that it's mostly
  just noise.
2020-11-03 07:30:27 -08:00
e904e891bd 🎨 🐛 Rename all shadowed types and variables 2020-11-03 07:30:27 -08:00
771292c328 Remove sizeof from unused variable silencer (#1974)
Using sizeof causes some compilers to complain:
'operand of sizeof is not a type, variable, or dereferenced pointer'

static_cast itself should be enough to silence unused variable warning

Co-authored-by: Łukasz Mitka <lukasz.mitka@aptiv.com>
2020-11-03 06:48:19 -08:00
86bf6045c6 Merge branch 'release' of github.com:fmtlib/fmt 2020-11-02 06:27:49 -08:00
5f7f7b954d Update version 2020-11-01 06:30:39 -08:00
5d3f0741e3 Update changelog and bump version 2020-11-01 06:28:06 -08:00
563cbb6c21 Add a macro to workaround clang/gcc ABI incompatibility on ARM 2020-11-01 06:10:04 -08:00
425778aa67 Fix ABI compatibility (#1961) 2020-11-01 06:09:31 -08:00
69a84198b0 Remove accidental parenthesis (#1968)
fails only when FMT_BUILTIN_CTZLL is not defined
2020-11-01 06:09:25 -08:00
5c04504932 Removed [-Wsign-conversion] warning in GCC 2020-11-01 06:09:11 -08:00
556a1cfb34 Instantiate to_decimal to make gcc lto happy (#1955) 2020-11-01 06:08:57 -08:00
28a8eae850 Cleanup 2020-11-01 06:08:50 -08:00
236fea1f00 Workaround bugs in gcc 8 2020-11-01 06:08:28 -08:00
e50ced88c6 Add a macro to workaround clang/gcc ABI incompatibility on ARM 2020-10-31 07:52:08 -07:00
112755cf91 Remove FMT_SAFEBUFFERS (#1966) 2020-10-29 17:42:45 -07:00
4081b2fe94 Fix ABI compatibility (#1961) 2020-10-29 11:29:47 -07:00
2d9311e860 Remove accidental parenthesis (#1968)
fails only when FMT_BUILTIN_CTZLL is not defined
2020-10-29 07:08:06 -07:00
b3a4f28ad1 Fix implicit signedness conversion warning (#1963)
Problem:
- On Apple clang 11.0.3 (clang-1103.0.32.62), pedantic mode compilation
  generates the following error:

    test/std-format-test.cc:114:22: error: implicit conversion changes
          signedness: 'int' to 'size_t' (aka 'unsigned long')
          [-Werror,-Wsign-conversion]
        width_arg_id = c - '0';
                     ~ ~~^~~~~

Solution:
- Use a `to_unsigned` to make the conversion explicit. This is
  guaranteed to be safe due to the check before the ASCII-to-int
  conversion.
2020-10-29 06:26:18 -07:00
97c8873214 Allocator::max_size support in basic_memory_buffer (#1960) 2020-10-29 06:17:00 -07:00
bb68f6089b Removed [-Wsign-conversion] warning in GCC 2020-10-28 06:02:17 -07:00
f4ca065cfb Range support 2020-10-28 05:35:37 -07:00
cb224ecaa3 Instantiate to_decimal to make gcc lto happy (#1955) 2020-10-27 07:46:40 -07:00
7977c2b4d0 Cleanup 2020-10-27 07:19:28 -07:00
e54eb67639 Workaround bugs in gcc 8 2020-10-27 06:11:31 -07:00
4fe0b11195 Update version 2020-10-25 10:44:22 -07:00
df4bd60f42 Bump version 2020-10-25 10:43:03 -07:00
764fb35e1f Always install the required version of breathe 2020-10-25 10:34:47 -07:00
e1bdc0ecaf Use the correct version of sphinx 2020-10-25 09:52:21 -07:00
39bde329bd Tweak markup 2020-10-25 09:19:38 -07:00
204d299abb Tweak markup 2020-10-25 09:12:22 -07:00
e0995b1c14 Update readme 2020-10-25 09:04:39 -07:00
4af178bdfe Remove outdated build config 2020-10-25 09:01:44 -07:00
aa41dc02b1 Remove unused script 2020-10-25 09:00:25 -07:00
6a77ea3c93 Tweak markup 2020-10-25 08:59:36 -07:00
62c72059d9 Update changelog 2020-10-25 08:56:46 -07:00
c10e3f7f4f Update changelog 2020-10-25 07:29:24 -07:00
e542e6953e Update changelog 2020-10-25 06:46:45 -07:00
530cf316b8 Point to the release, not dev documentation 2020-10-24 12:02:12 -07:00
740385d636 Update changelog 2020-10-24 11:18:33 -07:00
cd4651116e Update changelog 2020-10-24 09:24:47 -07:00
46291be348 Update changelog 2020-10-23 07:38:01 -07:00
90071c1df0 Update ChangeLog.rst 2020-10-22 09:30:27 -07:00
25293d7ac6 Update ChangeLog.rst 2020-10-22 09:28:23 -07:00
5024742f8a Update ChangeLog.rst 2020-10-22 09:27:49 -07:00
0452a4e71f Update changelog 2020-10-22 09:08:30 -07:00
8de96817ce Woraround bugs in gcc 8 2020-10-22 07:33:32 -07:00
47e167679a Simplify arg formatter 2020-10-21 19:04:02 -07:00
f0a42346a4 Move parsing optimization one level up 2020-10-21 18:18:53 -07:00
86287b8d56 Optimize common case in parse_format_specs 2020-10-21 17:16:58 -07:00
8924211f3b Update README.rst 2020-10-21 14:02:55 -07:00
525e7649cf Update CONTRIBUTING.md 2020-10-21 14:02:33 -07:00
0ecb3d1829 Optimize alignment parsing 2020-10-21 12:45:11 -07:00
9755307842 Optimize format_uint 2020-10-21 08:19:21 -07:00
7446818f98 Simplify vformat_to 2020-10-21 07:15:11 -07:00
280b5612c0 Add option to force usage of inline namespaces
Detection of inline namespaces is imperfect as some compilers
don't provide __has_feature

This option allows to override it if needed.
2020-10-21 06:38:59 -07:00
e57ec7d563 Merge vformat_to overloads 2020-10-20 17:39:50 -07:00
2a3f4de3f4 Remove iterator_category 2020-10-20 16:44:49 -07:00
27fdb4ead2 Unshadow floaty 2020-10-20 15:05:00 -07:00
297e0bad8c Apply clang-format 2020-10-20 14:10:28 -07:00
e3b4c22ec9 Simplify is_output_iterator 2020-10-20 14:09:57 -07:00
da8278e1e3 Update changelog and bump version 2020-10-19 14:37:14 -07:00
17fba753c4 added position independent documentation (#1939)
* added position independent documentation

* suggested fixes to usage

* linebreaks

Co-authored-by: Adnan Yunus <adnan@opus.ai>
2020-10-19 14:20:54 -07:00
71e705a273 Update README.rst 2020-10-19 08:54:55 -07:00
74654c8cbb Fix compilation for systems without fcntl.h (#1942)
Co-authored-by: darklukee <no-reply@hidden>
2020-10-19 07:43:06 -07:00
f468b203ad Avoid conversion from long long to size_t (#1935) 2020-10-18 09:25:33 -07:00
20d4f2e836 Fix handling of weird character types when parsing sign (#1932) 2020-10-17 09:40:30 -07:00
08370c39ff Update README.rst 2020-10-17 08:27:21 -07:00
bd3c792507 Fix float fuzzer 2020-10-16 07:35:53 -07:00
8d3fd86d6d Merge branch 'master' of github.com:fmtlib/fmt 2020-10-16 07:35:02 -07:00
4034715713 Update README.rst 2020-10-16 06:47:16 -07:00
37d738fa6b Update README.rst 2020-10-16 06:46:39 -07:00
271eff149f Make classes derived from buffer<T> final to silence the virtual destructor warning. (#1937)
Co-authored-by: Bart Siwek <bsiwek@cisco.com>
2020-10-15 17:41:56 -07:00
010efc310f Add float fuzzer and cleanup 2020-10-14 20:13:09 -07:00
811c8b58c5 Add float fuzzer and cleanup 2020-10-14 07:39:51 -07:00
82c4e2236a Cleanup fuzzing 2020-10-13 09:08:04 -07:00
63e40c9614 Fix naming of fuzzers 2020-10-12 16:48:25 -07:00
2f448ed565 Fix fuzzer timeouts 2020-10-12 16:46:21 -07:00
af28305961 Cleanup 2020-10-11 10:13:42 -07:00
48ea8193df Explain why assert-test is a separate test 2020-10-11 10:13:42 -07:00
1d112bdd1e Remove old test 2020-10-11 10:13:42 -07:00
5eb292a653 Update README.rst 2020-10-11 09:57:21 -07:00
7e56b6b6cb Fix coding style and remove duplicate fuzzer 2020-10-11 08:07:52 -07:00
41d97e1ef4 Fix a UB on ridiculously large precision 2020-10-11 08:07:52 -07:00
01c37e0a4b Added check for -mbig-obj and ref qualifier check (#1929)
* Added check whether mingw has -mbig-obj flag
* Removed ref qualifiers
2020-10-11 07:49:54 -07:00
a5e7e7db95 Fix handling of thousand separator (#1927) 2020-10-10 07:23:36 -07:00
bf19051a9f Optimize floating point formatting 2020-10-09 15:29:56 -07:00
3c13a88b14 Optimize floating point formatting 2020-10-09 11:01:01 -07:00
f6d75c534c Refactor write_float 2020-10-09 09:11:39 -07:00
e9c0b2d69e Merge write_float overloads 2020-10-08 20:00:38 -07:00
7eddbfed53 Cleanup exponent handling in write_float 2020-10-07 15:58:43 -07:00
b347b3023f Update dynamic_formatter comment (#1923) 2020-10-07 12:15:07 -07:00
3541880efd Fix integer overflow when using max int precision 2020-10-07 11:27:02 -07:00
7b50dc0b24 Don't exclude all detail symbols from docs 2020-10-07 09:07:39 -07:00
2805243103 Fix the doc config 2020-10-07 08:11:59 -07:00
34f22e88a1 Cleanup CMake config 2020-10-07 08:11:42 -07:00
a18b3fbbdc Fix fixed precision handling when rounding (#1917) 2020-10-07 07:42:23 -07:00
7277035736 Fix long lines in usage.md 2020-10-06 06:26:11 -07:00
7612c1ea87 Add reference to lhelper package manager in usage 2020-10-06 06:26:11 -07:00
b91d39f20b Get rid of float_writer 2020-10-05 06:34:04 -07:00
b4b64b9cce Refactor float formatting 2020-10-04 14:44:25 -07:00
712abe40f2 Workaround a bug in gcc 7.5 (#1912)
Thanks Martin Janzen.
2020-10-04 09:20:37 -07:00
af8a180aed Make GetCachedPower test more precise 2020-10-04 08:00:47 -07:00
a581e9e5d8 Fix warning C4018: '<=': signed/unsigned mismatch (#1908) 2020-10-02 06:30:57 -07:00
05a28312cf Update docs 2020-09-30 17:38:28 -07:00
4d0aa4d8fe Update link 2020-09-30 17:21:07 -07:00
575f401896 Simplify FP formatting and follow coding conventions 2020-09-30 06:36:17 -07:00
6f3536f974 Move zero-check to an earlier branch (#1906) 2020-09-29 06:24:53 -07:00
90ef46df0b Fix dragonbox integration 2020-09-28 18:10:46 -07:00
3ae88147e2 Fix declaration 2020-09-28 06:50:09 -07:00
6417952574 Improve dragonbox integration 2020-09-27 20:49:37 -07:00
79694d424c Fix WriteConsole signature 2020-09-27 14:26:28 -07:00
51f2e2ca27 Move nan test to where it belongs 2020-09-27 12:50:18 -07:00
68555fdbd2 Make format-test not depend on color.h 2020-09-27 09:17:57 -07:00
63e0c35412 Make dragonbox::to_decimal available in format.h 2020-09-27 07:27:44 -07:00
2213a7110c Update README.rst 2020-09-26 11:46:39 -07:00
79ba37f3bf Update README.rst 2020-09-26 10:13:04 -07:00
a905d8f704 Merge grisu-test into format-test 2020-09-26 08:23:16 -07:00
762c33a964 Simplify windows handling (#1903) 2020-09-26 08:20:38 -07:00
253d63159f Remove dependency on windows.h (#1900) 2020-09-26 07:03:16 -07:00
c156093ffd Fix carry in fallback_format 2020-09-25 10:12:44 -07:00
34179b3354 Update format.h (#1898) 2020-09-24 08:16:16 -07:00
0651e4598b Minor tweaks to get_cached_power 2020-09-23 16:04:40 -07:00
6c025520aa Test that max_k is correctly defined 2020-09-23 15:44:37 -07:00
51f8d0cc21 Reuse log10_2_significand constant 2020-09-23 13:19:21 -07:00
1305cbeb6f Fix MSVC2019 error C2049 when compiling with /clr (#1897)
'fmt::v7': non-inline namespace cannot be reopened as inline
2020-09-23 09:55:41 -07:00
2d4fde3a2e Don't emit trailing zero for consistency with std::format 2020-09-23 09:19:12 -07:00
5fd89d50e4 Minor simplifications 2020-09-23 08:05:31 -07:00
605ce5e429 Simplify divisible_by_power_of_2 2020-09-22 20:44:29 -07:00
085171e7e6 Remove grisu_count_digits 2020-09-22 19:36:52 -07:00
aa729bf25b Remove dead code 2020-09-22 16:58:02 -07:00
aa2ddf9b86 Simplify Dragonbox integration 2020-09-22 16:20:40 -07:00
c1654ce487 Simplify uint32_or_64_or_128_t definition 2020-09-22 15:08:37 -07:00
33712dc07a Combine pragmas 2020-09-22 14:47:35 -07:00
e5942ac9dd Tweak comments 2020-09-22 14:36:10 -07:00
aae7a1338c Remove unused pragmas 2020-09-22 14:00:41 -07:00
6bcde9aab2 https://github.com/fmtlib/fmt/pull/1882#issuecomment-696823912 (#1894) 2020-09-22 10:33:52 -07:00
bb0db5e51e clang-format 2020-09-22 08:19:37 -07:00
16410056bf Optimize copy_str for counting_iterator 2020-09-22 07:56:09 -07:00
2591ab91c3 MSVC optimizations for count_digits. (#1890)
Changed the clz implementations to use xor instead of subtraction so that when
count_digits "undoes" the BSR -> CLZ translation, the optimizer is more
willing to recognize the equivalence.
Changed the data array in bsr2log10 to static since otherwise MSVC generates
code to build the array every time the function is called.
2020-09-21 11:38:06 -07:00
d5b8002dcb Update README.rst 2020-09-21 09:40:49 -07:00
821471e1d1 qkw: generalizing aliasing | using fmt library and it's features (#1888)
I make extensive use of this library for building qkw targeting linux users. Please add this to your list.
https://github.com/ravijanjam/qkw
2020-09-21 09:39:07 -07:00
2e620ddbcd Small improvements that should have zero to negligible impact on the runtime (#1887) 2020-09-20 09:34:44 -07:00
2f7e08856b Disable range formatter if value type is not formattable (#1885) 2020-09-20 08:37:49 -07:00
c46a8de4e1 Simplify test 2020-09-20 07:24:24 -07:00
2696dc9273 add forgotten template argument to make_format_args which made some u… (#1877)
* add forgotten template argument to make_format_args which made some uses of FMT_COMPILE not work anymore after 54daa0864a, add more elaborate test cases to compile-test as regression tests

* fix old-style cast which gcc on travis thankfully doesn't accept anymore

* hopefully last forgotten (void*)
2020-09-20 06:51:11 -07:00
0016da7ab3 Don't generate zeros and fix UB on huge precision 2020-09-19 16:01:43 -07:00
ce3f76994a Merge intrinsic blocks 2020-09-19 07:54:45 -07:00
3b6248f602 Change formatting 2020-09-19 07:23:41 -07:00
2d9b1dd0ad Fix sign mismatch 2020-09-19 07:23:41 -07:00
1f0600a23b Fix bug regarding FMT_SAFEBUFFERS 2020-09-19 07:23:41 -07:00
2ecdbb986d Fix a bug in ctzll 2020-09-19 07:23:41 -07:00
6f81ea151a Fix typo (and thus bug) 2020-09-19 07:23:41 -07:00
0c8ffe9b0f Implement Dragonbox (first version) 2020-09-19 07:23:41 -07:00
42699bf408 Fix msvc version of clz & clzll (#1880)
Change msvc version of clz & clzll to match __builtin_clz & _builtin_clzll
2020-09-18 11:07:01 -07:00
bc51a8df04 Disable fallthrough attributes for the Intel compilers on Linux and MacOS (#1879)
* Disable fallthrough attributes for the Intel compilers

On MacOS and Linux the Intel compilers may be identified as the
host compilers (Clang or GNU) but do not support the corresponding
compiler specific fallthrough attributes.

* Rearrange ifdef logic for excluding pre-C++17 fallthrough attributes

This puts Intel and PGI compilers into a separate group
and thus makes the intent and logic more obvious.
2020-09-18 09:57:00 -07:00
45da432d60 fix compiler warnings in public header files 2020-09-17 15:53:53 -07:00
d55e61f120 Improve FMT_ALWAYS_INLINE (#1878)
1. FMT_ALWAYS_INLINE should imply inline; otherwise, there might be
   linkage problems
2. Add specialization for MSVC (__forceinline)
2020-09-17 15:21:17 -07:00
7e6827521a Remove trailing zeros when using fallback formatter (#1873) 2020-09-17 08:16:21 -07:00
1d696dc280 Handle exotic character types in compilation 2020-09-17 07:12:34 -07:00
f674434a67 Add format_to_n overload that accepts FMT_COMPILE (from #1767) (#1869)
* Add format_to_n overload that accepts FMT_COMPILE

* add FormatToNWithCompileMacro test into CompileTest

Co-authored-by: Dmitriy Kurkin <Dmitriy.Kurkin@itiviti.com>
2020-09-15 07:28:06 -07:00
5b5a597198 Fix handling of wide alignment 2020-09-15 06:53:06 -07:00
f80ed64dd9 Update README.rst 2020-09-14 11:13:51 -07:00
3813966497 Simplify fallback format 2020-09-13 11:27:34 -07:00
dce8e49b4f Handle float in fallback formatter 2020-09-13 09:28:40 -07:00
78b5944313 Spelling 2020-09-12 13:14:49 -07:00
f233b56cdd Don't generate insignificant digits 2020-09-12 09:19:50 -07:00
595902f8a0 Update test 2020-09-11 07:57:40 -07:00
4f2ee8921d Use built-in FP formatter for any precision 2020-09-11 07:20:16 -07:00
58a044be5d Use built-in FP formatter for any precision 2020-09-11 07:19:45 -07:00
efe3694f15 Macro tweak and clang-format 2020-09-07 14:43:00 -07:00
9f312fe87e Implement fallback FP formatting with given precision (#1526) 2020-09-07 09:34:30 -07:00
fb289cf56b Fix coding conventions 2020-09-06 09:26:32 -07:00
86f0a7046e Fix formatting 2020-09-06 08:58:19 -07:00
bff4d18efb Add color format_to overloads
* Fix variable size basic_memory_buffer colorization
* Fix an unused arguments warning on GCC that blocks the CI otherwise
* Ref #1842
* Ref #1593
2020-09-06 08:24:15 -07:00
f19b8885f2 Fixed a warning in mingw32/mingw64 (#1860) 2020-09-06 06:27:37 -07:00
f8e00a084a NOMINMAX not handled properly (#1855) 2020-09-03 09:45:47 -07:00
6cccdc24bc Fix move constructor (#1844) 2020-09-01 08:48:56 -07:00
69902c1787 Allow use of <fcntl.h> in Linux when __has_include is not available (#1848) 2020-09-01 06:29:34 -07:00
1edd38b96e Add append mode. (#1847) 2020-08-31 15:48:39 -07:00
e66ba16923 Added build2 usage instructions. (#1838)
The `fmt` package have been available for `build2` users for several version, see: https://cppget.org/fmt

This simply add the minimum instructions for making a `build2` project depend on it.

There are other ways to do it, but they need more understanding of `build2`.
2020-08-28 15:15:15 -07:00
f39e6fb617 Add formatters for chrono::time_point<system_clock> (#1837)
Add formatters for chrono::time_point and helper overloads for localtime/gmtime(time_point)
Fixes #1819
2020-08-28 07:41:38 -07:00
77b627be20 Fix bogus MSVC warnings (#1825) 2020-08-26 12:33:54 -07:00
5dff01d31b Add complex tests 2020-08-26 11:48:50 -07:00
d16d585e64 Update signatures 2020-08-26 09:35:19 -07:00
c7e6d8afb0 Fix usage of override (#1836) 2020-08-23 11:01:46 -07:00
92bff2fe2c Revert "Add missing includes"
This reverts commit 06895a7687.
2020-08-21 16:24:53 -07:00
a0dcfbc57b Add ptr to docs 2020-08-21 06:54:05 -07:00
1651b2d433 Fix detail::write with fallback formatter (#1829)
* add support for fallback_formatter in detail::write

* add ToString test into OStreamTest

to check fmt::to_string() with class that has output stream operator

* add WithOstreamOperator test into CompileTest

to check fmt::format() with FMT_COMPILE() and class that has output stream operator

* use conditional_t inside detail::write instead of 2 overloads

* Revert "add WithOstreamOperator test into CompileTest"

* remove Context from template parameters in detail::write
2020-08-20 06:41:09 -07:00
06895a7687 Add missing includes 2020-08-19 20:33:04 -07:00
92a448a071 Apply clang-format 2020-08-19 10:42:22 -07:00
6be6544668 Fixing buffer_appender's ++ slicing (#1822)
* Fixing buffer_appender's ++ slicing.

* This test requires C++14.

* Removing string_view dependency.

* Simplifying test case.

* Adding message to static_assert
2020-08-18 12:37:56 -07:00
951e0d2333 CMakeLists.txt: Added Wundef warning to clang and gcc. (#1823)
Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-18 07:04:44 -07:00
f9f02df719 CMakeLists.txt: Clang-warnings: removed -Wno-sign-conversion (#1817)
* CMakeLists.txt: Clang-warnings: removed -Wno-sign-conversion

* test/ranges-test.cc: changed type of integer literals to unsigned

* test/format-test.cc: fixed implicit conversion changes signedness warning in clang

Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-14 13:58:20 -07:00
76e97dc4df Eliminate shadowed variable warnings on intel (#1816)
The intel-19 compiler warns about hidden variables:
```
/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "begin" (declared at line 2668)
      FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
                                                ^
          detected during:
            instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
            instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"

/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "end" (declared at line 2669)
      FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
                                                                   ^
          detected during:
            instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
            instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"
```
Rename the second set of variables to `pbegin` and `pend` to eliminate warning.
2020-08-13 18:58:31 -07:00
e204df0e66 nvcc compiler should be EDG-based, but fails test (#1818)
Our nvcc compilers (10.1.243 and 9.2.X) do not define the correct value for `FMT_USE_UDL_TEMPLATE` and then end up with an error later on in the build.  Explicitly search for `__NVCC__` symbol not being defined.   Might want to instead use `FMT_NVCC` or some other check, but the raw `__EDG_VERSION__` check is not working correctly for nvcc.
2020-08-13 15:18:57 -07:00
1c8bb54703 small changes to reduce clang-9 warnings (#1808)
* include/fmt/format.h: int_writer: removed unnecessary iterator type re-declaration (prevents shadow-waringing in clang)

* include/fmt/format.h: int_writer: correctly cast signed integer to unsigned to prevent 'implicit conversion changes signedness'-warnings in clang.

Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-13 11:56:03 -07:00
4b69c78751 fix: warning C4100: unreferenced formal parameter (#1814)
Add [[maybe_unused]] to fix it.
2020-08-12 06:57:22 -07:00
fb0aeb8209 fix: disabled UDL templates for PGI (#1811) (#1812)
* fix: disabled UDL templates for PGI (#1811)

* fix: insert defined auround __PGI

Co-authored-by: n16h7hunt3r <n16h7hunt3r@nixos>
2020-08-11 15:27:27 -07:00
54daa0864a Add dynamic width support to FMT_COMPILE (#1809) 2020-08-10 09:40:11 -07:00
6fb7c6fb25 Workaround a bug in gcc10 (#1810) 2020-08-10 07:20:34 -07:00
16985fdadf Update README.rst 2020-08-09 08:56:51 -07:00
1378ddaefd Update README.rst 2020-08-08 18:01:56 -07:00
4fd95e4b4d Don't remove trailing zeros with # 2020-08-08 08:14:39 -07:00
e06ae32294 Avoid warnings on functions with external linkage that don't have declarations 2020-08-08 07:58:13 -07:00
7fc3d1f54c Add override to grow 2020-08-08 07:23:11 -07:00
065889a593 Use correct capacity in iterator_buffer (#1807) 2020-08-08 07:01:21 -07:00
d0dd678693 Adding convenience append(range) 2020-08-08 06:33:46 -07:00
0e7cef069b Merge commit 'c13f79e0' 2020-08-08 06:28:45 -07:00
e2c8c4557a Update README.rst 2020-08-07 20:58:29 -07:00
e4c954ff0e Update README.rst 2020-08-07 16:03:15 -07:00
c13f79e09e Merge release branch 2020-08-07 07:01:21 -07:00
d7921d649a Update README.rst 2020-08-06 19:41:17 -07:00
cd4af11efc Update version 2020-08-06 08:51:01 -07:00
1ebc2f7cc6 Bump version 2020-08-06 07:41:04 -07:00
f4c997062a Fix changelog 2020-08-06 07:40:46 -07:00
72920ba30a Update changelog 2020-08-06 07:39:37 -07:00
0907c08ae5 Fix handling of default alignmment with locale (#1801) 2020-08-06 07:39:09 -07:00
37c8f4eaf3 Don't use 128 bit integers with clang-cl (#1800)
clang-cl currently has a long-standing bug that using 128 bit integers
generates references to symbols that are provided neither by its own nor
by the Microsoft runtime: https://bugs.llvm.org/show_bug.cgi?id=25305
2020-08-06 07:38:57 -07:00
eaaaec9992 Workaround a bug in msvc 2020-08-06 07:38:51 -07:00
ccf8561cb3 Workaround broken numeric_limites, part 2 (#1787) 2020-08-06 07:38:32 -07:00
0cc73ebf79 Report error on missing named argument (#1796) 2020-08-06 07:38:18 -07:00
33efc3c94f Fix handling of iterators in locale-specific formatting (#1782) 2020-08-06 07:38:08 -07:00
4a4fc225ed Update changelog 2020-08-06 07:34:56 -07:00
61602a75db Remove -Wno-shadow 2020-08-05 10:55:09 -07:00
2f8fc29e9b Update README.rst 2020-08-05 10:53:49 -07:00
717b226b59 include/fmt/format.h: explicit cast to std::size_t for parameter to buffer.resize() in order to get rid of warning 'implicit conversion changes signedness:' in clang-8 (#1802)
Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-05 09:37:10 -07:00
2a69f56769 Tweak buffer size 2020-08-05 08:22:12 -07:00
ea76933802 Simplify ostream 2020-08-04 20:11:43 -07:00
5413713c95 Remove unused function 2020-08-04 19:08:06 -07:00
57f462428d Increase the default buffer size 2020-08-04 08:19:19 -07:00
0b6e7cc60a Update README.rst 2020-08-03 21:51:48 -07:00
e587adb4e9 Simplify count_digits 2020-08-03 15:45:48 -07:00
279d698e1b Fix handling of default alignmment with locale (#1801) 2020-08-03 10:51:42 -07:00
76cfb50b2d Test complex formatter 2020-08-03 10:05:18 -07:00
208291205d Optimize count_digits 2020-08-02 07:58:36 -07:00
8d9ab96736 Cut a few cycles from count_digits 2020-08-01 18:33:53 -07:00
734344931f Simplify ostream_params 2020-08-01 18:33:53 -07:00
2a47a1e48f Update README.rst 2020-08-01 12:00:01 -07:00
7c4c5c79d2 Make buffer size configurable 2020-08-01 10:53:58 -07:00
f0b84da5ff Don't use 128 bit integers with clang-cl (#1800)
clang-cl currently has a long-standing bug that using 128 bit integers
generates references to symbols that are provided neither by its own nor
by the Microsoft runtime: https://bugs.llvm.org/show_bug.cgi?id=25305
2020-07-30 17:21:35 -07:00
a3dfd6f927 Workaround a bug in msvc 2020-07-30 11:13:54 -07:00
51d05521e9 Workaround broken numeric_limites, part 2 (#1787) 2020-07-30 09:42:24 -07:00
21c8b5c142 Report error on missing named argument (#1796) 2020-07-30 07:16:15 -07:00
d82fdcc9e2 Fix handling of iterators in locale-specific formatting (#1782) 2020-07-30 07:03:11 -07:00
633213d96f Merge release branch 2020-07-29 08:52:53 -07:00
b9d749095e Update version 2020-07-29 07:30:55 -07:00
86b63bb71a Bump version 2020-07-29 07:14:25 -07:00
cbf6be9604 Update changelog 2020-07-29 07:07:56 -07:00
229ee9b469 Workaround broken numeric_limits (#1725) 2020-07-29 07:06:45 -07:00
2b7a146fa1 Fix a regression in handling digit separators (#1782) 2020-07-29 07:04:11 -07:00
89d0c7124b Fix compatibility with CMake 3.4 (#1779) 2020-07-29 07:03:59 -07:00
e8f2580a43 Bump version 2020-07-28 09:25:15 -07:00
6cefe55ac7 Update changelog 2020-07-28 09:15:02 -07:00
64e2da15cd Update README.rst 2020-07-28 08:35:28 -07:00
1c8c810f88 Update README.rst 2020-07-28 08:32:37 -07:00
c2399ccfca Update README.rst 2020-07-28 08:21:04 -07:00
a7c5db06d5 Update README.rst 2020-07-28 08:18:10 -07:00
a4c22acd0a Update README.rst 2020-07-26 12:12:31 -07:00
0c1f4b5a0d Update README.rst 2020-07-26 10:57:59 -07:00
63b422ee5e Update README.rst 2020-07-26 10:37:00 -07:00
26e81a6731 Update README.rst 2020-07-26 10:29:03 -07:00
de5fc6af3b Update README.rst 2020-07-26 10:19:55 -07:00
9c2edfd1aa Partially revert 638db5 because it breaks the doc build 2020-07-26 09:44:37 -07:00
810357c014 Document color 2020-07-26 08:22:56 -07:00
0a7032a400 Update README.rst 2020-07-26 08:14:18 -07:00
95d3abf95c Make format_to_n part of the core API 2020-07-24 09:25:26 -07:00
98626093d2 Correct the locale format specifier in api.rst (#1792) 2020-07-23 21:01:54 -07:00
47f8d7a345 Make formatted_size part of the core API 2020-07-23 08:51:38 -07:00
46a63b7087 Update docs 2020-07-23 07:12:19 -07:00
430f393d6f Disabled __attribute__((deprecated)) usage for LCC (#1790) 2020-07-23 06:34:03 -07:00
febffa4e64 Make join() handle non-const-only begin/end ranges (#1786)
See fmtlib/fmt#1784.

Add tests that demonstrate the problem and check obvious variations.
2020-07-21 12:13:00 -07:00
d69e2da221 Fix apidoc 2020-07-20 10:38:14 -07:00
ce73ea37fb Reorder functions 2020-07-20 09:42:14 -07:00
d39d661b18 Workaround broken numeric_limits (#1725) 2020-07-20 08:39:15 -07:00
c228bfe882 Improve docs 2020-07-20 07:56:20 -07:00
38ce19f738 Update README.rst 2020-07-20 07:29:57 -07:00
d11849bc0b Add FMT_REDUCE_INT_INSTANTIATIONS flag (#1781)
* Remove <typename UInt> from int_writer

Reduce code bloat by removing multiple instantiation of int_writer based
on the <typename UInt> parameter.

Rationale:
- The only functions that gains a speedup by int size would be
  int_writer::on_dec()'s call to count_digits which uses CLZ. Thus to
  still take advantage of this speedup, we store the size of the int
  so we can use a switch statement to call the correct count_digits.
- All other implementations of count_digits require some sort of looping
  that terminates when the value hits zero regardless of what sized int
  it is.

Caveats:
- There is a performance hit when dealing with and passing around
  64-bit/128-bit values compared to 32-bit values on 32-bit platforms,
  and with 64-bit values on 64-bit systems. But this should not reduce the
  performance that dramatically.
- There is also a performance hit for on_dec() due to the addition of a
  switch case. But, due to it size, this should reduce to a jump table.

Resolves #1778

* Add FMT_USE_SMALLEST_INT flag

When defined and set to zero, will use the largest available integer
container for writing ints. The has the benefit of reducing instances
the of int_writer class which will reduce the binary cost.

* Rename flag to FMT_REDUCE_INT_INSTANTIATIONS

Add comment above FMT_REDUCE_INT_INSTANTIATIONS definition describing
why a developer would use it.

* Move FMT_REDUCE_INT_INSTANTIATIONS to format.h

Co-authored-by: Khalil Estell <kammce@google.com>
2020-07-19 13:09:10 -07:00
c08518a25b Move make_args_checked to the public API 2020-07-19 10:23:46 -07:00
e2837084ee Add a color section 2020-07-19 09:51:52 -07:00
9f0c003371 Simplify format string checks 2020-07-19 09:24:11 -07:00
d615137ca0 Improve handling of buffer iterator 2020-07-19 09:02:26 -07:00
26b47b6fb5 Bump tested CMake version to 3.18
Use the version range feature introduced in 3.12. On CMake <3.12 the extra dots are simply interpreted as extra version number separators.
The fallback for ancient CMake versions is kept.
2020-07-19 08:50:34 -07:00
7a01c9c523 Update README.rst 2020-07-18 09:17:10 -07:00
b17d5c4f5d Fix a regression in handling digit separators (#1782) 2020-07-18 08:31:47 -07:00
eb90da2e82 Type erase output iterators 2020-07-18 07:50:29 -07:00
9d3cd0afb2 Type erase output iterators 2020-07-17 12:57:50 -07:00
18024853b6 Fix compatibility with CMake 3.4 (#1779) 2020-07-17 06:41:25 -07:00
f5d4215b7c Trying to clear ambiguous compile time claims (#1775)
* Trying to clear ambiguous compile time claims

Documentation was a bit misleading.
Many people assume that fmt does compile time checks by default, while it requires the use of `FMT_STRING`.
It was also unclear that FMT_COMPILE does the same checks.

https://github.com/fmtlib/fmt/issues/1772

* Update api.rst
2020-07-16 06:19:49 -07:00
c26349f4d2 Improve error reporting 2020-07-14 12:06:12 -07:00
f4b11ef6e2 Add a short anchor 2020-07-14 09:39:22 -07:00
0097cf113d Report unformattable type name more prominently 2020-07-13 08:46:53 -07:00
8fa20b471b dev -> latest 2020-07-13 06:15:47 -07:00
a03bd3ddb0 Autodetect MSVC static runtime (#1770)
* Autodetect MSVC static runtime

* Update condition (MSVC)
2020-07-13 06:11:23 -07:00
c108ee1d59 Clarify a comment 2020-07-12 10:59:33 -07:00
a8074a865a Update README.rst 2020-07-12 09:57:02 -07:00
5f62954864 Update README.rst 2020-07-12 09:55:24 -07:00
bd903f96ac Clarify precedence 2020-07-12 09:02:31 -07:00
16cac46a09 Improve handling of streamable and convertible to bool types (#1766) 2020-07-12 08:34:45 -07:00
415cd51913 direct_buffered_file -> ostream 2020-07-11 17:29:17 -07:00
e1bfb59619 Fix handling of code units in compile 2020-07-11 09:03:21 -07:00
ba8d98cbb7 Cleanup direct_buffered_file 2020-07-11 08:27:37 -07:00
04a1f6e991 Improve handling of single code units in compile 2020-07-11 08:21:14 -07:00
e4f57bfd7f Add an overload of write for buffer_appender 2020-07-11 08:20:30 -07:00
d870468159 Make append work with fixed-size buffer 2020-07-11 07:27:20 -07:00
e8ec09ae83 Cleanup core-test 2020-07-10 21:25:27 -07:00
a2c4fed981 Double buffering no more 2020-07-10 20:35:14 -07:00
36406509d9 Add a fixed buffer 2020-07-10 06:30:37 -07:00
60c43e8703 Apply clang-format 2020-07-09 09:06:24 -07:00
b998e0f30b Reduce symbol sizes and simplify iterator use 2020-07-09 08:51:43 -07:00
c5adfc51c5 Update README.rst 2020-07-09 06:21:02 -07:00
c4ad94ce26 Update README.rst 2020-07-08 18:17:26 -07:00
c1429651eb Fix image source link 2020-07-08 13:34:47 -07:00
638db5ca5e Use Cmake to find Python and Sphinx-doc.
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-07-08 08:06:57 -07:00
c090569751 Update readme 2020-07-08 08:01:36 -07:00
1efdb2dde4 Simplify readme 2020-07-08 07:47:18 -07:00
dc69afad14 Cleanup example 2020-07-08 07:44:36 -07:00
445f5d392b Break long lines 2020-07-08 07:36:07 -07:00
23063c3444 Update readme 2020-07-08 07:11:13 -07:00
f57b62575c Move PR template to the top level 2020-07-08 07:01:19 -07:00
f19b1a521e Update version 2020-07-07 07:47:44 -07:00
5c67fefb26 Fix a changelog entry 2020-07-07 06:58:44 -07:00
1d2a556e1b Fix undefined reference error 2020-07-07 06:37:17 -07:00
04c9b62fb4 Merge release branch 2020-07-07 06:34:39 -07:00
6be6762e57 Fix date 2020-07-07 06:32:19 -07:00
f1dd2eb3c0 Bump version 2020-07-07 06:24:32 -07:00
fbf3b943cc Workaround a bug in gcc 2020-07-07 06:06:50 -07:00
a29a01d304 Fix docs 2020-07-07 06:05:00 -07:00
9f0b3afb79 Bump version in namespace 2020-07-06 09:47:27 -07:00
86b2f99f8c Fix the docs 2020-07-06 07:53:07 -07:00
c472ff12d8 Update version 2020-07-06 06:45:20 -07:00
5173a76ba4 Update version 2020-07-05 08:43:47 -07:00
1614af3520 Minor corrections in the changelog 2020-07-05 08:43:01 -07:00
569a9b3a7f Bump version 2020-07-05 07:59:11 -07:00
4e7e3c65a3 Update docs 2020-07-05 07:32:43 -07:00
0f7a6bfa12 Add a section on std::format compatibility 2020-07-05 07:07:29 -07:00
4faec5a5ee Update README.rst 2020-07-05 06:41:51 -07:00
7dbc8ac716 Update changelog 2020-07-05 06:29:05 -07:00
c87dd746fa Update changelog 2020-07-05 06:21:54 -07:00
372175caf8 Revert changelog changes 2020-07-05 06:21:54 -07:00
9047548766 Add ClickHouse to the list of projects (#1751) 2020-07-05 05:57:04 -07:00
d30bca64e3 Revert changelog conversion since GFM is not supported there 2020-07-04 17:43:30 -07:00
d6047cdc4a Update changelog 2020-07-04 15:46:48 -07:00
810241b36e Convert changlog to markdown 2020-07-04 15:20:33 -07:00
661c474739 Rename changelog 2020-07-04 15:14:42 -07:00
7c33059fad Update ChangeLog.rst 2020-07-04 10:16:55 -07:00
9e20883ab3 Update README.rst 2020-07-04 09:37:27 -07:00
41899d5225 Update changelog 2020-07-04 09:31:12 -07:00
f42f459089 Update changelog 2020-07-04 08:40:42 -07:00
2381df654f Update readme 2020-07-04 08:27:57 -07:00
7ae816563e Update README.rst 2020-07-04 08:20:45 -07:00
c56cf3d074 Update changelog and readme 2020-07-04 08:20:10 -07:00
01309a34ab Deprecate arg_formatter 2020-07-04 07:29:11 -07:00
a62d060554 Update changelog 2020-07-04 07:24:49 -07:00
23e3a2eee8 Update changelog 2020-07-03 19:39:08 -07:00
d8e0554b97 Disable numeric formatting by default 2020-07-03 10:35:49 -07:00
1e8eea4f44 Update changelog 2020-07-03 10:31:14 -07:00
44bd5384a9 Fix formatting 2020-07-03 09:18:18 -07:00
20e19387a2 Update changelog 2020-07-03 09:14:11 -07:00
56fed78149 FMT_NUMERIC_ALIGN -> FMT_DEPRECATED_NUMERIC_ALIGN 2020-07-03 08:53:01 -07:00
56e63078ff Make the n specifier an opt-in 2020-07-03 08:02:48 -07:00
31ce6bc702 Fix a conversion warning with Clang10 on Windows (#1750)
Fixes #1747
2020-07-03 05:53:42 -07:00
c9c5b90da7 Fix a typo. Thanks Tracy Chapman from TripleChecker 2020-07-02 15:09:34 -07:00
1f3f84631c Fix a typo 2020-07-02 07:29:38 -07:00
5de62af604 Fix possible infinite recursion in FMT_ASSERT (#1744)
Use std::fprintf for assertion message output preventing infinite
recursion when output to stderr is limited or broken.
2020-07-01 08:28:27 -07:00
cbddab2fe2 Use consistent include style 2020-06-29 09:59:25 -07:00
f69b6eaabd Add a simple buffered stream with no sync 2020-06-28 09:55:29 -07:00
ba363b3a24 Use digit pairs as in unrolledlut 2020-06-27 12:05:38 -07:00
a6f8e7d860 Update changelog 2020-06-27 09:35:02 -07:00
e753244ab6 Update changelog 2020-06-27 06:02:34 -07:00
98a7a8b405 Update changelog and disable internal 2020-06-26 19:07:33 -07:00
3135d95fd9 Don't use non-portable attribute 2020-06-26 10:21:14 -07:00
8630a8f5ff Tweak the docs 2020-06-25 11:29:49 -07:00
cc3a88e6b3 Extract docs from compile.h 2020-06-25 08:36:07 -07:00
79c4b6bd70 Apply clang-format 2020-06-25 08:12:10 -07:00
d130ee070f Document format string compilation 2020-06-25 08:12:10 -07:00
d0f90b5be7 Spelling fixes 2020-06-24 06:29:54 -07:00
6e080660dc Update README.rst 2020-06-24 06:26:58 -07:00
31c3a24266 Spelling fixes 2020-06-23 15:56:16 -07:00
613b3b459d Spelling fixes 2020-06-23 15:55:31 -07:00
978521bb81 Fix a compile error introduced in #1738 2020-06-23 15:17:43 -07:00
4e94c649f9 Deprecate compile 2020-06-23 14:03:37 -07:00
1a83443e6c Add user-defined type support to compilation 2020-06-23 12:45:57 -07:00
8bef1c3b3a Tweaks for EDG based compilers (Intel, nVidia, MCST/Elbrus, etc).
Using the __EDG_VERSION__ macro for checks related to EDG-based
compilers instead of a macros specific for each of ones.
2020-06-23 05:50:25 -07:00
b287c37c65 Do not use -Wl,--as-needed with emscripten.
On some platform, fmt is using the following link flag:
```cmake
  target_link_libraries(fmt -Wl,--as-needed)
```

This is not supported by wasm-ld as of today.
This patch stop using it when compiling using emscripten.

Bug: https://github.com/fmtlib/fmt/issues/1736
2020-06-21 11:46:04 -07:00
2cac8a9d2e Reintroduce UDT support to fmt::to_string and test ADL 2020-06-21 09:21:07 -07:00
9a4cc88426 Add FMT_COMPILE support to format_to 2020-06-20 15:15:41 -07:00
5ddf9ee1bd Streamline default FP formatting 2020-06-20 07:12:50 -07:00
0b3a83f7f4 Update README.rst 2020-06-20 05:37:58 -07:00
5aa5c98738 Added #define WIN32_LEAN_AND_MEAN before including windows.h (#1729)
Co-authored-by: gabime <gmelman1@mgail.com>
2020-06-17 07:44:03 -07:00
397ad1bec3 Optimize common case 2020-06-15 18:30:31 -07:00
7431165f38 Make to_string bypass format 2020-06-15 17:55:16 -07:00
ee4d4c7fd0 Inline compiled format 2020-06-14 11:38:39 -07:00
ab2f8484e0 Finish text::format 2020-06-14 11:04:41 -07:00
e900d735bb Re-enable assert in format_decimal 2020-06-14 09:30:03 -07:00
f4de7b684a Fix ambiguity 2020-06-14 08:26:12 -07:00
1f8f5450b5 Reuse format_decimal 2020-06-14 07:42:52 -07:00
d702a68df2 Fix formatting of bool with FMT_COMPILE and add more tests 2020-06-14 07:16:50 -07:00
e956a14e9e Use write instead of format_int in to_string 2020-06-13 20:07:08 -07:00
98dcc251eb Undo branching reduction 2020-06-13 18:23:52 -07:00
5b8641dddf Undo branching reduction 2020-06-13 16:50:55 -07:00
8c88abde64 Fix sign handling in 'L' 2020-06-13 06:57:19 -07:00
23b976a615 Reduce branching 2020-06-12 19:46:00 -07:00
9edee0e727 Optimize small string parsing 2020-06-12 19:22:33 -07:00
a909d42b76 Fix a warning 2020-06-12 13:49:31 -07:00
16637341b9 Enable compilation for all types 2020-06-12 13:27:21 -07:00
2d71d7e030 Add a simple format string compilation API 2020-06-12 08:37:15 -07:00
d259fcfb05 Tweak comments 2020-06-12 06:22:05 -07:00
704ed557a1 Move project in order to solve a CMake warning
CMake Warning (dev) at /usr/share/cmake-3.17/Modules/GNUInstallDirs.cmake:225 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
2020-06-12 06:04:31 -07:00
8603bd20d0 Update README.rst 2020-06-11 17:25:20 -07:00
547f12ae63 Fix a warning (#1722) 2020-06-11 15:02:42 -07:00
f904e8a1b4 c++11 use formatting user-defined types (#1721) 2020-06-11 10:10:39 -07:00
100e8af08a Update README.rst 2020-06-10 07:46:01 -07:00
c11d0f056e Update README.rst 2020-06-10 07:02:12 -07:00
2453ee576a Improve default formatting 2020-06-09 08:59:01 -07:00
47ae521557 MINGW cross compiler fixes 2020-06-09 06:19:22 -07:00
936a1833c2 Add default_arg_formatter 2020-06-08 08:14:34 -07:00
f2c9cb6244 Fix a UB 2020-06-08 06:32:11 -07:00
d3107f8551 Cleanup arg_formatter_base 2020-06-07 20:55:38 -07:00
5e7c70e206 Simplify arg_formatter_base 2020-06-07 19:38:43 -07:00
38cc68b3e5 Inline visitor 2020-06-07 08:36:33 -07:00
6732ea5000 Make symbols readable 2020-06-07 07:49:11 -07:00
57ddc77ce7 Make advance_to a noop for back_insert_iterator 2020-06-06 19:36:39 -07:00
50bad7d62d Optimize format string parsing 2020-06-06 10:15:19 -07:00
8f7a824e47 Inline visit 2020-06-06 09:02:32 -07:00
f11e968708 Optimize format string parsing 2020-06-06 08:15:33 -07:00
09737dd83b Optimize format handler 2020-06-06 07:17:02 -07:00
d9e3d6e6ed Move format_handler to detail 2020-06-06 06:38:48 -07:00
795b47a7b5 Fix a warning (#1712) 2020-06-05 08:24:09 -07:00
95c6ac0cc8 fix typo which caused the loss of the counting information when using a printf context with a truncating_iterator 2020-06-05 07:37:54 -07:00
21409cfdda Fix warnings 2020-06-04 07:50:07 -07:00
88c8d534e7 Move digits10 to where they belong and add comments 2020-06-04 06:39:18 -07:00
0f3eaeac0a Fix a warning 2020-06-04 06:33:11 -07:00
344218510d Ignore /doc/node_modules directory 2020-06-04 05:19:39 -07:00
16aec06179 Cleanup arg_formatter_base 2020-05-31 10:58:52 -07:00
1e1193590d Fix format_decimal overloads 2020-05-31 10:12:34 -07:00
0893c9c2ef Inline parse_format_string 2020-05-30 20:30:18 -07:00
3245145a41 Remove undocumented buffer_range and output_range 2020-05-30 13:07:52 -07:00
57fc44907f Increase VM disk size 2020-05-30 11:25:40 -07:00
7d22bebb6f Remove uses of buffer_range 2020-05-30 06:50:45 -07:00
8f2b5fe74d Don't install sphinx cache files
When building documentation sphinx creates cached files in the .doctrees
directory and aren't required for viewing documentation only for
building. As added benefit this makes fmt reprodcubile as the cached
files are different when the build environment is varied.
2020-05-30 06:14:02 -07:00
f095c67b6a Remove uses of buffer_range 2020-05-29 18:14:03 -07:00
5aabf1f715 Simplify copy_str 2020-05-29 17:59:08 -07:00
19c5b5d159 Simplify arg_formatter 2020-05-29 16:53:12 -07:00
519571edec Simplify arg_formatter_base 2020-05-29 14:44:18 -07:00
ac8dfd841f Improve handling of separators 2020-05-29 08:15:44 -07:00
2c6165a22b Reduce the number of comparisons 2020-05-29 05:42:35 -07:00
28639969ef Use memcpy for copying digits 2020-05-28 22:33:08 -07:00
f5fa1dee54 Support custom FMT_INC_DIR in pkgconfig and cmake configs (#1702)
* Support custom FMT_INC_DIR in pkgconfig and cmake configs

When CMAKE_INSTALL_INCLUDEDIR or FMT_INC_DIR override the header
installation directory, they should be used instead of
${CMAKE_INSTALL_PREFIX}/include in fmt-targets.cmake and fmt.pc.

* Put headers into FMT_INC_DIR/fmt rather than directly into FMT_INC_DIR

This makes FMT_INC_DIR an alias for CMAKE_INSTALL_INCLUDEDIR and
simplifies generation of pkgconfig and cmake configs.

* Do not split target_include_directories
2020-05-28 08:17:34 -07:00
51bf9cfacb Fix Mingw support
If the ``_POSIX_`` flag is set, _fdopen will not be defined by
Mingw headers, which is addressed by this commit.

For what is worth, as opposed to ``fdopen``, ``_pipe`` *will*
actually have the ``_`` prefix when ``_POSIX_`` is set.
2020-05-26 06:39:22 -07:00
1a716caf5d Optimize common case 2020-05-25 19:16:35 -07:00
98d4bbf813 Update README.rst 2020-05-24 06:28:35 -07:00
8c8f74a870 fix zero flag for char types and make zero flag ignored if a precision is specified 2020-05-23 12:46:26 -07:00
bc1b89da26 Temporarily revert parsing changes 2020-05-22 15:39:33 -07:00
a7fb321ac6 Remove a redundant branch 2020-05-22 15:39:33 -07:00
8cadb96506 fix max/min macro (#1697) 2020-05-22 06:38:43 -07:00
297c3b2ed5 Fix an example (thanks Alexey Kuzmenko) 2020-05-20 15:52:19 -07:00
943532fece Make ostream formatter work with compile-time format strings (#1692) 2020-05-20 14:59:57 -07:00
bd8804019b Update README.rst 2020-05-19 19:25:46 -07:00
f230300ac5 Knuth is using fmt library (#1691) 2020-05-19 18:08:32 -07:00
a265e25b79 Optimize small string parsing 2020-05-19 13:44:22 -07:00
2aa2526f64 Optimize small string concatenation 2020-05-19 11:45:09 -07:00
8d78045e7c Move void_t to where it's used 2020-05-18 10:46:25 -07:00
7aafa6bc64 Update analytics 2020-05-18 10:26:22 -07:00
c66aae1652 Adding sentinel support to fmt::join(). (#1689) 2020-05-18 06:31:01 -07:00
6d66de3805 Add c specifier support to integral types (#1652) 2020-05-17 08:44:59 -07:00
6b219a58db fix interaction of space flag and '+' flag, as well as '-' flag and '0' flag (#1687) 2020-05-17 04:27:18 -07:00
eee2023c2a Update signatures 2020-05-15 15:25:02 -07:00
c5ed73aab2 Add fmt::detail::buffer to the docs (#704) 2020-05-15 14:35:55 -07:00
ea1cd9638c Fix apidoc 2020-05-15 10:03:02 -07:00
d3964d7b1e Merge branch 'master' of github.com:fmtlib/fmt 2020-05-15 09:43:38 -07:00
d18c6723a2 Update docs 2020-05-15 09:43:35 -07:00
96c18b26c2 make plus flag for printf not be ignored for char argument (#1683)
* make plus flag for printf not be ignored for char argument

* clarify overwriting of alignment specifiers for printf with char argument
2020-05-15 06:45:51 -07:00
ba25baeb97 Apply doc patch to 6.2.1 2020-05-14 19:11:40 -07:00
981b517ccf nested replacement fields may omit arg_id (#1681)
syntax.html already has examples like `fmt::format("{:.{}f}", 3.14, 1)` using this, 
and https://en.cppreference.com/w/cpp/utility/format/formatter#width_and_precision shows that this is the case for the C++20 std::format

The Format Specification Mini-Language grammar seems to be the only one not showing this; update it to match.
2020-05-13 17:20:05 -07:00
922ea924bf Make dynamic_format_arg_store reusable and add reserve() (#1677)
Implemented #1674: make dynamic_format_arg_store reusable and add
reserve() for better memory menagement.
2020-05-12 11:00:42 -07:00
e0d98923c7 Update version 2020-05-10 18:05:46 -07:00
8069265373 internal -> detail (#1538) 2020-05-10 07:34:30 -07:00
963ee08310 Simplify named arguments 2020-05-09 16:43:31 -07:00
02a6fe59fb Named arguments go brrr 2020-05-09 13:22:38 -07:00
de290f5c4c Ditch internal::arg_map 2020-05-09 12:43:11 -07:00
d0623de510 Bump version 2020-05-09 10:57:04 -07:00
73e335ed38 Make implicit capture explicit for C++20 (#1669) 2020-05-09 10:55:37 -07:00
b4d46e3988 Update changelog 2020-05-09 10:05:16 -07:00
a182f7341e Update changelog 2020-05-09 08:30:31 -07:00
68201831a5 Support named args in dynamic_format_arg_store (#1655). (#1663)
Dynamic arguments storage. Implementation of enhancement from issue
#1170.
2020-05-09 06:25:03 -07:00
7f723fbcb8 Consistently namespace qualify size_t 2020-05-07 15:59:46 -07:00
c06851456d Purge basic_writer 2020-05-07 15:04:48 -07:00
2f05054dd3 Purge basic_writer 2020-05-07 11:35:41 -07:00
f0ce21164c Revert enum change 2020-05-07 07:25:33 -07:00
44639b11fe Fix some warnings (#1667)
* Fix sign-conversion warning

* Add missing "extern template" declarations for non-header-only build

* Use typed enums to fix Wsigned-enum-bitfield warnings

* Consolidate FMT_HEADER_ONLY code
2020-05-07 06:14:07 -07:00
1c86a99e8f Purge basic_writer 2020-05-06 18:46:01 -07:00
8f511fc12f Make copyfmt not throw (#1666) 2020-05-06 17:38:46 -07:00
59fe455f36 Remove compatibility stubs 2020-05-06 07:31:35 -07:00
b0f47a13e6 Separate nonfinite formatting 2020-05-06 07:19:37 -07:00
d6cea50d01 Remove deprecated APIs 2020-05-05 20:03:48 -07:00
40bc7163fb Move FMT_MAYBE_UNUSED to where it's actually used 2020-05-05 19:41:07 -07:00
080e44d0bf Fix inconsistent type detection (#1662) 2020-05-05 19:09:21 -07:00
7e57cace5d Exclude std::abort from compilation when compiling CUDA with Clang (#1661) 2020-05-04 06:21:21 -07:00
7b66e2f219 Inherit arg_formatter_base from basic_writer 2020-05-03 21:05:45 -07:00
bab3f58003 Refactor pointer formatting 2020-05-03 20:33:25 -07:00
9cc7edfddc Move int_writer to the namespace scope 2020-05-03 17:34:48 -07:00
8d9d528bf5 Improve handling of alignment 2020-05-03 10:58:18 -07:00
8efd1a8ef6 Improve handling of alignment 2020-05-03 10:08:57 -07:00
a71bc9c825 Use '0' fill with numeric align for consistency with std::format 2020-05-03 09:52:31 -07:00
60d85d598c Suppress ubsan warning 2020-05-03 08:43:10 -07:00
c3099beb6f Cleanup 2020-05-02 22:00:34 -07:00
cbb4cb8991 Remove undocumented deprecated APIs 2020-05-02 21:34:44 -07:00
b85e9ac38b Simplify vformat_to 2020-05-02 21:34:44 -07:00
e3710ab972 FMT_CONSTEXPR -> constexpr 2020-05-02 21:34:44 -07:00
d59751f0f0 Update date formatting example to use threadsafe localtime 2020-05-02 09:04:31 -07:00
d6abb2fa03 Reduce library size 2020-05-01 17:23:45 -07:00
e9fdea90b5 Update README.rst 2020-05-01 10:40:07 -07:00
44b6584f22 Update README.rst 2020-05-01 10:39:28 -07:00
78f041ab5b build: Fix installation paths
It is not generally true that `CMAKE_INSTALL_<dir>` variables are relative paths:

https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
2020-05-01 10:27:24 -07:00
7ca89bf87a Reduce template bloat in write_int 2020-05-01 07:56:57 -07:00
3c114d091b Fix a shadowing warning (#1658) 2020-05-01 07:00:25 -07:00
e2ef12a8c0 Allow to avoid inclusion of os.cc in fmt target
- Allows to avoid part of #1654
- Not possible to use with MASTER_PROJECT as testing uses it a lot
2020-05-01 06:24:22 -07:00
bca82719ab Pass iterator by value 2020-04-30 21:06:17 -07:00
99da389627 Make write_padded non-members 2020-04-30 16:05:30 -07:00
f19d667943 Bump fuzzer allocation limit 2020-04-30 08:45:50 -07:00
3e69847616 Reduce branching in write_padded 2020-04-30 06:33:45 -07:00
9ac1eebd47 Reduce library size 2020-04-29 17:37:05 -07:00
e2ff910675 Replace FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION with fmt-specific macro (#1650)
Signed-off-by: Asra Ali <asraa@google.com>
2020-04-29 09:12:43 -07:00
f2ed03b919 Fix a warning (#1649) 2020-04-28 06:39:24 -07:00
9dde9f0131 Reduce library size 2020-04-27 20:43:30 -07:00
b1af642d1d Reduce library size 2020-04-27 18:50:49 -07:00
4a617f25c6 Clarify encoding conversion in chrono 2020-04-27 09:57:08 -07:00
6f435f55c8 Improve compile time by using extern template (#1452) 2020-04-26 14:02:15 -07:00
cb475cb884 Clarify why we don't check argument id 2020-04-26 13:38:42 -07:00
1e1ac6e964 Check dynamic width/precision id at compile time (#1614) 2020-04-25 08:36:24 -07:00
e51c449fe6 Revert "Check dynamic widht/precision id at compile time (#1614)"
This reverts commit 7d748a6f82.
2020-04-25 07:43:56 -07:00
0463665ef1 Don't access a C string past precision in printf (#1595) 2020-04-22 17:10:23 -07:00
7d748a6f82 Check dynamic widht/precision id at compile time (#1614) 2020-04-22 14:45:37 -07:00
2b75bd7ce6 Get rid of do_check_format_string 2020-04-22 12:15:29 -07:00
4a1d5931cb Simplify udl_formatter with FMT_STRING 2020-04-22 11:26:05 -07:00
811b0f9054 Enable compile-time error tests 2020-04-22 11:00:20 -07:00
450e8eed97 Fix markup 2020-04-22 09:30:09 -07:00
b8fbcec1be Clarify formatter reuse 2020-04-22 09:15:52 -07:00
56bc86ffac Suppress bogus MSVC analysis warnings 2020-04-22 07:51:25 -07:00
3f79357ef0 Fix a recent regression in handling max packed arguments 2020-04-22 07:15:19 -07:00
8a11148f99 Add Facebook Folly to the list of projects 2020-04-22 06:16:07 -07:00
e371e8b686 Tweak readme 2020-04-22 06:13:36 -07:00
813732fede Improve readme formatting 2020-04-22 06:07:12 -07:00
3670d5b3f6 README: add vectorized.io/redpanda in the list of users 2020-04-22 06:04:09 -07:00
9e2ad7cf68 Add windows terminal to the projects using {fmt} 2020-04-21 15:47:04 -07:00
63479c8519 Use a delegating ctor and add inlines 2020-04-20 19:17:16 -07:00
5944fcad37 Remove remaining wchar_t instantiation 2020-04-19 16:48:15 -07:00
e253b371b2 Don't generate RTTI for allocator 2020-04-19 15:57:48 -07:00
0c86f467bc Fix build on ancient gcc 2020-04-19 09:52:40 -07:00
1929df4bc2 Simplify format_args 2020-04-19 09:21:39 -07:00
a138221813 Always inline arg_data functions 2020-04-19 08:20:00 -07:00
04e0dfd4bd Always inline value ctors 2020-04-19 08:05:02 -07:00
04cde756bc Simplify checks 2020-04-19 07:35:19 -07:00
c9a57b9a81 Fix incorrect assumptions about nul termination 2020-04-18 06:51:52 -07:00
f46f5ecaf0 Reenable constexpr _compile on GCC 9 2020-04-17 06:10:57 -07:00
6e8d7e2776 Don't use constexpr on Intel compiler (#1628) 2020-04-16 07:08:04 -07:00
567ed03f88 Merge arg overloads and cleanup 2020-04-15 08:44:58 -07:00
c3fa333140 Remove warning in core.h with when compiling with gcc and -Wshadow
In file included from build/_deps/fmt-src/include/fmt/format.h:44:0,
                 from src/main.cpp:5:
build/_deps/fmt-src/include/fmt/core.h: In member function ‘const T& fmt::v6::internal::dynamic_arg_list::push(const Arg&)’:
build/_deps/fmt-src/include/fmt/core.h:1256:10: error: declaration of ‘node’ shadows a member of ‘fmt::v6::internal::dynamic_arg_list’ [-Werror=shadow]
     auto node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));
          ^~~~
build/_deps/fmt-src/include/fmt/core.h:1236:37: note: shadowed declaration is here
   template <typename = void> struct node {
2020-04-15 07:31:24 -07:00
84898b4626 Remove warning in format.h when compiling with gcc and -Wshadow
build/_deps/fmt-src/include/fmt/format.h: In member function ‘decltype (ctx.out()) fmt::v6::formatter<fmt::v6::bytes>::format(fmt::v6::bytes, FormatContext&)’:
build/_deps/fmt-src/include/fmt/format.h:3251:58: error: declaration of ‘writer’ shadows a global declaration [-Werror=shadow]
     internal::basic_writer<range_type> writer(range_type(ctx.out()));
                                                          ^~~
build/_deps/fmt-src/include/fmt/format.h:2741:53: note: shadowed declaration is here
 using writer FMT_DEPRECATED_ALIAS = internal::writer;
2020-04-15 07:31:24 -07:00
538d83fd08 Cleanup named arguments 2020-04-15 06:28:41 -07:00
8a4630686e Improve handling of named arguments 2020-04-14 11:56:55 -07:00
a9d62d3f35 Add check for CompiledFormat to avoid ambiguous call 2020-04-14 05:59:02 -07:00
fdcf7870a2 Add stack-based named argument storage 2020-04-13 08:03:51 -07:00
5899267c47 Fix a clang-tidy warning 2020-04-12 08:27:39 -07:00
07b4c246ea Fix a typo 2020-04-12 08:18:47 -07:00
e99809f29d Fix ostream support in sprintf (#1631) 2020-04-12 07:53:17 -07:00
3cd5179f32 Fixed clang tidy warning -multiple declarations in a single statement reduces readability 2020-04-12 06:29:09 -07:00
7404e33a73 Fix clang warning about explicit ctor 2020-04-12 06:19:16 -07:00
3aab2171ed Clean up basic_format_args 2020-04-11 08:22:53 -07:00
7645ca0724 Clean up printf 2020-04-11 08:01:00 -07:00
e30d8391e4 Suppress an MSVC warning (#1622) 2020-04-11 07:49:00 -07:00
8cd8ef03eb Simplify warning suppression 2020-04-11 06:17:31 -07:00
bbb6b357c7 Add floating-point L specifier (#1624) 2020-04-10 07:16:20 -07:00
36ea32640f Suppress a bogus MSVC warning 2020-04-10 06:44:07 -07:00
141a00d642 Define FMT_EXTERN_TEMPLATE_API on export 2020-04-09 11:54:55 -07:00
3860edc5d9 Bump version 2020-04-08 14:48:14 -07:00
7d01859ef1 Fix handling of unsigned char strings in printf 2020-04-08 13:05:42 -07:00
63b23e786a Merge branch 'master' of github.com:fmtlib/fmt 2020-04-08 13:03:44 -07:00
4999796c15 Fix the docs 2020-04-08 07:52:36 -07:00
34b3f7b7aa Avoid windows issue with min() max() macros
Including the ``windows.h`` file without defining ``NOMINMAX`` will define the `min()` and `max()` macros which will result in issues compiling any C++ code that uses any variant of `max`, for example `std::numeric_limits<std::streamsize>::max()` and many others.  Although max() isn't used in Fmt anywhere, it is often used in codes that include a format include file so simply upgrading to the current version of lib::fmt will break the windows build which worked prior to the update...
2020-04-07 08:34:34 -07:00
27e3c0fe9b Update signature in the docs 2020-04-06 07:17:41 -07:00
9bdd1596ce Update version 2020-04-05 06:46:41 -07:00
d151562bdd Fix punctuation in changelog 2020-04-04 12:49:56 -07:00
346500e70b Fix gcc version check 2020-04-04 11:23:40 -07:00
a434a8f778 Update changelog 2020-04-04 06:34:23 -07:00
9eb47d951a Fix markup 2020-04-03 08:49:29 -07:00
51c58a56ba Bump version 2020-04-03 08:32:45 -07:00
3fc33f6273 Update changelog 2020-04-03 08:29:02 -07:00
2e32db5b99 Update changelog 2020-04-03 07:42:02 -07:00
c1ce6e01f7 Update changelog 2020-04-02 08:18:42 -07:00
1c3c80dc1f Update changelog 2020-04-02 07:27:58 -07:00
d1d653d895 Implement the L specifier 2020-04-02 06:58:38 -07:00
73c8437485 Follow naming conventions 2020-04-01 09:30:28 -07:00
e588b02b17 Fix posix-mock-test 2020-04-01 08:42:14 -07:00
1a62711d01 Reduce binary size 2020-03-31 08:07:11 -07:00
5b02881582 Merge branch 'master' of github.com:fmtlib/fmt 2020-03-28 09:46:44 -07:00
a133187a8c Update changelog 2020-03-28 09:44:27 -07:00
80ce222ca6 Fix wide print overload (#1609) 2020-03-28 09:44:18 -07:00
770a94edef Use FMT_THROW macro where applicable 2020-03-27 12:17:22 -07:00
2864e8432a Update readme and add compatibility option 2020-03-26 07:18:27 -07:00
21a295c272 Undo comment change 2020-03-25 08:14:31 -07:00
96c68afe69 Fix -Wsign-conversion warnings 2020-03-25 07:46:00 -07:00
664dd88e31 Enable FMT_STRING() use with types other than string literals 2020-03-24 12:56:21 -07:00
69779b4ed6 Fix handling of small precision in general format 2020-03-24 09:01:57 -07:00
01a172c969 Add .vs to .gitignore 2020-03-23 15:01:02 -07:00
08ca40ea91 Detect /utf-8 in MSVC 2020-03-22 08:19:38 -07:00
dd97f4920c Improve exception safety in dynamic_format_arg_store 2020-03-21 08:58:50 -07:00
2951169481 Move FMT_USE_FLOAT and friends to fmt/format.h 2020-03-20 07:55:43 -07:00
d3e668418f Allow disabling floating point support (#1590)
* Allow disabling floating point support

Add FMT_USE_FLOAT, FMT_USE_DOUBLE and FMT_USE_LONG_DOUBLE to allow a
user of the library to configure the float types they want to allow.
This is specially useful in embedded environements where code size is
important.

* Avoid conditional macros to disable float support

* Add is_supported_floating_point constexpr function

* Fix empty-body warning
2020-03-20 06:46:31 -07:00
52d0e1bbe3 Don't use properties when setting FMT_LIB_NAME 2020-03-19 08:35:09 -07:00
5d32ccfc31 Add back missing OUTPUT_NAME in target properties. (#1598) 2020-03-19 07:01:51 -07:00
3cf619de55 Simplify dynamic_format_arg_store 2020-03-17 07:13:46 -07:00
2559983e7a Color formatting fixed for wide strings (fixes issue #1594) (#1596)
* Use std::char_traits::length for ansi_color_escape::begin

-Fixes issue #1594 https://github.com/fmtlib/fmt/issues/1594
2020-03-17 06:24:42 -07:00
026f99178e Simplify dynamic store 2020-03-16 19:10:41 -07:00
9f70fc3e7a Minor tweaks for dynamic_format_arg_store 2020-03-16 07:58:15 -07:00
6012dc9ab4 Dynamic arguments storage. Implementation of enhancement from issue #1170. (#1584) 2020-03-16 07:00:29 -07:00
85050aa2e6 Ability to join elements of std::initializer_list was added 2020-03-15 16:10:00 -07:00
ff486a72a7 Allow leading zeros in precision (#1579) 2020-03-14 11:37:38 -07:00
678341275b Deprecate fmt::char8_t 2020-03-14 10:32:34 -07:00
6f01b6ebb6 Fix a typo in CMake config: STRINGS -> STRING 2020-03-14 09:50:25 -07:00
61c5a51604 Fix handling of empty tuples (#1588) 2020-03-14 07:41:08 -07:00
02bfd8a9a5 Add FMT_HAS_CPP14_ATTRIBUTE / FMT_HAS_CPP17_ATTRIBUTE to test for language-specific attributes.
FMT_DEPRECATED is now defined as FMT_HAS_CPP14_ATTRIBUTE(deprecated), as this attribute was introduced in C++14.

FMT_FALLTHROUGH is now defined as FMT_HAS_CPP17_ATTRIBUTE(fallthrough), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED is defined as FMT_HAS_CPP17_ATTRIBUTE(maybe_unused), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED has been applied to fix a couple of -Wunused-member-function warnings from clang.
2020-03-13 09:03:52 -07:00
3c24052cf1 Workaround 'cannot call member function without object' error on gcc 4.9 2020-03-11 17:39:32 -07:00
f72a905eb3 Fix handling of volatile enums 2020-03-11 08:40:57 -07:00
941d5e147a Workaround broken fallthrough attribute in the PGI compiler (#1583) 2020-03-11 07:56:23 -07:00
ee2b828b9a Tweak a comment 2020-03-09 11:27:14 -07:00
5bb8856655 Workaround for broken [[deprecated]] in PGI compiler (#1581)
* Workaround broken [[deprecated]] in PGI compiler
  - similar to Intel and NVCC, add workaround for PGI compiler
2020-03-09 11:25:38 -07:00
1c0c59d4a0 Fix empty debug postfix 2020-03-09 08:34:02 -07:00
b1adaa9881 Remove gcc 4.4 workaround 2020-03-07 14:50:52 -08:00
48e8d0ebef set_doc -> set_verbose 2020-03-07 14:31:39 -08:00
ce00979152 Cleanup CMake config 2020-03-07 08:18:01 -08:00
db4a6cfbf9 is_static_compiled_format -> is_compiled_format 2020-03-06 07:25:34 -08:00
29a1ea795a Fix clang -Wdisabled-macro-expansion warning from FMT_STRING_IMPL.
FMT_STRING_IMPL has an internal helper named FMT_STRING, however FMT_STRING is also the name of the macro that invokes FMT_STRING_IMPL.

Renaming this helper avoids the appearance of a recursive macro.
2020-03-06 07:00:47 -08:00
8a06ca84c7 Fix ambiguous overloads of format & format_to 2020-03-05 12:22:43 -08:00
153f753bde Deprecate undocumented _u suffix 2020-03-04 19:20:19 -08:00
eafd079868 Improve width computation 2020-03-04 17:17:34 -08:00
0c6919ec72 Make FMT_DEBUG_POSTFIX a cache variable (#1566) 2020-03-04 08:37:11 -08:00
197a5c3721 Apply clang-format 2020-03-04 08:37:00 -08:00
68742e1d87 Fix clang -Wsign-conversion warning in grisu_count_digits. (#1573)
grisu_count_digits is only used by grisu_gen_digits, which assigns the unsigned result to a (signed) int.

Although grisu_count_digits always returns a positive integer this keeps its return type in sync with the type its result is assigned to.
2020-03-04 06:48:41 -08:00
1e8493196e Make compile-time checks in format_to handle references 2020-03-01 07:57:34 -08:00
58e6c84f5a Fix simple -Wsign-conversion cases. (#1571)
* Fix -Wsign-conversion in bigint::subtract_aligned.

n is assigned a size_t, and only used for comparisons with j.

j is assigned 0, compared to n (size_t), and passed to basic_memory_buffer::operator[] (size_t).

* Fix -Wsign-conversion in bigint::assign.

num_bigits is initialised to 0, is only ever incremented, and is passed to basic_memory_buffer::operator[] (size_t) and basic_memory_buffer::resize (size_t).
2020-03-01 07:22:15 -08:00
75a4525e5f Move FMT_CLANG_VERSION definition to core.h (#1568)
Previously format.h defined FMT_CLANG_VERSION after including core.h, however core.h tests FMT_CLANG_VERSION when it defines FMT_API.
2020-02-29 17:19:34 -08:00
6ccb2e241b Add FMT_NORETURN to assert_fail prototype. (#1569)
When building with -Werror,-Wmissing-noreturn clang identifies that assert_fail could be declared with the 'noreturn' attribute.
2020-02-29 17:17:55 -08:00
bed134a4aa Tentative fix for default template param in friend error 2020-02-27 15:29:46 -08:00
b2d3a86ec0 Make FMT_ASSERT work in constexpr on clang 4.0.1 2020-02-26 06:26:46 -08:00
13d82e32bd Don't use internal GTest API 2020-02-24 11:32:34 -08:00
2161a73f2b Fix FMT_FORMAT_AS const specifier position (#1554)
The current `FMT_FORMAT_AS` macro will make `formatter<Char *>::format`
have the first argument type `const Char *&` which is incorrect an
should be `Char *const &`.  This pull request fixes that by changing the
first argument type in the macro definition body from `const Type &` to
`Type const &`.
2020-02-23 07:27:22 -08:00
e00997b004 improved use of find (#1560)
* improved use of find

*begin is supposed to be different from '{' when this find is used, so we can avoid checking it.
2020-02-21 14:43:06 -08:00
0415cf2350 add const begin and end overload to buffer (#1553)
* add const begin and end overload to buffer

since there is a const overload for data I think there should also be one for begin and end
2020-02-19 14:59:50 +01:00
3bafd0749b Fix to_string docs 2020-02-15 09:51:35 +01:00
f733882b55 Remove misleading FMT_USE_WINDOWS_H 2020-02-14 14:09:27 +01:00
dc22360c34 Workaround broken UDL templates in GCC < 6.4 2020-02-10 17:08:14 +01:00
1f1b50707c Make formatter override implicit conversion to a C string 2020-02-07 19:24:36 -08:00
24924128e3 Fix a link error in gcc8 (#1548) 2020-02-07 18:34:05 -08:00
c54cd71800 only modify CMAKE_RUNTIME_OUTPUT_DIRECTORY if it is not already set 2020-02-07 07:10:03 -08:00
43e9b29e50 Only use compiler features if available 2020-02-06 15:43:33 -08:00
b55ea58705 string_view::char_type -> value_type (#1539) 2020-02-01 12:27:44 -08:00
4098970db2 Update README.rst 2020-01-31 11:33:51 -08:00
314e15001f Fix symbol visibility on Linux when compiling with -fvisibility=hidden (#1535)
Make FMT_API symbols use the default visibility on non-Windows
platforms. Otherwise, one cannot use the generated fmt library when
compiling globally with -fvisibility=hidden.

Fixes compile errors like:

```
../3rdParty/fmt/include/fmt/core.h:757: error: undefined reference to 'fmt::v6::internal::assert_fail(char const*, int, char const*)'
```

Note that the symbol exists, but is local:

```
$ nm -C libfmtd.so.6.1.3  | grep assert_fail
                 U __assert_fail
0000000000233ffa t fmt::v6::internal::assert_fail(char const*, int, char const*)
```

With this patch, the compile error is gone and the symbol is properly
exported:

```
$ nm -a bin/libfmtd.so -C | grep assert_fail
                 U __assert_fail
00000000002366ba T fmt::v6::internal::assert_fail(char const*, int, char const*)
```

Change-Id: I96054e622d9a2ae81907e1b01a1033e629767a91
2020-01-30 06:26:18 -08:00
f499b393d1 Apply coding conventions 2020-01-26 19:48:48 -08:00
6c30f41443 Configure fmt.pc library name correctly.
Simplify getting library name.

Add FMT_DEBUG_SUFFIX variable.
2020-01-26 19:48:14 -08:00
1acb73f970 Fix formatting std::chrono::duration types to wide strings (#1533)
* Fix formatting chrono durations to wide strings

* Make format buffers const correct

* Add FormatWide chrono test case

* Fix incorrect wide encoding of 'µs'
I think might be a source file encoding issue, so I used \u00B5 instead.

* Update FormatWide test to use proper encoding of µs

* Revert changes to format_localized's parameters

* Use different overload of `std::time_put<T>::put` to avoid needing a format string

* Use utf8_to_utf16 instead of having redundant overloads of get_units

* Revert some minor changes

* Remove FMT_CONSTEXPR from expression

This should hopefully fix compilation on VS <2019

* Make suggested changes from code review

* Run clang-format on chrono.h

* Make sure unit isn't null before constructing a string_view from it
2020-01-23 18:48:36 -08:00
09a13244c8 Disallow passing non-string-literals to FMT_STRING 2020-01-22 21:05:46 -08:00
419db8baa1 Fix length computation of constexpr C strings 2020-01-22 18:25:07 -08:00
9fc4161f5e fix interal compiler error when building with mingw 2020-01-22 18:14:46 -08:00
25d6916b3a Fix so can work without locale defined
If `FMT_STATIC_THOUSANDS_SEPARATOR` defined, then locale is not included or defined, so this call will be unresolved.  I think this is the correct fix based on the code in `format-inl.h` and `format.h`
2020-01-22 07:26:03 -08:00
0b2eb6501c Add locale example 2020-01-20 08:42:16 -08:00
fd1cabe464 Workaround a bogus MSVC warning 2020-01-20 06:56:22 -08:00
a844d7ab81 Add namespaces 2020-01-19 19:20:48 -08:00
47d3968092 Add more examples 2020-01-19 19:15:54 -08:00
7800173eb1 Update fill docs 2020-01-19 18:57:32 -08:00
b4218aa0f8 Test invalid fill 2020-01-19 16:52:36 -08:00
8a3a8177d6 Bump version 2020-01-19 15:34:30 -08:00
e5f2f8ce7a Add variable-width fill support (#1109) 2020-01-19 14:49:51 -08:00
75765bfad5 Avoid unnecessary unsigned overflows (#1515) 2020-01-18 08:19:27 -08:00
9bd9738da0 Remove static and simplify names 2020-01-18 07:43:59 -08:00
bd5f903f28 Add a locale example 2020-01-18 07:11:45 -08:00
06e437fd98 Move docs to the proper place 2020-01-18 06:59:21 -08:00
1bd4f54fa6 update format 2020-01-17 11:07:55 -08:00
11cc2903e4 re-fix url link 2020-01-17 11:07:55 -08:00
b124e3e8e7 fix url link 2020-01-17 11:07:55 -08:00
ffd5f3469f Correct display format 2020-01-17 11:07:55 -08:00
0f0e5ddf5f Add vcpkg installation instructions 2020-01-17 11:07:55 -08:00
1f110702a1 Remove redundant braces 2020-01-15 15:07:30 -08:00
4ccbe4b5f2 Avoid namespace clash for fmt
## Problem

In the case of an existing `fmt` namespace (in my project this looks like `Project::fmt`) it is possible to get a namespace clash in debug builds (MSVC 2017)

## Proposed Solution

When referencing `fmt` internally, be explicit that it is relative to the global namespace using `::fmt`
2020-01-15 11:23:24 -08:00
40638a75b3 Use C++11 compatible std::is_same operations
The `operator()` member function of `std::is_same` was added in C++14.  For C++11, the `::value` needs to be used instead.
2020-01-15 11:20:47 -08:00
c8dd9cc99d Use type_identity to block unnecessary template argument deduction (thanks Tim Song) 2020-01-15 10:27:50 -08:00
4bbe57cebf Work-around for nvcc
The nvcc compiler (at least up to 9.2) defines `__SIZEOF_INT128__`, but doesn't support 128-bit integers on device code:
```
error: "fmt::v6::format_arg_store<fmt::v6::basic_format_context<std::back_insert_iterator<fmt::v6::internal::buffer<char>>, char>, const char *, int, const char *>" contains a 128-bit integer, which is not supported in device code
```
2020-01-15 07:31:58 -08:00
55b6130055 Use C++11-compatible operations
The `std::is_base_of<T,U>()` and `std::is_reference<T>()` member functions were added in C++14.  To maintain C++11 compatibility, use the `::value` instead.

Current code fails on intel-17 and other compilers if using strict C++11
2020-01-15 07:23:39 -08:00
ae3ea156ea Fix for older versions of intel compiler
The intel-17 and intel-18 compilers seem to require that `u` be `const`:
```
/src/fmt/format.h(226): warning #437: reference to local variable of enclosing function is not allowed
        char data[sizeof(u)];
```
If `u` is declared as `const auto u =1u` instead of just `auto u=1u`, the file compiles with no warnings.
2020-01-14 17:56:06 -08:00
77165fdf85 Use FMT_NOEXCEPT instead of noexcept directly
Otherwise breaks on compilers without noexcept support
2020-01-14 09:31:31 -08:00
65ac626c58 Improve join docs 2020-01-12 07:26:16 -08:00
cd0b3f9695 check if _SECURE_SCL is defined not equal to 0 2020-01-09 15:01:48 -08:00
cef1e4354b Optimize grisu_gen_digits 2020-01-07 16:11:18 -10:00
0201c8db21 Restructure float_format 2020-01-07 14:41:30 -10:00
9e3f3e8cff Fix handling of output iterators in format_to_n (#1506) 2020-01-05 09:59:01 -10:00
aa07c57654 Move vprint_mojibake to the internal namespace 2020-01-04 08:31:18 -10:00
a73d89e9c7 Catch invalid uses of fmt::arg 2020-01-04 07:11:35 -10:00
cb8e7caf7c Convert 'char8_t' character sequences to 'char' sequences
Otherwise, Google Test will insist on inserting 'char8_t' NTBS into 'char' streams, but basic_ostream<char>::operator<< overloads taking 'char8_t' arguments are defined as deleted by P1423.
Handling individual 'char8_t's is done inline.

This fixes the compilation errors seen in C++20 mode beginning with VS2019 Update 2.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2020-01-04 07:01:48 -10:00
b3fd0005dd Suppress a bogus -Wdouble-promotion warning 2020-01-03 06:57:14 -10:00
7b478f9dec Simplify example 2020-01-02 07:31:45 -10:00
c85efef312 More showpoint fixes and tests (#1498) 2019-12-30 13:08:35 -10:00
455a7c0787 Clarify lifetime of basic_format_args 2019-12-30 08:51:47 -10:00
674c326d7c Update syntax.rst 2019-12-29 07:25:34 -10:00
061a9897fe Update syntax.rst 2019-12-26 16:49:40 -10:00
d2d1c9c560 warning C4267: 'argument': conversion from 'size_t' to 'DWORD', possible loss of data 2019-12-26 08:07:24 -08:00
b6e19e5953 Update apidoc 2019-12-24 12:08:37 -08:00
f219dcd59b Add fmt::bytes 2019-12-24 10:45:15 -08:00
dea7fde8b7 Deprecate u8string_view 2019-12-24 09:44:57 -08:00
5390e29d42 Enable mojibake 2019-12-24 08:42:29 -08:00
9f6434dcde Improve UTF-8 handling on Windows 2019-12-23 16:19:11 -08:00
dac9a7f99d Improve UTF-8 handling on Windows 2019-12-22 12:05:28 -08:00
3ca9533f38 Flatten forward 2019-12-22 08:23:54 -08:00
7eec036d9a Improve UTF-8 support 2019-12-21 19:53:52 -08:00
e6b37b4aff Handle block boundaries in utf8_to_utf16 2019-12-21 16:33:34 -08:00
8cf4c52068 Apply clang-format 2019-12-21 13:10:45 -08:00
74532c23a3 Make type a scoped enum 2019-12-21 12:22:17 -08:00
b308159be5 Make round_direction a scoped enum 2019-12-21 09:24:42 -08:00
162995fedd Add os.h to docs 2019-12-18 14:17:49 -08:00
8b41362a0a Add trailing decimal point if # is specified (#1476) 2019-12-18 12:41:56 -08:00
1b1c70108a trailing_zeros -> showpoint 2019-12-18 12:12:09 -08:00
d7e72a09e0 Simplify FMT_STRING_IMPL 2019-12-18 11:50:47 -08:00
2201890d7a Apply clang-format and update inclusion guards 2019-12-18 11:17:36 -08:00
6100ed4bb3 Eliminate NVCC NVidia compiler emits unreachable code warnings
Similar to the MSC Compiler, the NVidia NVCC compiler also
emits unreachable code warnings when there is a return
statement following an exception.  These changes eliminate
those warnings.
2019-12-18 10:39:40 -08:00
1afe201ae8 Handle block boundaries in utf8_to_utf16 2019-12-18 10:35:51 -08:00
cd2b99032f Chore(readme): use https (#1481) 2019-12-17 06:48:27 -08:00
9acf89fef6 Mitigate MSVC issue with min/max macros (#1480) 2019-12-16 08:24:00 -08:00
9ea42fb26e Rename posix-test to os-test 2019-12-15 16:43:40 -08:00
da2569827e posix.cc -> os.cc 2019-12-15 12:36:15 -08:00
35959a31d7 Move OS-specific APIs to a separate header 2019-12-15 11:46:45 -08:00
ec2463c905 Implement utf8_to_utf16 using utf8_decode 2019-12-15 09:35:26 -08:00
0012917f69 Add a UTF-8 decoder 2019-12-15 07:28:19 -08:00
9e450911fa Give an error on precision overflow 2019-12-14 07:45:27 -08:00
068d20bc31 Avoid shadowing warnings in FMT_STRING 2019-12-14 07:00:08 -08:00
a99fbe67b9 Apply a typo fix retroactively 2019-12-14 06:50:53 -08:00
adbed11ed4 Fix a typo 2019-12-13 15:49:40 -08:00
8ab1c5c6e8 Squelch MSVC warning exporting subclasses of runtime_error (fix for PR #1433) (#1470)
* Squelch MSVC warning exporting subclasses of runtime_error

When compiling {fmt} as a DLL, MSVC complains that we are exporting
classes that inherit from "std::runtime_error", which we are not
exporting.

In this case, it's not really a problem because that symbol is already
exported via the C++ stdlib. So we just add a pragma to silence the
warning.

* Fix compilation with MinGW

Commit 3bc28fcc6b ("Squelch MSVC warning exporting subclasses of
runtime_error", 2019-11-29) silenced a MSVC warning under. The MinGW
compiler also defines _WIN32, but does not support the "warning" pragma.

Introduce a helper macro to squelch the MSVC warning only when using the
Microsoft compiler.

Signed-off-by: Beat Bolli <dev@drbeat.li>

* Fix compilation with VS2015 (#1450)

VS2015 does not support the __pragma(...) syntax in the midst of a
class declaration, so move it to just before the declaration.
2019-12-13 12:16:36 -08:00
a770009fcc Improve error reporting 2019-12-13 11:34:03 -08:00
598e6042d1 warning C4468: 'fallthrough': attribute must be followed by a case label or a default label 2019-12-12 06:25:33 -08:00
e09814dc93 Merge branch 'master' of github.com:fmtlib/fmt 2019-12-11 15:44:44 -08:00
b272fb3605 Extend FMT_FALLTHROUGH compatibily to gcc and clang pre-C++17 (#1469) 2019-12-11 14:28:20 -08:00
f94b7364b9 Update version 2019-12-11 06:16:42 -08:00
7abec071b5 Update changelog 2019-12-11 06:15:06 -08:00
b7eb8c8921 Prepare for the next release 2019-12-10 21:50:14 -08:00
ae7c50185d Reintroduce sprintf_format for ABI compatibility 2019-12-10 20:44:08 -08:00
9f2e7edaeb Fix handling of types convertible to std::string_view 2019-12-09 13:25:08 -08:00
fd52de0c6b Add FMT_CUDA_TEST CMake option to enable cuda-test 2019-12-09 07:30:34 -08:00
f675cb887e Remove redundant cast 2019-12-08 18:01:59 -08:00
73a16b827f Fix handling of int128_t in format-impl-test (#1461) 2019-12-08 17:07:20 -08:00
72879db40e Clean-up sign-conversion warnings in public headers 2019-12-08 16:07:55 -08:00
d3aa0c3a28 Clean-up sign-conversion warnings in test code 2019-12-08 16:07:43 -08:00
31de9a1b80 Revert "Clean-up sign-conversion warnings in test code"
This reverts commit 227bfe62dd.
2019-12-08 15:47:24 -08:00
227bfe62dd Clean-up sign-conversion warnings in test code 2019-12-08 15:21:38 -08:00
95dfdc6cc4 Update README.rst 2019-12-07 10:12:56 -08:00
5916ff63c4 Update README.rst 2019-12-07 10:12:15 -08:00
1ab80aa92c Fix handling of types with custom formatters that are convertible to std::string_view 2019-12-06 11:40:21 -08:00
4f4d876616 Remove '%' from the docs 2019-12-06 07:06:19 -08:00
f443bd3baf Ditch decimal_formatter (#1363) 2019-12-05 19:07:45 -08:00
1219b65f21 Relax fallthrough attribute detection 2019-12-05 10:40:15 -08:00
071794ec65 Update version 2019-12-04 12:21:48 -08:00
d22e4ad85b Remove trailing comma 2019-12-04 12:20:52 -08:00
983806b0c1 Update changelog 2019-12-04 12:03:44 -08:00
02af5beb8a Bump version and update changelog 2019-12-04 10:22:07 -08:00
123e7f7fc3 Revert #1433 because of build failures (#1450) 2019-12-03 09:24:15 -08:00
168460f02c Remove TYPES 2019-12-03 06:45:00 -08:00
a64f60c849 Remove unneeded FMT_API. 2019-12-03 05:55:04 -08:00
1a599117d8 Export assert_fail with FMT_API. This fixes dll build. 2019-12-03 05:55:04 -08:00
b160123e39 Update ChangeLog.rst 2019-12-02 16:18:06 -08:00
5981588565 Fix compilation with MinGW
Commit 3bc28fcc6b ("Squelch MSVC warning exporting subclasses of
runtime_error", 2019-11-29) silenced a MSVC warning under. The MinGW
compiler also defines _WIN32, but does not support the "warning" pragma.

Introduce a helper macro to squelch the MSVC warning only when using the
Microsoft compiler.

Signed-off-by: Beat Bolli <dev@drbeat.li>
2019-12-02 12:56:46 -08:00
8bbe76af3a Add a missing decimal point in exponent notation with trailing zeros 2019-12-02 11:36:33 -08:00
4ca6821e8f Update version 2019-12-01 16:58:40 -08:00
7111a1eb9f Bump version 2019-12-01 16:50:07 -08:00
ae00bbdc91 Update changelog 2019-12-01 16:39:58 -08:00
e71e07d9fb Update changlog 2019-12-01 16:26:07 -08:00
0184df7020 Update docs 2019-12-01 14:49:56 -08:00
1cbae6e9ba Put vprint declarations in one place 2019-12-01 14:43:51 -08:00
159f89e2b8 Fixing installation directory of '*.dll' files on Windows 2019-12-01 14:36:21 -08:00
4b120b68ae Clean up includes 2019-12-01 10:19:07 -08:00
186b225d9d Update changlog 2019-12-01 10:16:01 -08:00
4cbf4888ea Update changelog 2019-12-01 10:04:38 -08:00
e31f2b3d03 Update changelog 2019-12-01 09:27:28 -08:00
62da1db62a Avoid wchar_t instantiations 2019-12-01 07:34:09 -08:00
3bc28fcc6b Squelch MSVC warning exporting subclasses of runtime_error
When compiling {fmt} as a DLL, MSVC complains that we are exporting
classes that inherit from "std::runtime_error", which we are not
exporting.

In this case, it's not really a problem because that symbol is already
exported via the C++ stdlib. So we just add a pragma to silence the
warning.
2019-11-30 12:00:25 -08:00
3c05fa46c6 Update changelog 2019-11-30 09:18:16 -08:00
ba6e330fd3 digits -> num_bits 2019-11-30 08:41:07 -08:00
6037b3cae9 Fix dangling else problem in FMT_ASSERT 2019-11-30 07:52:33 -08:00
fafb03fa6d Fix handling of fallback_uintptr 2019-11-30 07:31:38 -08:00
2f9acd1838 Remove dependency on <cassert> 2019-11-29 09:37:18 -08:00
aaf829bfb1 Fix fallback pointer formatting on big endian, take 2 2019-11-29 07:07:08 -08:00
b994a0ab13 Fix handling of missing fraction in snprintf_float 2019-11-29 06:17:29 -08:00
bb205d940d Fix fallback pointer formatting on big endian 2019-11-29 05:15:59 -08:00
ef7369ce90 Update docs 2019-11-28 08:09:46 -08:00
40e4c227db Update changelog 2019-11-28 07:43:22 -08:00
ea54b21e78 Remove invalid noexcept annotation
buffered_file& operator=(buffered_file&& other) calls close which can
throw.
2019-11-28 06:43:08 -08:00
9cbf4b087c Fix -Wconversion warnings 2019-11-28 06:43:08 -08:00
1200a34e10 Update changelog 2019-11-27 16:15:42 -08:00
9c7e2a6c6f Add missing newline 2019-11-27 11:06:40 -08:00
34e921f6fe Update docs 2019-11-27 09:26:32 -08:00
c3be0f593d Refactor floating-point formatting 2019-11-27 08:08:22 -08:00
c68703c9f4 float_spec -> float_specs 2019-11-26 15:53:24 -08:00
9a21728b0a Remove gen_digits_params 2019-11-26 11:27:53 -08:00
3de36e9348 Enable -Wswitch-enum in CI 2019-11-26 10:17:48 -08:00
4afb39bc24 Update README.rst 2019-11-26 08:33:16 -08:00
7ffa62db18 Fix precision handling in snprintf_float 2019-11-25 20:00:10 -08:00
0d07db1234 Fix handling of streamable and convertible to string types 2019-11-25 16:46:33 -08:00
d19ed6716d Fix hexfloat buffer reallocation 2019-11-25 15:54:04 -08:00
99b6e928d4 Fix handling of types with deleted rvalue conversion to string (#1421) 2019-11-25 08:30:47 -08:00
57cd3f72e9 Update comment 2019-11-24 15:34:33 -08:00
111fc127fe Remove fp::operator- 2019-11-24 13:28:15 -08:00
6003ec3f25 Simplify Grisu implementation 2019-11-24 13:24:28 -08:00
8877a67724 Instantiate snprintf_float 2019-11-24 08:57:39 -08:00
75fff1db64 Minor cleanup 2019-11-24 08:43:56 -08:00
28d7191c27 Don't print trailing zero with fixed, precision=0, and showpoint (#1417) 2019-11-24 08:23:10 -08:00
43271ba8e8 Handle null terminator at the end of the buffer 2019-11-24 07:15:25 -08:00
63a9f3fcd4 fix bad oss fuzz link in the oss-fuzz badge 2019-11-23 12:37:59 -08:00
4cf59ce734 Integrate Grisu and sprintf digit generators 2019-11-23 06:56:29 -08:00
7395472dde Refactor floating-point formatting 2019-11-22 18:49:19 -08:00
9108b25da9 Merge branch 'float' 2019-11-22 08:54:28 -08:00
4d366c68b7 Merge branch 'master' of github.com:fmtlib/fmt 2019-11-22 08:53:58 -08:00
ded1e7679e Refactor floating point formatting 2019-11-22 08:22:22 -08:00
c7edd8e570 Cleanup FP formatting 2019-11-20 13:17:03 -08:00
75108a56f6 Don't print % for nan and inf 2019-11-20 12:26:48 -08:00
3e1f70fe02 Merge write_fp into write 2019-11-20 12:20:17 -08:00
125fc5e520 Update comment 2019-11-20 11:45:25 -08:00
6793ffc1d6 Update README.rst 2019-11-20 09:33:59 -08:00
f4fcc5fd28 Update README.rst 2019-11-20 09:31:11 -08:00
4de41aa655 Move basic_writer::write_fp to where it belongs 2019-11-20 08:22:34 -08:00
404a880bd4 Make parse_arg_id more readable 2019-11-20 08:12:23 -08:00
092d2dc7b2 Merge safe-duration-cast.h into chrono.h 2019-11-20 08:05:18 -08:00
093e554211 Remove redundant qualification 2019-11-20 07:44:34 -08:00
d0696b0aa6 warning C4456: declaration of 'num_digits' hides previous local declaration 2019-11-20 06:43:46 -08:00
66d7746bb3 Use grisu for exponent notation 2019-11-19 16:55:11 -08:00
e9bff78814 Don't parse % unless FMT_DEPRECATED_PERCENT is set 2019-11-19 11:54:18 -08:00
57b6f2966d Deprecate the fmt macro 2019-11-19 11:28:17 -08:00
d79493e5ee Remove Grisu2 2019-11-19 09:50:59 -08:00
78842ce0d6 test: add default constructor for a const value
This fixed a compilation error of the OS X 10.11.6 C++ compiler:

    ./fmt/test/format-test.cc:1861:16: error: default initialization of an object of const type 'const Answer' without a user-provided default constructor
      const Answer const_answer;
                   ^
                               {}
2019-11-19 08:32:35 -08:00
5420bcce2d Make % an opt-in to improve compatibility with std::format 2019-11-18 08:04:43 -08:00
56a2e2075c Refactor float spec parsing 2019-11-18 07:37:36 -08:00
ed117baa4f Replace bool with float_format and add exponential 2019-11-17 15:52:13 -08:00
f26446290b Move float_spec_handler to internal namespace and update asserts 2019-11-17 13:47:00 -08:00
7e1cb3237a Fix indentation 2019-11-17 13:17:43 -08:00
f67783d7e6 Clarify that numeric alignment is deprecated 2019-11-17 10:24:55 -08:00
1c6d85f7bb Apply coding conventions to examples 2019-11-17 10:15:16 -08:00
4a1da44f91 Apply coding conventions to examples 2019-11-17 10:14:06 -08:00
080b6899d2 Tweak the docs 2019-11-17 10:10:32 -08:00
c01ec54fde Document and clean basic_format_parse_context 2019-11-17 09:28:26 -08:00
b0c2ab93fa Bump version 2019-11-17 08:35:26 -08:00
9b7fe2a4a1 Don't use POSIX API on UWP 2019-11-17 08:29:08 -08:00
c58b7d9c2f Use overridden locale in ostream 2019-11-17 06:22:22 -08:00
ceff9b0b2e Tweak the docs 2019-11-16 07:14:57 -08:00
3dc8639f8a [docs] Added conda 2019-11-16 06:19:33 -08:00
dcde089b4e Improve POSIX API detection 2019-11-15 07:28:02 -08:00
2145a7bdcc Move has_formatter into the public fmt namespace. (#1407)
* Move has_formatter into the public fmt namespace.

This will allow users to do SFINAE-friendly checks for
the formattability of a type.

Fixes #1369
2019-11-14 07:08:24 -08:00
52ae134f84 Remove broken CI config 2019-11-14 07:06:38 -08:00
0d6dd0cc6a Correct basic_string_view from string ctor 2019-11-14 05:57:23 -08:00
1f918159ed [clang-tidy] Replace deprecated C headers
Found with modernize-deprecated-headers

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
6868f888b2 [clang-tidy] Add missing override
Found with hicpp-use-override

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
87cd545a1e [clang-tidy] Replace {} with = default
Found with hicpp-use-equals-default

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
12f9437e22 [clang-tidy] Use auto
Found with hicpp-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
bb0c8bfea8 [clang-tidy] Add noexcept where move is used
Found with performance-noexcept-move-constructor

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
e6e8298904 [clang-tidy] Add parentheses to macro arguments
Found with bugprone-macro-parentheses

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
0f0848e4f4 [clang-tidy] Use braced init list
Found with modernize-return-braced-init-list

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
a1fb5c7337 [clang-tidy] Changes suffixes to uppercase
Found with hicpp-uppercase-literal-suffix

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
8a411c2bca [clang-tidy] Turn deleted function to public
Found with modernize-use-equals-delete

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-08 09:35:26 +00:00
0047dc10a2 Mark apidoc as rst 2019-11-06 15:16:02 +00:00
263cdef8a0 Merge branch 'master' of github.com:fmtlib/fmt 2019-11-06 13:19:56 +00:00
d4ca54253a Update docs 2019-11-06 12:48:21 +00:00
5bb7b28e15 Document members 2019-11-05 10:43:18 +00:00
1409dfe76b Try fix CI 2019-11-05 10:39:14 +00:00
f1559e1d56 Use grouping() from locale for specifier 'n' 2019-11-05 07:22:12 +00:00
ffd05e65ed basic_parse_context -> basic_format_parse_context per standard and document 2019-11-05 07:13:58 +00:00
0889856d61 Fix UTF-8 truncation 2019-11-03 11:53:15 +00:00
d6eede9e08 Remove redundant ctor 2019-11-01 12:09:04 -07:00
213e09644f Workaround X11 madness (#1388) 2019-11-01 08:47:11 -07:00
6bfc9af8c9 Add double support to compile 2019-10-30 20:45:29 -07:00
3487f1b9cd Always inline grisu_gen_digits and disable grisu2 by default 2019-10-30 16:52:00 -07:00
791294d17b Apply get_cached_power optimization by jk-jeon 2019-10-30 08:07:01 -07:00
8e700619b7 Simplify format_handler 2019-10-30 07:02:38 -07:00
58c6f8c7f5 Make unsigned-integer-overflow sanitizer happy (#1377) 2019-10-28 14:41:09 -07:00
40414b3446 Don't emit trailing zeros in exponential notation (#1376) 2019-10-28 12:31:00 -07:00
b7a157401e Simplify grisu_writer 2019-10-23 13:52:09 -07:00
7aa58c30bf Simplify NVCC checks 2019-10-23 11:32:35 -07:00
8e9bffa986 clang-format 2019-10-23 11:20:21 -07:00
ce4d87acd4 Remove obsolete comment and clang-format 2019-10-23 11:15:43 -07:00
21acc2af43 Fix more Visual Studio 2019 pedantic warnings (#1371)
* format-inl.h(444,1): warning C4804: '>>': unsafe use of type 'bool' in operation
format.h(2808,1): warning C4127: conditional expression is constant

* More fixes for VS2019 pedantic warnings

* Fix "conditional expression is constant" VS2019 warning in more specific way

* Use const_check to silence constexpr warning
2019-10-22 17:13:03 -07:00
00669427df Patch compiler error when building using nvcc
If you compile using `nvcc` and pass the option `--expt-relaxed-constexpr` it will crash with an internal compiler error. This modification prevents using `constexpr` in `fmtlib` when compiling using `nvcc` and prevents the crash.
2019-10-22 08:34:52 -07:00
d39ebf3ff2 Optimize counting 2019-10-21 06:57:42 -07:00
6498bc6d31 Simplify grisu_writer 2019-10-20 19:29:24 -07:00
a967dcbe20 Improve handling of signs 2019-10-20 19:05:38 -07:00
8498bc97dd Initialize all the things 2019-10-20 17:53:18 -07:00
e2ea940673 Handle assymetric boundaries 2019-10-20 07:55:05 -07:00
2bc5585ff0 Fix computing lower boundaries for smallest normalized double 2019-10-18 17:56:52 -07:00
bb728a572a packed_arg_bitsize -> packed_arg_bits and remove packed_arg_mask 2019-10-18 10:06:57 -07:00
36d1390e67 Implement round half to even 2019-10-18 07:21:12 -07:00
599e0aef45 Support single precision floats in grisu formatting
Fixes #1336
2019-10-18 07:08:41 -07:00
91f7619cc9 Fix Visual Studio 2019 pedantic warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 2019-10-14 08:55:18 -07:00
c4dc6bef24 Apply clang-format 2019-10-13 18:31:09 -07:00
646966e973 Reduce bigint capacity 2019-10-13 14:06:38 -07:00
a5abe5d95c Handle negative exponent and nonnegative power 2019-10-13 13:16:09 -07:00
1cbc5fa6cb Handle negative exponent and rename value/pow10 to numerator/denominator 2019-10-13 12:50:48 -07:00
f7a5748fd3 Partially implement (FPP)^2 2019-10-13 09:28:35 -07:00
0e94b931a2 Fix a linkage error introduced by #1360 (#1362) 2019-10-13 08:23:47 -07:00
5e58eb97b1 Implement add_compare 2019-10-13 08:05:06 -07:00
3a15ea3ea5 Rename write_double to write_fp
It handles all floating point types, not just doubles.
2019-10-12 11:41:24 -07:00
b87ac4d840 Distinguish float from double 2019-10-12 11:41:24 -07:00
a927dda9bb Use words for packed constants 2019-10-12 11:41:24 -07:00
dd11d45847 Encode types using 5 bits
This is needed to support more than the current 16 types.
2019-10-12 11:41:24 -07:00
b55551f900 Implement more comparison operators 2019-10-12 09:22:24 -07:00
96f91428c6 Add defaulted copy and move operations to format_error and system_error (#1347)
* Avoid weak vtables by providing a private virtual member function

* Add warning Wweak-vtables to clang when FMT_PEDANTIC is on

* Add defaulted copy and move operations to format_error and system_error

Compiler generated copy operations are deprecated and move operations
are not generated altogether.

* Add warning Wdeprecated to clang when FMT_PEDANTIC is on
2019-10-11 10:44:20 -07:00
b732f28c00 Deduplicate color vformat and vprint
After #1351 they became essentially the same.
2019-10-11 10:42:11 -07:00
a82c1dc6d9 use memory_buffer to make color print behave atomic #1348 (#1351) 2019-10-10 08:28:56 -07:00
2730e90186 Fix compile error in printf with gcc9 (#1354) 2019-10-09 18:58:40 -07:00
e4d6d9d7c8 Implement divmod 2019-10-09 13:40:50 -07:00
a1079e9fd6 Fix undefined in format-test (#1349)
When `MoveCtor` performs `check_move_buffer`, the buffer allocator becomes null,
but then `MoveCtor` attempts to use it to allocate a dynamic buffer. This
succeeds nevertheless because a typical `std::allocator<char>::allocate` does
not use `this`, so it does not crash when `this` is null.

Fixes #1344
2019-10-08 15:42:51 -07:00
b66bb6b71f Fix undefined in core-test and printf-test (#1345)
* Fix undefined in core-test

Fixes "reference binding to null pointer" in BufferTest.Ctor

buffer.operator[] attempts to return a reference to `buffer.ptr_[0]` when `ptr_`
in `mock_buffer<int> buffer` is null.

* Fix undefined in printf-test

Fixes "signed integer overflow" in PrintfTest.Length

This occurs in `TestLength<long long>("ll")`, since its minimum value minus one
does not fit in long long.

* Fix undefined in printf %0$

Printf counts arguments from 1.

Fixes "shift exponent -4 is negative" in PrintfTest.InvalidArgIndex.

`do_get` is called with index -1 when `basic_printf_context.arg` is called with
id 4294967295 when basic_printf_context::get_arg subtracts 1 from arg_index 0 in
the format string "%0$d".
2019-10-08 06:28:39 -07:00
b60114533f Implement more bigint operations 2019-10-06 12:49:23 -07:00
c41cea8b18 Initial implementation of square 2019-10-05 16:37:52 -07:00
0c7650373c Fix handling of types convertible to std::string_view 2019-10-05 06:58:37 -07:00
0571013709 Repoint one more Python 2 link to Python 3
One more python reference, this one acknowledging the `str.format` function.
2019-10-01 11:44:36 -07:00
d2c9276fcd let README point to python 3 instead of 2 2019-09-29 08:30:47 -07:00
0fc7bd1573 Fix ambiguity for types with dodgy conversions 2019-09-28 11:35:20 -07:00
b4f1988c4b Provide overload for fmt::join that handles std::tuples
Address enhancement request #1322.

The overload is provided in `ranges` (original `fmt::join` exists
currently in `format.h` for historical reasons.

Tests for prvalue and lvalue tuple arguments as well as the empty
tuple are provided in `ranges-test.cc`.
2019-09-27 14:05:35 -07:00
4b8f8fac96 Update README.rst 2019-09-25 07:14:45 -07:00
3b2fc033d1 Making CUDA test work with CMAKE_MSVC_RUNTIME_LIBRARY
CMake 3.15 introduced a new way of handling MSVC CRT type definition for
the build: CMAKE_MSVC_RUNTIME_LIBRARY variable.
(https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)

This is supposed to be the way to go with MSVC CRT selection in new
projects. Using this method however breaks the current CMake script for
CUDA test. The reason is the CUDA test uses "FindCUDA" CMake module to
detect and set up CUDA support in CMake, which is deprecated since CMake
version 3.10, and which does not support CMAKE_MSVC_RUNTIME_LIBRARY
selector correctly (i.e. it does not propagate the compiler option
related to the CRT).

I did not find a way to "patch" in the correct compiler options, so
(while knowing this feature is only available from CMake 3.15 on) I
decided to change also the way CUDA is handled and instead of using
FindCUDA, used enable_language. Apart from having some nice additional
side-effects, it also fixed the problem with CRT selection.

However, the propagation of the compiler options (and in particular the
options related to C++ standard selection) is still a bit flaky on
Windows+MSVC platform, so it had to be done manually.

The patch makes two things in parallel:

1) Introduces MSVC_BUILD_STATIC, which, together with CMake version >=
3.15, allows building static version of the 'fmt' lib (and all the
tests).

2) At the same time, for CMake >= 3.15 it switches handling of CUDA
support from (old) FindCUDA to (new) enable_language, to fix the
problems which the old method has with the new CRT selector for MSVC in
a new CMake.

Added a check for CUDA before enabling it.

Using VERSION_LESS instead of VERSION_GREATER_EQUAL

Since apparently VERSION_GREATER_EQUAL exists only from CMake 3.7, while
Android is using CMake 3.6.

Removed MSVC_RUNTIME_LIBRARY logic from the CMake file.

The static build can be set on the command line with CMake >= 3.15
by defining the policy and the CMAKE_MSVC_RUNTIME_LIBARY this way:

cmake -G <gen> <options>
    -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
    -DMSVC_BUILD_STATIC=ON
    -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"

When MSVC_BUILD_DEBUG is set the test 'posix-mock-test' is skipped as it
does not build with the static runtime.
2019-09-25 06:46:11 -07:00
ac59d9f3a4 workaround VS2019 Update 3 compiler bug. (#1328) 2019-09-24 11:29:29 -07:00
8f27ce4d8b add test for multiple compilation types 2019-09-24 06:25:21 -07:00
89b0c71fa9 fix name clash in header-only mode 2019-09-24 06:25:21 -07:00
f6a783ad2e fix get 2019-09-24 06:25:21 -07:00
ccc8f5db02 Disable integral operator<< (#1316) 2019-09-23 20:34:08 -07:00
20fdb88a1c Remove redundant and nonportable test (#1313) 2019-09-23 13:36:12 -07:00
f29901097f Don't use const char* overload of operator<< (#1309) 2019-09-23 12:35:08 -07:00
758446c80d Fix a warning (#1319) and simplify code 2019-09-19 16:00:40 -07:00
f7aedc5fc4 Fix shared build on Solaris 2019-09-19 14:12:03 -07:00
840a817ed2 add oss fuzz badge 2019-09-19 08:23:05 -07:00
79c923ba2c fmt.pc.in: Fix for cross compilation
These variables get set to /usr/lib and /usr/include , which is totally wrong in a cross compilation
environment.

Changed to standard pkgconfig values consistent with most other ones.
2019-09-16 17:18:21 -07:00
5dc577c064 Update ChangeLog.rst 2019-09-12 18:20:48 -07:00
c6d1a94a9f Fix fallback_format (#1306) 2019-09-09 17:28:53 -07:00
0656045d02 Fix format overload that takes text_style (#1305) 2019-09-08 18:41:02 -07:00
c85ae23c73 Add max_value 2019-09-08 09:21:30 -07:00
b3bf665764 Implement multiplication and part of assignment from pow of 10 2019-09-08 08:27:00 -07:00
0887887e23 Implement left shift 2019-09-07 18:10:36 -07:00
ac71d853be Refactor normalize and clean up 2019-09-07 17:28:59 -07:00
6649b8e0ca value -> bigit 2019-09-07 14:23:19 -07:00
56b5c192a0 Add a bigint stub and reenable grisu 2019-09-07 13:50:22 -07:00
b2f0b6e44e Tweak comment 2019-09-07 08:43:35 -07:00
3d9f3c163b Integrate new format string compilation 2019-09-07 07:01:51 -07:00
19547d5148 Update index.rst 2019-09-06 13:27:28 -07:00
972ffd3151 Update README.rst 2019-09-06 13:13:30 -07:00
2ed412fa38 Update README.rst 2019-09-06 13:03:14 -07:00
df4dcf2ece Fixed vs 2015 warning about unused variable when grisu is off 2019-09-06 11:29:56 -07:00
f7a4b4ab91 Make numeric alignment optional 2019-09-06 09:43:53 -07:00
611cf0b3c6 Format octal 0 as 0 2019-09-06 07:03:47 -07:00
58a8f2f539 Add ccache to the list of projects 2019-09-06 06:26:09 -07:00
1882b9687b Reduce the numer of ifdefs with an empty (u)int128_t fallback 2019-09-05 18:03:47 -07:00
6de0454b42 Add support for built-in __int128 when available 2019-09-04 07:05:08 -07:00
16e3c48bb0 Move definition of FMT_USE_INT128 to core.h 2019-09-04 07:05:08 -07:00
8ce5f680f2 Rename internal::is_integral and internal::is_arithmetic
To reserve space for the type traits sharing the same name as the ones
from standard library.
2019-09-04 07:05:08 -07:00
2fd8f9ec8a Initial implementation of optimal compile-time formatter generation 2019-09-02 19:50:30 -07:00
fe642d7648 Clarify use of the core API in header-only mode (#1296) 2019-09-02 17:14:30 -07:00
a128b5b2cb Simplify format string compilation 2019-09-02 06:48:19 -07:00
466128de00 Remove unused code and refactor 2019-09-01 13:08:53 -07:00
22e98a5b6a Make compile work with user-defined types 2019-09-01 11:49:27 -07:00
f18a3f36a7 Remove string_view_metadata
string_view_metadata was introduced to make compiled format relocatable.
However, format string compilation is an optimization and therefore
adding overhead and extra complexity for relocation is undesirable.
In most cases the string will be either static or outlive compilation
and formatting and if it doesn't, it's possible to make compiled
representation relocatale by other means.
2019-09-01 11:10:49 -07:00
7cad33563c Refactor format string compilation 2019-09-01 10:28:41 -07:00
e1ab6bc006 Simplify format string compilation 2019-09-01 08:31:32 -07:00
24a88545d9 Add -Werror to tests 2019-08-31 09:26:45 -07:00
422e7b9d70 Fix compile-time checks for user-defined types (#1292) 2019-08-31 08:35:38 -07:00
d1dd9d5327 Document floating-point n specifier (#1291) 2019-08-31 08:16:47 -07:00
9a56a608ee Fix warnings (#1288) 2019-08-31 08:16:47 -07:00
c76957565c FixedEnum -> StrongEnum and make it a regression test 2019-08-31 08:16:47 -07:00
200ee6f108 Fix minor clang-tidy warnings
using instead of typedef.

climits instead of limits.h

Added missing cast to size_t.
2019-08-31 07:02:21 -07:00
bcd9b9331a Map not int enum to correct underlying_type (#1286)
* Map not int enum to correct underlying_type

* Use non-zero constant in TestFixedEnum
2019-08-31 06:25:38 -07:00
345ba07f1d Add a CUDA test
test cuda: import fmt in CUDA source code

Current test is only for Windows(cl.exe).
Need to test more with the other host compilers...

* Activate the test when `find_package(CUDA)` worked
* The test runs with C++14

Detailed comments in 'test/cuda-test'

test cuda: add more comment / macro check

* checks both `__NVCC__` and `__CUDACC__`

More comments for CMake and CUDA source file.

test cuda: <fmt/core.h> checks NVCC and CUDA

The header file checks 2 things.

* __NVCC__: if the compiler is from NVIDIA
* __CUDACC__: if the source code is CUDA(.cu) file

Since we can't sure all users prefer latest, Version for
`find_pacakge(CUDA)` is downgraded to 9.0.
This is the minimum version for C++14 in CUDA
2019-08-30 17:45:50 -07:00
hhb
9e2490be4c Rename precision parameter
To avoid clang warning:

fmtlib/include/fmt/chrono.h:753:32: error: declaration shadows a field of 'formatter<duration<type-parameter-0-0, type-parameter-0-1>, type-parameter-0-2, void>' [-Werror,-Wshadow]
2019-08-28 07:29:04 -07:00
3f75e2b69e Make buffer_range public and update custom formatting docs (#1281) 2019-08-28 06:50:20 -07:00
744302add0 Workaround broken [[deprecated]] in Intel compiler (#1273) 2019-08-28 05:58:09 -07:00
f5556225a4 Eliminate shadow variable warning
gcc-9 gives the following shadow warning:
```
In file included from /Users/libraries/ioss/src/fmt/ostream.h:12,
                 from /Users/libraries/ioss/src/Ioss_DatabaseIO.C:59:
/Users/libraries/ioss/src/fmt/format.h: In function 'void fmt::v6::internal::parse_format_string(fmt::v6::basic_string_view<Char>, Handler&&)':
/Users/libraries/ioss/src/fmt/format.h:2442:10: warning: declaration of 'struct fmt::v6::internal::parse_format_string(fmt::v6::basic_string_view<Char>, Handler&&)::writer' shadows a global declaration [-Wshadow]
 2442 |   struct writer {
      |          ^~~~~~
/Users/libraries/ioss/src/fmt/format.h:1703:7: note: shadowed declaration is here
 1703 | using writer = basic_writer<buffer_range<char>>;
      |       ^~~~~~
```

Since the `writer` struct is only used internally in the `parse_format_string` function, its name can be changed somewhat aribtrarily to avoid conflicts with names in an outer scope.

Note that this warning is also present in the 6.0.0 release.
2019-08-27 14:29:39 -07:00
ad3c7855e2 Fix typos. 2019-08-27 06:26:17 -07:00
7512a55aa3 Update version 2019-08-26 06:23:37 -07:00
9bd2f1f9af Temporarily disable Grisu 2019-08-26 06:11:44 -07:00
b9815cf048 Simplify part_counter 2019-08-25 08:30:59 -07:00
fe00cddde2 Move part counter to the namespace scope
to reduce the number of instantiations
2019-08-25 08:22:43 -07:00
1a7d172dc7 which_value -> kind 2019-08-25 08:08:46 -07:00
006c2546f2 Get rid of basic_prepared_format 2019-08-25 07:57:56 -07:00
4ce006fb6e Simplify format string compilation 2019-08-25 07:48:09 -07:00
e2e557e273 Remove preparator 2019-08-25 06:47:15 -07:00
a5f470eb10 Test and fix compiled format_to_n and formatted_size 2019-08-25 06:38:41 -07:00
4070c1d80b PrepareTest -> CompileTest 2019-08-25 06:22:13 -07:00
f8b59251c4 Remove unused preparator 2019-08-24 12:48:24 -07:00
643aa4c8c4 Simplify format string compilation 2019-08-24 09:39:40 -07:00
ffe29a92f4 Get rid of internal::compile 2019-08-24 09:04:03 -07:00
e94d723667 Fix compiled format string version of format_to_n 2019-08-24 09:00:30 -07:00
a9337395a2 Remove unused variable 2019-08-24 08:46:15 -07:00
562a9f4991 Remove parts_container_concept_check 2019-08-24 08:41:43 -07:00
b257c56e51 Fix size types 2019-08-24 08:36:14 -07:00
1488df3395 Bump version 2019-08-24 07:31:25 -07:00
b918e3ff81 Fix docopt usage 2019-08-24 07:24:42 -07:00
23b04ca6d5 Update usage instructions 2019-08-24 07:16:45 -07:00
5d5918a74d Update usage instructions 2019-08-24 07:04:24 -07:00
413d97b33a Fix formatting in changelog 2019-08-24 06:46:43 -07:00
790fd90f40 Update changelog 2019-08-24 06:34:19 -07:00
c0890be77d Update changelog 2019-08-24 06:32:47 -07:00
5a4b24613b Update the default floating-point format docs (#1270) 2019-08-22 15:21:14 -07:00
45dc3486fe Update license 2019-08-22 08:37:36 -07:00
5a353fa8cf Draft license 2019-08-21 14:31:22 -07:00
c84d227da9 Update changelog 2019-08-21 13:06:21 -07:00
b2d4ca1546 Workaround an issue with std::filesystem::path being an infinitely deep range (#1268) 2019-08-21 11:22:59 -07:00
2aae6b120c Fix doc for importing header only target with CMake 2019-08-14 13:59:15 -07:00
9f09b8eed1 Fix a warning 2019-08-11 11:38:16 -07:00
2bb8120d98 Fix a warning 2019-08-11 09:27:59 -07:00
c1e97392be Fix warnings 2019-08-11 08:44:12 -07:00
4e99e09bb3 Fix warnings 2019-08-10 16:56:57 -07:00
1607a01870 Suppress a warning 2019-08-10 14:15:55 -07:00
e8219952c6 Restrict fmt::compile to literal strings
to make sure we don't break the API too much when making all of this
compile-time only.
2019-08-10 13:18:11 -07:00
544b537334 Update changelog 2019-08-10 10:01:23 -07:00
83c13a1fe3 Update changelog 2019-08-10 09:56:13 -07:00
2546dafece Update changelog 2019-08-10 09:25:16 -07:00
02c04b1736 Update changelog 2019-08-10 07:59:33 -07:00
5360ab0b59 Fix iteration over named arguments (#1168) 2019-08-09 11:53:07 -07:00
b615eca964 Update changelog 2019-08-05 05:37:44 -07:00
22a42c0b01 Cleanup compile implementation 2019-08-04 11:15:43 -07:00
c63624ed45 Update changelog 2019-08-04 10:38:33 -07:00
211d312406 Don't terminate on I/O errors in report_error 2019-08-04 09:38:47 -07:00
ef55e74e08 Update changelog 2019-08-04 09:20:49 -07:00
612669d343 Update changelog 2019-08-04 07:28:48 -07:00
ba63ac8c18 Make format_to a non-member 2019-08-04 06:47:49 -07:00
3fe49163bd Revert "Make format_to a non-member"
This reverts commit a5bd3ddb28.
2019-08-03 16:12:34 -07:00
a5bd3ddb28 Make format_to a non-member 2019-08-03 08:36:53 -07:00
3df0ea34e5 Remove unnecessary overloads 2019-08-03 08:26:51 -07:00
436acf3489 Make formatted_size & format_to_n non-members 2019-08-03 07:54:49 -07:00
823128049b Make format a non-member 2019-08-03 06:31:24 -07:00
1dfa2591b3 Make operator _a constexpr 2019-08-01 16:56:49 -07:00
6f2dd30e38 Simplify udl_formatter return type 2019-08-01 16:56:49 -07:00
431d0f85cf Use basic_string_view in non-template UDL 2019-08-01 16:56:49 -07:00
ad71f5a706 Use forwarding references in UDL template 2019-08-01 16:56:49 -07:00
d0f2f3b816 Update usage.rst 2019-07-27 20:25:40 +03:00
eac2796ce3 Fix locale detection 2019-07-26 12:13:05 +03:00
ee36257469 Internalize format_part 2019-07-26 09:02:45 +03:00
bbf0bada33 Simplify compile 2019-07-26 07:58:19 +03:00
3730b4f039 Cleanup compile implementation 2019-07-25 21:26:22 +03:00
25ff2efc0a Update changelog 2019-07-25 19:59:59 +03:00
9393fe26f6 prepare -> compile 2019-07-25 19:39:41 +03:00
b48ffc14a4 Update changelog 2019-07-25 18:44:40 +03:00
3268531bc9 Workaround a broken C locale on Windows 2019-07-25 12:55:23 +03:00
8bd59ec936 Use fputws for outputting wide strings
Also adds fwide byte/wide orientation checking to verify streams are
able to receive the character type in question.

On Windows, the fwide calls are no-ops that pass through the second
arg and optimize out the if statement entirely.
2019-07-25 10:29:32 +03:00
1235f0a24a Fix typo in usage.rst 2019-07-24 15:54:02 +02:00
4fb73d1145 Update README.rst 2019-07-21 15:28:48 +02:00
f9ceefb0fe Fix a warning and is_negative usage 2019-07-19 14:18:10 +02:00
6bcc3fd216 Fix warnings 2019-07-19 13:27:41 +02:00
6a497e1d06 Fix warnings 2019-07-19 06:18:46 +02:00
e9b9b0aefa clang-format 2019-07-18 06:28:53 +02:00
ec24342b2b Fix more warnings 2019-07-18 06:28:17 +02:00
230b24944c Fix sign conversion warnings 2019-07-17 21:18:55 +02:00
cadd92d69f Fix #1232. 2019-07-17 11:52:10 +02:00
41076d1de3 Use FMT_THROW in fmt/color.h.
This allows fmt to be compiled with `-fno-exceptions`.
2019-07-17 10:15:31 +02:00
d561cb47a7 Opt-in macro to enforce use of compile-time format strings 2019-07-16 07:08:59 +02:00
699fe8e711 Remove const qualification in compile-time checks 2019-07-15 09:20:16 +02:00
da2d33f1f1 Update changelog 2019-07-12 16:21:13 -07:00
af4734fd15 Fix warnings 2019-07-12 16:03:12 -07:00
a3a74672a0 Update signatures 2019-07-09 17:05:34 -07:00
c11e68305f Update signatures 2019-07-09 17:01:13 -07:00
dd8cc8b0ba Disallow passing views as lvalues 2019-07-09 12:18:48 -07:00
f6f0415b83 typedef -> using 2019-07-07 17:14:26 -07:00
c92dc37464 typedef -> using 2019-07-07 15:40:34 -07:00
e3f20d3e13 Remove gcc 4.4 workaround and use proper alias templates (#940) 2019-07-07 14:35:56 -07:00
b438812324 Clean up is_output_iterator 2019-07-07 12:59:55 -07:00
bc15e3700e typedef -> using 2019-07-07 10:44:06 -07:00
cf5ebf2059 Cleanup 2019-07-07 10:09:22 -07:00
9c20e72de3 Cleanup 2019-07-07 07:58:30 -07:00
79209598f5 core_format_specs -> sprintf_specs 2019-07-07 06:54:25 -07:00
5488d0b53a spec -> specs 2019-07-07 06:39:20 -07:00
e4f84ee1c6 Refactor format_specs for #1109 and #940
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
2019-07-06 20:57:40 -07:00
8e0dcd20b3 Remove old deprecated functions 2019-07-06 07:55:52 -07:00
1d3e3d8c04 Make the 'n' format specifier work with grisu disabled 2019-07-04 15:15:14 -07:00
bc628f8d49 Fix EXPECT_DEBUG_DEATH_IF_SUPPORTED (#1214) 2019-07-04 07:55:36 -07:00
edd13fcc1c Fix small number rounding with fixed precision in grisu 2019-07-04 07:11:40 -07:00
6a031347e5 Remove unnecessary qualification 2019-07-03 21:14:45 -07:00
bc14c6ee20 Use the decimal point from locale 2019-07-03 17:55:00 -07:00
476f25cd81 Remove ancient gcc workaround 2019-07-03 16:37:02 -07:00
c9d5a08ed8 Add the 'n' float format specifier 2019-07-03 16:36:23 -07:00
f487ddbdfa thousands_sep -> add_thousands_sep 2019-07-03 16:18:12 -07:00
d8fd1699b1 Make data names follow naming conventions 2019-07-03 16:14:14 -07:00
c286ffc88d int_traits -> uint32_or_64_t 2019-07-03 16:01:21 -07:00
1289782f06 Get rid of add_thousands_sep 2019-07-03 15:50:05 -07:00
2249f5571e Simplify thousands separator handling and cleanup 2019-07-03 15:30:45 -07:00
e76446958c Cleanup and remove deprecated visit 2019-07-03 14:31:01 -07:00
de37de912b Remove deprecated color API 2019-07-03 14:19:24 -07:00
df1a3a141b Remove null_terminating_iterator 2019-07-03 14:00:55 -07:00
78dec87a46 typedef -> using 2019-07-03 11:05:20 -07:00
ded0a3bb3d Internalize undocumented basic_writer 2019-07-03 10:01:03 -07:00
83174f2a1f Refactor ranges 2019-07-03 07:23:08 -07:00
c2e84ee9cc Fix FormatTest.StrError on Solaris 2019-07-03 06:09:24 -07:00
2711cb1672 Apply clang format and other minor formatting tweaks 2019-06-30 08:52:15 -07:00
ab0ba8a9d0 Don't emit decimal point if there are no trailing digits (#1210) 2019-06-30 08:44:59 -07:00
bd3fd3bfda clang-format 2019-06-30 06:58:49 -07:00
260c115908 Fix formatting of 0.0 with (#1210) 2019-06-30 06:54:41 -07:00
9d97201ede add oss-fuzz support
see https://github.com/google/oss-fuzz/pull/2381

the history of the fuzz branch is long and messy and
is difficult to rebase on top of the current master.

Squashed commit of the following:

commit b9d6db50010e185d0af2590a35472e9334102248
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 29 21:50:34 2019 +0200

    update exception with a more accurate description

commit f3fbaf60cc80c7f57fa95962dc0069b10c3d3e61
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 29 21:34:55 2019 +0200

    fix missing flags in reproduce build

commit 40a17bec7a1ad724203577842a254ca9c42da388
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 29 21:22:48 2019 +0200

    move check for large precision values closer to where needed

commit ef6e23e1f52d639c5aec1a1e713157cec380a8c3
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 28 20:55:34 2019 +0200

    simplify the fuzzer build script

commit eadee6e0557be6df695e80f0f2717046a29846e0
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 28 20:47:54 2019 +0200

    minimize source code pollution

commit 1ece6416438f199c164ee9aa89f42ad1f21a4985
Merge: f404079b 037b84f2
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 28 20:22:52 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	CMakeLists.txt

commit f404079b4e00e51b0d5a4c9218cbe7afb350b777
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 28 20:20:52 2019 +0200

    make named_arg write into a string or a memory_buffer

    this makes the fuzzer consistent with the others.

commit 545dbe136817eef9e734c32991a324874a51bb4a
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu Jun 20 06:34:17 2019 +0200

    tidy up extra newlines, missing std:: etc.

commit 2d816ef2b13fc2a46c0df76a91f7912bd7196087
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:49:08 2019 +0200

    update unit test to handle expected result following review comment

commit a5b9a26808d0165acd2edc4c3baabf9bff40d8bd
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:40:06 2019 +0200

    update build script to reflect changes after review

commit 8411cb78984f76c74bca273c0bb18918e084e711
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:39:39 2019 +0200

    review comment: clarify what the .gitignore is for

commit 18d9e7bb43d98568fe491e076106e4fa29070b33
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:36:56 2019 +0200

    review comment: don't touch root .gitignore

commit 7683d7faa116a6e261da824ec6c1a6a75689841b
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:35:40 2019 +0200

    review comment: condiionally include main.cpp

commit be0bdaeb27b0c1914cc0b0fd85c2b3bcc6fd2245
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:31:28 2019 +0200

    review comment: drop commented out code not working on travis

commit 013429812d7fb745eec146296623ea245c4848b4
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:30:26 2019 +0200

    review comment: renumber case labels

    the old ones were to be able to reuse the corpus, let's drop it

commit f66fe7bead4a71978f21d9e47a8f3f9e4935fccd
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:06:47 2019 +0200

    review comment: libfmt->fmt

commit 4a4ddb654dd5b90646cd7e6ff45318c17b66dc9f
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:05:32 2019 +0200

    reuse fmt_safe_duration_cast

commit 0a1679411a8bd77c2ff34e1cd572307c92e12040
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:02:48 2019 +0200

    review comment: name convention, better name

    C was for "chrono duration"

commit 63084cac00b798c636e0dc13207df46a5c4539f6
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 20:00:50 2019 +0200

    reuse earlier extract fmt_safe_... function

commit b23388d4d7f919163ead9a9e9bdd50d14daf80b7
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:58:55 2019 +0200

    review comment: don't output inf.inf

commit 6f861f1d89d2127bbe2446d176d59a354665cc15
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:57:00 2019 +0200

    review comment: extract function for invoking safe_duration_cast

commit df19bc87ccff77d4bedf54fa3d3992f78ef699bd
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:47:30 2019 +0200

    review comment: leftover garbage

commit 84eea802efb1164c4f2a83b2e480a7c5bdf4e921
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:45:22 2019 +0200

    review comment: turn cmake option into macro for SAFE_DURATION_CAST

    decided to have it on by default

commit c3a159498c2544a52662cd03d23d5a1d00537bba
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:40:14 2019 +0200

    review comment: extra newline

commit aa556875c5161d817c347ff984dad171c7a35df9
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 19:38:49 2019 +0200

    review comment: file name convention

commit 4102d82c455324bda4ccd64072eab86b3f0ecebf
Merge: 28add37d 4912cff6
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 17 16:29:29 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 28add37df3944cbaa00f614e8063210a6d83c17c
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 21:44:06 2019 +0200

    disable check to pass travis

commit 4119378aedfd3e4063058e8f1f03c29d9f44d5e8
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 21:32:39 2019 +0200

    add missing include

commit ba2efb82f20d6ecb5e49a8c6ced96a7febedc175
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 21:04:41 2019 +0200

    try working around build issue on travis

commit 380671a2cb6e52f2b7d5eaad409d491baba5b7e6
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 20:22:41 2019 +0200

    write positive infinity without sign

commit fd72b9adace17e00c46aae24e061bf14c3af6bb1
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 20:20:50 2019 +0200

    remove leftover from merge

commit 1ae3128be2c53914e4c840d12e1b02c59758c378
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 20:14:45 2019 +0200

    format to buffer instead of string

commit 1d83a561244c2fe81231d17e911c6eb24c87cac4
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 19:50:19 2019 +0200

    fix warnings

commit a33b45a7bb5cf70eb3ef1cd95908282621195f1f
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 19:43:46 2019 +0200

    refactor and fix warnings

commit 02afb12dd5b05804a1a8b55e1b9fb7e3de593e84
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 19:17:27 2019 +0200

    use fixed size input

commit 35f84c8cf20efb18a137efecd10dcdc6bcebf7b5
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 19:07:43 2019 +0200

    factor out main into a separate file

commit a23b7a198ba739dd813897901855c98441e6f29b
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 18:56:40 2019 +0200

    refactor

commit 9a3f4cfb3bc32a304a1a49b8ff24fbc2f924266c
Merge: 7842582a 12f46838
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri Jun 14 18:20:03 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	include/fmt/chrono.h

commit 7842582a0089c24a5d44bbb2d156beb732bb7b58
Merge: 90cab5aa cbbee1b3
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu Jun 13 10:41:34 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 90cab5aa023271a3a746cf9c60dd613b4546ca10
Merge: 8feb8a3f e5422db4
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed Jun 12 18:49:08 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 8feb8a3fe20da043a8303e59b1580b4b2862cc57
Merge: e9fabac1 87fbc6f7
Author: Paul Dreik <github@pauldreik.se>
Date:   Tue Jun 11 19:18:35 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit e9fabac1dd6d710fec1b30ca51dc953f57f2f9f5
Merge: eaff9316 e1a67b52
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 10 22:38:36 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit eaff93166402ff9a16a9ab0fab1081104f4f06b8
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 22:29:01 2019 +0200

    drop old crashes

commit 7f861e481abb7367bd187c92fe202e25d36d0dd0
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:47:30 2019 +0200

    build fuzzers as part of the linux clang 6 build

commit 42c339066dce148723f452d4a94487a6ac80637f
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:42:12 2019 +0200

    travis has old libs

commit 9264e3ac82582a941eba3501301dee1468175c08
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:33:26 2019 +0200

    more travis workarounds

commit c6eed3adaf6cf65d440dd58c88a034f61c55114f
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:27:49 2019 +0200

    travis workaround

commit 5e230d6240841dbc67f0c08ace3a1c24defea54f
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:15:36 2019 +0200

    fix constexpr issues

commit cc5fc033479c769a8ac19115aef48020c532c943
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 21:11:13 2019 +0200

    add a fuzzer build

commit 3997375296eca0d0455e0935ef3aed8b010ecf2d
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:53:04 2019 +0200

    fix minor documentation errors

commit 1572411261abd5c0756ff2998ab707f1131d4fdf
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:49:25 2019 +0200

    polish the documentation

commit 9e5274437cfc3e9c82131c14cf7f3a0abdb10025
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:32:45 2019 +0200

    remove unused headers

commit 4b2492a5e037d3153de342ef7f2729b69e8f5dce
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:28:12 2019 +0200

    clang format

commit a0004ebb417bce5a24c15ea65a0f3741e45b8480
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:27:02 2019 +0200

    format also void*

commit 820142ee2076ae17fea25857c41a1ecdca4a8521
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:12:21 2019 +0200

    improve two_args with lessons learnt from the others

commit 7b8fd7f5123fccf78b600c69ca25d025582c095e
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:11:18 2019 +0200

    improve function names

commit 641bf36a7a061abf6a02d5e31f3adeb33b079f43
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:07:29 2019 +0200

    clang format

commit 7975c0c3cbe19a7159336ad8fcb170fa6259b1cb
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 20:06:02 2019 +0200

    apply lessons learned from chrono fuzzer on sprintf

commit 972124c9f921f8ef786f99c294f556bb7dd9b9ee
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:55:49 2019 +0200

    format to buffer instead of string

commit 7b015c692364d1e087a59dfe83dda1b8f8fd2991
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:50:25 2019 +0200

    apply lessons learned from the chrono fuzzer at one_arg

commit daa8ea95dd71704e367b760fa6605f5a7cac6890
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:41:17 2019 +0200

    renumber cases

commit a667365d0e0f3eb0bc6d6f2cfee5e128a6574aee
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:38:06 2019 +0200

    clang format

commit e0e361b8a3594c43e131d661a28381613a186c2b
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:36:35 2019 +0200

    disable fuzzing by default

commit ccb4274ab246ee1fe3becb2b73432179a8a5fe6f
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:36:25 2019 +0200

    refresh named_arg with lessons learnt from the chrono fuzzer

commit 60da706d4ef35c18eb967bf4ba8d395ef05a9c61
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:36:00 2019 +0200

    fix build error

commit e361bfc24246d7c7e91f5e45209eda2f22689d98
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 19:00:11 2019 +0200

    add comment about formatting to string vs. memory buffer

commit 74c0ed062d34eae1786ca699886ad4f3bccc7fd1
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 18:51:23 2019 +0200

    try to use better names

commit 4efea36f77020eecf3c7826f891417f94aedf6f4
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 18:46:07 2019 +0200

    fix clang build error

commit 03cdd2e4631ad302dde3e1048671d3bb08956096
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 18:44:21 2019 +0200

    drop workarounds fixed upstream

commit e936829ebbd97ed2e6f8c5f595b414c0982f2e4d
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 18:41:02 2019 +0200

    move the fuzzers into the test/ subdirectory

commit 2967765698259764c1f06966a7cdefbc5365e5f2
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 18:30:03 2019 +0200

    revert temporary tests handled upstream

commit 749c5027b0eab3d90d8fbfb6e55ee313a7f7dfe4
Merge: dee69088 5d9100fa
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:49:00 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit dee690881bd33bb77bee1d5ffce643e8bef84a33
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:40:37 2019 +0200

    keep documentation comment formatted properly

commit 87d2c99487eef586ce54d432697f384cbe7a50e1
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:36:12 2019 +0200

    switch to fmt constexpr macros

commit c23fa59139c425a3dfa2e5eeaeb3269c251c90d1
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:30:22 2019 +0200

    clang format

commit 9e58207e9b24a8cc90c721277405b409dd61740d
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:27:03 2019 +0200

    get rid of safe_duration_cast submodule

    replaced with an embedded miniature version

commit a4d36eac46e5db45ded96f80f84986f4f76ea0ec
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Jun 9 17:25:00 2019 +0200

    add safe_duration_cast into fmt

commit 7d5b0ecef37722c40952251c88d74a2552221d84
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 8 22:39:33 2019 +0200

    mark #1194 as fixed

commit ee91514ecf7a8788f2081996db85eef50d7cd57b
Merge: 60569117 4faadff0
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 8 22:25:37 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 6056911784bc86e6caf56a61fd64142f113d531e
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed Jun 5 09:58:30 2019 +0200

    format to small size buffer instead of string

commit 9f006097255c239188840b589f6e39cbb4476481
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed Jun 5 09:45:23 2019 +0200

    switch to fmt::string_view and workaround reported bug

commit 387de0d9440852fac974ff165b2555d54e2380da
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed Jun 5 06:26:15 2019 +0200

    ignore build directories

commit 55da271c5bb3c11a239c4e46570b6741803ce329
Merge: 3716491e c264e641
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed Jun 5 06:12:36 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 3716491ec51c34a918834857c67300eea180ba02
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 3 07:03:29 2019 +0200

    fix UB in on_second

commit 2740241b13b7417a4dae655f825ea5a551ffe7ba
Merge: 1c258402 d54e64b3
Author: Paul Dreik <github@pauldreik.se>
Date:   Mon Jun 3 06:37:18 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	include/fmt/chrono.h

commit 1c258402a4bd03f390e0256fa9475cc5187d37f9
Merge: ca9596d1 f57227a1
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Jun 1 08:01:58 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit ca9596d1c91b0315b407ce2c4b3e9e5ba1aeb640
Merge: 1c274cfd d07cc202
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 19:42:33 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 1c274cfd4112138bfc59dd16f58022016128fe85
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 08:12:10 2019 +0200

    make it easier for the chrono fuzzer to explore

    using a fixed size makes the cases cross pollinate
    each other better.

    the execution speed is much higher as well

commit f0d7cccdc70c98576b7129428c416e7c9e68a8aa
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 07:36:21 2019 +0200

    add a build adapted for analysis of fuzzing performance

commit 56f7cf3fa979de415174a10b18221727e3138b7b
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 06:25:10 2019 +0200

    allow negative values again

commit a77a5fc505bbeab1cfa36be16d40f7799689317a
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 05:45:55 2019 +0200

    fix UB on signed int overflow in chrono_formatter constructor

    see https://github.com/fmtlib/fmt/issues/1179

commit b6a592720be520b58ed2f2d8668ffc6c8b71f0f7
Merge: 492a2046 30bce6c1
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 30 05:26:30 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	include/fmt/chrono.h

commit 492a204623c3c4bbf04c9d47d69979d3a484959c
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 21:36:00 2019 +0200

    fix bad assert

commit 0ae68b03fbb0e80e292a01f529d5cd7e76349907
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 21:35:49 2019 +0200

    add unsigned types for chrono fuzzing

commit 2753d7db76645e8847ff2110c5e98f5c8de4a6b9
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 20:25:21 2019 +0200

    use C++17

commit bc12742f098ec8b513985daedc57faa518203eb0
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 19:44:59 2019 +0200

    add symlink for safe_duration_cast

commit 67201d2639b93736768e109d73b3e9ccc9401c48
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 19:40:40 2019 +0200

    turn on safe duration cast for the fuzzer builds

commit 31a70080a63a5213594e4b4e6a33e7e315cf756e
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 19:32:52 2019 +0200

    clang format

commit 981e30c5782d04453ece1b31e887da4f29268370
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 19:30:19 2019 +0200

    reduce maximum allocation size

commit 7ba51da81de7ecbc5498a22dc29de5b0648bcad2
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 19:30:01 2019 +0200

    make nan unit test pass

commit 95b4b9c28a589c30727826dd4e1367bebfad5894
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 18:39:08 2019 +0200

    special case nan and inf

commit 2673c965506e51d150c005340698a6e15d98aaba
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 16:40:11 2019 +0200

    build a fast fuzzer, for making coverage fast

commit db52b62612fd7ea3ceeaee05584fd8cb83e54a35
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 16:39:48 2019 +0200

    add safe duration cast as submodule

commit c8a028faec5d91728472f5de01ea8b1766fb929d
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 16:00:26 2019 +0200

    enable chrono fuzzing for non-negative values

commit de3555cc573e561691858ca16586f8b45a3ae703
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 13:06:35 2019 +0200

    try start using safe duration cast

commit 5c3245118c3debcb3f6f69c04c2c32d48449ee16
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 09:59:34 2019 +0200

    add failing test

commit 3a565d3b091c29210e24042f86869fecafb70914
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 09:59:09 2019 +0200

    fix cmake option type (should be string, not bool)

commit 61c67564207a13992b1c69d95614b2c4aec5df86
Merge: 63e7b9e3 bb254d14
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 29 07:03:42 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 63e7b9e32c714c594d019ef463c9c40a3510a2f2
Merge: 7dd1d80f 5e7bdf1b
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri May 17 19:17:20 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 7dd1d80f3a32465d0fa13ce733bff8686a5b0bad
Merge: 2c9aa5a3 2a9e8b52
Author: Paul Dreik <github@pauldreik.se>
Date:   Tue May 14 19:38:32 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 2c9aa5a31e64af25f8bb4afa8134258822532d3e
Merge: 16a442c8 2c77562b
Author: Paul Dreik <github@pauldreik.se>
Date:   Tue May 14 06:33:16 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 16a442c864dbdce70c22b4a859dba5e3b5edaf35
Merge: b1d70b61 f4dfd6e3
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 12 15:24:31 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	include/fmt/chrono.h

commit b1d70b6144c7a61e580eb44ec7d1bdd2368f5531
Author: Paul Dreik <github@pauldreik.se>
Date:   Fri May 10 08:52:57 2019 +0200

    prevent excessive time (found by oss-fuzz)

    the following triggered this:
    std::string message =
          fmt::format("\377{:.214718908}\377", fmt::arg("/\0", 0.f));

    there are probably more places with calls to fill_n which could be checked

commit 9a91093a6b20fd22afd6739f5dcba3b00f6f8eaf
Merge: 7de0fdec e9bab6d0
Author: Paul Dreik <github@pauldreik.se>
Date:   Thu May 9 06:06:32 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	include/fmt/chrono.h

commit 7de0fdec38270f2d0302413904a5ef1b13d47177
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 20:08:53 2019 +0200

    clang format

commit bb375e1ca10eb3cc2c6684bf698ad4738ab7eb10
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 19:47:10 2019 +0200

    seems to pass the unit test now (except for the nan stuff from victor)

commit 786b4b7351bc8e305ad7e68d11ca6b542f66d456
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 19:25:23 2019 +0200

    add assert triggering data, and unit test

commit 2790e480b81ec83d00315aa69407fe71b8c4c637
Merge: fa859a05 ca978b3d
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 18:42:51 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit fa859a05c2c3abef263166f3a44cdbaa3122d642
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 18:18:54 2019 +0200

    add crash

commit 1f6e341b1c4bc966a44c7a98b63f22bd65958d0b
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 18:18:27 2019 +0200

    assert floating point is finite internally

commit 50877748d08a0f4433af4f1213c5bc9021e76e7a
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 17:32:03 2019 +0200

    invoke undefined behaviour inside chrono

commit bac7ac4149f2d001f7b36236e1710484674d029b
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 17:31:35 2019 +0200

    refactor the fuzzer build script

commit b19c4cd84a0c8b6d4a7beb281ad881156173ce78
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 16:25:11 2019 +0200

    add one more crash

commit 7607592e06ebaa189dc180441fa1863430e0938e
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 16:24:05 2019 +0200

    add crashing input

commit b059a98b27b40cd284e08a54493c25363d743557
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 16:21:25 2019 +0200

    trigger undefined behaviour with NaN durations

commit 7cce33250282b397c00159e6809125f5fc1c0190
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 16:20:51 2019 +0200

    add asan only fuzzer

commit 757319a4e30978d8661b3be8f75937266071b413
Merge: a574b21c c1d430e6
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun May 5 06:34:59 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	test/chrono-test.cc

commit a574b21c840339abef5e4ad33612b6efac6ad54b
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat May 4 12:54:13 2019 +0200

    disable chrono fuzzing for now

    it triggers integer overflow and is not trivial to solve.

commit ff17322bceba53e0c2d9ebcf3756115ad148195e
Merge: d6a59851 29c10fbf
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat May 4 07:29:39 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit d6a598511c7dc0c208c2d688b2943b0d7c092029
Merge: 663b1592 4a4d72f9
Author: Paul Dreik <github@pauldreik.se>
Date:   Wed May 1 20:44:16 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

    # Conflicts:
    #	test/chrono-test.cc

commit 663b159235f8ae5f58fe80bb02d49bfa392056b0
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 22:36:07 2019 +0200

    add crash case (triggers assertion)

commit 082a5cb226142ea30b415d4231cea9425748741a
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 21:44:19 2019 +0200

    add const

commit b8d70919ea6be0d2e4c58ef82887496f55125ba9
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 21:29:43 2019 +0200

    provoke assertion

    fmt/include/fmt/core.h:246:
    typename std::make_unsigned<_Tp>::type fmt::v5::internal::to_unsigned(Int)
    [with Int = long int;
     typename std::make_unsigned<_Tp>::type = long unsigned int]:
    Assertion `(value >= 0) && "negative value"' failed.

commit e1966013af4eb7febf047d4629cc6236a6aae0e3
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 20:46:16 2019 +0200

    add more crashes

commit 1394ae3fe915319ce7dc63d6a9dc820a29c9539e
Merge: 89338cad 4c721e3a
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 17:16:14 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 89338cad4eed9441644ec8c5f1687b511c829ea4
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 09:40:32 2019 +0200

    add notes on how to reproduce crashes

commit 7dc3e4c7223617da274c4cccb9cf5459d0510e0b
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 09:28:20 2019 +0200

    add crashes from chrono duration

commit b62e8bc783134c2d15ebf0372c8a61b41624e6b1
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 09:26:53 2019 +0200

    rename fuzzer

commit 7f4ab2b80d072fe3ad96e37e45f3fa807a85c99f
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 09:15:38 2019 +0200

    clang format

commit a6cc2a35a9799e88b9ed89e578b7aefd9b09ad09
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 09:12:04 2019 +0200

    add chrono duration fuzzer

commit 682713c9a61d52b46e95fdb7d970a8733f77ce88
Merge: 8b934b37 8d8ea21c
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 28 08:07:56 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 8b934b37161d1389de603ced6560982507bb7ae5
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 10:23:44 2019 +0200

    clang format

commit 793d97b9af33269f5628094f547f9771e968e3f2
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 10:23:17 2019 +0200

    tighten memory allocation

commit e2301f2430b15c9817433206597ef82c990f49a0
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 10:19:56 2019 +0200

    clean up and set license (BSD 2-clause simplified, same as fmt)

commit e64c3fb35719afa644dee1f9f17829cace6e17ff
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 10:04:23 2019 +0200

    clean up and add afl

commit ab46241206aaf46759fd3f292ee4a1088b652d15
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 09:54:48 2019 +0200

    drop c++17 requirement

commit 20c01e1acf330c8a28192f55b16efeebddb72ab0
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 09:25:19 2019 +0200

    initial oss-fuzz compatible version

commit 6cbd91a37cf36a1d0e994bb16cf44a12622f7dca
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 08:42:51 2019 +0200

    initial commit of fuzzers from https://github.com/pauldreik/fuzzfmt

commit eaddfb16d86ef1c259b737e2aab40145b0c956a6
Merge: e37d7db3 134904c8
Author: Paul Dreik <github@pauldreik.se>
Date:   Sat Apr 27 08:38:19 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit e37d7db3b938c82f569d71e6bb00bd1bf8394db7
Merge: 99b2e08b bd516e34
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 21 17:28:06 2019 +0200

    Merge remote-tracking branch 'upstream/master' into fuzz

commit 99b2e08b6bef25b793df5ef07621c9c4402587de
Author: Paul Dreik <github@pauldreik.se>
Date:   Sun Apr 21 10:30:56 2019 +0200

    stop high memory use when fuzzing
2019-06-30 06:10:07 -07:00
037b84f214 Fix warnings 2019-06-24 16:46:48 -07:00
e37ee419c6 Export exceptions destructors
Reenabling Compiling and Linking as DLL.
2019-06-24 08:53:35 -07:00
e3488fcae2 Fix Warning
QtCreator (4.9) Clang Code Model (Clang 7) gives the
warning:core.h:404:11: error: an attribute list cannot appear here
core.h:116:24: note: expanded from macro 'FMT_NORETURN'
2019-06-24 08:53:35 -07:00
d5d5865615 Move strtod_l check to CMake since it's very system-specific 2019-06-23 17:10:57 -07:00
29ef7d31e4 Fix a warning 2019-06-23 11:09:15 -07:00
af83192d79 Fix warnings 2019-06-23 08:14:15 -07:00
6952732b6c Remove misplaced checks 2019-06-23 06:33:07 -07:00
b97e5d8c2a Remove deprecated fmt/time.h 2019-06-23 06:13:17 -07:00
572b077dbf Fix warnings 2019-06-22 20:52:33 -07:00
72e519a4bd Add formatter<std::string_view> 2019-06-22 20:26:28 -07:00
635e01fe74 Update <format> to the current wording 2019-06-22 13:44:48 -07:00
0e72c98043 Make undocumented output_range internal 2019-06-19 20:08:11 -07:00
f13906f408 back_insert_range<internal::buffer> -> buffer_range 2019-06-19 14:12:29 -07:00
22ddd4b989 Simplify feature checks 2019-06-19 07:46:09 -07:00
bb827341ed Add FMT_FUNC where necessary 2019-06-18 09:48:23 -07:00
64c54703d4 Cleanup 2019-06-17 11:02:18 -07:00
1c3197b8d8 Fix warnings 2019-06-17 09:21:29 -07:00
fd2292f13a Cleanup checked iterators 2019-06-17 08:30:37 -07:00
4912cff65d Fix handling of mapped types in compile checks (#1200) 2019-06-16 16:06:06 -07:00
4639843839 Cleanup 2019-06-15 09:44:51 -07:00
e29708ee57 uintptr -> fallback_uintptr to avoid confusion with uintptr_t 2019-06-14 18:47:36 -07:00
f03a6c5325 Cleanup 2019-06-14 13:38:44 -07:00
6c3d584e67 Simplify warning suppression 2019-06-14 13:03:34 -07:00
12f4683883 Make iterator_t an alias template 2019-06-13 21:32:58 -07:00
874d6727e4 Remove workarounds for pre-C++11 compilers 2019-06-13 20:56:08 -07:00
a9940192fb Fix warnings 2019-06-13 08:56:35 -07:00
34b5418359 Fix warnings 2019-06-13 07:29:10 -07:00
cbbee1b385 Fix handling of hexfloat 2019-06-12 20:53:01 -07:00
92a44db11c Fix warnings 2019-06-12 19:44:08 -07:00
d05d42751c Remove old msvc workaround from arg_formatter_base and fix warning 2019-06-12 19:27:23 -07:00
d32fe0f3f6 Fix hadling of nullptr 2019-06-12 09:22:36 -07:00
e5422db4b2 Fix handling of uintptr_t 2019-06-12 08:16:41 -07:00
9d7b64a259 More cleanup 2019-06-11 22:11:47 -07:00
5e293bd97a Remove unnecessary qualification 2019-06-11 20:36:39 -07:00
4a502d9802 Add remove_reference_t 2019-06-11 20:28:05 -07:00
d384cdd397 Make is_contiguous_back_insert_iterator internal 2019-06-11 20:16:57 -07:00
32544b6108 More cleanup 2019-06-11 19:22:19 -07:00
39f522a13a get_types -> encode_types 2019-06-11 18:50:14 -07:00
d7d2bebf99 Remove redundant typename 2019-06-11 18:29:47 -07:00
9427f15bef Fixed issue with formatting to an array of chars 2019-06-11 18:09:18 -07:00
87fbc6f756 get_type -> mapped_type_constant 2019-06-11 07:23:39 -07:00
a48daa60e5 Remove remove_volatile 2019-06-10 20:25:04 -07:00
afdbbac75c Cleanup 2019-06-10 18:10:26 -07:00
e33fe14f5b Simplify visit 2019-06-10 08:28:39 -07:00
e895da2ec3 Clean up value 2019-06-10 07:58:00 -07:00
e1a67b5285 Remove TODO 2019-06-10 06:54:09 -07:00
a291f07e1a Clean up argument mapping 2019-06-09 22:27:40 -07:00
5d9100fa2f Move char8_t to fmt/core.h 2019-06-08 09:42:11 -07:00
4faadff0a0 Add preliminary user-defined type support 2019-06-08 09:04:46 -07:00
5d48733596 Clean up value construction 2019-06-07 19:27:20 -07:00
0f0b42861b Cleanup 2019-06-07 17:53:25 -07:00
209db68b28 Get rid of FMT_CONSTEXPR11 2019-06-07 14:00:57 -07:00
cb4c59495e Deprecate convert_to_int 2019-06-07 13:38:08 -07:00
40779749ac is_formattable -> has_formatter 2019-06-07 06:51:21 -07:00
b3cf8613b1 Make formatter specializations override implicit conversions 2019-06-07 06:25:46 -07:00
3fdba04924 Reduce the number of nontrivial formatter instantiations 2019-06-06 22:02:53 -07:00
f5f3ffac59 Merge string make_value overloads 2019-06-06 08:29:16 -07:00
a38b99a188 Fix a regression in named argument handling introduced by prepare 2019-06-05 16:50:04 -07:00
aa31028b2c char_t_impl -> char_t 2019-06-05 10:13:34 -07:00
0787d69747 Simplify SFINAE 2019-06-05 09:02:33 -07:00
bae00aa8d7 Simplify is_string 2019-06-05 08:41:00 -07:00
388bb389e6 integral_constant -> bool_constant 2019-06-05 08:14:47 -07:00
7e39c7e6f4 Put stringy stuff together 2019-06-05 07:43:20 -07:00
3eff8f94d2 Update docs 2019-06-05 06:24:18 -07:00
469a4bbd35 Use enable_if_t 2019-06-04 21:38:18 -07:00
d2ee5f2407 Merge tests 2019-06-04 21:31:23 -07:00
c264e641ea Add conditional_t for pre-C++14 2019-06-04 18:50:30 -07:00
4aa0dc578b Fix docs 2019-06-04 18:02:55 -07:00
064ce6b6c0 Specialize is_char for character types 2019-06-04 17:08:58 -07:00
7893d85394 Clarify why we cannot have nice things 2019-06-04 08:47:25 -07:00
5bafcb437b Add comments about things broken in MSVC 2019-06-03 19:14:16 -07:00
1530242551 Fix signature in the docs 2019-06-03 17:35:15 -07:00
eddb84cfc0 Fix formatting of exotic characters 2019-06-03 17:08:00 -07:00
7e42c65bb6 Document a more useful to_string_view overload 2019-06-03 11:57:33 -07:00
1e6e87cb74 Update docs 2019-06-03 11:35:12 -07:00
0c6a6e0250 Get rid of the FILE* hack and reword apidocs 2019-06-03 10:27:00 -07:00
1653244c69 Fix compilation issue on VS2019 (#1186) (#1191) 2019-06-03 08:34:27 -07:00
d54e64b3c8 Make buffer_context an alias template 2019-06-02 18:28:49 -07:00
ec6651087d Remove old is_constructible workarounds and replace typedefs with using 2019-06-02 16:46:45 -07:00
4d4b8c238d FMT_CHAR -> char_t 2019-06-02 15:03:37 -07:00
56d2b91108 Install git 2019-06-02 13:57:19 -07:00
89d6c959b2 Fix cmake link 2019-06-02 13:24:32 -07:00
76ef39fc50 Update vagrant config 2019-06-02 13:19:33 -07:00
af2c73772c Implement parsing of string_views 2019-06-02 11:11:28 -07:00
9df0e2d1f1 Implement string parsing 2019-06-02 07:39:38 -07:00
5b7bbf8853 Revert "FMT_CHAR -> char_t"
This reverts commit 4c650057a0.
2019-06-01 15:01:04 -07:00
4c650057a0 FMT_CHAR -> char_t 2019-06-01 12:32:24 -07:00
2833c76f22 Move char_t to template param to reduce symbol size 2019-06-01 12:14:27 -07:00
67feef5589 Make enable_if_t more std-like and move to fmt namespace 2019-06-01 10:05:16 -07:00
78daa50ffc Fix handling of chrono durations with minimal signed rep 2019-06-01 09:36:37 -07:00
87e4ea2906 Fix a warning 2019-06-01 08:24:36 -07:00
c56b17029a Add msvc2019 to CI 2019-06-01 07:50:15 -07:00
c929684e33 inlines count_code_points(basic_string_view<char8_t)
count_code_points(basic_string_view<char8_t>) was defined in
fmt/format-inl.h, and only declared in fmt/format.h, but not defined
in src/format.cc. This commit moves the overload to fmt/format.h and
inlines it.
2019-06-01 07:17:22 -07:00
f57227a148 FMT_ENABLE_IF -> enable_if_t 2019-05-31 20:09:19 -07:00
634f707f2b Simplify char_t and remove msvc2013 from CI 2019-05-31 19:28:37 -07:00
406e632bd1 result_of -> invoke_result_t 2019-05-31 08:54:32 -07:00
49f78a427b Demacrify 2019-05-30 21:30:29 -07:00
637bf3c6d9 Workaround a bug in clang-format 2019-05-30 11:46:31 -07:00
8302c2f33b fmt::internal::declval -> std::declval 2019-05-30 09:46:10 -07:00
d07cc2026b FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr 2019-05-30 07:42:36 -07:00
4a7966c773 Drop gcc 4.4 from CI 2019-05-30 06:51:59 -07:00
9b3c24b99b One weird trick to simplify docs; doxygen hates it 2019-05-29 21:09:43 -07:00
30bce6c14c Fix a few chrono formatting corner cases (#1178) 2019-05-29 18:02:26 -07:00
e5512c5d57 Use static_assert instead of SFINAE in arg(...) 2019-05-29 13:21:24 -07:00
afc571aedc Document join and relax its compiler requirements 2019-05-29 11:21:05 -07:00
ad360a62b0 add gcc 8 c++17 release build 2019-05-29 06:50:43 -07:00
3cf12d7b11 add gcc 8 c++17 build 2019-05-29 06:50:43 -07:00
bb254d146b Disable std-format-test by default 2019-05-27 20:02:08 -07:00
291ba837f2 Remove wrong compile-time checks from printf (#1173) 2019-05-24 07:50:13 -07:00
01c631af95 Implement unsigned and long long parsing 2019-05-19 07:34:54 -07:00
4fcd4a4bd0 Reuse parse_format_string in scan 2019-05-18 14:18:06 -07:00
2346779d6b More documentation fixes 2019-05-18 09:30:36 -07:00
afc1a74a6c Minor documentation fixes 2019-05-18 09:10:17 -07:00
ad0eade471 Remove MSVC nonsense 2019-05-18 09:05:19 -07:00
28c187bcd7 Capitalize titles 2019-05-18 08:56:49 -07:00
91bb3aaf06 fmtlib.net -> fmt.dev 2019-05-17 15:42:00 -07:00
5e7bdf1b97 Clean up vagrant config 2019-05-16 12:22:04 -07:00
570453f271 Add a vagrant config for testing gcc 4.4 2019-05-16 06:26:16 -07:00
ef6282fc45 Fix gcc 4.4 build 2019-05-15 22:37:00 -07:00
e3e470bb69 Remove deprecated format_decimal 2019-05-15 10:34:45 -07:00
67179dbc23 Remove deprecated format_decimal 2019-05-15 10:34:38 -07:00
a5ffa735db Fix gcc 4.4 build 2019-05-15 10:20:51 -07:00
5ee0804631 Experiment with scan API 2019-05-15 10:02:40 -07:00
25b72fc4cd Move <format> to tests not to confuse users 2019-05-15 09:08:42 -07:00
d179ec5f8b Simplify Grisu 2019-05-15 08:40:21 -07:00
2a9e8b52de Fix advance_to() and begin() using iterator (#1159) 2019-05-14 08:41:11 -07:00
2c77562b13 Fix ambiguous formatter specialization in fmt/ranges.h (#1123) 2019-05-12 13:03:20 -07:00
98b3775297 Add support for exotic string_view iterators (#1156) 2019-05-12 11:07:49 -07:00
b488df6cfe Fix Grisu3 stopping conditions 2019-05-12 08:56:50 -07:00
f4dfd6e30f Suppress all clang-target-msvc test warning in CMake and other misc fixes (#1151)
* Fix conditional `char8_t` from `format.h` and fix `-Wunused-result` of [[no_discard]] begin() when in c++17

* Suppress `-Winconsistent-dllimport` when in clang-target-msvc

* Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations

Suppress warning _CRT_SECURE_NO_WARNINGS in MSVC and -Wdeprecated-declarations of POSIX functions in Clang target MSVC.
Those functions are used by gtest.

* Remove FMT_FUNC, mark FMT_API to export
2019-05-11 11:48:27 -07:00
a6e8ed15c4 Disable UDL templates on GCC 9 by default (#1148) 2019-05-11 08:58:39 -07:00
de5da50910 Fix formatting of extreme durations (#1154) 2019-05-11 08:42:02 -07:00
ea2976e6d5 Move internal::uintptr_t test to format-impl-test (#1152) 2019-05-11 06:58:22 -07:00
77d6036cd5 Fix unexpected trailing decimal point (#1153) 2019-05-11 06:34:47 -07:00
ccc318e807 Update README.rst 2019-05-10 10:04:44 -07:00
4c8efd694c Update README.rst 2019-05-10 09:56:40 -07:00
d22d11b5ff Update README.rst 2019-05-10 09:54:42 -07:00
e9bab6d028 Improve handling of large durations 2019-05-08 12:40:33 -07:00
f52c09f924 Fix format_to_n docs in 5.1.0 2019-05-08 12:40:25 -07:00
118d8bccc2 Fix compilation error under MSVC 19.21 (#1140) 2019-05-08 11:20:55 -07:00
6828d549e8 Add FMT_ENABLE_IF_T
for definitions of functions which declared using FMT_ENABLE_IF
2019-05-08 11:20:55 -07:00
3fd134be03 Move test_count_digits to format-impl-test and disable gtest warnings (#1147)
* This translation unit includes `gtest.h` in which using something like `strncpy`

Suppress MSVC warnings from `gtest.h` included.

Warning sample:
fmt-master\test\gtest\gtest.h(2873,10): warning: 'strncpy' is deprecated: This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]

* Moving `test_count_digits` to format-impl-test then count_digits<4>(internal::uintptr_t) shall not be exported

* retaining _CRT_SECURE_NO_WARNINGS always defined should be no harms.
2019-05-07 12:09:11 -07:00
ca7c1f89dc Fixed a compile error under MSVC.
The #warning directive is not supported by MSVC.
To still get a message to the user we use #pragma message() under MSVC now.
2019-05-05 14:04:04 -07:00
ca978b3d21 Fix handling of nan durations 2019-05-05 08:53:23 -07:00
c1d430e61a Improve handling of negative durations 2019-05-04 17:52:20 -07:00
38a85502ed Use the same rep type for seconds to prevent overflow 2019-05-04 09:22:09 -07:00
241414028d Eliminate shadowed variable warnings from gcc-7.2
The gcc-7.2.0 compiler (and others) were giving shadowed variable warnings for this include file.  A simple renaming of a couple local variables eliminates the warnings.
2019-05-04 08:00:31 -07:00
29c10fbf6e Fix DLL visibility of explicit instantiation "declaration" of internal::basic_data<void> in header format.h and the explicit instantiation "definition" in format.cc (#1134)
* Update format.cc

As the explicit instantiation *declaration* of `internal::basic_data<void>` in format.h, this explicit instantiation *definition* should mirror FMT_API also.

* Mirror visibility of explicit instantiation declaration 

explicit instantiation declaration of internal::basic_data<void> should mirror visibility of FMT_API

* Eliminate `__declspec(dllexport)` designation on extern template internal::basic_data<> when `extern` affected during exporting phase.

* Add `FMT_EXTERN_TEMPLATE_API` for designate DLL export `extern template`

When exporting DLL, do not designate `__declspec(dllexport)` any template that has any explicit class template declaration a.k.a. `extern template`. Instead, designate `__declspec(dllexport)` at single point where we have explicit class template definition a.k.a. normal instantiation without `extern`

Note: this is a c++11 feature.

* Delete whole `FMT_USE_EXTERN_TEMPLATES` block and its condition

1. Remove whole `FMT_USE_EXTERN_TEMPLATES` block
(trailing `FMT_UDL_TEMPLATE` block)
````
#ifndef FMT_USE_EXTERN_TEMPLATES
#  ifndef FMT_HEADER_ONLY
#    define FMT_USE_EXTERN_TEMPLATES                           \
      ((FMT_CLANG_VERSION >= 209 && __cplusplus >= 201103L) || \
       (FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11))
#  else
#    define FMT_USE_EXTERN_TEMPLATES 0
#  endif
#endif
````

2. Delete `FMT_USE_EXTERN_TEMPLATES` condition, only condition, that trailing basic_data class template definition.
````
#if FMT_USE_EXTERN_TEMPLATES
extern template struct basic_data<void>;
#endif
````

3. Replace `FMT_API` with new `FMT_EXTERN_TEMPLATE_API` added in `core.h` for sake of extern template of `basic_data<void>`

* Add `#define FMT_EXTERN extern` only when not `FMT_HEADER_ONLY`

* Replace `extern` on basic_data<void> with the `FMT_EXTERN` condition in core.h

* replace misspelled if !define() with ifndef
2019-05-02 07:49:01 -07:00
4a4d72f917 Fix handling of invalid string in chrono formatting 2019-05-01 10:06:42 -07:00
b3cc9c0567 Merge remote-tracking branch 'upstream/master' into invalidcolons
# Conflicts:
#	test/chrono-test.cc
2019-04-28 21:35:21 +02:00
2e3352fd05 provoke assertion
fmt/include/fmt/core.h:246:
typename std::make_unsigned<_Tp>::type fmt::v5::internal::to_unsigned(Int)
[with Int = long int;
 typename std::make_unsigned<_Tp>::type = long unsigned int]:
Assertion `(value >= 0) && "negative value"' failed.
2019-04-28 21:34:09 +02:00
4c721e3a2f Fix chrono formatting with invalid argument id (#1132) 2019-04-28 07:08:41 -07:00
8d8ea21c69 Partially implement Grisu3 2019-04-27 12:17:21 -07:00
40a7975640 Remove trailing zeros 2019-04-27 07:42:27 -07:00
cb46397dfb Fix typo 2019-04-27 07:13:35 -07:00
134904c886 Re-enabled constexpr tests 2019-04-26 17:07:37 -07:00
bd516e3429 Convert negative precision to zero in printf (#1127)
and remove redundant check in grisu2_prettify.
2019-04-21 07:44:04 -07:00
5efb24dd2b Add specialization test 2019-04-19 17:15:46 -07:00
946498cfbc Fix handling of zero precision 2019-04-19 15:10:12 -07:00
6b20863918 fmt::ptr: support unique_ptr and shared_ptr. 2019-04-18 10:12:11 -07:00
d306585a3f Don't inject internal names into std (#1120) 2019-04-17 13:25:31 -07:00
544b927933 Don't detect C compiler 2019-04-17 06:18:53 -07:00
dc94010fa5 Remove char_traits (#1117) 2019-04-16 17:08:24 -07:00
397e8dd9d5 clang-format 2019-04-15 11:39:19 -07:00
2b415b7af7 Restructure printf_arg_formatter to make it customizable 2019-04-15 11:10:31 -07:00
5d755d0a4e Fix handling of volatile char (#1115) 2019-04-14 12:34:56 -07:00
bade46aae5 Optimize grisu using uint128_t 2019-04-13 13:44:41 -07:00
41fbaeb3b1 Add <format> test 2019-04-13 11:37:52 -07:00
8bc0adb9ba Get rid of obsolete cmake stuff 2019-04-13 11:37:52 -07:00
1763d0e7a2 Add MongoDB to "Projects using this library" 2019-04-12 15:52:04 -07:00
f569c1ba28 doc fix: time -> chrono
Change refs to fmt/time.h -> fmt/chrono.h
RST label rename time-api -> chrono-api
2019-04-12 14:51:32 -07:00
ccd70f59ee Workaround bogus unreachable warnings in MSVC 2019-04-11 17:59:35 -07:00
a4969ebe06 Link to fmt(...) docs from index 2019-04-10 19:22:10 -07:00
a6ad29aa34 Update <format> 2019-04-10 09:09:34 -07:00
52eb3fe274 Update <format> 2019-04-10 08:29:07 -07:00
09e2ac5e46 Update <format> 2019-04-10 07:56:50 -07:00
df4ea0c76c Update <format> 2019-04-10 06:25:42 -07:00
718f60accb Fix shadowing warning (#1105) and clang format 2019-04-08 19:14:32 -07:00
aeb5ad3ce1 Enable [[noreturn]] some. 2019-04-08 07:53:59 -07:00
2808395481 basic_buffer -> buffer
This reduces symbol sizes and gets rid of shadowing warnings.
2019-04-07 20:32:28 -07:00
6e37c20030 Use compile features cxx_auto_type cxx_variadic_templates instead of cxx_std_11 2019-04-07 08:47:17 -07:00
3de3d76a36 Add compile features for cmake 3.8+ 2019-04-07 08:47:17 -07:00
07d5a86a7c Fix warnings 2019-04-06 22:10:10 -07:00
ab1474ef66 Workaround segfault in doxygen and apply clang-format 2019-04-06 15:55:14 -07:00
918ab77baa Try fixing doc build 2019-04-06 10:04:56 -07:00
735b1fadc3 Only update key on Linux 2019-04-06 09:49:35 -07:00
3c531b735b Fix expired key error when installing with apt
Error:
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6B05F25D762E3157
W: http://ppa.launchpad.net/couchdb/stable/ubuntu/dists/trusty/Release.gpg: Signature by key 15866BAFD9BCC4F3C1E0DFC7D69548E1C17EAB57 uses weak digest algorithm (SHA1)
W: Failed to fetch https://packagecloud.io/github/git-lfs/ubuntu/dists/trusty/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6B05F25D762E3157
W: Some index files failed to download. They have been ignored, or old ones used instead.
2019-04-06 09:32:38 -07:00
f10a7e2e46 Test exotic pointer formatting 2019-04-06 09:04:44 -07:00
bd8177177a Add support for platforms without uintptr_t 2019-04-06 08:11:03 -07:00
0302927f56 Optimize pointer formatting 2019-04-05 20:36:37 -07:00
bb6842ba35 Simplify to_string 2019-04-05 19:15:22 -07:00
b23c8633fa Detect presence of uintptr_t 2019-04-05 07:43:00 -07:00
b588d7f35f Fix a couple of deprecated things. 2019-04-04 16:26:22 -07:00
018d8b57f6 Remove broken snprintf 2019-03-30 20:27:52 -07:00
1987db663b clang-format 2019-03-30 07:48:53 -07:00
a6d1ad741d handle fwrite results #1098 2019-03-30 07:48:53 -07:00
e979c782d3 Extend basic_writer with write() method for doubles with optional format_specs argument 2019-03-25 19:16:41 -07:00
9e1531c1e1 install pkg-config file into libdir
Most pkgconfig files contain a Libs: variable, which is either /usr/lib
or /usr/lib64. If a 32bit and a 64bit variant of fmt libraries is
installed, the last one wins. As a result compiling for the other
bitsize will fail.

Instead of sharedir use libdir as install target.

Fixes commit 9d0c9c4bb1
Fixes commit 287342dab1

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2019-03-25 19:15:35 -07:00
0a66e4cbbb Update README.rst 2019-03-24 11:37:07 -07:00
91acfe6852 Fix UBSAN warning 2019-03-22 07:56:02 -07:00
b7e6bf9671 clang format 2019-03-21 20:51:37 -07:00
da0ea4161a Make compile-time checks work with fallback formatter (#1088) 2019-03-21 19:26:53 -07:00
7ad3015f5b Added missing typename to FMT_STRING. (#1089)
* Added missing typename to FMT_STRING.

This is so that FMT_STRING can be used in a template.
2019-03-20 20:37:00 -07:00
f0b572da05 Update wording test 2019-03-20 06:53:31 -07:00
6d416cf674 Forward declare is_string<FILE*> specializations 2019-03-19 05:20:18 -07:00
b742f622ab Create PR template to help agree to the licensing terms (#1083) 2019-03-18 14:41:17 +01:00
02a6f16b52 Update LICENSE.rst 2019-03-17 18:49:12 -07:00
294fd7df96 Remove isinf workaround 2019-03-17 14:49:19 -07:00
17c6900f83 Update docs 2019-03-17 14:15:48 -07:00
0faa968cc3 Make floating-point formatting locale-independent 2019-03-17 13:26:56 -07:00
bc784d3625 Remove isnan workaround 2019-03-17 12:23:36 -07:00
53379dfd0c Don't set CMAKE_BUILD_TYPE if fmt is a subproject (#1081) 2019-03-17 10:50:40 -07:00
76d326a2a2 Enable grisu for general format 2019-03-17 09:48:50 -07:00
c21c6b8c4b Move enable_if to template params 2019-03-16 15:15:38 -07:00
ec645ca262 Update readme and doxygen config 2019-03-16 10:47:50 -07:00
ae0b0dab9f Remove obsolete TODO 2019-03-16 10:04:16 -07:00
5466a5b41f Document inherited members 2019-03-16 08:22:16 -07:00
9b392a683d Update readme 2019-03-16 07:59:58 -07:00
0fa65cf329 Add example 2019-03-16 07:36:27 -07:00
fdd0149e71 Update readme 2019-03-16 07:27:53 -07:00
e19a95b271 Update readme 2019-03-16 06:51:35 -07:00
ef39274973 Update readme 2019-03-16 06:47:18 -07:00
a7f68dcc01 Update readme 2019-03-16 06:46:19 -07:00
1428b34299 Update readme 2019-03-16 06:30:50 -07:00
97619e27a2 More fixed precision tests 2019-03-15 10:20:20 -07:00
dd6cc0e6ac Merge time-test into chrono-test 2019-03-14 18:10:56 -07:00
a939c75956 Merge fmt/time.h into fmt/chrono.h 2019-03-14 18:07:42 -07:00
17e4b53926 Make chrono formatting work without exceptions (#1062) 2019-03-14 18:01:03 -07:00
a82b3680dc More tests and fixed precision fixes 2019-03-13 19:47:07 -07:00
287342dab1 cmake: default FMT_PKGCONFIG_DIR to a relative path 2019-03-13 11:28:50 -07:00
e28429ee73 Prevent overflow with zero precision 2019-03-13 10:46:25 -07:00
49bbf3c876 Simplify shadowing warning fix 2019-03-13 08:29:37 -07:00
5e5506f833 Update readme 2019-03-12 06:08:18 -07:00
e06523361d Visual Studio 2017: warning C4456: declaration of 'result' hides previous local declaration 2019-03-11 14:15:23 -07:00
ebec00138b Reword licensing part 2019-03-10 17:42:36 -07:00
8daa3c6834 Clarify contribution licensing
This is similar to https://github.com/apple/swift/blob/master/CONTRIBUTING.md
with an explicit clause that allows changing license for #1073.
2019-03-10 17:38:26 -07:00
0d418a8d58 Update and rename CONTRIBUTING.rst to CONTRIBUTING.md 2019-03-10 17:25:06 -07:00
4c66dad8c1 Refactor digit generation 2019-03-10 15:45:06 -07:00
b1f7cca89e stop -> handler and swap args 2019-03-10 14:43:26 -07:00
f90d33ca12 error_ulp -> error 2019-03-10 14:29:28 -07:00
78c755dc48 Update readme 2019-03-10 12:17:35 -07:00
f230170157 Update readme 2019-03-10 12:13:14 -07:00
ced8aa8c9e Update readme 2019-03-10 12:07:57 -07:00
77d54251f0 Update benchmark results 2019-03-10 11:21:24 -07:00
1632f72cbe Test get_round_direction 2019-03-10 11:14:50 -07:00
8129b9bc46 Test that the library can be compiled witout locales 2019-03-10 07:57:29 -07:00
835087dd04 Add color-test 2019-03-10 07:57:29 -07:00
4523053e6f Fix typos. 2019-03-10 07:49:33 -07:00
8407f4cb24 Round close to zero fixed precision 2019-03-09 15:18:34 -08:00
49d244c065 Don't emit more than precision digits (#1072) 2019-03-09 13:53:23 -08:00
3466d9c845 Don't override fixed formatting depending on exponent (#1072) 2019-03-09 13:22:07 -08:00
93d22dec35 Implement rounding up and clean up FP formatting 2019-03-09 10:40:36 -08:00
d560ddac25 Temporarily disable Grisu for fixed formatting 2019-03-08 19:09:05 -08:00
2d981bb133 Add documentation for '%' format type. (#1071) 2019-03-06 11:50:32 -10:00
d8434baa03 Declare the size of RESET_COLOR.
This is so that the format with a text_tyle will compile even if
header-only mode isn't enabled. Addresses #1063.
2019-03-06 09:41:45 -10:00
8f7780a4f6 Correct comment 2019-03-06 09:23:16 -08:00
2e526a664a Fix handling of output iterator in ranges 2019-03-06 08:10:46 -08:00
79b79f329e Add support for '%' type to output floating point values as a
percentage.

This helps with compatibility with Python's format strings.
2019-03-05 17:36:20 -08:00
287eaab3b2 Increment output iterator in basic_writer::write for character types (#1056) 2019-02-26 12:16:34 -10:00
a97757736b Use grisu for fixed precision 2019-02-23 15:50:50 -10:00
327d4b6e9e Fixes for some pedantic warnings (#1054)
* Fix order of initializers

* Remove unused parameter

* Disable warning "-Wswitch-enum"
2019-02-23 09:40:08 -10:00
8af651be39 Implement fixed precision 2019-02-22 10:47:27 -10:00
187bd1b8b2 Clarify lifetimes of named_arg parameters (#1051)
* Clarify usage of fmt::arg

Document that fmt::arg takes a non-owning
reference, even if that reference is to
a temporary. As such, users should make sure
the lifetime of the reference lasts as long
as the named argument.

* Clean up language

Remove mentions of `std::reference_wrapper` and rvalues
in favor of more common terminology like dangling references.
2019-02-22 06:37:19 -10:00
4e5694fd05 Update arg signature 2019-02-21 17:38:30 -10:00
82c24edcf6 Workaround a bogus Qt Creator warning 2019-02-19 06:33:55 -10:00
ed138d794a test: assert-test: fix typo in else-branch of EXPECT_DEBUG_DEATH_IF_SUPPORTED
Patch by Ievgen Liubymkin (jackyf).
2019-02-18 14:02:02 -10:00
0476a51cba Add Sublime syntax (#1037) 2019-02-15 15:08:58 -08:00
c5aad69f2a Restore deprecated begin() 2019-02-15 15:00:02 -08:00
5b0006476a Make stopping condition configurable in grisu 2019-02-14 18:25:13 -08:00
a44238f2ef Improve grisu 2019-02-13 20:03:27 -08:00
83808076e3 Minor cleanup 2019-02-13 19:28:02 -08:00
9660ea1bff Simplify format string checks 2019-02-10 18:00:19 -08:00
4a9d676362 Gradle 4.10 >> Gradle 5.2
TravisCI
- replaced from manual Gradle download to install with 'sdkman'
- changed build name

Gradle
- updated build tool version
2019-02-10 16:15:32 -08:00
f041f128f5 Minor cleanup 2019-02-10 15:20:40 -08:00
e4572e5def Update std implementation 2019-02-10 07:56:33 -08:00
442fa1bd46 Decouple format and parse contexts 2019-02-09 20:39:37 -08:00
744e66bb08 Deprecate format_context::parse_context() 2019-02-09 16:15:20 -08:00
d231d68a8b Fix handling of custom context 2019-02-09 07:36:09 -08:00
01f34d0b0b Fix library deprecation warning
Since C++17, using template specialization 'std::allocator<void>' in any shape or form (even just mentioning it) is deprecated! A simple workaround is replacing 'void' by another (preferably empty) type, e.g. 'fmt::monostate'.

Found by Clang 9 in Visual Studio.
2019-02-07 12:20:46 -08:00
9a0a24f90b Test is_streamable with overloaded comma operators 2019-02-06 15:44:59 -08:00
430e6ac9b6 Protect against overloaded comma operators in decltype 2019-02-06 15:44:59 -08:00
467520e7a4 Remove unused macro 2019-02-06 11:34:59 -08:00
5a314a5288 Eliminate extra copy on floating-point formatting 2019-02-06 10:17:50 -08:00
9989e7f4e3 Update benchmark results 2019-02-04 17:56:33 -08:00
31510cb437 Fix warnings from Visual Studio
Name hiding.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-02-04 11:58:56 -08:00
61c9b563c2 Replace 'std::result_of' by 'std::invoke_result' where possible (#1025)
C++17 deprecated 'std::result_of' in favour of 'std::invoke_result' and will ban it outright in C++20. Therefore
- implement 'internal::result_of' in terms of 'std::invoke_result' when compiling C++17 mode.
- implement 'internal::result_of' in terms of 'std::result_of' when compiling in modes C++11 or C++14.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-02-04 11:25:22 -08:00
864b9a2202 Correct the comment 2019-02-04 08:29:39 -08:00
1538336836 Remove unnecessary checks 2019-02-04 08:25:41 -08:00
22de5a755f Fix warnings from Travis 2019-02-03 15:25:09 -08:00
355eb6d29a Enable grisu for shortest roundtrip (default) formatting 2019-02-03 10:38:28 -08:00
b8d34e0db3 Fix rounding 2019-02-02 09:19:46 -08:00
e61cac687d Minor grisu improvements 2019-02-02 07:41:52 -08:00
7fbbfed8c6 Fix warnings caused by usage of deprecated functionality 2019-02-02 05:48:39 -08:00
c3268f4e50 Remove use cases of deprecated functionality 2019-02-02 05:48:39 -08:00
34951f1999 Replace comments regarding deprecation with attributes 2019-02-02 05:48:39 -08:00
3f52336e6c Simplify formatter selection 2019-01-30 19:39:42 -08:00
7ca8fc3b17 Fix a bogus warning 2019-01-30 07:06:40 -08:00
5289dd600b Test formatting of special numbers 2019-01-30 06:56:46 -08:00
bf6529f2ce Update docs 2019-01-30 06:07:59 -08:00
0700612249 Implement 'chrono' formatting specifiers '%Q' and '%q'
Howard Hinnant's 'date' library recently gained these two new formatting specifiers. This implementation in {fmt} includes support for 'std::chrono::duration' specializations with floating-point representation types and user-definable precision.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-27 11:10:08 -08:00
06c005b7b0 Clarify that compile-time checks don't support named arguments 2019-01-27 10:10:13 -08:00
4f6fda558c Add a grisu test stub 2019-01-27 10:10:13 -08:00
9f70b034e1 Implement precision for floating-point durations.
The formatting syntax follows p1361r0, augmented by a precision field as proposed in #1004.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-23 07:17:00 -08:00
7cdb1e5e40 Workaround broken is_default_constructible in MSVC 2019-01-21 10:54:49 -08:00
5f1ceebc7f Make formatter<T> override ostream<< for templates (#952) 2019-01-21 09:42:55 -08:00
1b11b000c7 Update readme 2019-01-20 15:33:30 -08:00
83f052930a Add code from p0645 2019-01-20 15:12:01 -08:00
fdd8e333c1 Fix compilation with locales disabled (#1011) 2019-01-19 07:16:05 -08:00
dad1eec842 Workaround unimplemented T... on gcc 4.6.x (#1008) 2019-01-16 11:41:20 -08:00
b0cde860ae Implement 'snprintf(OutputIt it, size_t n, const S &format, const Args & ... args)' (#917)
Mostly equivalent to 'sprintf(const S &format, const Args & ... args)' but generates at most 'n' characters through output iterator 'it'. The output type is the same as with 'format_to_n'.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-13 13:08:01 -05:00
e05dfb0887 Fix compile errors due to name-hiding and an unused function argument.
These problems are pointed out by clang-tidy and fail compilation on msvc at /W4 /WX.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-13 12:18:05 -05:00
dde095fab8 Revert "Reorder defines"
This reverts commit 4a059914a9.
2019-01-13 08:13:38 -08:00
4a059914a9 Reorder defines 2019-01-13 07:40:37 -08:00
58b6f8db48 Format the code using clang-format 2019-01-13 06:58:20 -08:00
9a777b9e1c Implemented fmt::prepare()
Implementation of fmt::prepare() function and features around it.
2019-01-12 10:53:31 -08:00
da55e96f53 Install ninja to fix android build 2019-01-09 15:55:29 -08:00
dc8f8ce4c0 Fix handling of dynamic width in chrono formatter
Thanks to Howard Hinnant.
2019-01-09 15:23:21 -08:00
f5cc77cea0 Get rid of 'null_terminating_iterator' in printf.h (#980)
The iterator class itself and its helpers 'to_pointer' are removed after reformulating the formatting loop in terms of a 'basic_string_view<Char>::iterator'.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-04 12:18:14 -05:00
39623a7400 Replaced usage of gtest's internal scoped_ptr with unique_ptr.
scoped_ptr was removed in with gtest google/googletest@e857f9cdd9.
2019-01-02 19:05:51 -05:00
ae1de3a8d3 Add support for using text_style in format and vformat directly (#993)
* Closes #993
2019-01-01 09:26:54 -05:00
1b8a216ddf Improve docs 2018-12-28 15:05:42 -08:00
b3ad759a0a Bump version and correct changelog 2018-12-28 13:09:31 -08:00
9e554999ce Update version 2018-12-28 12:31:41 -08:00
b34d92b051 Bump version 2018-12-28 12:23:29 -08:00
d39ece1870 Make rst2md runnable and update changelog 2018-12-28 12:04:34 -08:00
fe2d715ff1 Update changelog 2018-12-24 11:56:48 -08:00
27b306701f Update changelog 2018-12-24 11:51:20 -08:00
68837079aa Update changelog 2018-12-24 11:48:41 -08:00
c98b202eb4 Update changelog 2018-12-24 11:47:06 -08:00
587a7f6634 Update changelog and docs 2018-12-24 10:56:13 -08:00
84e5170c9c Update changelog and deprecate visit 2018-12-24 10:02:41 -08:00
130e412b64 Update changelog and docs 2018-12-24 09:37:52 -08:00
0bbdca5b8b Fix conversion warnings (#989)
* Fix sign conversion warnings

* Ignore unused local typedefs

* Remove cast reported as useless on GCC

* Remove warning on unused variable

* Enable conversion warning checking for pedantic build

* Fix sign-conversion warnings in headers
2018-12-20 06:24:19 -08:00
77a7244804 Implement fill/align/width for strftime-like formatting 2018-12-19 07:03:02 -08:00
3e01376e08 Implement fill/align/width parsing in chrono formatter 2018-12-16 09:08:11 -08:00
1f92f8a9d8 Remove noexcept 2018-12-15 06:41:32 -08:00
8668639ae2 Get rid of null_terminating_iterator in format 2018-12-15 06:17:25 -08:00
93fd473b8f Add support for builtin terminal colors. (#974) 2018-12-15 06:16:00 -08:00
61ad543c3e Windows .sln filename changed from FORMAT to FMT 2018-12-14 07:50:54 -08:00
7f7504b3f5 Clean up docs 2018-12-12 18:21:13 -08:00
37f599b1a1 Fix docs 2018-12-12 17:50:50 -08:00
8c2e15aed5 Make printf work in search (#164) 2018-12-12 16:07:54 -08:00
de71db6d42 Fix asan error (#977) 2018-12-12 11:29:39 -08:00
b180b39152 Fix default formatting 2018-12-12 06:39:47 -08:00
24594c747e Disable printing the reset escape code when no style modifiers where applied. (#973) 2018-12-09 15:57:20 -08:00
b0f2224719 Implement default chrono formatting 2018-12-09 15:56:15 -08:00
749276072f Add file stream support for stylized text printing. (#967) 2018-12-09 09:28:48 -08:00
f54f3d0fb7 Move chrono-specific code to a separate header 2018-12-09 06:45:20 -08:00
bf1f1c73e3 Fix time test 2018-12-07 08:19:13 -08:00
b6bc6ec246 Add default ctor and fix use of constexpr macros in text_style 2018-12-07 07:22:18 -08:00
acfa95d4a8 Workaround a bug in MSVC's strftime (#965) 2018-12-07 07:07:21 -08:00
628f830583 More chrono formatting 2018-12-07 06:36:08 -08:00
aa3b5aba41 Implement locale-specific minute formatting 2018-12-06 16:12:10 -08:00
639de21757 Workaround more MSVC bugs 2018-12-06 12:16:04 -08:00
3242ddf7b5 Fix warnings 2018-12-06 08:16:12 -08:00
bd1104046b Workaround a bug in MSVC 2018-12-06 08:16:01 -08:00
81b5c4a5fd Add experimental emphasis support (#961) 2018-12-06 07:56:01 -08:00
7c4eb0fbeb Fix warnings in time.h 2018-12-05 14:38:08 -08:00
2d624218bf Fix another warning 2018-12-05 10:19:53 -08:00
b31680990e Fix a warning 2018-12-05 09:49:39 -08:00
b10ccb83e1 Add rpclib to projects 2018-12-05 06:42:33 -08:00
0497875ff3 Stop the orgy of casts 2018-12-05 06:27:31 -08:00
37dc495b9d Simplify MSVC workaround 2018-12-05 06:22:18 -08:00
2ff4996d05 Fix ambiguous complier error C2666 in vs2017.The '+' opeator may cause ambiguity.Avoid implicit conversion. 2018-12-05 05:55:43 -08:00
77656c672c Fix sign-conversion warnings reported by Clang7 2018-12-03 16:22:59 -08:00
ea5e4790bd Fix formatting 2018-12-03 08:58:48 -08:00
86681c4bb0 Update README.rst 2018-12-03 08:04:21 -08:00
e867768ee6 Do not override user provided compile flag 2018-12-03 07:31:19 -08:00
0c7f5c3ca4 Update README.rst 2018-12-02 08:22:51 -08:00
e7e2ab1070 Make return type of basic_format_args::max_size() consistent.
This squashes nasty narrowing conversion warnings.
2018-12-01 17:07:21 -08:00
29352af369 Update README.rst 2018-12-01 08:19:20 -08:00
68214bd904 More time formatting 2018-11-30 20:12:01 -08:00
bcf3fcd673 Clean up bit fiddling for argument packing 2018-11-30 17:04:49 -08:00
9dcf127fa5 Workaround a bogus MSVC warning 2018-11-30 13:47:04 -08:00
b8b06e3e10 Fix conversion warnings in Grisu 2018-11-30 10:37:40 -08:00
322b2594e0 Implement more time specifiers 2018-11-30 09:25:18 -08:00
0835f1ba3b Use full paths for fmt.pc.in 2018-11-30 06:17:33 -08:00
a084495d7e Add Ceph to projects 2018-11-28 17:28:27 -08:00
fa1d4dbcfd Fix warnings 2018-11-28 16:15:15 -08:00
2b2cfdac19 Update docs 2018-11-28 12:53:09 -08:00
99744f8f8f Suppress unfixable warning 2018-11-28 12:52:41 -08:00
f5fe849238 Specialize formatter for chrono durations 2018-11-28 11:39:21 -08:00
a5a9805a91 First stub at the datetime format parser 2018-11-25 17:25:22 -08:00
645c76a9a5 Fix dummy warnings 2018-11-25 15:33:28 -08:00
fecb2d6f0d Eliminate msvc compiler warnings (#931)
The sheer presence of 'std::gmtime' or 'std::localtime' gives rise to C4996 warnings in Microsofts compilers. Alas, the 'fallback(internal::null<>)'functions containing these library calls are never ADL-picked in the respective 'handle(internal::null<>)' selectors. Therefore hiding the fallbacks from msvc is perfectly fine.
2018-11-25 13:48:52 -08:00
64690d3a97 Add context_base::arg() 2018-11-24 10:49:48 -08:00
01640f44cf Fully qualify dummy_int (#941) 2018-11-24 06:22:59 -08:00
e37d6a9840 add make_printf_args and make_wprintf_args functions (#934)
* add make_printf_args and make_wprintf_args to printf.h
add minimal test for make_printf_args and make_wprintf_args to printf-test.cc

renamed the old printf_context template to basic_printf_context_t. the original wish was to rename it basic_printf_context, but that clashed with the name of the inner typedef. this style matches the format_context_t struct.
2018-11-22 13:57:07 -08:00
982ee5c699 parse_context -> format_parse_context 2018-11-21 07:10:22 -08:00
b7b8548559 thousands_sep -> thousands_sep_impl (#939) 2018-11-20 15:43:17 -08:00
00a8cc8325 Fix formatting 2018-11-20 07:43:40 -08:00
33fbb3a7eb Fix remaining linker errors. 2018-11-20 07:01:21 -08:00
bd6121596f Disable fmt-impl-test in windows + shared lib. 2018-11-20 07:01:21 -08:00
702b3d1618 Fix link error in windows with shared library. 2018-11-20 07:01:21 -08:00
9d4ef94350 Install pdb files. 2018-11-20 07:01:21 -08:00
6c95fb3562 Default Context to format_context 2018-11-18 07:19:25 -08:00
16b78ee629 fix incompatibilities with c++2a mode in clang 2018-11-17 08:38:04 -08:00
19e008876b More locale support 2018-11-14 16:25:49 -08:00
f2ee988105 Improve locale support 2018-11-14 12:07:39 -08:00
1385050e26 More formatter tests 2018-11-08 16:26:55 -08:00
03c1b110a5 Fix gcc 4.4 build 2018-11-08 12:41:55 -08:00
cc805c6162 Test enabled formatters 2018-11-08 10:59:10 -08:00
e01579231d Disallow leading zeros in arg-id 2018-11-08 08:48:56 -08:00
34030deca9 Cleanup warning flags 2018-11-06 17:22:30 -08:00
6b26e3f2d7 Manifest & Gradle comment
- #926
- The version of android build results follows latest release(5.2.1)
- Comment for Gradle and its plugin for android
 - `net.fmtlib` package name in the manifest
2018-11-05 17:31:09 -08:00
d286c97753 Update for Gradle build
Recovered Gradle build with latest release (ver. 4.10.2)

TravisCI
- Changed several apt configurations & build steps for Android

AndroidManifest:
- package name: fmt -> org.fmtlib

Gradle:
- Plugin version 3.1.3. Requires Gradle 4.4+
- Removed `x86` (duplicated with `x86_64`)
- `-std=c++17`. Latest NDK(clang7) should support this
- Missing `repositories` configuration

For some reason, the `repositories` config affects to the error:
"Could not find com.android.tools.lint:lint-gradle:26.1.3."
2018-11-05 17:31:09 -08:00
d951f6dfe7 Get latest Gradle (ver. 4.10.2)
Recovery of Gradle build. 1 of N
Modified several apt configurationss and order of the build
2018-11-05 17:31:09 -08:00
a23d592472 Fix check_format_string (#925) 2018-11-03 16:51:15 -07:00
36161284e2 Update docs 2018-10-28 09:28:51 -07:00
38f355d87b Revert "find sphinx-build before calling build.py"
This reverts commit 07200f445a because
the latter doesn't work with virtualenv correctly.
2018-10-28 09:26:21 -07:00
324eac1aa5 Make locales work with any character type 2018-10-28 09:03:27 -07:00
bdda4d6030 Simplify compile-time strings 2018-10-28 09:02:03 -07:00
5ee1a4bc8a check for property 'mutable iterator' and SFINAE on it 2018-10-28 08:57:43 -07:00
2dea780fbd change type naming and fix sfinae bug 2018-10-28 06:00:55 -07:00
b98e8301d5 add non-char support for compile-time format check 2018-10-28 06:00:55 -07:00
ccd3e8bbf3 Make is_constructible public (#918) 2018-10-27 17:10:19 -07:00
4373153800 Update usage.rst 2018-10-27 12:59:51 -07:00
73cfd8f325 Fix colored print 2018-10-25 17:18:46 -07:00
ec384302db additional test for print with background color
checks for clashes with other function overloads in fmt with templated parameters on the first or second position in the parameter list
2018-10-25 16:54:54 -07:00
0a96c032b9 Parameterize v*printf on string type (#920) 2018-10-25 13:52:08 -07:00
61e6d2e38c Fix core version of vformat_to 2018-10-25 06:21:41 -07:00
ea4010d704 Merge has_to_string_view into is_string 2018-10-24 18:16:00 -07:00
486fff597c Add sprintf_format instantiations and remove syntactic noise 2018-10-24 16:46:32 -07:00
1e3dcbba81 fix: 'format_to_n' compiles 'std::back_inserter' arguments
std::back_insert_iterators model the OutputIterator concept but differ considerably in their traits and behavior. In particular the former made compilation to fail when format_to_n is given a back_inserter as first argument. The emulation of an OutputIterator is not perfect due to the behavioural differences of back_insert_iterators (e.g. assignment always implies increment) but good enough to be used within fmt's machinery.
2018-10-24 16:45:18 -07:00
f0328f8e36 Use char_traits::length in string_view ctor (#914) 2018-10-24 15:21:21 -07:00
895fb98456 Disallow gcc 4.4 failures 2018-10-24 10:52:13 -07:00
20c708bf6d Fix build on gcc 4.4 2018-10-24 10:52:02 -07:00
9d0c9c4bb1 cmake: output share/fmt.pc 2018-10-24 07:14:08 -07:00
2d2326a76d Fix compilation with older gcc 2018-10-23 07:31:24 -07:00
1ec0272303 Get rid of FMT_UNION 2018-10-22 20:19:31 -07:00
2c81c851b2 Adapt any string-like type to be used by {fmt} just like the standard string types already supported. The adaption is totally non-intrusive.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-22 18:25:52 -07:00
846c644e84 Workeround broken sprintf in MSVC 2018-10-19 07:30:59 -07:00
13d472bd8c Compute output size for grisu 2018-10-18 17:16:50 -07:00
b71d3fe7ab Remove use_grisu 2018-10-17 17:01:45 -07:00
847abb6f8f Fix test 2018-10-17 11:57:06 -07:00
dda47c9466 Merge min_digits and max_digits 2018-10-17 10:49:30 -07:00
2924622157 Fix naming of basic_format_specs members 2018-10-17 10:13:10 -07:00
bda5f9a556 Replace grisu2_specs with core_format_specs 2018-10-17 08:55:45 -07:00
b1ca608bac Remove unused empty_spec 2018-10-17 08:39:58 -07:00
e8efdef8de Avoid extra copy 2018-10-17 08:19:46 -07:00
98f1c1fe87 Remove unused code 2018-10-14 15:36:45 -07:00
50b18a3c10 Integrate Grisu 2018-10-14 14:33:25 -07:00
699297520a Implement Grisu rounding 2018-10-13 11:18:54 -07:00
4bb76ef0c7 Remove redundant definition of print 2018-10-13 11:15:46 -07:00
ddd7caf38e Fix locale-dependent formatting (#905) 2018-10-13 11:15:41 -07:00
10e03e695b use found python executable for launching sphinx-build
there is chance that the distro install python as python3, in that case
the shebang of
```
```
in build.py won't work.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2018-10-13 09:14:53 -07:00
07200f445a find sphinx-build before calling build.py
this allows us to use sphinx-build-3, as user might already in a python3
world, and distros, like fedora 28, tend to add a "-3" suffix to sphinx-build.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2018-10-13 09:14:53 -07:00
08a65c2282 Workaround broken constexpr in MSVC2017 2018-10-11 06:38:25 -07:00
167f8fe325 Fix a typo in api.rst 2018-10-10 10:51:43 -07:00
57983423c3 Remove signbit workaround 2018-10-10 09:41:46 -07:00
7bebb3e128 Clarify overload resolution in docs 2018-10-10 09:41:46 -07:00
939fbe5567 Remove basic_fixed_buffer.
Issue #873 indicates that this class is no longer required,
as it has been superseded by a new API.

Fixes #873
2018-10-09 06:51:01 -07:00
61f81a0719 minor documentation corrections
In the Format API section, it says fmt:print writes to a file, but it
writes to a stream as referenced from fopen(3), "stream open
functions". Also in the Safety section a typo; tim should be time.
2018-10-08 06:27:25 -07:00
f27defc639 Parameterize printf functions on the type of the format string.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-08 06:22:04 -07:00
6a685571df Make 'std::*::basic_string_view' a valid argument type for 'format_str' parameters.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-08 06:12:02 -07:00
87a0408c64 Fix ostream.h build 2018-10-07 12:58:20 -07:00
2b5acad4a9 Remove redundant size argument to write_padded 2018-10-07 12:45:34 -07:00
655ce53383 is_format_string -> is_string 2018-10-07 12:45:22 -07:00
fea712abb1 Parameterize ostream functions on the type of the format string.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-07 09:21:14 -07:00
f16a118e88 Fix non-matching char types.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-07 05:56:21 -07:00
041bf83d9b Improve fmt::format readability 2018-10-05 18:42:02 -07:00
2299032392 Document how to write a formatter for a type hierarchy 2018-10-05 13:21:29 -07:00
f5480635c0 visit -> visit_format_arg 2018-10-05 07:15:41 -07:00
cdf3fa08dc Put related code together in fmt/core.h 2018-10-04 19:44:09 -07:00
38325248e5 Count width in code points (#628) 2018-10-03 20:09:46 -07:00
deb901b9e4 Parameterize core functions on the type of the format string.
Take #2 of n

Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-10-03 14:19:08 -07:00
0f98de3011 Update docs 2018-10-03 12:07:55 -07:00
c797708fcc Workaround strlen being non-constexpr in ARM toolchain 2018-10-03 09:23:49 -07:00
49b4c1e9db Update docs 2018-10-02 06:21:19 -07:00
63a87beba4 Add to_string_view 2018-10-01 18:48:18 -07:00
4e0c314654 checked_format_args -> checked_args 2018-10-01 07:14:59 -07:00
c3538a1eee Simplify variadic functions further 2018-09-30 22:19:32 -07:00
2d7d0835d7 Simplify variadic functions 2018-09-30 21:52:47 -07:00
3f4cfa6c60 Implement UTF-8 string support 2018-09-30 15:45:58 -07:00
f8027414f5 Impelement char8_t support 2018-09-30 12:31:25 -07:00
76a47d41c8 Cleanup the use of FMT_CHAR 2018-09-30 08:45:57 -07:00
267fdc7a1b Parameterize core functions on the type of the format string.
Take #1 of n

Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-09-30 08:40:58 -07:00
5bced12421 Parameterize more functions on string type 2018-09-30 08:02:19 -07:00
674999c527 fix vs2017 warning fmt::v5::localtime 'not all control paths return a value'. 2018-09-30 07:23:35 -07:00
e4fea22d15 Make char8_t a strongly-typed enum 2018-09-30 07:11:37 -07:00
66992e90d2 Clarify that writing to memory_buffer appends (#877) 2018-09-28 06:22:12 -07:00
e864acfdbd Fix compilation with intel compilers (ICC/ICPC) v14.0 2018-09-27 07:11:23 -07:00
4cf21f58b2 constrain templated format_to on proper format string type.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-09-26 21:05:47 -07:00
d7f17613f5 Fix compilation on platforms with exotic double (#878) 2018-09-26 08:45:34 -07:00
e4ca37ccf6 Parameterize format_to on string type (#880) 2018-09-25 07:47:15 -07:00
d66fa2216e Reduce syntactic noise 2018-09-23 14:31:14 -07:00
48e6dcd0f2 Implement workarounds for gcc 4.4 2018-09-23 12:29:48 -07:00
0ea3221d34 Remove is_named_arg and add FMT_CHAR 2018-09-23 09:44:01 -07:00
73c53d7833 Parameterize 'printf(rgb color, ...)' and 'vprint_rgb(rgb color, ...)' on the type of the format string.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-09-23 09:15:27 -07:00
d41be23acd Simplify string_view detection 2018-09-23 07:29:35 -07:00
2def9e4c82 Remove FMT_DTOR_NOEXCEPT 2018-09-22 18:51:32 -07:00
ff6e46ed97 More cleanup 2018-09-22 16:00:34 -07:00
715f2b4c00 Remove require_wchar and internalize no_formatter_error 2018-09-21 18:25:24 -07:00
ec0cdc46f6 Workaround Windows slowness 2018-09-21 17:11:57 -07:00
3e75ad9822 Update version 2018-09-21 10:18:51 -07:00
4f043f8e00 Bump version 2018-09-21 10:07:56 -07:00
cc02cbc455 Fix formatting 2018-09-21 09:48:21 -07:00
73c0238e3b Update changelog 2018-09-21 09:48:21 -07:00
cb122a4d03 Fix format_to formatting to wmemory_buffer 2018-09-21 09:48:21 -07:00
dc69cc45d2 Clean tests 2018-09-21 09:48:21 -07:00
9d8021f0d6 Add checks for NVIDIA's CUDA compiler
- Disable templated user-defined literals when compiled under nvcc

Similarly to Intel's C++ compiler, nvcc fails to compile templated UDLs
as they both share the same parsing engine (EDG C++ Front End).  This
fixes building CUDA programs which make use of fmt.
2018-09-21 06:55:45 -07:00
9d2221b954 Improve error message when formatting unknown types 2018-09-20 07:01:39 -07:00
70a6a4bb01 prevent ""fmt/range.h"" from specializing fmt::basic_string_view (#865) 2018-09-19 20:13:05 -07:00
e4fc856c2f Disable android build due to gradle issues 2018-09-19 19:53:47 -07:00
3f4984fb36 Clean core-test and fix linkage errors on older gcc 2018-09-19 12:24:38 -07:00
d43665056d Workaround visit lookup issues in printf.h on gcc 2018-09-19 09:16:26 -07:00
894b6fac8e Changed to use scoped enum
Changed "reusing existing formatters example" to use scoped enum instead.
2018-09-16 17:28:40 -07:00
59f555ad8f Workaround more visit lookup issues on gcc 2018-09-15 08:46:12 -07:00
a7e356cc80 Update README.rst 2018-09-14 07:52:30 -07:00
e758bfbae1 Merge branch 'release' of github.com:fmtlib/fmt 2018-09-13 07:38:23 -07:00
66381e308d Minor cleanup 2018-09-13 07:37:50 -07:00
295a0d84d9 Update version 2018-09-13 07:28:20 -07:00
1fb1c4c912 Update docs 2018-09-13 07:20:43 -07:00
465a593536 Add table support to rst2md 2018-09-13 07:15:18 -07:00
d62f4c3bc1 Formatting 2018-09-12 19:00:26 -07:00
a243490ad7 Add more methods to benchmark results 2018-09-12 18:28:26 -07:00
9e12ca6069 Update changelog 2018-09-12 18:07:29 -07:00
fbca830dd1 Update changelog, readme and improve compat 2018-09-12 12:44:04 -07:00
6146248cf4 Update changelog 2018-09-12 10:42:50 -07:00
bc26fbf1b0 Move experimental color API to fmt/color.h 2018-09-12 09:04:26 -07:00
97cc889374 Workaround a visit lookup issue in gcc 8 (#851) 2018-09-12 08:45:14 -07:00
7110b46076 Optimize default formatting 2018-09-12 08:45:14 -07:00
c8a8464f7d Optimize buffer construction 2018-09-12 08:45:14 -07:00
8cbfb6e727 Get rid of conversion warning in gcc-4.8 (#854)
Get rid of conversion warning in gcc-4.8 

Get rid of the following warning:
conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Werror=conversion]
2018-09-11 06:14:39 -07:00
6ffc828a79 Phasing out null_terminating_iterator 2018-09-10 06:51:38 -07:00
aeb6add336 Skip strchr for the common case 2018-09-09 09:08:41 -07:00
5614289dd8 Optimize and simplify format string parsing 2018-09-09 08:41:27 -07:00
10c7f89351 Optimize format string processing on dumb compilers 2018-09-09 08:13:06 -07:00
59c268a5f8 Use strlen when possible since it's constexpr on gcc 2018-09-08 16:17:22 -07:00
918bb1ce8f Optimize argument capture 2018-09-08 15:29:32 -07:00
a3ba6b4f62 Disable the fmt(...) macro by default (#853) 2018-09-08 09:55:41 -07:00
8671689449 Update docs and formatting 2018-09-08 09:06:54 -07:00
cc10b4607f Make format_to faster on older gcc 2018-09-08 07:22:29 -07:00
981797f059 Get rid of implicit-fallthrough warn. in GCC 7 and 8
This change enables FMT_FALLLTHROUGH also for GCC-Compilers in the versions 7 and 8.
2018-09-07 12:43:32 -07:00
2117775747 Micro-optimize parsing 2018-09-05 07:10:50 -07:00
be0e268468 Optimize processing of trailing '}' 2018-08-31 15:34:31 -07:00
fbc38b9083 Pass heavy arguments by ref 2018-08-31 15:17:18 -07:00
8dc69b9da9 Workaround a bug in Intellisense 2018-08-29 20:40:54 -07:00
1489d3b7fa Implement exponential notation 2018-08-29 18:55:57 -07:00
dd8c5ce442 Implement more FP formatting options 2018-08-29 09:34:57 -07:00
46484da711 Fix a warning 2018-08-29 07:00:24 -07:00
802ff8866e Fix compilation of time.h when localtime_t is a macro (#843) 2018-08-29 06:40:54 -07:00
95a718992c Remove conversion compiler warnings (#844)
* Remove conversion compiler warning

When compiling with g++8, I get the following two errors:
include/fmt/format-inl.h:400:29: error: conversion from ‘int’ to ‘char’ may change value [-Werror=conversion]
       buffer[size++] = zero + static_cast<char>(digit);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
include/fmt/format-inl.h:416:28: error: conversion from ‘int’ to ‘char’ may change value [-Werror=conversion]
       buffer[size++] = '0' + digit;
                        ~~~~^~~~~~~

With this change, the errors are gone.
2018-08-29 06:38:56 -07:00
e483a01a0f Implement some formatting options in Grisu 2018-08-27 17:51:49 -07:00
f51080916e Revert "Implement some formatting options in Grisu"
This reverts commit 2a952dd0b2.
2018-08-27 17:51:27 -07:00
2a952dd0b2 Implement some formatting options in Grisu 2018-08-26 09:51:49 -07:00
0de44a469a Implement exponent formatting 2018-08-26 08:12:35 -07:00
f0d0a1ebd7 Implement Grisu2 digit generation 2018-08-25 20:45:50 -07:00
569ac91e0b Implement Grisu boundary computation 2018-08-25 11:39:38 -07:00
a11eb3a090 Workaround various icc bugs (#822) 2018-08-22 09:07:17 -07:00
62010520ed Disable gnu-string-literal-operator-template warning 2018-08-22 08:12:59 -07:00
987514761e Make convert_to_int public (#818) 2018-08-22 07:40:06 -07:00
ba95e36a58 Clarify that '\0' cannot be used as fill (#832) 2018-08-19 08:37:40 -07:00
abde38b4fb Add compilation support with Newlib nano for embedded targets
Remove the dependency on std::locale to reduce executable sizes

For embedded target the usage of locale bring a huge amount of code to the executable, just to get hold of the thousands separator. Using a static defined thousands separator makes libfmt embedded target friendly.
2018-08-19 07:40:34 -07:00
18400503da Fix C4127 warning in basic_writer<Range>::write_double 2018-08-17 07:36:38 -07:00
9de312112a Reformat and add a comment 2018-08-15 06:54:43 -07:00
8bbb0b48b4 Update README.rst 2018-08-15 06:34:34 -07:00
5c0101ab2d Use the correct function signature in the docs 2018-08-12 11:34:48 -07:00
fbe6410e53 Fix docs 2018-08-12 08:52:47 -07:00
8b9fb9fb7e Fix ambiguous instantiation with formatter in fmt/ostream.h (#830) 2018-08-11 09:13:54 -07:00
0f04ec68a9 Fix package upload (#828) 2018-08-11 07:57:45 -07:00
809073851f Update changelog 2018-08-11 07:22:41 -07:00
5d02041c59 Update changelog 2018-08-11 07:12:52 -07:00
4b868b8922 Re-enable compile-time format-string checking
Since the commit 691a7a9 compile-time string checking was accidently not possible anymore.
With this change, it should be possible again.
2018-08-07 07:43:47 -07:00
4061a0d35d Parameterize vformat to support custom char types 2018-08-05 10:44:59 -07:00
c68bab7014 Remove broken fmt::internal::format_enum (#818) 2018-08-01 07:11:53 -07:00
0c63d15ee9 Improve wording 2018-07-27 07:37:45 -07:00
ce19309d09 Workaround a bug in icc 15 2018-07-26 07:59:41 -07:00
c684349195 Move contiguous version of format_to to fmt/core.h 2018-07-22 18:09:22 -07:00
8db14efa84 util-test -> core-test and minor cleanup 2018-07-22 17:05:23 -07:00
ffe414cad1 Add compile-time format string checks to format_to (#783) 2018-07-22 15:30:51 -07:00
c178ab440f Remove FMT_USE_RVALUE_REFERENCES 2018-07-22 15:07:53 -07:00
5befe6584d Remove fmt/folly.h and clean up core API 2018-07-22 14:42:25 -07:00
35538ca66c Merge more format overloads 2018-07-22 12:24:47 -07:00
4f16409730 Merge format overloads using SFINAE 2018-07-22 08:06:42 -07:00
2a4e948864 Add UTF-8 types 2018-07-22 06:36:21 -07:00
d778bded95 Make line in tests fit within 80chars 2018-07-20 17:07:23 -07:00
7b4f170c94 Fix warning about using old-style cast 2018-07-20 17:07:23 -07:00
b1d10a2884 Add support for dynamic arg sets
This allows construction of basic_format_args from a dynamic set of arguments. The syntax is a little clunky and could probably be improved but this at least enables the functionality.
2018-07-20 17:07:23 -07:00
cf2719bd12 Add support for types explicitly convertible to wstring_view 2018-07-18 19:12:10 -07:00
50584f42b4 Test formatting of an object with templated conversion to string-like 2018-07-18 16:24:46 -07:00
73bed45b7a Add support for types explicitly convertible to fmt::string_view 2018-07-18 14:42:26 -07:00
6eaa507473 Fix global initialization issue (#807) 2018-07-18 09:49:21 -07:00
48dff9f3c5 Update docs 2018-07-18 06:44:46 -07:00
a9e261599b Minor cleanup 2018-07-17 08:54:22 -07:00
efd8ee8a7f Reduce warnings, support #809 2018-07-16 12:37:54 +02:00
8615ff2acc Micro-optimize argument retrieval 2018-07-15 07:28:31 -07:00
916ed99dab Micro-optimize argument retrieval 2018-07-14 15:28:55 -07:00
e7e9578ed4 Optimize format string parsing 2018-07-14 14:27:56 -07:00
c99a259739 Mark new functions with FMT_API (#808) 2018-07-14 07:43:16 -07:00
e0f6a2f8be Add a formatter for folly::StringPiece 2018-07-14 07:31:47 -07:00
ae4a3945f5 Revert "Better support for newer CMake's"
This reverts commit 0eb01b832c.
2018-07-14 06:34:20 -07:00
a317448bd4 Keep noexcept specifier when exceptions are disabled. 2018-07-13 12:46:15 -07:00
0eb01b832c Better support for newer CMake's 2018-07-11 07:08:17 -07:00
2a4cd6d05e Fix the returned value of format_to_n with user-defined types having operator<<. 2018-07-10 14:01:12 -07:00
9c32e73abf Fixing return unreachable warning on NVCC 2018-07-09 21:33:10 -07:00
e5c93108e6 Added clear() to basic_buffer 2018-07-09 20:25:49 -07:00
60c662b3a7 Add an example of reusing formatters 2018-07-08 15:00:44 -07:00
f66ba6508a Optimize format string parsing 2018-07-08 10:15:24 -07:00
f21268aa72 Revert "Optimize format string parsing" because of a bug in MSVC
https://godbolt.org/g/rpiDgh

This reverts commit f9e9bf0231.
2018-07-08 08:08:50 -07:00
07b690a679 Update README.rst 2018-07-07 18:18:56 -07:00
f9e9bf0231 Optimize format string parsing 2018-07-07 16:50:22 -07:00
c2ce7e4f07 Update version 2018-07-05 06:22:54 -07:00
434eb9167e Update README.rst 2018-07-04 18:07:17 -07:00
09d94162f9 Update changelog 2018-07-04 17:47:46 -07:00
e6362642cf Fix pedantic conversion warning 2018-07-04 17:45:28 -07:00
f0110e8125 Update changelog and CI 2018-07-04 17:43:07 -07:00
479ee2a8c6 Fix MSVC build, take 2 2018-07-04 14:24:07 -07:00
e928b6724c Fix MSVC 2013 build 2018-07-04 12:33:15 -07:00
ec218a3ad1 Fix redefinition warning for RESET_COLOR 2018-07-04 07:52:19 -07:00
c04fb91b03 Fix handling of user-defined types in format_to (#793) 2018-07-04 07:40:56 -07:00
323b92bffe Force linking of inline functions into the library (#795) 2018-07-03 19:10:23 -07:00
c6d9730ddb Fix sign conversion warnings (#790) 2018-06-27 14:31:20 +02:00
2e95823ef7 Move new color support to format.h and mark old as deprecated 2018-06-24 06:39:22 -07:00
ab2d88ca8e Make format_to work with basic_memory_buffer (#776) 2018-06-23 08:29:26 -07:00
3abd036c47 Fix compilation on gcc 4 2018-06-23 07:18:59 -07:00
c2f3805488 Add vformat_to_n (#769) 2018-06-23 07:03:00 -07:00
ce500635c7 Renamed enum color to colors.
Added enum colors conversion to rgb struct.
Added colors_test.cpp.

Removed print_colored.
Renamed enum colors back to color.

Removed unnecessary inline keyword.
Removed print_rgb.
2018-06-23 06:14:44 -07:00
0508bbc7ae Add wchar_t overload of format_to_n (#764) 2018-06-13 08:24:32 +02:00
c2fbadb9cf Fixed issue #779 2018-06-12 07:39:44 +02:00
47268ecd80 Fixed GCC version test 2018-06-10 20:35:38 +02:00
9ff3b6af2e Fix handling of compile-time strings when including ostream.h (#768) 2018-06-10 19:05:27 +02:00
e3707ef14b Document that file should be in wide-oriented mode for wide print 2018-06-09 09:12:49 +02:00
45fa4ee949 Merge branch 'master' of github.com:fmtlib/fmt 2018-06-08 21:43:56 +02:00
9c07b37fff Using enum class now.
Renamed from hex to color.
Changed colr names to snake case.
2018-06-08 21:40:35 +02:00
5b5886a993 Fixed line length. 2018-06-08 19:48:41 +02:00
d2bfee13e2 Added quotes for strings in ranges and tuple likes. 2018-06-08 19:48:41 +02:00
aff6e45e14 Added support for rgb color output. 2018-06-07 22:49:16 +02:00
1b8a7f8fa0 Fix postincrement in truncating and counting iterators 2018-06-07 20:20:36 +02:00
4bc26f0a7b Merge branch 'master' of github.com:fmtlib/fmt 2018-06-07 18:42:30 +02:00
fc6e0fe992 Fix FP formatting to a non-back_insert_iterator with sign & numeric alignment (#756) 2018-06-07 18:41:40 +02:00
cd5b5670ba Make is_range and is_tuple_like public API, fix #751 2018-06-06 21:49:14 +02:00
6322b47e60 Minor cleanup 2018-06-06 16:51:35 +02:00
691a7a91a1 Add more compilers to CI and increase FMT_PEDANTIC warning levels (#736)
* Add a _lot_ more warnings to FMT_PEDANTIC
Fix these warnings

* Add more compilers to CI
Fix (some) of the compiler errors with them

* Enable -Werror on CI
Increase warning level on MSVC when compiling with FMT_PEDANTIC

* Add VS 2013 and 2015 to Appveyor

* Fix Appveyor tests
Formatting

* Implement requested changes
Fix some of the MSVC warnings
Implement C++11 integer_sequence

* Reintroduce appveyor-build.py

* Remove ranges-test from tests

* Remove (some) explicit warning suppressions
Fix C++ standard setting in CI

* Remove (some) explicit warning suppressions
Fix C++ standard setting in CI

* Fix test builds with C++11

* Enable pedantic warnings on tests

* Fix warnings from edits to master

* Cleanups

* Add C++11 support to ranges.h
Re-enable ranges-test
Fix a Visual Studio error about function not returning a value in printf.h
Fix a bug in .travis.yml
2018-06-06 15:57:59 +02:00
dd1a5ef7f9 Let requests close the file 2018-06-05 16:58:02 +02:00
d5c462596b Fix formatting of more than 15 named arguments (#754) 2018-06-05 08:32:28 +02:00
47d147b65d Simplify the nvcc warning fix 2018-06-04 21:27:20 +02:00
911a75114b Fix nvcc warnings (#752) 2018-06-04 21:00:28 +02:00
94b476283c Fix docs 2018-06-04 19:56:22 +02:00
252f11f85d Fix a bogus MSVC warning about unreachable code, take 2 2018-06-04 18:17:55 +02:00
81d5663825 Fix more bogus MSVC warnings about unreachable code (#748) 2018-06-04 06:10:52 +02:00
68f0ac8271 Fix a bogus MSVC warning about unreachable code 2018-06-03 08:03:56 +02:00
b60a5c5d49 Improve floating-point formatting 2018-05-28 20:16:30 -07:00
8dc2360b11 Fix a comment 2018-05-28 17:21:39 -07:00
4e4b8570e5 Implement simple version of Grisu 2018-05-28 11:25:07 -07:00
4027557958 Fix tests on 64-bit MSVC 2018-05-27 11:38:53 -07:00
5c32aa411c Workaround a bug in MSVC 2018-05-27 11:18:27 -07:00
468c243ca8 Add a function to get cached power of 10 2018-05-27 10:57:26 -07:00
2f257b7291 Implement normalization and simplify power table 2018-05-27 08:04:30 -07:00
6a5bb6e268 Move Android.mk to support and update 2018-05-27 06:20:54 -07:00
e282d963fe Bump version 2018-05-26 09:46:59 -07:00
e2cd521b8f Fix incorrect call to on_align in '{:}=' (#750) 2018-05-26 09:23:09 -07:00
fba352a92a Don't use UDL templates on Intel C++ compiler (#742) 2018-05-26 08:07:45 -07:00
6dcc526d5b Update release script 2018-05-26 07:02:49 -07:00
5386f1df20 Update version 2018-05-21 21:00:04 -07:00
ba6640b257 Fix formatting 2018-05-21 20:50:23 -07:00
507a50c3ad Fix changelog 2018-05-21 20:38:07 -07:00
147807c911 Detect integer_sequence support on MSVC 2018-05-21 20:30:58 -07:00
8b246531e6 Update changelog 2018-05-21 20:27:58 -07:00
5ad54256c5 Fix a conflict between fmt::join and fmt/ostream.h (#744) 2018-05-21 20:21:06 -07:00
6ebc1a967d Merge locale.h into format-inl.h 2018-05-20 17:16:34 -07:00
6966db1dab Update docs 2018-05-20 17:10:34 -07:00
2196025dd1 Fix a warning 2018-05-20 17:09:12 -07:00
589f5f37b6 Update changelog 2018-05-20 16:00:39 -07:00
edd5f1445d Fix compilation errors on gcc 4.4 2018-05-20 09:09:03 -07:00
936aba5f90 Fix compilation errors on gcc 4.4 2018-05-20 07:42:09 -07:00
3e3a27740e Update changelog 2018-05-19 11:46:55 -07:00
b76bb79613 Improve naming consistency 2018-05-19 10:32:53 -07:00
fbd5153487 Update changelog 2018-05-19 10:31:49 -07:00
69823bf852 Improve naming consistency 2018-05-19 08:59:37 -07:00
d940fa679c Disable unsafe implicit conversion to std::string (#729) 2018-05-19 07:14:27 -07:00
d2bf93fe22 Update changelog 2018-05-19 07:13:06 -07:00
550ef1d29d MSVC improvements and data truncation cleanup.
MSVC is timid about evaluating constexpr functions unless it has to, so the "TYPES" variables end up in read-write memory even though the optimizer removes the initializer. Making TYPES constexpr causes MSVC to try harder to initialize these variables at compile time, which also ends up completely removing the (named) variable from the final compiled binary.
Fixed a data truncation warning being reported in ostream-test.
2018-05-17 18:46:31 -07:00
728e4f5a8d Fix docs 2018-05-16 08:26:55 -07:00
8c2557710d Update docs and changelog 2018-05-16 07:58:53 -07:00
a68fd44ecc Add ranges.h to FMT_HEADERS in CMakeLists.txt (#738) 2018-05-14 06:16:30 -06:00
e3f7f3a2e9 Add support for ranges, containers and tuple-like types in fmt/ranges.h 2018-05-13 13:28:11 -07:00
984232db15 Remove duplicate ChangeLog entries 2018-05-13 13:14:28 -07:00
78677e3fcf Update ChangeLog and docs 2018-05-13 12:42:55 -07:00
ad23270ec7 Document to_wstring 2018-05-13 09:11:29 -07:00
3c0f8c2601 Update ChangeLog 2018-05-13 08:53:16 -07:00
989378930a Detect inline namespaces on gcc 2018-05-13 08:53:04 -07:00
dfb6546932 Fix docs 2018-05-13 08:04:39 -07:00
3aa2911579 Update ChangeLog.rst 2018-05-13 08:02:06 -07:00
d3f6c841c1 Update ChangeLog.rst 2018-05-13 07:22:41 -07:00
c1441ae4c4 Update ChangeLog.rst 2018-05-12 16:02:20 -07:00
dece85b31f Fix docs, take 2 2018-05-12 13:57:56 -07:00
6a1df3bd05 Fix docs 2018-05-12 12:57:16 -07:00
838400d29b Add inline namespace fmt::v5 2018-05-12 11:02:15 -07:00
b64b24ebc5 Update ChangeLog.rst 2018-05-12 09:42:59 -07:00
fc9087114f Update ChangeLog.rst 2018-05-12 09:10:11 -07:00
46c374a8a9 Fix compilation with new gcc and -std=c++11 (#734) 2018-05-09 20:58:05 -07:00
f0ae725721 Clarify the use of allocators 2018-05-09 06:43:54 -07:00
d72d046254 Update paths in fmt.pro 2018-05-09 06:21:00 -07:00
edbbf7ce6c Fix FreeBSD 12
FreeBSD 12 changed the type of freelocale to the type defined by
POSIX. Check the FreeBSD version when building for FreeBSD.
2018-05-09 06:10:37 -07:00
a4e4f74530 Fix a -Wundef when FMT_GCC_VERSION < 600 2018-05-09 06:09:25 -07:00
7d3de49715 Implement double to fp conversion 2018-05-06 13:37:49 -07:00
a4c7d99f70 Add bit_cast 2018-05-06 11:52:51 -07:00
0adccaefb6 Fix a -Wundef of _LIBCPP_VERSION 2018-05-05 07:43:22 -07:00
2570f1afdc Provide more overloads for the wide string flavour
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-05-05 07:31:44 -07:00
ca31ca13f1 Fixed arg_formatter_base::write_pointer to not mutate the format specs.
This fixes cases where arg_formatters are reused, like with arg_join.
2018-05-01 07:12:27 -07:00
6cd666100f remove trailing spaces.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-05-01 07:10:05 -07:00
fe19c266ce Move format_string to fmt namespace for ADL 2018-04-29 08:35:20 -07:00
2768af2388 Add cached powers of 10 2018-04-29 06:33:05 -07:00
dd296e1de0 Add a script to compute powers of 10 2018-04-28 14:32:05 -07:00
0efc8a1808 Fix compiler warning about narrowing
Signed-off-by: Daniela Engert <dani@ngrt.de>
2018-04-27 06:41:43 -07:00
df1ba52b64 Update example 2018-04-22 17:04:28 -07:00
221b08fd8f Merge branch 'master' of github.com:fmtlib/fmt 2018-04-22 09:16:34 -07:00
fa9066fe3e context_base::begin -> out 2018-04-22 09:16:32 -07:00
90ff31b38e Fix a -Wundef warning on clang
Resolves #715
2018-04-22 09:13:55 -07:00
b1f68c43b5 Merge branch 'master' of github.com:fmtlib/fmt 2018-04-21 19:21:41 -07:00
cd90097ca4 Implement handmade FP 2018-04-21 17:26:24 -07:00
822eccc3b8 Sync API with standards proposal 2018-04-21 14:29:24 -07:00
2ae41242a5 allow time formatting with wchar_t contexts
change total specialization of 'struct formatter<std::tm>' into partial specialization 'template <typename Char> struct formatter<std::tm, Char>', backed by matching 'strftime'-like overloads
2018-04-18 18:55:49 -07:00
a1579b0ff8 Update key 2018-04-16 18:22:03 -07:00
ded921f0a2 Fix documentation build, take 2 2018-04-15 10:34:04 -07:00
3284751f43 Fix documentation build 2018-04-15 09:49:37 -07:00
bb738c4c26 Remove section on Write API since it's being superceeded by compile-time Format API 2018-04-15 09:13:44 -07:00
d180c25c8f Update godbolt link 2018-04-15 06:19:38 -07:00
1ed842a3b4 Update godbolt link 2018-04-14 12:41:08 -07:00
e80aba1c2b Remove format_float stub 2018-04-14 12:40:53 -07:00
7b8cb3135a Make context_base::args() public 2018-04-14 12:40:26 -07:00
48ae0506de fixes MSVC compiler warning bloat (Visual Studio 2017, latest updates) 2018-04-11 06:53:27 -07:00
096c4051b2 Simplify char_traits 2018-04-08 13:38:12 -07:00
7610c5362a Remove unused macro 2018-04-08 11:54:22 -07:00
111fa5814b Update README.rst 2018-04-08 09:03:37 -07:00
52fcef1e57 Update docs 2018-04-08 07:33:07 -07:00
7d28674d3a make_args -> make_format_args 2018-04-08 07:21:26 -07:00
9382b76f2a context_t -> format_context_t 2018-04-08 07:09:34 -07:00
fd0b07a75a (w)context -> (w)format_context 2018-04-08 07:03:44 -07:00
26aa34f319 basic_context -> basic_format_context 2018-04-08 06:45:21 -07:00
44cc034651 Relax string_view requirements 2018-04-07 16:18:01 -07:00
0829cab8f2 Remove from_checked 2018-04-07 15:21:48 -07:00
cb7bbc6224 Improve checked iterator support 2018-04-07 15:11:34 -07:00
5079f924d6 Fix a narrowing warning 2018-04-07 14:42:09 -07:00
5859e58ba1 Fix msvc warnings 2018-04-04 21:11:31 -07:00
1e747f603f Fix msvc warnings 2018-04-04 20:57:02 -07:00
9d4efd7aa2 Iterator Wars VI: Return of the checked iterator 2018-04-04 20:15:02 -07:00
9764f55891 Update docs 2018-04-04 07:53:19 -07:00
4ef97b9bb2 Add a missing comma 2018-04-04 07:43:51 -07:00
23759b2688 basic_arg -> basic_format_arg, arg_store -> format_arg_store 2018-04-04 07:38:21 -07:00
4975297eb0 Simplify counting iterators 2018-03-31 07:47:30 -10:00
e8e006f4e7 Fix compile checks for mixing narrow and wide strings (#690) 2018-03-30 09:29:47 -10:00
c5ebecf7c6 Document format_to_n 2018-03-30 08:31:41 -10:00
3cf0526316 Return output iterator to the end from format_to_n 2018-03-30 08:20:12 -10:00
174087bfdb Implement format_to_n 2018-03-29 15:13:10 -10:00
050f3f1f0e Remove parts of obsolete write API 2018-03-29 07:36:37 -10:00
e90b1da367 Fix linker errors using fmt as shared library in MSVC 2018-03-28 07:14:56 -10:00
8e10d404db Fix compile tests 2018-03-27 07:39:03 -10:00
7a41d61d79 Add make_printf_args
Fixes #687
2018-03-27 07:15:51 -10:00
4fea018b2d Fix string_view detection 2018-03-26 07:00:41 -10:00
6957d28cfb Detect string_view on libc++ (#686) 2018-03-26 06:50:22 -10:00
0ea70defbe Update readme 2018-03-21 09:25:28 -07:00
9ce5e30c06 Update readme 2018-03-21 09:15:28 -07:00
8c29459eda Fix handling of empty string_view (#689) 2018-03-21 09:01:51 -07:00
a24005d5fd Fix a narrowing warning 2018-03-21 08:29:06 -07:00
3651b7fca6 Fix a narrowing warning 2018-03-21 07:59:42 -07:00
b64486dae9 Add format.cc 2018-03-21 07:51:56 -07:00
3da71d51e0 Move source files to the src directory 2018-03-21 07:50:59 -07:00
7971ed3db3 Update readme 2018-03-21 06:48:36 -07:00
f61ca2ec4f Update readme 2018-03-21 06:46:41 -07:00
84e520b79c Update readme 2018-03-21 06:16:13 -07:00
e8aa0f3315 Update docs 2018-03-21 06:12:10 -07:00
17258e9c63 Update docs 2018-03-19 19:47:14 -07:00
6d339e32a0 Improve comment 2018-03-16 16:26:31 -04:00
c3d05245fe Fix a shadowing warning 2018-03-16 16:26:11 -04:00
b58c8ddeb4 Update docs 2018-03-16 16:04:12 -04:00
505b3ae66f Workaround GCC bug 67371 (#682) 2018-03-16 12:02:19 -04:00
70dffc639a Remove unnecessary check 2018-03-15 09:58:26 -04:00
df828f88da Don't define FMT_GCC_VERSION on clang 2018-03-15 09:55:31 -04:00
42f70c8b4f Avoid narrowing casts 2018-03-15 09:45:31 -04:00
10b939b096 Remove unneeded usage of anonymous struct on clang 2018-03-15 09:28:50 -04:00
3adfaae20c Remove extra semicolon in format_args constructor 2018-03-15 09:28:50 -04:00
4006678577 Fix warnings under MSVC (#679)
Closes #678.
2018-03-14 20:17:15 +01:00
9c5f54a723 Add format example for padded hex byte
Fixes #2
2018-03-13 23:05:48 -04:00
7bab90e52d Remove extra comma 2018-03-13 22:45:14 -04:00
2e21e7d1f1 Fix util-test 2018-03-13 22:20:06 -04:00
acb469ae2e Fixed UTF8/16 converters to support empty string input
Previously an exception was thrown since Win32 WideCharToMultiByte API
returns error on zero-length input.
2018-03-13 21:33:21 -04:00
c37c4c437e Fix find-package-test 2018-03-13 14:13:39 -04:00
6d21fc43b9 add alias targets with fmt namespace
For the consumer it should not matter if fmt has been added to the
project as subdirectory or via find_package. With the alias targets
the library can be always imported via fmt::fmt.
2018-03-13 13:51:48 -04:00
e02aacc634 Add CMake namespace (#511) 2018-03-13 13:03:18 -04:00
aee4512cc5 Gradle (#649)
* Gradle

Gradle support to make ease of import in Android Java projects.

* Gradle

Gradle support for Android projects.
For command line build, `gradle assembe` will trigger build phase

 - Config for Android .so file generation
 - Commented build.gradle
 - Automatic file copy after build
 - Dummy AndroidManifest file

* Build with Gradle

 - Build job for Travis CI
 - Moved gradle file to support/

* Gradle Path

 - Absolute path for Gradle binary

* File check after Gradle build

 - Additional script for build success
 - Check the Gradle's `assemble.doLast` task
2018-03-12 15:40:25 -04:00
7db0e94b9e Fix handling of numeric alignment with no width (#675) 2018-03-11 21:04:42 -04:00
9facc119a6 Update docs 2018-03-10 09:44:37 -08:00
a1d187113b Merge branch 'master' of github.com:fmtlib/fmt 2018-03-10 06:46:51 -08:00
daf650c49a Disallow formatting of multibyte strings into a wide buffer (#606) 2018-03-10 06:46:41 -08:00
8fd7e30f37 Update README.rst 2018-03-09 15:44:46 -08:00
ca93be130a Use fmt(s) as an alias for FMT_STRING(s) 2018-03-09 15:40:40 -08:00
80e57c7a3d Update to new naming conventions 2018-03-07 07:36:13 -08:00
ae3cc844e7 Check format string at compile time in print 2018-03-07 05:41:45 -08:00
585512fc7c Remove unnecessary instantiations 2018-03-04 15:14:02 -08:00
7755cdc199 Make symbols readable 2018-03-04 15:00:22 -08:00
f867d08239 Update docs 2018-03-04 12:09:34 -08:00
a103b9bc46 Workaround missed optimization in gcc (#668) 2018-03-04 11:45:20 -08:00
bb47109a78 Cleanup 2018-03-04 11:25:40 -08:00
f1ede6380b Make inline_buffer_size public and update docs 2018-03-04 10:33:42 -08:00
995b63adfe Update copyright 2018-03-04 10:11:44 -08:00
4023291759 Update docs 2018-03-04 09:55:17 -08:00
86a9bc8291 Cleanup 2018-03-04 09:16:51 -08:00
b7632e9641 Make format_to return iterator and update docs 2018-03-04 08:13:08 -08:00
5281ea6ad2 do_vformat_to -> vformat_to and update docs 2018-03-04 06:40:43 -08:00
d07ba49821 Fix docs 2018-03-03 22:12:23 -08:00
418659adbe Fix compilation errors on gcc 4.4 2018-03-03 14:04:59 -08:00
1d2adef28d Fix compilation errors on gcc 4.4 2018-03-01 03:45:25 -08:00
45518c3fe1 Fix compilation errors on gcc 4.4 2018-02-28 07:47:24 -08:00
698d909706 Workaround a bug in gcc 5.1 2018-02-28 06:14:56 -08:00
81074c7048 Fix more compilation errors on gcc 4.6 2018-02-28 05:23:25 -08:00
1b4525384b Fix more compilation errors on gcc 4.6 2018-02-28 05:09:24 -08:00
6090e51b65 Fix compilation errors on gcc 4.6 2018-02-28 04:49:20 -08:00
0827ec5aa9 Fix compilation errors on gcc 4.6 2018-02-28 04:33:43 -08:00
4d35f94133 Always use fallback string_view to pass format string (#664) 2018-02-24 18:19:30 +00:00
34cf54c2fc Update README.rst 2018-02-24 09:37:17 +00:00
0565d65461 Fix gcc 7.2 issue 2018-02-24 09:29:15 +00:00
f5dc0ed342 Break long lines 2018-02-24 08:39:17 +00:00
ea06f021f8 test: comment out one FormatStringErrors constexpr test
GCC 7.3 complains that this is not a compile time constant.

test/format-test.cc: In member function ‘virtual void FormatTest_FormatStringErrors_Test::TestBody()’:
test/format-test.cc:1919:3: error: non-constant condition for static assertion
   static_assert(test_error<__VA_ARGS__>(fmt, error), "")
   ^
test/format-test.cc:1924:3: note: in expansion of macro ‘EXPECT_ERROR’
   EXPECT_ERROR("{0:s", "unknown format specifier", Date);
   ^~~~~~~~~~~~
2018-02-24 08:20:20 +00:00
5b49177352 test: Initialize some local variables
GCC 7.3 complains about uninitialized varaibles in constexpr context.
2018-02-24 08:20:20 +00:00
f45f70af09 Use trailing return type instead of deduction
C++11 does not support deduction of return type.
2018-02-24 08:20:20 +00:00
db86e8d5d3 Remove a couple of unused argument names 2018-02-24 08:20:20 +00:00
55f5c9f21b Use FMT_NULL instead of 0 is a few more places.
Found with GCC and -Wzero-as-null-pointer-constant
2018-02-24 08:20:20 +00:00
e92ba1071d Fix Python str.format link to point to Python 3 docs 2018-02-20 17:40:49 +00:00
a7ae5666a0 Enable join on msvc 2018-02-19 21:03:51 +00:00
24d249b0b4 Fix formatting of objects convertible to string_view 2018-02-19 20:25:56 +00:00
e508e30800 Don't define FMT_LOCALE on OpenBSD
OpenBSD doesn't have strtod_l() (at least under the default
headers), so the class Locale that the macro gates won't compile.
2018-02-19 19:24:33 +00:00
0ee4273b04 Put is_enum check first not to instantiate convert_to_int unnecessarily 2018-02-18 05:47:29 +00:00
8ca3ab2c4c Revert problematic pragma 2018-02-18 05:38:32 +00:00
18ac98700e Fix formatting of objects convertible to std::string 2018-02-17 12:57:18 +00:00
ce4a65ffea Add pointer support to basic_writer 2018-02-17 09:38:46 +00:00
91721caa42 Add detection of wostream operator<< (#650) 2018-02-17 09:03:43 +00:00
1efc15c177 Fix MSVC build 2018-02-16 18:13:54 +00:00
8ed264fcd4 Rename type enum constants to prevent collision with poorly written C libs (#644) 2018-02-16 17:20:33 +00:00
4ba3f7db82 Update docs 2018-02-15 18:52:44 -08:00
7d2723d57c posix.cc: Fix compilation with -fno-exceptions
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>
2018-02-15 18:39:36 -08:00
24d66c5d65 compilation fix & warnings 2018-02-15 18:37:45 -08:00
229887bd40 Make constexpr remove_prefix gcc version check tighter (#648) 2018-02-14 05:46:41 -08:00
f3f19e762f Update docs 2018-02-11 13:43:16 -08:00
e9fa42acb8 Fix docs and build issues on gcc-4.6 2018-02-11 09:43:54 -08:00
affb35cfb9 Replace using with typedef for compatibility with gcc-4.6 2018-02-11 09:23:47 -08:00
9710c058aa Update documentation building script 2018-02-11 09:23:17 -08:00
1a4e892765 Move output_range to format.h 2018-02-11 08:36:44 -08:00
522de7b55d Replace using with typedef for compatibility with gcc-4.6 2018-02-11 08:32:02 -08:00
0b508fd29d Fix c++0x detection 2018-02-11 07:32:22 -08:00
1849735f12 Fallback to c++11 if c++14 not available 2018-02-11 07:25:53 -08:00
3239c51814 Get rid of generic lambdas 2018-02-11 07:05:14 -08:00
78166ccd36 Get rid of generic lambdas 2018-02-11 06:50:56 -08:00
d8ef8a9e9b Cleanup 2018-02-11 06:24:22 -08:00
822222181b Update README.rst 2018-02-10 07:45:32 -08:00
b00053247c Merge the std branch 2018-02-10 07:38:27 -08:00
a502decddb Added a fmt.pro to support build using qmake (#641) 2018-02-10 07:22:02 -08:00
61065e1a5c Fix unreachable code warning when signbit returns bool 2018-02-10 07:21:17 -08:00
403ae0a23b Add debug postfix for libfmt (#636) 2018-02-10 07:17:40 -08:00
5096c0fe97 Fix string_view detection 2018-02-10 07:17:29 -08:00
5b3f9eab94 Update syntax.rst 2018-02-10 07:03:44 -08:00
e802cf14e3 Add note about errno to the documentation 2018-02-10 07:01:59 -08:00
c96d64652b CMakeLists: Use GNUInstallDirs to set install location 2018-02-10 07:00:14 -08:00
dbd84697ff Update usage.rst 2018-02-10 06:54:26 -08:00
5013c15737 Silence MSVC 2017 constant if expression warning 2018-02-10 06:52:46 -08:00
cdfcee27fb Use allocator_traits if available 2018-02-10 06:51:13 -08:00
66b25ef0d0 Add examples 2018-02-10 06:33:03 -08:00
6cb68f9496 Fix warnings 2018-02-10 06:28:43 -08:00
0b635c9dc5 Fix handling of fixed enums in clang (#580) 2018-02-10 06:17:42 -08:00
66afd9b33a Fix compilation on gcc 6 2018-02-10 05:16:16 -08:00
67e070fe5a Make format work with C++17 std::string_view (#571) 2018-02-07 08:14:54 -08:00
867b330966 Remove ANDROID macro check per comment in #458 2018-02-07 07:44:15 -08:00
64599973e9 Enable stream exceptions (#581) 2018-02-07 07:36:15 -08:00
35f8f03670 Use less version 2.6.1 and sudo to fix npm install issues on travis 2018-02-07 07:17:34 -08:00
92a250fdb6 Suppress Clang's warning on zero as a null pointer 2018-02-07 07:16:00 -08:00
2f13d41e30 Add to_wstring 2018-02-07 07:08:14 -08:00
1e19ae8348 Workaround a bug in MSVC 2018-02-07 06:31:42 -08:00
3810d7e4d4 Workaround a bug in MSVC 2018-02-04 09:29:50 -08:00
5c7474e1fb Relax constexpr requirements 2018-02-04 08:58:21 -08:00
1f57243b49 Relax constexpr requirements 2018-02-04 08:52:43 -08:00
dc5403612e Conditionally compile constexpr 2018-02-04 08:21:31 -08:00
5d8ba816de Fix a segfault in test on glibc 2.26 #551 2018-02-02 19:34:08 -08:00
a9f810c188 Update README.rst 2018-02-02 19:17:19 -08:00
2582f41e12 Fix ifdefs 2018-02-02 19:16:13 -08:00
1a7d0ba2d0 Adding OpenSpace to the list of projects 2018-02-02 19:10:25 -08:00
8921f613de Update build script 2018-02-02 18:46:39 -08:00
f62e225e82 Automatically update version in release script (#431) 2018-02-02 18:45:05 -08:00
94806747df remove 'FMT_CPPFORMAT' CMake option 2018-02-02 18:42:22 -08:00
bfce29ffef Improve conversion 2018-02-02 18:40:36 -08:00
8cf30aa2be Fix segfault on complex pointer formatting (#642) 2018-02-01 21:49:03 -08:00
f164e4c72f Remove old bcc-related comments 2018-02-01 16:49:47 -08:00
c57029c1f0 Add Drake & Lyft Envoy to the list of projects 2018-02-01 16:46:41 -08:00
8fa9acb8e5 Workaround broken __builtin_clz in clang with MS codegen (#519) 2018-02-01 16:43:16 -08:00
3dae25828f Describe cmake use of header-only target 2018-02-01 16:42:53 -08:00
1c7b751d70 Fix handling of implicit conversion to integral types larger than int 2018-02-01 16:42:15 -08:00
08dff3774c Allow compiling and using as DLL in windows #502 2018-01-28 20:50:43 -08:00
c753a2af39 Don't include the world with WIN32_LEAN_AND_MEAN (#503) 2018-01-28 20:26:25 -08:00
a5185ec8d4 add SOURCELINK_SUFFIX for compatibility with Sphinx 1.5 2018-01-28 20:20:39 -08:00
768061c85e Fix FormatBuf implementation (#491) 2018-01-28 20:08:51 -08:00
0c136381e3 Move back_insert_range to format.h 2018-01-27 18:56:50 -08:00
5060568f72 %.f should have zero precision, not default precision 2018-01-27 17:56:19 -08:00
a09f748894 Add Kodi (xbmc) to the list of projects using fmt 2018-01-27 17:47:41 -08:00
f9fa7c405f Add FMT_API and FMT_OVERRIDE where needed 2018-01-27 17:15:14 -08:00
a980d3b46b Add fmt::join to format ranges (#466) 2018-01-27 16:04:45 -08:00
87eab90ea8 Fix missing intrinsic when included from C++/CLI (#457) 2018-01-27 09:25:15 -08:00
75005bbcd5 Don't export the -std=c++11 flag from the fmt target 2018-01-27 09:18:20 -08:00
19f990a9c0 Use https to fetch dependencies from github 2018-01-27 09:15:28 -08:00
bca9de9e68 Return iterator from format_to 2018-01-27 07:03:26 -08:00
0555cea5fc Added a fmt.pro to support build using qmake (#641) 2018-01-26 17:12:48 -08:00
a93270fd60 Replace a bunch of craft with type_traits, take 2 2018-01-22 18:56:53 -08:00
21429c8646 Revert "Replace a bunch of craft with type_traits"
This reverts commit e79588d6c1.
2018-01-21 18:53:38 -08:00
0473c48f88 Add std::basic_string allocator support (#441) 2018-01-21 18:21:16 -08:00
72d9fffd78 Fix test compilation for FreeBSD (#433) 2018-01-21 18:18:05 -08:00
e79588d6c1 Replace a bunch of craft with type_traits 2018-01-21 18:11:57 -08:00
3a6c7d0cbd Fix signbit detection (#423) 2018-01-21 16:41:55 -08:00
5e4c34b25a Add version macro FMT_VERSION (#411) 2018-01-21 16:36:22 -08:00
bd8a7e7ea1 More iteratification 2018-01-21 14:30:38 -08:00
f78c3e41be Fix unreachable code warning when signbit returns bool 2018-01-21 06:11:29 -08:00
0a402056bc Add CONTRIBUTING.rst 2018-01-20 19:52:19 -08:00
e35d41fff5 Add extern templates for format_float (#413) 2018-01-20 19:17:59 -08:00
d8c25a175a Use nullptr if available 2018-01-20 19:11:19 -08:00
e95e4659d9 Add syntax.rst to build 2018-01-20 17:55:43 -08:00
e51119508c argument index -> argument id 2018-01-20 17:55:28 -08:00
229ee34eea Fix compiler warnings 2018-01-20 17:54:06 -08:00
7fe0f3dabc Update ChangeLog 2018-01-20 17:39:15 -08:00
38b603a42f Update README.rst 2018-01-20 17:12:43 -08:00
a1e7e4a768 Fix compilation with -fno-exceptions (#402, #405) 2018-01-20 17:10:14 -08:00
3f24a38840 Thread-safe time formatting (#396) 2018-01-20 11:35:23 -08:00
f853d94a15 Remove unnecessary fmt/ prefix (#397) 2018-01-20 10:28:10 -08:00
9649919d01 Document use of format_arg for user-defined type #393 2018-01-20 10:07:29 -08:00
c8efe145b4 Add api.rst to build 2018-01-20 09:52:29 -08:00
da80005f11 Fix compilation on Cygwin (#388) 2018-01-20 09:52:03 -08:00
8ed163533c Fix a typo 2018-01-20 09:43:56 -08:00
1760c31b52 Workaround Doxygen mess 2018-01-20 08:53:03 -08:00
72606f2391 Add missing types to counting_iterator 2018-01-20 08:20:18 -08:00
c15710032e Add debug postfix for libfmt (#636) 2018-01-20 06:47:12 -08:00
6822466aa3 Handle nested braces in join (#638) 2018-01-20 06:26:22 -08:00
64b349aee2 More iterator support & fmt::count 2018-01-17 22:04:24 -08:00
e3b69efbe1 Suppress msvc warnings in gmock 2018-01-17 05:46:14 -08:00
322736d3bb Add support for arbitrary output iterators 2018-01-15 12:46:44 -08:00
1029119497 Cleanup 2018-01-15 11:37:39 -08:00
c1d137ed5f Add support for nonconiguous iterators 2018-01-15 11:30:53 -08:00
f6fd38bb3a More iterator support 2018-01-15 08:48:37 -08:00
c2fecb9b2a Clean API 2018-01-14 14:15:59 -08:00
9a53a706fc Add support for back_insert_iterator 2018-01-14 13:12:26 -08:00
91ee9c9acd Return iterator from the format method 2018-01-14 11:00:27 -08:00
67928eae28 Don't inherit context from parse_context 2018-01-14 09:27:40 -08:00
217e7c76f1 Pass ranges by value 2018-01-14 08:13:48 -08:00
22994c62f7 Decouple arg_formatter_base from buffer 2018-01-13 15:34:48 -08:00
00f1450d9a Update tesmplate parameter names 2018-01-13 14:57:43 -08:00
3a2e89e134 Reduce dependency on buffer 2018-01-13 12:57:27 -08:00
c719d94473 Fix experimental/string_view detection 2018-01-13 07:57:33 -08:00
cea3c20747 Give a better error message for function pointers (#633) 2018-01-13 07:02:45 -08:00
232ceabbc3 Workaround an internal compiler error in MSVC 2018-01-13 06:43:03 -08:00
c095445394 Replace buffer with range 2018-01-10 22:41:23 -08:00
c3d6c5fc4c Replace buffer with range 2017-12-30 07:42:56 -08:00
0f98773164 add transition helper to format.h
the transition from v3 to v4 introduced an API change that format.h does
not provide printf functionality. to easi the transition we introduce a
define `FMT_FORMAT_PROVIDE_PRINTF` that will pull in printf.h from format.h
2017-12-27 21:48:55 -08:00
d165d9c483 Decouple locale and buffer 2017-12-26 17:22:07 -08:00
3663414053 Parameterize basic_writer on buffer type 2017-12-26 09:00:22 -08:00
6f2769d0b4 Revert "Added support for format string containing '\0' in _format udl (#619) (#620)"
This reverts commit 3aaa25fa70 for
reasons discussed in #622.
2017-12-23 08:00:51 -08:00
5f1c73db7d Shorten a comment in locale.h 2017-12-23 08:00:38 -08:00
319346025d Update version 2017-12-20 08:38:07 -08:00
51a16f8c58 Update ChangeLog.rst 2017-12-20 08:33:31 -08:00
a00874603d Merge release branch 2017-12-20 08:30:58 -08:00
941663d038 Merge ostream.cc into ostream.h 2017-12-17 09:33:56 -08:00
955062da2e Merge printf.cc into printf.h 2017-12-17 08:36:19 -08:00
5705bf1c71 Added support for pre-c++17 experimental string_view (#607)
Added support for pre-c++17 experimental string_view
2017-12-16 09:03:11 -08:00
cabce31f45 Update syntax.rst 2017-12-16 08:58:54 -08:00
ccaae0c019 Refer to jeaiii project 2017-12-10 16:09:35 -08:00
e37151021e Add a integer formatter based on jeaiii 2017-12-10 16:05:51 -08:00
b3495f2e4b Update README.rst 2017-12-10 06:54:51 -08:00
61f296e30c Move FMT_HAS_BUILTIN to format.h 2017-12-09 08:56:44 -08:00
ce801c9095 Remove dependency on <vector> and <array> 2017-12-09 08:48:30 -08:00
41fc29907a Merge branch 'std' of github.com:fmtlib/fmt into std 2017-12-09 08:16:34 -08:00
971fb584c3 Allow mixing named and automatic arguments 2017-12-09 08:15:13 -08:00
af0f21da0f add missing inline in header-only mode (#626) 2017-12-09 07:50:53 -08:00
7cea163809 numeric -> arithmetic 2017-12-09 06:19:15 -08:00
5328907f7f Get rid of <limits> dependency 2017-12-06 09:18:17 -08:00
faaafc7e12 Remove <utility> dependency and replace typedefs with using 2017-12-06 09:13:23 -08:00
94edb1a71c Add a lightweight header for the core API 2017-12-06 07:42:42 -08:00
3aaa25fa70 Added support for format string containing '\0' in _format udl (#619) (#620)
Added support for strings containing '\0' in udl (#619)
2017-12-06 06:21:34 -08:00
84bd2f1962 Merge include/fmt/CMakeLists.txt into the main CMake file 2017-12-03 09:59:55 -08:00
7f351dec27 Decouple <locale> for better compile times 2017-12-03 09:51:59 -08:00
81bd9e8ea3 args -> format_args 2017-12-03 08:00:22 -08:00
10e70a06c9 Improve handling of custom arguments 2017-12-02 09:44:48 -08:00
f9c97de46b Add note about errno to the documentation 2017-11-28 07:33:51 -08:00
e0243000de arg_index -> arg_id 2017-11-26 10:05:49 -08:00
ac5f95208c Automatically add package to release 2017-11-25 08:23:13 -08:00
0e914372fb Avoid conflict with the macro CHAR_WIDTH
It looks like CHAR_WIDTH is a macro in glibc. See
https://sourceware.org/ml/libc-alpha/2016-09/msg00225.html
2017-11-25 07:25:06 -08:00
f03a35a679 Check string specs at compile time 2017-11-24 09:54:28 -08:00
e9da574147 Check char specs at compile time 2017-11-24 07:54:22 -08:00
b25a029284 Check pointer type specs are compile time 2017-11-23 10:12:23 -08:00
c8a9d902dd Check floating-point type specifiers 2017-11-23 09:14:37 -08:00
6570dc3122 Disallow formatting of multibyte strings into a wide buffer (#606) 2017-11-23 07:23:07 -08:00
3851994ab0 Fix yet another internal compiler error in MSVC 2017-11-19 09:06:49 -08:00
44e186512b Refactor parse context and fix warnings 2017-11-19 08:49:58 -08:00
e7e270f511 Test error on invalid type spec and remove unused alias 2017-11-19 08:25:34 -08:00
692b82d32c UdlArg -> udl_arg 2017-11-19 08:02:07 -08:00
c523dd584f Use error handler to report errors 2017-11-19 07:36:01 -08:00
5a32e64b05 More tests 2017-11-19 07:03:12 -08:00
093e2a4780 Improve error handling 2017-11-18 09:16:35 -08:00
dc104cbaaa Workaround internal compiler errors in MSVC 2017-11-18 09:05:05 -08:00
39411504a5 More tests 2017-11-18 08:16:59 -08:00
e3eb5ea074 Add parse_context::error_handler() 2017-11-18 06:58:14 -08:00
734e722da4 Fix warnings 2017-11-18 06:56:29 -08:00
62af25dca8 Workaround yet another MSVC internal error 2017-11-18 06:31:47 -08:00
594bd8feba More tests 2017-11-16 06:55:49 -08:00
f2b52bba05 More tests 2017-11-15 07:06:03 -08:00
62df6f27cb CMakeLists: Use GNUInstallDirs to set install location
CMake's GNUInstallDirs knows where particular Linux architectures and
distributions want to have their libraries installed. In particular,
Debian-derived "multi-arch" distributions keep their libraries in triplet
sudirectories under /lib. Other "bi-arch" distributions keep 64-bit
libraries in /lib64.

Including GNUInstallDirs and using CMAKE_INSTALL_LIBDIR and
CMAKE_INSTALL_INCLUDEDIR means that fmt's libraries and header files are
installed in the correct locations.

Tested with OpenEmbedded and on Debian GNU/Linux 9 (the special naming only
applies when installing in /usr.)
2017-11-13 22:01:41 -08:00
dfdb1adea5 More tests 2017-11-12 10:03:39 -08:00
7967c2f874 Disable test that triggers an MSVC bug 2017-11-12 09:47:15 -08:00
18a0b94b0e Fix overflow check 2017-11-12 09:25:28 -08:00
493586cbca Fix overflow check 2017-11-12 07:09:36 -08:00
1d751bc617 fix warning in header: signed/unsigned comparison 2017-11-12 06:23:57 -08:00
686ff942af Fix compile-time parsing and add more tests 2017-11-11 11:40:56 -08:00
5b95b5d77c Test compile-time errors 2017-11-11 10:28:05 -08:00
246bdafc74 Add FMT_STRING macro for compile-time strings 2017-11-11 07:39:12 -08:00
e805543341 Remove FMT_USE_VARIADIC_TEMPLATES 2017-11-11 07:02:58 -08:00
dba1ccc4d7 Update readme 2017-11-10 07:38:51 -08:00
e613b3c7b1 Update readme 2017-11-10 07:24:16 -08:00
11415bce3c Update usage.rst 2017-11-08 18:27:10 -08:00
9982dd0130 Fix for warning C5030 in VS2015 2017-11-08 18:18:36 -08:00
9fda7a36fd Check integral type specs at compile time 2017-11-08 07:58:09 -08:00
92847a0d11 Add integral type handler 2017-11-08 05:56:52 -08:00
a03842b0d5 More compile-time checks 2017-11-05 13:26:19 -08:00
42e88c4fcb Silenced MSVC 2017 constant if expression warning 2017-11-05 12:27:48 -08:00
1c855a4762 Integrate constexpr format specs parsing 2017-11-05 09:28:50 -08:00
780b44bf82 Add compile-time format string check 2017-11-04 09:02:47 -07:00
8ca6e76dbc Detect user-defined literal templates 2017-11-04 08:23:24 -07:00
a7e986166a Workaround another MSVC madness 2017-10-29 08:19:55 -07:00
db9ffa1405 Make parse_format_string constexpr 2017-10-29 07:32:14 -07:00
e926ae78ac Add parse_format_string 2017-10-29 07:00:47 -07:00
57e266ab1d Rename handlers 2017-10-27 06:44:00 -07:00
d29c7c3aca Workaround a bug in MSVC 2017-10-25 07:37:50 -07:00
aadb38a5e6 Make specs_checker constexpr 2017-10-24 07:46:30 -07:00
dd0b72e1ee Remove refactoring artefacts 2017-10-22 14:44:52 -07:00
e52b10e33f Merge branch 'vitaut-patch-1' of github.com:fmtlib/fmt into std 2017-10-22 10:35:37 -07:00
529d88ce95 Make dynamic_format_specs construction constexpr 2017-10-22 10:19:09 -07:00
d2f2a8b0ca constexpr support of dynamic width and precision 2017-10-22 09:32:46 -07:00
7a9c1ba190 FMT_VARIADIC_CONST - Support for const variadic methods (#591)
FMT_VARIADIC_CONST - Support for const variadic methods
2017-10-22 08:55:40 -07:00
6b3840b73c Make format_specs construction constexpr 2017-10-22 08:18:26 -07:00
a38bd9ca24 Fix formatting and naming 2017-10-22 07:19:45 -07:00
91014f0171 Naming conventions 2017-10-22 06:43:41 -07:00
932ab2bfca Report error from parse_nonnegative_int via handler 2017-10-21 08:37:52 -07:00
0ebdf41efa Fix compile-test 2017-10-21 08:17:00 -07:00
170f5c671f Move headers to include/fmt 2017-10-21 07:38:49 -07:00
3d11eac784 Workaround another MSVC constexpr bug 2017-10-21 07:13:20 -07:00
c69e308690 Update README.rst 2017-10-20 18:00:31 -07:00
25aac0bee5 Fix travis build on macOS 2017-10-20 06:47:17 -07:00
b83241ff4d Make format spec parsing constexpr 2017-10-19 07:36:46 -07:00
bd5188c811 Remove MinGW because it's not on appveyor image 2017-10-19 06:46:25 -07:00
62616b88a6 Workaround a bug in MSVC's constexpr handling 2017-10-19 06:06:13 -07:00
b8f85f671f Use Visual Studio 2017 image on appveyor 2017-10-18 08:38:16 -07:00
7174de0d79 Fix contexpr-ness of pointer_from 2017-10-18 06:36:08 -07:00
3785afc5a3 Pass errors to handler instead of throwing (#566) 2017-10-18 06:28:18 -07:00
324415c036 Use allocator_traits if available.
This is to avoid using functionality deprecated in C++17.
2017-10-18 06:11:15 -07:00
1b5ccf6c13 Make parse_arg_id constexpr 2017-10-15 16:54:47 -07:00
5f39721c0a Fix a warning 2017-10-15 14:58:41 -07:00
ca96acbe4f Add examples 2017-10-15 07:38:03 -07:00
708d9509ff fix(Clang CodeGen): remove warnings
./fmt/fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
         ^
1 warning generated.
format.cc In file included from fmt\fmt\format.cc:28:
fmt\fmt/format.h(308,10): warning : unknown pragma ignored [-Wunknown-pragmas]
         ^
fmt\fmt\format.cc(165,17): warning : 'strerror' is deprecated: This
function or variable may be unsafe. Consider using strerror_s instead.
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details. [-Wdeprecated-declarations]
      buffer_ = strerror(error_code_);
                ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\string.h(178,24) :  note: 'strerror' has been explicitly marked deprecated here
_ACRTIMP char* __cdecl strerror(
                       ^
fmt\fmt\format.cc(78,37): warning : unused function 'strerror_s' [-Wunused-function]
static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
                                    ^
3 warnings generated.

refactor: use attribute to remove -Wunused-function warnings instead of dummy function call
2017-10-15 07:04:45 -07:00
9328a074b1 Fix handling of fixed enums in clang (#580) 2017-10-14 08:47:08 -07:00
2c077dd442 Enable stream exceptions (#581) 2017-10-14 07:38:16 -07:00
933a33a794 Added MSVC checking for support for string_view.
Also, driveby adding "override" to classes with inherited virtual destructors.
2017-10-08 19:44:09 -07:00
17f93fe084 Make basic_string_view ctors constexpr 2017-09-29 12:26:57 -07:00
d5e918b61f Detect C++14 compiler support 2017-09-28 08:57:54 -07:00
be5b4552d9 Make null_terminating_iterator more iteratory 2017-09-27 22:40:58 -07:00
643fb0662e Check for argument indexing switch 2017-09-27 21:18:37 -07:00
bef89db6e7 Fix a bogus -Wduplicated-branches gcc warning (#573) 2017-09-27 19:32:53 -07:00
d45544d14e Fix width handling in dynamic formatting 2017-09-27 19:04:15 -07:00
2a619d96dd Make format work with C++17 std::string_view (#571)
Tests for C++17 std::string_view
2017-09-20 06:21:11 -07:00
8cbf544733 Add parse context 2017-09-17 09:05:01 -07:00
e051de37f3 Use less version 2.6.1 and sudo to fix npm install issues on travis 2017-09-17 08:41:17 -07:00
5de459bf33 Suppress Clang's warning on zero as a null pointer 2017-09-16 18:44:29 -07:00
ec4f5175f1 Replace Range with ParseContext in parse() 2017-09-16 17:07:03 -07:00
83dd2ab919 Simplify dynamic_specs_handler 2017-09-16 15:30:13 -07:00
5a8ae0bb05 Fix a warning 2017-09-13 08:36:06 -07:00
39bc319b35 Update test results 2017-09-10 07:35:32 -07:00
534bff7d31 Fix handling of max packed arguments 2017-09-09 07:38:52 -07:00
0cda806dcc Fix compile tests 2017-09-08 11:25:49 -07:00
a3191a9903 Get rid of FMT_MAKE_WSTR_VALUE macro 2017-09-08 08:42:01 -07:00
fced79b0ee Get rid of old compat macros 2017-09-08 08:26:05 -07:00
be887d9269 Replace internal::get with std::declval 2017-09-08 08:09:28 -07:00
53cf073561 Get rid of FMT_MAKE_VALUE macro 2017-09-08 07:43:04 -07:00
2972de4ba3 Char -> char_type 2017-09-06 07:29:48 -07:00
9ee7c2163c Type -> type 2017-09-06 07:12:07 -07:00
1a09194ae6 Cleanup type handling 2017-09-06 07:00:21 -07:00
c18a4041f9 Remove conditional and to_iterator 2017-09-04 13:56:14 -07:00
1cade7ef4d Remove FMT_USE_RVALUE_REFERENCES 2017-09-04 13:52:29 -07:00
7413239f49 Remove unnecessary qualification 2017-09-04 13:12:52 -07:00
af00e4f9c9 Remove printf_arg_formatter from format.h and cleanup 2017-09-04 12:28:53 -07:00
44a26e5e21 CharPtr -> pointer_type and move to writer 2017-09-04 11:58:14 -07:00
0fbd846561 Replace fmt::internal::make_unsigned with std::make_unsigned 2017-09-04 11:41:15 -07:00
8a2bc0ab1b Add nullptr support 2017-09-04 11:10:08 -07:00
80505995d0 Allow delayed type checking 2017-09-04 09:33:22 -07:00
165895346c Make ArgMap::init not explicitly instantiated (#563)
Make ArgMap::init not explicitly instantiated
2017-09-03 19:26:08 -07:00
3e75d3e001 Fix handling of types convertible to int 2017-09-02 07:08:19 -07:00
b0867f3fa0 AlignSpec -> align_spec and fix a warning 2017-08-27 09:56:45 -07:00
89654cd127 to_wstring added 2017-08-27 18:52:57 +02:00
f194a418f9 Replace fmt::is_same with std::is_same 2017-08-27 09:16:50 -07:00
47c84d7974 Move part of write API (spec factories) to a separate header 2017-08-27 09:08:44 -07:00
20168147dd Add ptr, a helper function for pointer formatting 2017-08-27 08:41:28 -07:00
77c892c88e Fix more warnings 2017-08-27 08:16:46 -07:00
be7d72ba0d Fix expansion-to-defined warning 2017-08-27 08:00:15 -07:00
d4c504ae1c Fix a warning 2017-08-27 06:38:23 -07:00
27ad6cee82 Use standard enable_if 2017-08-26 10:41:58 -07:00
64681739fd Fix a warning 2017-08-26 09:32:37 -07:00
388061674a Remove FMT_HAS_GXX_CXX11 2017-08-26 09:23:00 -07:00
a7320bdce9 Fix a warning 2017-08-26 09:19:03 -07:00
016acebb56 Remove legacy code 2017-08-26 09:09:43 -07:00
07f8ffc44f Suppress shadowing warnings 2017-08-26 08:50:09 -07:00
466386d5cd Suppress a warning in gmock 2017-08-26 08:50:09 -07:00
70ef82a8e3 Workaround a bug in MSVC 2017-08-20 09:47:21 -07:00
37eb419af2 Fix noreturn attribute detection (#555) 2017-08-20 09:39:28 -07:00
14d8534900 Explicitly cast range length to std::size_t to prevent conversion warnings 2017-08-20 06:52:52 -07:00
c2201ce02e Accept wide chars as integers to prevent conversion warning 2017-08-20 06:52:52 -07:00
6efbccb387 Add one more CMake warning fix
This will remove one more warning that can't be stopped from a calling CMakeLists. This possibly should be set to new at some point (CMake 3.3 behavior would be different / better), as well as 0048.
2017-08-19 07:03:56 -07:00
5e0562ab51 Separate parsing and formatting 2017-08-13 13:09:02 -07:00
032c83807f Fix a segfault in test on glibc 2.26 #551, take 2 2017-08-10 09:27:06 -07:00
6655e804c4 Fix a segfault in test on glibc 2.26 #551 2017-08-06 20:18:04 -07:00
1102d46508 Make format spec parsing context-independent 2017-07-30 08:58:24 -07:00
45911770c5 Separate parsing and formatting in extension API 2017-07-29 07:50:16 -07:00
7bd776e7db Explain why null_terminating_iterator is used 2017-07-26 08:48:59 -07:00
873c8451ed Remove system_header pragma 2017-07-26 08:42:57 -07:00
9f7957c073 Separate argument parsing and formatting 2017-07-26 08:37:46 -07:00
da439f2838 Suppress warning about missing noreturn attribute (#549)
Suppress warning about missing noreturn attribute

Adding `[[noreturn]]` to `report_unknown_type` suppresses the Clang/GCC `-Wmissing-noreturn` warning:

Clang outputs:

    .../fmt/fmt/format.cc:294:74: warning:
          function 'report_unknown_type' could be declared with
          attribute 'noreturn' [-Wmissing-noreturn]
      ...code, const char *type) {
                                 ^

GCC outputs:

    .../fmt/fmt/format.cc:294:74: warning: function might be candidate for
        attribute 'noreturn' [-Wsuggest-attribute=noreturn]
      ...code, const char *type) {
                                 ^

Cherry-picked d16c4d.
2017-07-23 20:21:11 -07:00
eefdb379f9 Fix an unused argument warning 2017-07-23 20:15:52 -07:00
2f4f49fd60 Switch from cstring_view to string_view 2017-07-22 08:24:37 -07:00
d16c4d20f8 Suppress warning about missing noreturn attribute (#549)
Suppress warning about missing noreturn attribute

Adding `[[noreturn]]` to `report_unknown_type` suppresses the Clang/GCC `-Wmissing-noreturn` warning:

Clang outputs:

    .../fmt/fmt/format.cc:294:74: warning:
          function 'report_unknown_type' could be declared with
          attribute 'noreturn' [-Wmissing-noreturn]
      ...code, const char *type) {
                                 ^

GCC outputs:

    .../fmt/fmt/format.cc:294:74: warning: function might be candidate for
        attribute 'noreturn' [-Wsuggest-attribute=noreturn]
      ...code, const char *type) {
                                 ^
2017-07-21 20:47:01 -07:00
9c56a8ce5c Make format_arg() accept class hierarchies
If a base class can be formatted, it is assumed
that the hierarchy can be formatted from the base
class. The idiom is not uncommon with ostreams.
2017-07-18 06:16:46 -07:00
a8d6f309c8 Minor optimizations 2017-07-17 06:52:56 -07:00
ca0e38304c Update README.rst 2017-07-16 14:12:48 -07:00
d16582a038 Move printf-related code to printf.cc 2017-07-15 09:46:18 -04:00
81790d726f Update format.h to remove C4574 error on MSVC 14.2
Similar to the Pullrequest #539, `_SECURE_SCL` caused the same  `warning C4574: '_SECURE_SCL' is defined to be '0': did you mean to use '#if _SECURE_SCL'`.  `_SECURE_SCL` is defined in the `MSVC/14.10.25017/include/yvals.h` by Microsoft itself
2017-07-14 15:29:57 -04:00
3028344380 Fix undefined behavior in UDL macro
`FMT_USE_USER_DEFINED_LITERALS` macro expands to `defined()` which is undefined behavior.
2017-07-13 19:10:11 -04:00
361911dd18 Use preinstalled version of cmake on travis 2017-07-13 19:06:20 -04:00
9ea183aaba Fix MSVC build 2017-07-13 19:00:21 -04:00
8f4b918c5b Check argument index 2017-07-12 13:24:51 -04:00
4193485b43 Remove test files 2017-07-12 13:15:06 -04:00
07123e8ff3 Use Ubuntu Trusty on Travis for a new CMake 2017-07-12 13:13:36 -04:00
586d63636a Implement more efficient handling of large number of format arguments 2017-07-12 00:26:54 -04:00
4045d7fea2 Fix warning about missing ' character 2017-07-11 20:45:17 +02:00
89c3bc585c Remove warning C4668 in MSVC for FMT_GCC_VERSION and FMT_HAS_GXX_CXX11 2017-07-10 13:59:08 -04:00
4af9421ff0 Adding OpenSpace to the list of projects 2017-07-07 20:59:39 -07:00
1a398b5404 Fixed CMake CMP0048 warning. 2017-07-05 16:55:46 -07:00
589ccc1675 Bump version 2017-07-01 10:37:45 -07:00
c38170461d Add an error on broken includes 2017-07-01 10:09:25 -07:00
16bdd8424f Update scripts 2017-07-01 07:30:51 -07:00
b492316d5d Update version list 2017-07-01 06:57:32 -07:00
91f4ce02b6 Automatically update version in release script (#431) 2017-07-01 06:41:30 -07:00
398343897f Update version 2017-06-27 19:02:24 +02:00
749ed39d79 Bump version number and update changelog 2017-06-25 19:40:23 +02:00
aba72982df remove 'FMT_CPPFORMAT' CMake option 2017-06-25 08:08:26 -07:00
e8ef103799 Fix undefined-var-template warning on clang when not compiling with -std=c++11 2017-06-25 07:49:31 -07:00
5e23fff052 remove unnecessary method 2017-06-25 06:07:57 -07:00
f61e71ccb9 Add Drake to projects 2017-06-22 06:31:50 -07:00
d9f0c58c65 Add Lyft Envoy to the list of projects 2017-06-22 06:20:51 -07:00
569c5bdbf1 Workaround broken __builtin_clz in clang with MS codegen (#519) 2017-06-17 07:57:07 -07:00
eafc6a3292 Update Changelog 2017-06-14 18:20:51 +02:00
dc8c943372 Describe cmake use of header-only target 2017-05-29 16:31:52 -07:00
ac5484c4e7 add alias targets with fmt namespace
For the consumer it should not matter if fmt has been added to the
project as subdirectory or via find_package. With the alias targets
the library can be always imported via fmt::fmt.
2017-05-25 14:36:16 +03:00
746adc5e71 added new namespace to the header only target in the find package test 2017-05-25 14:36:16 +03:00
048d2aec27 CMake imported targets should be namespaced 2017-05-21 14:17:12 +03:00
e14bac62a0 Changing ArgArray template argument from unsigned to size_t
Each instantiation of ArgArray template uses sizeof operator, which
returns a std::size_t value. GCC 7.1 warns about invalid conversion
(error: conversion to ‘unsigned int’ from ‘long unsigned
int’ may alter its value [-Werror=conversion]).
2017-05-20 07:19:16 +02:00
0284a2893a Use Ubuntu Trusty on Travis for a new CMake 2017-05-20 08:07:57 +03:00
07ed421521 Fix handling of implicit conversion to integral types larger than int (#507) 2017-05-06 10:23:20 -07:00
c56d345985 Don't define WIN32_LEAN_AND_MEAN in header-only mode 2017-05-06 09:13:32 -07:00
dcfd40a1b8 Revert #456
Revert #456 because it causes issues for known types (#495) and is not C++98-compatible.
2017-05-06 08:36:54 -07:00
79f11dbaa7 Allow compiling and using as DLL in windows (#502)
* printf.h fixed to compile clean - need to check whether this is the right
thing to do

* fix warnings and errors in test compiles with BUILD_SHARED_LIBS

* did requested changes and added one change to allow all tests to succeed
in windows DLL
2017-05-05 14:58:09 +02:00
52aabbe7ef Workaround MSVC lookup issue in ArgFormatterBase
Fixes #505.
2017-05-05 14:40:58 +02:00
4423490d0b Don't include the world with WIN32_LEAN_AND_MEAN (#503) 2017-05-03 21:22:01 +02:00
d49f206183 fmt::internal::is_streamable works on gcc 4.7
i test the the code on https://gcc.godbolt.org/, and only gcc 4.7 works,
gcc 4.6 fail to complie
2017-04-16 21:27:28 -07:00
7a4ac9ec9c add SOURCELINK_SUFFIX for compatibility with Sphinx 1.5
With Sphinx 1.5, this is needed by searchtools.js to display the source
snippets (see sphinx-doc/sphinx#2454).

With earlier Sphinx versions, this is a no-op because the undefined variable
will evaluate to an empty string.
2017-04-15 08:42:05 -07:00
82bb4f4e89 Fix Visual Studio 2017 new warning (C4244: 'argument': conversion from 'int' to 'const char', possible loss of data) 2017-04-15 08:38:43 -07:00
73ca9948fe Fix FormatBuf implementation (#491)
Fixes #491 (and probably #480) Before, the put-area of the custom streambuf
implementation was (sometimes) incorrectly extended beyond the writeable buffer.
The new implementation is in some cases not as efficient as the old, but avoids
to write into uninitialized memory.
2017-04-08 09:07:33 -07:00
cbac016cce %.f should have zero precision, not default precision 2017-04-08 07:18:10 -07:00
12252152ac CStringRef -> cstring_view 2017-03-26 15:13:10 -07:00
5aa8d6ea21 Return locale by value 2017-03-25 08:57:23 -07:00
32ec13f149 Switch to C++ locale 2017-03-25 08:20:06 -07:00
b4f4b7e21a Clean the buffer API (#477) 2017-03-12 09:48:21 -07:00
f423e46835 Replace clear() with resize(0) and data_ -> store_ 2017-03-11 08:30:15 -08:00
c03f55ec3a Add Kodi (xbmc) to the list of projects using fmt 2017-03-11 08:28:52 -08:00
23b8c24da4 Add noexcept 2017-03-11 07:38:16 -08:00
7175bd8ae6 Fix error on MinGW 2017-03-09 06:09:43 -08:00
7258d1b8f3 Fix tests 2017-03-08 08:08:08 -08:00
fbc8ea8c3e False -> FalseType (#483) 2017-03-08 07:17:08 -08:00
6c3aa28c94 fix for nvcc_wrapper compiler 2017-03-08 06:20:52 -08:00
e3b5d806a8 Don't bring Arg struct into global namespace
This fixes compiling fmtlib in header-only mode when user code also has
something called 'Arg' defined. Now qualifying Arg struct with internal
namespace.
2017-03-08 06:19:11 -08:00
3610f34c70 Fix windows build 2017-03-04 07:10:54 -08:00
cc736e7611 Remove redundant include (#479) 2017-03-03 06:06:34 -08:00
789ebea863 Merge branch 'printf' of github.com:fmtlib/fmt 2017-02-26 07:17:38 -08:00
6f8006c2ce Add printf overloads that takes a writer (#476) 2017-02-25 09:58:42 -08:00
589b93de45 Add default copy constructor to SystemError (#475)
* Add default copy constructor to SystemError
* Add FMT_DEFAULTED_COPY_CTOR macro
2017-02-25 09:37:06 -08:00
db0d54f855 Fix error on MinGW 2017-02-25 09:00:56 -08:00
703960aa54 Merge branch 'master' of github.com:fmtlib/fmt 2017-02-24 07:06:12 -08:00
e208fbff52 Document which header defines formatting functions 2017-02-24 07:06:05 -08:00
572491ad1f Document which header defines formatting functions 2017-02-24 07:04:44 -08:00
20089c23ca Added missing FMT_OVERRIDE specifier to FormatBuf::overflow (#473) 2017-02-22 20:55:15 +01:00
c333dca065 Follow standard naming conventions 2017-02-21 06:56:26 -08:00
6a2ff287b2 Follow standard naming conventions 2017-02-19 08:05:41 -08:00
eedfd07f8b internal::MemoryBuffer -> basic_memory_buffer 2017-02-18 09:13:12 -08:00
4ec8860783 ArgFormatter -> arg_formatter 2017-02-18 07:46:32 -08:00
50e716737d StringRef -> string_view, LongLong -> long_long 2017-02-18 07:34:52 -08:00
e022c21ddc Fix windows build 2017-02-18 06:29:33 -08:00
87b691d80c Merge StringWriter into StringBuffer 2017-02-17 06:23:16 -08:00
c2f021692f Merge ArrayWriter into FixedBuffer 2017-02-17 06:09:26 -08:00
fefaf07b6f Pass buffer instead of writer to format_value 2017-02-14 19:39:34 -05:00
6e568f3a08 buffer -> basic_buffer 2017-02-14 12:08:37 -05:00
ad6d78f2a8 added FMT_API declarations where needed when using FMT_EXPORT from a separate dll 2017-02-12 12:14:58 -05:00
a00006119f Add join argument allowing formating list of values separated by a (#466)
Add join argument allowing formating list of values separated by a
string. Each value is formated according the format specifier.
2017-02-08 06:55:12 -08:00
bb1c82ef7d Fix build 2017-02-05 08:04:13 -08:00
a13b96ed88 Simplify API 2017-02-05 06:54:03 -08:00
624c58682d Simplify API 2017-02-05 06:41:39 -08:00
7ae8bd7073 basic_format_arg -> basic_arg, Buffer -> buffer 2017-02-05 06:09:06 -08:00
bf0f107564 Parameterize format_specs on character type 2017-01-28 13:17:47 +00:00
296e9cada2 FrmatSpec -> format_spec 2017-01-28 12:51:35 +00:00
b5fb8dd18b stream -> buffer 2017-01-28 12:44:36 +00:00
984a102921 Remove IntFormatSpec and StrFormatSpec 2017-01-28 04:26:48 -08:00
4863730eca Remove pad 2017-01-22 19:11:47 -08:00
aaa0fc396b Improve compatibility with old compilers and fix test 2017-01-22 12:16:16 -08:00
aea5d3ab00 Improve compatibility with older gcc and update tests 2017-01-22 11:50:52 -08:00
8485027710 Use named argument emulation instead of nested functions 2017-01-22 11:28:55 -08:00
ec15ef7b7b Replace operator<< with write function 2017-01-22 10:00:34 -08:00
bc6af7548b Fix Android not being detected with latest NDK toolchain (#458)
When using the NDK 13b toolchain standalone or with CMake, ANDROID is not defined,
but __ANDROID__ is defined instead.
2017-01-20 11:20:43 +01:00
67662702aa allow to stream user defined types in a MemoryWriter (#456)
* allow to stream user defined types in a MemoryWriter

* fix indent

* follow Google C++ Style

* make code c++98 compatible

* fix macro usage

* disable ability to stream user defined types if not at least c++11

* fix for disable ability to stream user defined types if not at least c++11

* use FMT_STATIC_ASSERT
2017-01-19 20:47:43 +01:00
9e9ad57f58 Workaround an nvcc bug 2017-01-19 06:24:15 -08:00
a2596d685d Fix missing intrinsic when included from C++/CLI
Managed C++ code doesn't have the _BitScanReverse* intrinsics, we must use the fallback code for count_digits etc.
2017-01-18 06:23:25 -08:00
d8754af063 Allow %s as generic format specifier in printf (#453)
* Allow %s as generic format specifier in printf

Signed integers are formatted as %d
Unsigned integers are formatted as %u
Doubles are formatted as %f
Chars are formatted as %c
Void Pointers are formatted as %p

* Remove '%S' handling and use visitor for generic format strings

* Default for floating point is now "%g" rather than "%f"
2017-01-14 11:45:48 -08:00
e0251fdcef BasicContainerWriter utility added 2017-01-05 20:44:35 -08:00
b77c8190ca FPUtil -> fputil 2016-12-30 13:12:27 -08:00
8428621ddc BasicWriter -> basic_writer 2016-12-30 12:26:12 -08:00
e1689cb985 Custom FormatSpec (#439) (#444)
* A custom FormatSpec type can be passed as a template argument to the ArgFormatter chain (#439)

* Corrected nested-name-specifier error

* Spec template argument defaulted to FormatSpec

* Forward declaration of FormatSpec

* Style

* Style (part 2)

* Style (part 3)
2016-12-30 11:29:40 -08:00
939aff2936 Remove unnecessary template arg from basic_format_args 2016-12-30 10:19:38 -08:00
f69786a715 Remove Not 2016-12-30 09:29:41 -08:00
b2a0d8914a Merge value and MakeValue 2016-12-30 09:25:01 -08:00
acd1811c50 Value -> value 2016-12-30 08:05:26 -08:00
42a319074c Parameterize Value on context 2016-12-29 18:07:05 -08:00
a4d6cb32d1 Clean up basic_format_arg 2016-12-29 17:17:18 -08:00
b9aaa507fc Don't export the -std=c++11 flag from the fmt target 2016-12-29 16:04:16 -08:00
d705d51671 Parameterize basic_format_arg on context (#442) 2016-12-29 15:25:22 -08:00
02553d13a0 Use https to fetch dependencies from github 2016-12-29 10:44:02 -08:00
422236af7c Don't erase writer type 2016-12-28 07:55:33 -08:00
abb6996f36 MakeArg -> make_arg 2016-12-27 07:55:44 -08:00
ee1651ce07 Handle empty format_arg state 2016-12-27 07:43:25 -08:00
3bbc5799b6 Fix MinGW build 2016-12-26 12:20:49 -08:00
63fcfc5798 Fix build on older gcc 2016-12-26 10:55:30 -08:00
db780cb119 Add std::basic_string allocator support to StringRef, StringBuffer and relatives (#441)
* - added basic_string allocator support to BasicStringRef, BasicCStringRef, BasicWriter::str, StringBuffer and BasicStringWriter

* - removed templated str() and to_string() function
- code style fixes
2016-12-26 08:36:56 -08:00
d86e51e9c1 Don't inherit basic_format_arg from internal::Value 2016-12-24 07:46:50 -08:00
f05888692c Fix handling of unpacked args (#437) 2016-12-23 08:24:48 -08:00
1183621867 Add support for exotic character types 2016-12-15 08:36:18 -08:00
763ca9780f Parameterize Value on character type 2016-12-15 08:26:10 -08:00
6cba8fe9ba Move stuff out of internal::Value 2016-12-15 07:51:40 -08:00
fac5546321 Fix test compilation for FreeBSD (#433) 2016-12-14 06:28:41 -08:00
e1ee5bf0ba Replace StringValue with StringRef 2016-12-11 21:13:54 -08:00
0854f8c3bf Parameterize formatting argument on char type. 2016-12-11 15:43:11 -08:00
9cf6c8fdc6 Get rid of fmt::internal::Arg 2016-11-26 10:21:31 -08:00
5f022ae081 Remove FMT_DISPATCH 2016-11-20 10:14:23 -08:00
41d4bcf0cc Ingore Xcode files 2016-11-20 10:13:16 -08:00
284297019f Merge BasicArgFormatter and ArgFormatter 2016-11-20 09:36:27 -08:00
d4084ac5b1 Get rid of ArgVisitor 2016-11-20 09:11:13 -08:00
d58cc8a4a8 Merge BasicPrintfArgFormatter and PrintfArgFormatter 2016-11-20 07:42:38 -08:00
796beaaddb Fix collision with global convert function (#425) 2016-11-19 12:05:49 -08:00
e2dfd39c75 Update arg visitors 2016-11-19 09:29:09 -08:00
751ff64bdb Update ArgConverter to the new visitor API 2016-11-19 08:40:24 -08:00
c9dc41ab3f Replace ArgVisitor::visit with a free visit function 2016-11-19 07:59:54 -08:00
caa60b9c99 Update comment 2016-11-19 07:41:28 -08:00
95a53e1f62 Refactor argument visitor API (#422) 2016-11-19 07:39:07 -08:00
def687462c Fix signbit detection (#423) 2016-11-14 20:14:52 -08:00
6d24116763 Improve visitor API 2016-11-13 09:42:17 -08:00
25f8ad13dd Correction of 418 (#420) 2016-11-11 18:27:39 +01:00
1d2049b53e Issue #418 - Minimal supported library subset (#419) 2016-11-10 20:29:12 +01:00
f5b1c16e2c Add version macro FMT_VERSION (#411) 2016-11-07 19:04:44 -08:00
a1dd524b6f format_arg -> do_format_arg 2016-11-07 18:22:21 -08:00
55a1ac5035 Fix test 2016-11-07 08:55:40 -08:00
85793a18cd Simplify API 2016-11-06 19:27:14 -08:00
9998f66f8c Replace formatter with context 2016-11-06 18:59:17 -08:00
cfd00af37a Fix warnings on C++98 2016-11-06 12:58:49 -08:00
6274401919 Fix warnings 2016-11-06 12:37:31 -08:00
2fa4655af6 Fix warning in FMT_STATIC_ASSERT on older GCC (#414) 2016-11-06 11:48:01 -08:00
8cef95f7c3 Create pull_request_template 2016-11-06 20:22:43 +01:00
922ae4896b Add CONTRIBUTING file 2016-11-06 11:00:58 -08:00
05ba3e7888 Fix Klockwork compilation warning 2016-11-06 10:01:55 -08:00
1daddec151 FMT_NULLPTR -> FMT_NULL and improve formatting 2016-11-06 09:05:58 -08:00
d8867a2b07 Fix missing '>' 2016-11-05 21:09:31 +01:00
6c0125785b Add extern templates for format_float
Fixes #413.
2016-11-05 21:03:40 +01:00
49ccb2e449 Using FMT_NULLPTR instead of literal 0 2016-11-03 06:39:40 -07:00
7ce7def515 argument index -> argument id 2016-11-01 17:00:59 -07:00
8f455c10b0 fix newer clang warnings 2016-11-01 07:05:34 -07:00
e599fe7436 Add 3.0.1 Changelog entry 2016-11-01 10:49:34 +01:00
c577f72596 Update README.rst 2016-10-31 18:19:49 -07:00
15d0f32773 Fix Windows compilation with -fno-exceptions (#405) 2016-10-31 21:55:52 +01:00
8c63ea432c Fix Linux compilation with -fno-exceptions (#402) 2016-10-29 16:16:40 -07:00
2bba420337 Pass writer directly to format_value (#400) 2016-10-26 17:54:11 -07:00
b656a1c133 Make value the second argument to format_value 2016-10-25 06:19:19 -07:00
edf98792a5 Pass writer to format_value 2016-10-25 05:55:40 -07:00
64ca334a2d CharType -> Char 2016-10-22 09:15:28 -07:00
be613204ab Char -> char_type 2016-10-22 08:19:19 -07:00
f85d5f4dac BasicFormatter -> basic_formatter 2016-10-22 08:04:20 -07:00
18dfa257d0 Pass correct formatters to make_format_args 2016-10-21 06:46:21 -07:00
abbefd7166 CHAR_WIDTH -> CHAR_SIZE to avoid collision with ISO/IEC TS 18661-1:2014 macro 2016-10-19 06:52:55 -07:00
ed874df293 Merge branch 'master' of github.com:fmtlib/fmt 2016-10-17 07:00:58 -07:00
1e018e65cb Thread-safe time formatting
This adds thread-safe (at least on platforms that provide necessary extensions) replacement functions for std::localtime and std::gmtime. Alternatively they could be placed in a new source file time.cc, but time.h seems so empty right now...
2016-10-17 07:00:04 -07:00
1500f00525 Remove unnecessary "fmt/" prefix which should be maintained with additional include_directories() in each project. (#397) 2016-10-11 06:45:04 -07:00
dafbec7553 Fix type safety when using custom formatters (#394) 2016-10-07 08:37:06 -07:00
506435bf71 Fix formatting 2016-10-07 03:41:23 -07:00
f287994084 Fix formatting 2016-10-07 03:22:14 -07:00
4809e2956a Minor documentation changes 2016-10-06 07:38:19 -07:00
61fb85618c Merge pull request #393 from pwm1234/master-pwm
Document use of format_arg for user-defined type
2016-10-06 06:49:34 -07:00
88c4bc33d2 Document use of format_arg for user-defined type 2016-10-05 15:04:08 -04:00
48fe97835b Add format_arg::operator bool 2016-10-02 09:36:40 -07:00
119a63ab72 internal::Arg -> format_arg 2016-10-02 09:29:11 -07:00
65a8c2c343 format_arg -> format_value 2016-10-02 08:49:10 -07:00
13b04044e5 Add format_args::size_type 2016-10-02 08:26:32 -07:00
cee50b7572 Fix compilation on Cygwin (#388) 2016-10-01 21:32:16 -07:00
8a77e7927e Enable C++11 in tests. 2016-10-01 07:18:55 -07:00
1e8553d679 Enable C++11 in tests. 2016-10-01 07:02:58 -07:00
06bab3edb0 Workaround mingw bug https://sourceforge.net/p/mingw/bugs/1531/ 2016-09-30 07:20:57 -07:00
f66d37fb1c Merge pull request #390 from chronoxor/master
Introduced NamedArgWithType<Char, T> : NamedArg<Char>
2016-09-29 08:11:46 -07:00
6fd6ecc10d Enable C++11 for no-windows-h-test 2016-09-28 07:45:28 -07:00
c4212f9ec2 format -> vformat 2016-09-28 07:09:26 -07:00
1546b9e336 Introduced NamedArgWithType<Char, T> : NamedArg<Char> 2016-09-28 00:18:09 +03:00
17c17d1585 Merge pull request #389 from chronoxor/master
Extend ArgLists to support serialization/deserialization in third-party components
2016-09-27 08:11:36 -07:00
d09dd1a81a Extend ArgLists to support serialization/deserialization in third-party components 2016-09-27 17:40:05 +03:00
21c6700b83 Don't build std branch with -std=c++0=98 2016-09-26 07:35:27 -07:00
64a0016680 Merge pull request #385 from jcelerier/master
Add FMT_OVERRIDE macro to allow specifying overriding functions
2016-09-25 07:44:37 -07:00
9ec3bea2d6 Add FMT_OVERRIDE macro to allow specifying overriding functions in c++11 compilers 2016-09-24 21:10:11 +02:00
1fb0586b06 Merge pull request #381 from hghwng/master
Fix compilation on Android.
2016-09-13 08:07:43 -07:00
5f26b5da28 Fix compilation on Android. 2016-09-13 10:34:54 +08:00
209a1d58bf Get rid of macros 2016-08-27 09:06:21 -07:00
9a07973261 Test types 2016-08-27 08:55:01 -07:00
0d25f6fcbb Move the paper to the docs repo 2016-08-27 08:26:47 -07:00
ea28a63706 Get rid of FMT_VARIADIC_CTOR 2016-08-27 08:23:44 -07:00
0d8aca8de3 Get rid of FMT_VARIADIC_VOID 2016-08-27 08:16:49 -07:00
4ece95a754 Make make_format_args public 2016-08-27 07:57:48 -07:00
0028ce57b6 Get rid of FMT_VARIADIC 2016-08-26 17:23:13 -07:00
ece7ae5f49 Make format_arg_store convertible to format_args 2016-08-26 15:09:40 -07:00
621447fece Make initialization C++11-compatible 2016-08-26 14:41:18 -07:00
a0190e4bbd Add a missing include 2016-08-26 10:26:33 -07:00
b903f5c123 format -> vformat 2016-08-26 09:10:23 -07:00
43c0095aa3 Refactor type mapping 2016-08-26 08:50:09 -07:00
4873685c7e ArgArray -> format_arg_store 2016-08-26 06:44:41 -07:00
fc73e10620 ArgList -> format_args 2016-08-25 08:50:07 -07:00
92605eb4f7 Remove FMT_USE_VARIADIC_TEMPLATES 2016-08-25 08:44:53 -07:00
9bb213e920 FormatError -> format_error 2016-08-25 08:38:07 -07:00
2ae6bca488 Complete syntax section 2016-08-25 07:23:04 -07:00
04335aeadb Correct syntax 2016-08-25 07:08:36 -07:00
3d5125cd87 Update paper 2016-08-25 06:50:09 -07:00
d775a20fff Update paper 2016-08-24 07:41:07 -07:00
4dc9fd995f Update paper 2016-08-24 06:55:18 -07:00
a79c7b4e8f Fix handling of unsigned char strings (#373) 2016-08-23 08:42:25 -07:00
195d6a5663 Update paper 2016-08-23 08:10:35 -07:00
6c184efa75 Remove old compatibility headers 2016-08-22 08:39:26 -07:00
93975c70bb Update paper 2016-08-21 07:50:31 -07:00
53f9e7f65c Add 'a' and 'A' format specifiers 2016-08-20 09:55:07 -07:00
768739c310 Update paper 2016-08-20 07:39:10 -07:00
94d387cd45 Update paper 2016-08-19 21:41:19 -07:00
721c9100f2 Update paper 2016-08-19 16:43:10 -07:00
108498bdd0 Add initial draft of the paper 2016-08-19 09:33:59 -07:00
f19d8f9655 Improve error reporting (#357) 2016-08-16 07:08:53 -07:00
2bf59a97c6 Add CUAUV, Seastar and ScyllaDB to the list of projects that use fmt 2016-08-10 08:29:44 -07:00
12a6027b40 Don't use -std compiler flag if CMAKE_CXX_STANDARD is specified (#366) 2016-08-05 08:22:45 -07:00
a5d0adf395 Use a heuristic to detect empty strftime result (#367) 2016-08-05 07:27:56 -07:00
1a23f9c274 Correct buffer growth when formatting time (#367) 2016-08-04 08:47:59 -07:00
9dbb60c4c8 Move fmt::fprintf to printf.h 2016-08-03 08:52:05 -07:00
ed30108918 Add "n" to integer formatting types 2016-07-26 07:36:35 -07:00
d5893c9a13 Update homepage and break long lines 2016-07-21 09:00:23 -07:00
6ee9f2ed09 Make printf argument formatters public (#335, #360) 2016-07-21 06:59:28 -07:00
631ffef438 Merge pull request #361 from nmoehrle/fix-unreachable-code
Remove unreachable code below FMT_THROW
2016-07-21 06:35:38 -07:00
355861f1ff Document PrintfFormatter::format 2016-07-20 08:26:14 -07:00
ab054532ce Move writer to PrintfFormatter object for consistency with BasicFormatter 2016-07-20 08:21:13 -07:00
9823675832 Break long lines 2016-07-20 08:17:33 -07:00
d4ddaaf2b1 Make PrintfFormatter public (#335, #360) 2016-07-20 08:09:14 -07:00
fa0f870ac9 Merge pull request #362 from smellman/smellman-patch-1
Update usage.rst: change Homebrew package name
2016-07-19 16:03:51 -07:00
1dbc6bd1fc Update usage.rst: change Homebrew package name 2016-07-20 07:34:21 +09:00
c8c9973669 Remove unreachable code below FMT_THROW 2016-07-19 20:33:55 +02:00
65cd664195 Fix handling of wide strings in StringWriter 2016-07-18 08:47:11 -07:00
c110c6eca7 Update readme 2016-07-16 08:44:27 -07:00
1acfd07f1e Workaround broken MinGW installation on AppVeyor (#355) 2016-07-16 08:00:53 -07:00
d4885cea62 Document BasicStringWriter 2016-07-16 08:00:53 -07:00
903357c853 Break a long line 2016-07-16 08:00:53 -07:00
88b84d6429 Merge pull request #358 from arvedarved/fix-freebsd
Fix compile on FreeBSD
2016-07-15 15:23:51 -07:00
d7c4e1cb1f Fix compile on freebsd 2016-07-15 14:28:18 +02:00
0d5ef5c2a6 Fix inclusion of printf.h in the header-only config (#354) 2016-07-12 06:59:35 -07:00
8631694021 check -> const_check to avoid a conflict with AssertMacros.h (#350) 2016-07-12 06:40:23 -07:00
4133e501f3 Merge branch 'locale' 2016-07-11 06:48:38 -07:00
0e6df7e511 Fix handling of thousands separator (#353) 2016-07-11 06:31:23 -07:00
44c926d96f Merge pull request #348 from LogicalKnight/fix-clang-extern-header-only
Fix building with clang in header-only mode
2016-06-27 09:21:16 -07:00
75f862bf57 Fix building with clang in header-only mode
Building under a recent clang compiler causes the use of an extern
template for the BasicData struct. However, the only instantiation of
that structure in format.cc is only done if FMT_HEADER_ONLY is not
defined. This causes the build to fail in C++11 or C++14 mode.
Therefore, only declare the BasicData template as extern if
FMT_HEADER_ONLY is not defined.
2016-06-25 05:22:07 +00:00
116914a949 Remove unused scripts 2016-06-22 20:58:19 -07:00
689fd2ad49 Refactor release script 2016-06-22 07:58:35 -07:00
7a0806a366 Fix release script 2016-06-22 07:29:34 -07:00
a81bff9349 Update documentation build instructions 2016-06-22 07:18:37 -07:00
5c876088d3 Reduce noise 2016-06-22 06:33:56 -07:00
d688072990 Break a long line 2016-06-22 06:29:18 -07:00
aa1e6b0f75 Handle images in rst2md converter 2016-06-22 06:28:51 -07:00
26819461bd Fix links in older docs 2016-06-17 07:30:42 -07:00
2e69e454d0 Fix a link (#347) 2016-06-16 11:18:40 -07:00
a914384bc4 Merge update-website and release scripts 2016-06-16 07:53:07 -07:00
41356aa00a Format scripts 2016-06-15 16:15:34 -07:00
e9a0d3141b Merge branch 'locale' 2016-06-15 15:04:24 -07:00
c7d0241abb Fix docs 2016-06-15 07:16:04 -07:00
e0d6f630f8 Fix MSVC warnings 2016-06-15 06:29:47 -07:00
a201c61977 Suppress -Wpadded warnings 2016-06-14 22:17:34 -07:00
4569b4dbd6 Fix -Wpessimizing-move 2016-06-14 15:53:40 -07:00
c9bb5468b6 Fix clang warning 2016-06-14 15:42:32 -07:00
b26e76efe9 Fix a -Wweak-vtables warning in clang 2016-06-14 08:54:08 -07:00
c7739536e8 Don't use strtod_l on Android (#345) 2016-06-14 06:57:12 -07:00
dfa631e64a Bump version 2016-06-14 06:33:57 -07:00
18e3f16576 Suppress clang's documentation warnings 2016-06-12 09:09:36 -07:00
72d51e0b1e Implemented #335: custom printf support 2016-06-09 08:41:56 -07:00
6ccb5673c4 Update README.rst 2016-06-03 08:40:07 -07:00
a82026746d Fix download link 2016-06-03 08:19:24 -07:00
9d36a5a3b0 Remove .doctrees 2016-06-03 08:11:24 -07:00
81e2dac955 Improve documentation build 2016-06-03 07:19:05 -07:00
5940431e2d Don't exclude the current version from dropdown menu 2016-06-03 06:23:49 -07:00
15008bf05d Generate docs for all versions 2016-06-02 08:47:33 -07:00
06045cb4a5 Minor fixes to documentation build scripts 2016-06-02 06:52:07 -07:00
9492b9ff03 Pass versions from CMake to Sphinx 2016-06-02 06:41:25 -07:00
0d9870dd9e Implement website update script 2016-06-01 07:45:54 -07:00
5e70843a73 Don't fail if a package was not found 2016-05-31 08:49:34 -07:00
d25e07660e Specify minimum required Breathe version 2016-05-31 08:46:28 -07:00
579736f210 Don't install Sphinx if it the minimum version is satisfied 2016-05-31 08:40:29 -07:00
8650c57ccd Reuse virtualenv to speed up builds 2016-05-26 08:00:41 -07:00
9071daebe9 Make work dir configurable 2016-05-26 07:35:10 -07:00
fcaf8a0cdc Make virtualenv dir configurable and break long lines 2016-05-26 06:52:51 -07:00
231c16df25 Break long lines 2016-05-26 06:48:12 -07:00
971359997f Implement website update script 2016-05-26 06:44:20 -07:00
f7abf9fd0f Implement website update script 2016-05-25 08:22:40 -07:00
e68836c123 Don't use --upgrade because it causes pip install older version of sphinx 2016-05-25 07:46:47 -07:00
dc1e36fa0e Make documentation installation optional (#333) 2016-05-24 07:03:08 -07:00
7bb1b50835 Update sphinx 2016-05-24 06:55:57 -07:00
96c28f748d Detect if lconv contains thousands_sep 2016-05-23 07:41:22 -07:00
e160c2b79a Add fmt prefix to includes (#332)
Technically it is not necessary, but prevents errors when people add the
fmt directory itself rather than its parent to includes.
2016-05-22 16:42:44 -07:00
e2a332e5df Use a mock to test locale support 2016-05-19 17:38:44 -07:00
ebff26f8f1 Improve formatting consistency 2016-05-19 13:36:00 -07:00
559739ec1d Merge pull request #328 from dpantele/android-fix
Workaround for missing lconv support in android
2016-05-19 13:31:38 -07:00
45a1509455 Workaround for missing lconv support in android (#327) 2016-05-19 13:29:21 -04:00
5b106083e7 Check if setlocale succeeded 2016-05-19 06:48:35 -07:00
2d8a7ed086 Add include to example 2016-05-19 06:39:03 -07:00
b18f783fed Add string.h to the docs 2016-05-18 21:04:34 -07:00
b6c0cf9683 Add fmt::to_string (#326) 2016-05-18 19:54:52 -07:00
d00b43c592 Workaround an issue with "delete this" in GMock and gcc 6.1.1 2016-05-14 17:58:14 -07:00
cc9b051d12 Move format_system_error to the public API (#323) 2016-05-13 07:19:39 -06:00
d67eb8af2f Correct docs 2016-05-10 11:07:53 -07:00
3400e0d609 Fix clang -Weverything warnings (#250) 2016-05-10 08:50:42 -07:00
f76583276a Clarify performance tradeoffs (#320) 2016-05-10 07:29:31 -07:00
31a4f0ab05 Implement website update script 2016-05-09 08:36:16 -07:00
744c2824c5 Fix a clang warning about an undefined template (#318) 2016-05-08 09:45:32 -07:00
140f11190b Add a website update script 2016-05-08 08:03:01 -07:00
fb67a2f660 Fix building source package 2016-05-08 07:28:34 -07:00
d2b65f77e8 Fix formatting 2016-05-08 07:27:41 -07:00
03cdd4ca50 Ignore virtualenv in subdirectories 2016-05-08 07:27:20 -07:00
e5e4fb370c Update version 2016-05-07 09:50:47 -07:00
70d93078e3 Update links 2016-05-07 09:37:38 -07:00
b344bd9582 Fix release script and changelog format 2016-05-07 09:21:26 -07:00
add6bcca3e Document ostream support 2016-05-07 09:09:33 -07:00
836415b215 Update changelog 2016-05-07 08:59:19 -07:00
7ce503e6a0 Update changelog 2016-05-07 08:50:51 -07:00
a4538ac1e8 Update ChangeLog.rst 2016-05-07 08:44:51 -07:00
6dfdada493 Update ChangeLog.rst 2016-05-07 08:00:12 -07:00
b7fe7dfad1 Update changelog 2016-05-07 07:50:56 -07:00
9c865560fd Fix a warning 2016-05-07 07:10:40 -07:00
1788883262 Fix warnings 2016-05-07 07:03:21 -07:00
90730e706b Move ostream support to ostream.{h,cc} 2016-05-06 07:37:20 -07:00
041725e9d0 Update changelog 2016-05-05 08:20:12 -07:00
c5fe3eb87e Fix code bloat regression on gcc 5.3.1 with -std=c++11 (#315) 2016-05-05 07:48:06 -07:00
b2a8141373 Update changelog 2016-05-04 08:49:29 -07:00
408c84cd42 Update copyright (#314) 2016-05-04 06:27:03 -07:00
6825ac9ccf Merge pull request #313 from dean0x7d/test-fixes
Fix a few bugs related to compile tests
2016-05-04 06:22:17 -07:00
f3d6d3a8f2 Fix find-package-test failure with non-default compiler
The failure would happen when the main project was configured with
a compiler which is not the system default. The new configuration
was not forwarded to "ctest --build-and-test". This fixes it.
2016-05-04 00:51:28 +02:00
8eaad79de7 Fix FMT_STATIC_ASSERT compile test
FMT_STATIC_ASSERT is defined in posix.h so expect_compile_error was
actually failing on a missing macro instead of the static assert.
2016-05-04 00:36:48 +02:00
131d446183 Fix compile tests not clearing the cache after an error
The cache bug meant that a failed test would appear forever broken,
even if the proper fix was applied.
2016-05-04 00:36:11 +02:00
4042198262 Merge pull request #312 from dean0x7d/intel-udl-fix
Fix user-defined literal detection for Intel C++ compiler (#311)
2016-05-03 08:34:53 -07:00
729491eab7 Use FMT_ICC_VERSION everywhere internally 2016-05-03 14:26:01 +02:00
3a04ebf14f Fix user-defined literal detection for Intel C++ compiler 2016-05-03 13:43:51 +02:00
b64d13a357 Merge pull request #309 from jwilk/spelling
Fix typos
2016-05-01 06:48:34 -07:00
e0ac51cbd9 Fix typos 2016-05-01 12:29:21 +02:00
4e279e2a70 Correct formatting 2016-04-29 07:02:37 -07:00
a3929b719a Document date/time formatting and move example to the docs 2016-04-29 06:40:31 -07:00
63be22d5dc Update template 2016-04-28 07:09:05 -07:00
f171d1f3d6 Update a link 2016-04-28 07:05:28 -07:00
c33f3e281b cppformat -> fmt 2016-04-28 07:00:22 -07:00
59d0efd6d6 Update links 2016-04-28 06:54:37 -07:00
56b6c05bf9 Update links 2016-04-28 06:47:43 -07:00
8dd48923d8 Update links 2016-04-28 06:45:50 -07:00
7dac3c44f5 Update links 2016-04-27 18:26:23 -07:00
4a0d9dbc30 Update build script 2016-04-27 18:22:44 -07:00
c916ab3319 Update docs 2016-04-27 08:35:59 -07:00
f9ee5f4b43 Update README.rst 2016-04-27 08:28:24 -07:00
e817bb9cc4 Update links 2016-04-27 08:23:03 -07:00
5946029585 Update README.rst 2016-04-27 08:15:49 -07:00
f4b5aeaed2 Update README.rst 2016-04-27 08:13:56 -07:00
5a6a58576a Update README.rst 2016-04-27 08:05:40 -07:00
90accff030 Fix a warning 2016-04-26 07:23:03 -07:00
49f6771ca9 Grow buffer 2016-04-25 08:24:14 -07:00
fa5ebd27d4 Implement time formatting 2016-04-25 08:07:27 -07:00
4cddbfa7cf Update README.rst 2016-04-25 06:36:26 -07:00
f1cd5413e9 Update README.rst 2016-04-24 10:46:21 -07:00
7f0d8184c9 cppformat -> fmt 2016-04-24 10:39:33 -07:00
e569297d6a Update Android config 2016-04-24 10:23:02 -07:00
bea282dae9 cppformat -> fmt 2016-04-24 09:18:15 -07:00
17544b1824 Add compatibility headers 2016-04-24 09:10:58 -07:00
afd67497de cppformat -> fmt 2016-04-24 09:06:12 -07:00
5e1576f79f cppformat -> fmt 2016-04-24 08:17:47 -07:00
848ab63a2a CPPFORMAT_VERSION -> FMT_VERSION 2016-04-24 07:16:33 -07:00
c7d9d79ad2 Document visitors and formatters 2016-04-21 07:31:32 -07:00
9ae2ac2fb7 Document ArgVisitor 2016-04-21 06:59:48 -07:00
125bb0f19a Revise docs 2016-04-21 06:50:54 -07:00
bfdca8b576 Make ArgVisitor public and document it
Also remove unnecessary namespace qualification.
2016-04-20 09:11:33 -07:00
da3467b7f9 Document BasicArgFormatter 2016-04-20 07:45:11 -07:00
fb5350543c Correct case 2016-04-20 07:44:37 -07:00
ccbc891992 Document argument formatters 2016-04-20 07:16:52 -07:00
b69e6dcead Make BasicArgFormatter public and add ArgFormatter
This allows providing custom argument formatters without relying on
internal APIs (#235).
2016-04-19 08:56:31 -07:00
4d8cee2d48 Document the n format specifier 2016-04-17 20:46:08 -07:00
f68771abe4 Implement locale-specific integer formatting 2016-04-17 19:06:03 -07:00
581afee039 Enable wstring in gtest (#304) 2016-04-13 08:26:42 -04:00
e49a4e0aff Bump version and adjust comments 2016-04-12 07:42:47 -04:00
753e9a04c0 Update version 2016-04-11 20:02:42 -04:00
18c69c998d Update changelog and version 2016-04-11 19:59:22 -04:00
6cfe43539a Update version 2016-04-11 19:59:01 -04:00
c61043450b Update changelog 2016-04-11 19:57:39 -04:00
e4f7d0d311 Resolve overloads 2016-04-11 09:32:24 -04:00
d8e246daaf Merge pull request #299 from niosHD/minor-packaging-improvements
Minor packaging improvements
2016-04-07 07:35:09 -07:00
620f999e80 ignore the current build directory when packaging
This makes sure that the current build directory is not packaged
with the regular source tree when `make package_source` is used.
2016-04-06 09:49:34 +02:00
dcbb6b1e4d make the install location for the generated cmake files configurable
By default the cmake files are installed to "<prefix>/lib/cmake/cppformat".
This can now be customized using the `FMT_CMAKE_DIR` cache variable.
Valid paths are documented in the cmake manual [1].

e.g., install the cmake files to "<prefix>/share/cmake/cppformat"
```
cmake -DFMT_CMAKE_DIR=share/cmake/cppformat <path-to-source>
```

Tip: Try `make package` to examine the result.

[1] https://cmake.org/cmake/help/v3.0/command/find_package.html
2016-04-06 09:33:13 +02:00
a99891e7a5 Use a mock to test custom argument formatter 2016-03-19 07:36:28 -07:00
52f89065e1 Make argument formatter customizable 2016-03-19 07:20:31 -07:00
9ffe98c00e Fix/suppress MSVC warnings 2016-03-19 06:39:33 -07:00
63d7f3d116 Don't check for C++11 features if C++11 support is disabled 2016-03-18 08:10:06 -07:00
c052cf11b9 Improve coding style consistency 2016-03-18 07:59:04 -07:00
0c901efb16 Use less strict pedantic flags for tests because of GMock (#291) 2016-03-18 07:52:24 -07:00
030cccfeef Update changelog 2016-03-17 07:28:21 -07:00
062e3bd757 Add a branch option to the release script 2016-03-13 10:27:15 -07:00
5174b8ca28 Update README.rst 2016-03-10 10:52:21 -08:00
090de29ddf Update README.rst 2016-03-10 10:51:52 -08:00
59607f5e99 Fix warnings on GCC 4.6.3 2016-03-09 07:47:08 -08:00
763d1fe6a3 Suppress warnings in Google Mock 2016-03-08 07:36:22 -08:00
7d6622942c Break a long line 2016-03-08 06:55:41 -08:00
0867c1b447 Test writing to ostream 2016-03-08 06:47:53 -08:00
6883d6e724 Merge pull request #285 from mwinterb/winerror_winu
Changed format_windows_error to not need LocalFree
2016-03-06 06:55:37 -08:00
8f4b8edb8b Added test of error code that forces the insufficient buffer code path. 2016-03-04 17:47:37 -08:00
5324d385c0 Fix a MSVC warning 2016-03-04 06:44:12 -08:00
fc505b5447 Merge pull request #286 from Naios/master
Define FMT_NOEXCEPT empty when exceptions are disabled
2016-03-03 09:54:27 -08:00
3c3d6b3d2a Define FMT_NOEXCEPT empty when exceptions are disabled
* Fixes warnings about disabled exception support in MSVC
2016-03-03 17:23:25 +01:00
2a05a87fe7 Changed format_windows_error to not need LocalFree
This is for non-'Desktop' applications that have a
more limited collection of functions.
2016-03-02 17:35:34 -08:00
3ecad55910 Fix sign conversion warnings 2016-03-02 07:53:14 -08:00
d929fdeb9b Fix clang warnings 2016-03-02 07:02:57 -08:00
9d577cae6f Fix handling of negative error codes in format_error_code 2016-03-02 07:01:21 -08:00
6e820841d4 Add mongo_smasher to the list of projects 2016-03-01 14:28:52 -08:00
82d6813e7c Fix a bunch of Clang sign-conversion warnings 2016-03-01 08:12:29 -08:00
2f12a32c20 Merge pull request #277 from PSPDFKit-labs/fix-switch-fallthrough
Fix switch fall-through warning
2016-02-23 10:28:17 -08:00
6178bc6f8e Fix switch fall-through warning
Clang with `-Wimplicit-fallthrough` enabled shows a warning here without
the break.
2016-02-23 12:59:26 -05:00
209748f128 Workaround a bug in Apple LLVM version 4.2 of clang (#276) 2016-02-23 07:27:01 -08:00
f64ea6235f Include xlocale.h for LC_NUMERIC_MASK on OS X 2016-02-19 13:30:18 -08:00
80d288b146 Correct comment 2016-02-11 07:25:00 -08:00
6500f161f7 Fix a warning in freelocale mock (#274) 2016-02-11 06:55:53 -08:00
abd93d824a Move gmock into test/ 2016-02-10 07:16:49 -08:00
2b2aa8926f add_subdirectory-test -> add-subdirectory-test for consistency 2016-02-10 07:01:40 -08:00
21b8279cfe Remove biicode because it has been shut down 2016-02-09 21:25:52 -08:00
cd7f6c1fda Comment 2016-02-09 15:40:26 -08:00
70e44a8e7f Simplify locale mock 2016-02-09 11:31:04 -08:00
b8c6192a61 Simplify build config and enable C++11 by default 2016-02-09 08:43:39 -08:00
c7b7141b11 Merge pull request #273 from niosHD/extend-ci-tests
Extend CI tests with older c++ standards
2016-02-09 06:53:58 -08:00
c57f8f563b omit the c++ 2003 tests 2016-02-09 09:08:11 +01:00
016af73d19 fixed typo in script 2016-02-07 18:47:39 +01:00
f961683516 specify c++11 as c++0x for travis 2016-02-07 18:41:46 +01:00
27a1b787c8 test in c++ 98, 03 and 11 mode 2016-02-07 18:32:23 +01:00
6a79a3279b build and test in c++11 and in c++98 mode 2016-02-07 18:23:02 +01:00
734d3bf175 Remove link to API compatibility report which is no longer functional 2016-02-05 08:31:19 -08:00
8c8877df5a treat format.cc like a header
Given that it is required for header only builds it has to be
installed too.
2016-02-05 15:27:49 +01:00
754be04f11 state that sudo is required for CI
This informs travis that the container-based build environment can
not be used.
2016-02-05 14:33:56 +01:00
1adee75e1c Check if -fno-delete-null-pointer-checks flag is supported 2016-02-04 08:36:41 -08:00
a4b611a3d3 Workaround GTest bug 705 (#268) 2016-02-04 08:15:19 -08:00
220bb764e5 Use quotes for local includes 2016-02-04 08:08:33 -08:00
a750114a38 Merge pull request #271 from newnon/master
fix android build
2016-02-04 06:14:24 -08:00
4d56c5ce4c fix android build 2016-02-04 12:46:59 +03:00
c0ad9a888b Update the source location in the documentation build script 2016-02-03 09:28:44 -08:00
0598d84f61 Merge pull request #267 from niosHD/update-project-layout
Update project layout
2016-02-03 08:48:25 -08:00
b09c83504e test for gnu++98 instead for c++98 because of mingw ... 2016-02-03 14:11:30 +01:00
3133925ab2 Merge branch 'master' into update-project-layout
Conflicts:
	posix.h
2016-02-03 13:15:26 +01:00
03b9485cb3 perform the slower tests only in PEDANTIC mode 2016-02-03 13:05:18 +01:00
ded46cc1b6 build test-main library again to improve build time 2016-02-03 12:59:03 +01:00
c1a4cd0fa7 check if cppformat is the master project or just used as dependency
Based on that information less intrusive option defaults are choosen.
Additionally, packaging support is omitted.
2016-02-03 11:20:19 +01:00
797d72133e restored smoke test for syntax compatibility with the 98 c++ standard 2016-02-03 10:01:53 +01:00
56cfd9f4ce installed posix.h too when it is built into the library 2016-02-03 09:59:55 +01:00
e0e8f717a0 FMT_USE_FILE_DESCRIPTORS is apparently only needed for the tests 2016-02-03 09:14:32 +01:00
cfb25b0e80 Use typedefs instead of macros 2016-02-02 22:06:54 -08:00
e489f879c3 Add locale tests 2016-02-02 17:21:09 -08:00
c0e926109e use the same warning options like before the PR
Additional notes on how to improve the current state have been added.
2016-02-02 17:14:51 +01:00
b05a02b91c remove comment which is now superfluous since the code has been moved 2016-02-02 17:04:12 +01:00
d411aa165e use quotes for including cppformat headers from the tests 2016-02-02 16:58:41 +01:00
be961bae0f fixed typo in python script 2016-02-01 10:41:45 +01:00
0a4acc9656 use the cmake and ctest to drive the appveyor build 2016-02-01 10:22:47 +01:00
d3fe82c55b propagate the build type into the find test 2016-01-31 20:17:39 +01:00
a659d8079e Merge branch 'master' into update-project-layout 2016-01-31 17:00:05 +01:00
00fda9b25a add a test for the find script on the build directory 2016-01-31 00:02:49 +01:00
4aeeb49d23 updated compile-test and include a working test
This makes sure that the test does not break due to other reasons.
2016-01-30 23:49:39 +01:00
fee52f79b8 update the includes in the tests to get rid of the deprecated warnings 2016-01-30 22:33:37 +01:00
4952e79e45 Document that floating-point formatting is locale-dependent. 2016-01-30 09:20:43 -08:00
95c0fb5075 Add a "C" numeric locale 2016-01-29 16:29:46 -08:00
62ac1d98a4 export the header only library also during installation 2016-01-29 16:57:45 +01:00
5aa5116edc moved the library definition and the installation into a sub CMakeLists.txt 2016-01-29 16:39:03 +01:00
5e7ab2f4ea major cleanup of the test folders CMakeLists.txt
The new code does not rely on globally defined include directories
anymore. Additionally a lot of conditional code and has been removed
which improves readability a lot.
2016-01-29 16:21:17 +01:00
b52d0bd9d4 define cppformat cmake targets with proper interface definitions 2016-01-29 13:23:08 +01:00
0fb474be3a outlined the compiler feature tests to improve script readability 2016-01-29 13:03:47 +01:00
3019a8c1fd moved code into cppformat subdirectory
Proxy headers have been placed into the project root to emit
deprecation warnings.
2016-01-29 12:49:35 +01:00
7ee287d3d9 Sign extend arguments of smaller types passed to %ll? (#265) 2016-01-27 07:03:19 -08:00
ae6368c985 Add a comment to clarify why convert to unsigned 2016-01-26 07:13:34 -08:00
bb7a80b1ab Correct comment 2016-01-25 06:46:43 -08:00
8474a6232d Don't perform narrowing conversion for integers in printf (#255) 2016-01-24 00:43:42 +01:00
22f61140d1 Format CMake files, ignore generated files and don't copy header 2016-01-13 07:14:32 -08:00
52ee516cf3 Merge pull request #264 from niosHD/improve-find-and-package-support
Improve find and package support
2016-01-13 06:37:41 -08:00
ef7bbfff87 removed workaround for cmake versions prior to 2.8.10 2016-01-13 09:54:02 +01:00
891e9117f6 trying to update cmake to 2.8.12 in travis via a ppa repo
Whitelist of repos:
https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json

Whitelist of packages:
https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
2016-01-12 16:57:40 +01:00
3fc3ecd184 reverted removal of CPACK_SOURCE_PACKAGE_FILE_NAME
The use of `CPACK_PACKAGE_NAME` leads to
`cppformat-<version>-Source.zip` as the name for the source package
which is different from the expected `cppformat-<version>.zip`.
2016-01-12 16:48:53 +01:00
06f3abe26d Return early from ArgMap::find 2016-01-12 06:37:39 -08:00
50f14f225c Merge pull request #262 from mwinterb/argmap_vector
Changed ArgMap to be backed by a vector instead of a map.
2016-01-12 06:23:19 -08:00
b732455fd3 enable package support for out of source builds 2016-01-12 12:52:05 +01:00
daf74ae0b1 upgrades to cmake 2.8.12 and adds config and export support
This commit upgrades cmake to 2.8.12 to implement proper cmake
`find_package` support using config and export file generation.
Having this support enables users to use installed cppformat
with a simple `find_package` call. Directly using a version
from a build directory is also supported.

main.cpp:
```
 #include <cppformat/format.h>
int main(int argc, char** argv)
{
  for(int i = 0; i < argc; ++i)
    fmt::print("{}: {}\n",i,argv[i]);
  return 0;
}

```

CMakeLists.txt:
```
cmake_minimum_required(VERSION 2.8.12)

project(cppformat-test)

find_package(cppformat REQUIRED)

add_executable(cppformat-test "main.cpp")
target_link_libraries(cppformat-test cppformat)

```
Configuring when cppformat is installed under `CMAKE_INSTALL_PREFIX`: `cmake <PATH_TO_TEST_SRC>`

Configuring when cppformat is installed `ELSEWHERE`: `cmake -Dcppformat_DIR=<ELSEWHERE>/lib/cmake/cppformat <PATH_TO_TEST_SRC>`

Configuring when cppformat is only built: `cmake -Dcppformat_DIR=<cppformat_BUILD_DIR> <PATH_TO_TEST_SRC>`
2016-01-12 12:47:19 +01:00
4af764d040 Changed ArgMap to be backed by a vector instead of a map.
The main reason for this is to avoid a dynamic memory allocation in every format() call with Visual Studio if there are no named arguments.
2016-01-10 15:30:34 -08:00
97e9ed11bc Set interface include dir for gmock 2016-01-09 08:07:31 -08:00
f55bf55d43 Correct comment 2016-01-09 08:06:59 -08:00
e604d5347f Fix links in README (#260) 2016-01-08 13:03:34 -08:00
979e70f10d Merge pull request #259 from mwinterb/unknown_pragma_bsr
Fixed unknown pragma warnings for _BitScanReverse.
2016-01-08 07:25:48 -08:00
b203beb61d Don't define the MSVC clz functions unless __builtin_clzll is unavailable.
This is mainly just to avoid including intrin.h unnecessarily.
2016-01-07 15:38:08 -08:00
28a303ddd4 Fixed unknown pragma warnings for _BitScanReverse.
Changed to only define the MSVC implementations for clz and clzll if the builtins are not available to avoid warnings about an unknown #pragma for "intrinsic".
2016-01-06 14:42:27 -08:00
3943803412 Merge pull request #256 from mwinterb/clang_ms_clz
Fixed macro redefinition warnings when compiling with clang-cl.
2016-01-06 06:46:17 -08:00
7185e96da1 Fixed issues with MSVC emulations of clz and clzll.
Both clang-cl and Clang/C2 #define _MSC_VER but also have support for __builtin_clz and __builtin_clzll, leading to duplicate macro definition warnings. Emulation of clz using _BitScanReverse is suppressed if the builtins are already available.

Additionally, the value of the output parameter of _BitScanReverse is undefined if the input value is 0, which is avoided by construction, so the code analysis warning for using uninitialized data is now suppressed.
2016-01-05 16:03:06 -08:00
251a0869be Fixed macro redefinition warnings when compiling with clang-cl.
Both clang-cl and Clang/C2 #define _MSC_VER but also have support for __builtin_clz and __builtin_clzll, leading to duplicate macro definition warnings. This change suppresses emulation of clz using _BitScanReverse if the __clang__ macro is defined.
2016-01-01 18:07:06 -08:00
804ad8f4df Document std::ostream overload of fprintf 2015-12-24 07:00:22 -08:00
8b0504825d Merge branch 'master' of github.com:cppformat/cppformat 2015-12-24 06:58:05 -08:00
77d3761b50 Enable macro expansion in Doxygen (fixes #248) 2015-12-24 06:54:37 -08:00
0525a03a69 Merge pull request #251 from nickhutchinson/work/fprintf-streams
Add fprintf overload that writes to a std::ostream
2015-12-23 06:58:44 -08:00
1a5a1708b7 Add fprintf overload that writes to a std::ostream
For completeness, add an overload for printf that takes a std::ostream.
2015-12-23 15:59:13 +13:00
4797ca025e POD -> trivially copyable/constructible 2015-12-20 07:29:59 -08:00
3121ebd044 Merge pull request #249 from dean0x7d/variadic-v3
Reduce compile time of variadic functions (2)
2015-12-20 07:10:00 -08:00
b098306839 Replace template recursion with array initialization 2015-12-19 18:19:18 +01:00
a721319e3a Add MakeArg constructor for Arg 2015-12-19 18:19:18 +01:00
29726cefb8 Remove extra '*'s 2015-12-18 07:30:03 -08:00
811964502d Add BasicFormatter's members to the docs 2015-12-18 07:24:25 -08:00
0629d76bb0 Fallback to sized integer types on MSVC if stdint.h is not available 2015-12-18 07:20:05 -08:00
016714c57b Add BasicFormatter to the docs 2015-12-18 07:16:40 -08:00
c679352517 Define FMT_API to nothing for Doxygen 2015-12-18 07:13:43 -08:00
1042ddda0f Document BasicFormatter 2015-12-18 07:07:41 -08:00
d998b5d038 Add version 2.0.0 to the dropdown menu 2015-12-18 06:47:37 -08:00
bf6651d1ca Add github-btn style 2015-12-17 07:59:09 -08:00
1cba0aea27 Simplify CMake config and do minor adjustments
for consistency with used coding conventions.
2015-12-10 07:24:23 -08:00
a9d2e826fe Merge pull request #245 from macdems/master
Declarations for shared library in Windows.
2015-12-10 07:05:33 -08:00
c47318afa8 Declarations for shared library in Windows.
Added __declspec(dllimport) and __declspec(dllexport) declarations
when compiled in Windows.
2015-12-10 13:36:18 +01:00
ecd52bc610 Fix for a bogus MSVC warning (#244) 2015-12-09 08:57:29 -08:00
5c76d107cb Fix MSVC build 2015-12-06 14:17:34 -08:00
98c1f76f24 Replace uninitialized_copy with memmove (#242)
because the memory areas may overlap.
2015-12-06 07:44:07 -08:00
e7f4566dd4 Replace <algorithm> with <memory>
~20% faster compile time on bloat-test
2015-12-04 22:57:36 -08:00
e0179ee190 Fix a warning and remove extra newline 2015-12-04 17:52:36 -08:00
e567fe6960 Replace "!!" with "!= 0" for readability 2015-12-04 17:52:06 -08:00
7c60db1e24 Fix a warning 2015-12-04 14:12:42 -08:00
0ea73df717 Merge branch 'custom-formatter' 2015-12-04 07:24:09 -08:00
aa7bb101ed Undefine fileno if defined in posix-test 2015-12-03 20:17:04 -08:00
3bc97a5564 Merge pull request #241 from Gachapen/fix_fileno
Fix fileno causing compile error when #defined
2015-12-03 20:15:10 -08:00
c2ffa14684 Fix fileno causing compile error when #defined
Error:
expected unqualified-id before '(' token
 int fmt::BufferedFile::fileno() const {

This is an issue with Android NDK and mingw32.
2015-12-03 23:21:42 +01:00
535dbdd1c8 Move formatter methods to the header
and improve naming consistency
2015-12-03 09:38:06 -08:00
00d56e06ef Bump version 2015-12-03 08:15:03 -08:00
7e94fcb680 Reapply accidentally reverted changes by ReadmeCritic 2015-12-03 08:09:53 -08:00
6ced4230f4 Initial support for custom formatters 2015-12-02 08:41:05 -08:00
5f8af5ef1d Update version 2015-12-01 07:33:30 -08:00
5837851cb2 Update docs 2015-12-01 07:31:15 -08:00
abe932164a Update changelog 2015-12-01 07:20:33 -08:00
19de4a863a Merge pull request #236 from Jopie64/master
Silence some performance warnings in Visual Studio
2015-12-01 06:58:09 -08:00
328c8888ec Make compilable under Visual Studio 2008
Older Visual Studio versions are not shipped with stdint.h
2015-12-01 09:34:13 +01:00
df2dfd9612 Silence some performance warnings in Visual Studio 2015-12-01 08:59:59 +01:00
fac207816c Update release script 2015-11-30 08:23:16 -08:00
ec80a1ab51 Update changelog 2015-11-30 08:22:03 -08:00
3bf900e301 Update changelog 2015-11-30 08:17:47 -08:00
722c8e4ae6 Update changelog 2015-11-30 08:10:49 -08:00
13d6b2d38c Update changelog 2015-11-30 07:22:51 -08:00
b8bd80ff28 Fix handling of empty non-null-terminated strings 2015-11-25 09:49:01 -08:00
7cbb29f61e Make FormatBuf::size() const 2015-11-25 08:27:46 -08:00
053df632f8 Minor simplification and adjustment of coding style for consistency
in custom stream buffer implementation:

* basic_formatbuf -> internal::FormatBuf
* remove unused Traits template argument
2015-11-25 08:00:57 -08:00
222f2d28f5 Fix MSVC warnings 2015-11-25 07:47:43 -08:00
f60c4b9947 Fix an MSVC warning (#234) 2015-11-25 07:17:05 -08:00
0519737b95 Don't use _ecvt (#233) 2015-11-25 07:11:28 -08:00
9a08fb52bf Fix compilation with clang and old libstdc++ 2015-11-24 09:13:48 -08:00
8265263c5d Remove unnecessary stuff. 2015-11-24 09:09:09 -08:00
d266adf805 Implement custom stream buffer (#92) 2015-11-24 09:06:33 -08:00
6cff6d8137 Use overloaded operator<< for enums if available (#232) 2015-11-24 08:18:19 -08:00
1a2a333a1a Use format specifiers when formatting null pointers & strings 2015-11-23 21:01:28 -08:00
289885e8c0 Fix branch detection on Travis 2015-11-23 08:47:46 -08:00
4118b89139 Get rid of the html directory when installing docs 2015-11-23 08:22:21 -08:00
96731cebe1 Print branch name 2015-11-23 08:21:22 -08:00
b83fd00183 Pass version from CMake to Sphinx 2015-11-23 08:10:02 -08:00
646829e34d Fix MSVC warnings 2015-11-21 07:31:00 -08:00
8beadace37 Improve detection of isinf, isnan and getsign 2015-11-21 07:20:18 -08:00
223575b567 Tyop 2015-11-20 08:28:29 -08:00
ee3e68dc16 Improve compatibility with bcc32 2015-11-20 08:14:10 -08:00
e5d599875c Improve compatibility with bcc32 2015-11-20 07:56:16 -08:00
b53994fd0d Suppress a warning 2015-11-20 07:49:29 -08:00
fd1753484e Fix example 2015-11-19 07:23:43 -08:00
6606971aae Improve compatibility with bcc32 2015-11-18 08:42:09 -08:00
31aced8b59 Improve compatibility with bcc32 2015-11-18 08:04:04 -08:00
1dd5e035eb Simplify signbit 2015-11-18 07:38:05 -08:00
0219d5591b Improve compatibility with bcc32 2015-11-17 08:53:15 -08:00
3a2f91bd58 Fallback to ecvt if _ecvt_s is not available. 2015-11-17 08:35:30 -08:00
c1a8dfe555 Improve detection of signbit 2015-11-17 07:40:22 -08:00
d9e0f5c04e Merge pull request #229 from LogicalKnight/fix_intel_warning
Fix warning when using Intel C++ on OS X
2015-11-13 16:48:34 -08:00
9c03176e6b Fix util-test 2015-11-13 15:16:10 -08:00
2157375d5c Use textual formatting for bool with %s specifier in printf (#224) 2015-11-13 07:18:44 -08:00
7dcf05108e Move cstddef include to format.cc and refactor Buffer::append 2015-11-13 06:52:13 -08:00
32f0295460 Fix warning when using Intel C++ on OS X
Unfortunately, Intel's C++ compiler defines `__clang__` which means that
some of the pragmas in use that Intel C++ doesn't use will cause
warnings to be generated.
2015-11-13 08:01:59 -05:00
3df9bf3a91 Merge pull request #228 from dean0x7d/fix_warning
Fix static_assert feature detection on clang
2015-11-12 12:38:27 -08:00
7d94b5bbeb Fix static_assert feature detection on clang 2015-11-12 21:03:08 +01:00
ef5e5e02b4 Only update docs from master branch on travis 2015-11-12 08:47:07 -08:00
11f946efff Make release script create a GitHub release 2015-11-12 07:39:09 -08:00
57ba9436a0 Format null string as (nil) with p specifier 2015-11-12 06:09:08 -08:00
5e37698911 Implement release script 2015-11-11 08:41:29 -08:00
b5fda1c90d Format null pointer as (nil) and null string as (null) in printf (#226) 2015-11-11 07:57:19 -08:00
e61c8d4cba Update documentation config 2015-11-11 07:35:31 -08:00
89cd4a5e17 Set version in one place 2015-11-11 07:22:07 -08:00
0550f1217c Store unsigned char value in uint_value instead of int_value 2015-11-11 06:45:27 -08:00
d6d019aa12 Don't assume that StringRef::compare returns +/-1 2015-11-11 06:44:57 -08:00
477962884e Add a release script 2015-11-10 08:20:21 -08:00
aa741bafe6 Don't assume that char_traits::compare returns +/-1 (#225) 2015-11-10 06:40:20 -08:00
8b86a74ad5 Allow formatting C strings as pointers (#223) 2015-11-09 07:17:36 -08:00
7c24973637 Format (un)signed char as integer by default (#217) 2015-11-05 20:46:22 -05:00
9beb01d8e5 Add an appveyor/cmake workaround 2015-11-04 10:19:59 -05:00
5b7dd17dff Merge pull request #220 from inguin/master
Fix warnings
2015-11-04 09:55:36 -05:00
41ebedf516 Fix warning when building with -Wundef and disabled exceptions 2015-11-03 11:21:09 +01:00
9954aa064b Disable GCC sign-compare warning in the header file 2015-11-03 11:14:48 +01:00
f4d8884af1 Add casts to fix warnings with -Wconversion 2015-11-02 19:14:47 +01:00
fe34b2f357 Fix bogus warning when compiling with -Wctor-dtor-privacy 2015-11-02 18:33:35 +01:00
8af9bf1d06 Use FMT_SECURE_SCL instead of _SECURE_SCL 2015-11-02 09:22:59 -05:00
de3cea7f02 Merge pull request #218 from inguin/master
Fix warnings
2015-11-02 09:08:25 -05:00
27c2e880d0 Fix warning when building with -Wfloat-equal 2015-11-02 14:44:27 +01:00
b4b13ee2b8 Fix warnings when compiling with -Wundef 2015-11-02 13:55:31 +01:00
96d518f2f8 Update ChangeLog.rst 2015-10-30 08:23:35 -07:00
0cb37ce2eb Merge branch 'master' of github.com:cppformat/cppformat 2015-10-30 07:55:06 -07:00
82acd483ae Fix warnings (#216) 2015-10-30 07:54:55 -07:00
b1a55d50bf Update ChangeLog.rst 2015-10-30 07:43:15 -07:00
e1ed1d789c Update ChangeLog.rst 2015-10-30 07:35:18 -07:00
dc7a372bfc Update ChangeLog.rst 2015-10-30 06:56:07 -07:00
387b23f890 Update ChangeLog.rst 2015-10-30 06:45:56 -07:00
1133fe8ab0 Update ChangeLog.rst 2015-10-30 06:24:36 -07:00
0bfa6bed4b Update ChangeLog.rst 2015-10-30 06:20:13 -07:00
a4e3cf834b Update ChangeLog.rst 2015-10-29 08:26:03 -07:00
09e288e55b Update ChangeLog.rst 2015-10-29 08:24:31 -07:00
17869454c2 Update ChangeLog.rst 2015-10-29 07:41:26 -07:00
6a93dda265 Update ChangeLog.rst 2015-10-29 07:28:47 -07:00
4d3be75bcd Update ChangeLog.rst 2015-10-29 07:24:54 -07:00
587b4894ba Update ChangeLog.rst 2015-10-29 07:24:39 -07:00
c6a67b91de Update ChangeLog.rst 2015-10-29 07:16:59 -07:00
2ebdd49e96 Update ChangeLog.rst 2015-10-29 07:14:21 -07:00
b3411bdeed Update ChangeLog.rst 2015-10-29 06:44:51 -07:00
0ba89d256b Update ChangeLog.rst 2015-10-29 06:28:51 -07:00
c04617c8d4 Update ChangeLog.rst 2015-10-29 06:24:15 -07:00
fa88490453 Merge branch 'master' of github.com:cppformat/cppformat 2015-10-28 12:22:08 -07:00
7638a3be1e Fixed virtualenv activation on Windows
Thanks to @mapgccv.
2015-10-28 12:21:57 -07:00
7610e98a37 Update ChangeLog.rst 2015-10-28 08:31:12 -07:00
333770bfa3 Update ChangeLog.rst 2015-10-28 08:15:40 -07:00
1b187ce57f Update ChangeLog.rst 2015-10-28 08:13:36 -07:00
bcc136de81 Update ChangeLog.rst 2015-10-28 08:03:18 -07:00
83b639987c Update ChangeLog.rst 2015-10-28 08:01:06 -07:00
1942ff4c70 Update ChangeLog.rst 2015-10-28 08:00:25 -07:00
fef203bf6c Update ChangeLog.rst 2015-10-28 07:49:31 -07:00
1df1af0245 Update ChangeLog.rst 2015-10-28 07:21:08 -07:00
d2f707e33a Remove broken biicode badge 2015-10-28 07:17:57 -07:00
4800554fc2 Update ChangeLog.rst 2015-10-28 07:09:17 -07:00
0bf9b07173 Update ChangeLog.rst 2015-10-28 07:08:45 -07:00
2d727e7d0e Suppress bogus coverity warnings 2015-10-28 07:01:28 -07:00
522e0e8371 Merge branch 'master' of github.com:cppformat/cppformat 2015-10-28 06:31:45 -07:00
316b05cf34 Avoid magic constants 2015-10-28 06:31:37 -07:00
17960dd3d3 Remove unused parameter name 2015-10-28 06:23:22 -07:00
9bbdf3b4c9 Update ChangeLog.rst 2015-10-27 21:59:42 -07:00
def5d983de Update ChangeLog.rst 2015-10-27 21:55:57 -07:00
4822044dc9 Update ChangeLog.rst 2015-10-27 08:41:10 -07:00
247fe7a2a6 Update ChangeLog.rst 2015-10-27 08:27:07 -07:00
b91eea5549 Update ChangeLog.rst 2015-10-27 08:22:11 -07:00
87a2a61d56 Update ChangeLog.rst 2015-10-27 07:03:42 -07:00
f27f848bb8 Update ChangeLog.rst 2015-10-27 06:55:25 -07:00
5b7d8db684 Merge pull request #215 from dmkrepo/master
MSVC 2015 supports noexcept
2015-10-26 06:16:47 -07:00
b92c60c171 MSVC 2015 supports noexcept 2015-10-26 13:11:04 +03:00
d1ae63032d Update ChangeLog.rst 2015-10-25 08:58:05 -07:00
acfa858e3c Disable wchar_t instead of unsigned short overload
if _NATIVE_WCHAR_T_DEFINED is defined
2015-10-25 07:13:45 -07:00
716ab0499d Merge pull request #214 from slavanap/master
MS Visual Studio "/Zc:wchar_t-" compiler parameter support added
2015-10-25 07:11:56 -07:00
4e9faed8f9 MS Visual Studio "/Zc:wchar_t-" compiler parameter support added 2015-10-25 14:37:31 +03:00
024eae91fb Update ChangeLog.rst 2015-10-23 08:41:30 -07:00
2167da4bb3 Update ChangeLog.rst 2015-10-23 08:15:45 -07:00
fe3d4513cc Update ChangeLog.rst 2015-10-23 08:04:00 -07:00
59442e968d Update ChangeLog.rst 2015-10-23 07:23:54 -07:00
74ea872b0c Update ChangeLog.rst 2015-10-23 07:20:54 -07:00
ef741a4649 Update ChangeLog.rst 2015-10-23 07:17:38 -07:00
c43603b363 Update ChangeLog.rst 2015-10-23 07:10:24 -07:00
a5b45dc389 Update ChangeLog.rst 2015-10-23 07:09:26 -07:00
64e66befd5 Update ChangeLog.rst 2015-10-23 07:00:45 -07:00
ce973be1bb Udate changelog 2015-10-23 06:52:12 -07:00
ae48a4c6f9 Add missing include 2015-10-22 08:56:52 -07:00
f080b62047 Implement StringRef comparison operators
and use lexicographical comparison (#183)
2015-10-22 08:41:42 -07:00
fb27723a9f Try fixing bogus coverity warnings, take n 2015-10-22 07:33:01 -07:00
b64913b00b Suppress bogus coverity warnings 2015-10-22 05:58:37 -07:00
869ed1ec19 Update breathe 2015-10-21 16:08:50 -07:00
ecbfdb46d3 Fix sanitize 2015-10-21 10:39:58 -07:00
23e84472b2 Hook Coverity model file 2015-10-21 08:45:48 -07:00
ab25cd2c8b Suppress a bogus coverity warning 2015-10-21 08:30:10 -07:00
13e0e38d99 Workaround a bogus coverity warning 2015-10-21 07:17:48 -07:00
cd097d334e Workaround bogus coverity warnings 2015-10-21 06:16:55 -07:00
adee0dfc39 Fix travis config 2015-10-20 08:48:25 -07:00
cb5a1698c9 Update breathe to fix overload issue 2015-10-20 08:39:34 -07:00
c684886dfc Make coverity happy 2015-10-20 08:29:41 -07:00
221dd0cb66 Try workaround for a bogus Coverity warning 2015-10-20 07:22:38 -07:00
a68ce59c74 Ignore bin in subdirectories 2015-10-20 07:17:20 -07:00
3814a07c44 Handle fast forward in update-coverity-branch.py 2015-10-20 07:14:40 -07:00
49382a0aa7 Ignore .so files 2015-10-20 07:14:11 -07:00
d25d775ae6 Suppress bogus coverity warnings 2015-10-20 06:26:31 -07:00
22d572d7a2 Fix potential segfault when exceptions are disabled 2015-10-20 06:23:16 -07:00
a9582bb1a2 Update coverity branch 2015-10-19 08:39:47 -07:00
5a648b300f Suppress another bogus warning in Coverity 2015-10-19 08:39:31 -07:00
85a93a8078 Suppress another bogus warning in Coverity 2015-10-19 08:25:30 -07:00
56d3b9135f Try a workaround for a bogus Coverity warning 2015-10-19 08:17:05 -07:00
317ff51fd9 Add a script to update the coverity branch 2015-10-19 08:08:23 -07:00
6bed5e5b01 Merge branch 'master' of github.com:cppformat/cppformat 2015-10-19 08:05:18 -07:00
931173ab77 Move appveyor.yml to support 2015-10-19 08:05:09 -07:00
3242e624d5 Update branch name and remove .gitattributes 2015-10-19 08:01:18 -07:00
566f393b49 Update coverity branch 2015-10-19 07:59:45 -07:00
a43e242716 ours -> keep-ours 2015-10-18 10:24:54 -07:00
5405b09ff4 Merge pull request #212 from dean0x7d/fix_shared_lib
Fix shared library build on OS X
2015-10-18 09:22:10 -07:00
e81c0aef39 Fix bogus coverity warnings. 2015-10-18 09:16:10 -07:00
b2714f83cc FMT_NO_STREAM_LIBRARIES -> FMT_USE_IOSTREAMS
for consistency with similar macros and removed unnecessary
checks.
2015-10-18 08:50:35 -07:00
6049fd9d66 Merge pull request #208 from JodiTheTigger/Make-streams-optional
Issue 205: Make iostream support optional.
2015-10-18 08:40:01 -07:00
77b32006a3 Workaround a bug in MSVC when _CRTDBG_MAP_ALLOC is defined 2015-10-18 06:42:24 -07:00
9608a98b01 Fix shared library build on OS X 2015-10-18 14:49:17 +02:00
caa8f76a88 Make content wider on medium-size devices (#210) 2015-10-17 17:35:51 -07:00
044ef900bc Grammar 2015-10-17 08:34:58 -07:00
6d9712c7fd Fix links 2015-10-17 08:21:23 -07:00
826edabae1 Add building the documentation section 2015-10-17 08:17:32 -07:00
5898720c28 Make documentation build script compatible with Python 3 2015-10-17 08:05:58 -07:00
a596b8724b Improve error message when less is not installed 2015-10-16 08:28:58 -07:00
79d7aacff3 Remove diagnostics 2015-10-16 08:13:54 -07:00
aaa8b1e0aa Upgrade distribute if it is 0.6.24 or lower
because installation of sphinx with distribute 0.6.24 available on Travis
is broken.
2015-10-16 08:07:44 -07:00
2d921c96e0 Update sphinx 2015-10-16 07:34:38 -07:00
ee1fdc575b Print alabaster version 2015-10-16 07:18:04 -07:00
418cd1c82a Pip show no more 2015-10-16 07:03:45 -07:00
884c55741f Install a version of sphinx without sphinx-rtd-theme
because the latter breaks the sphinx-build
2015-10-16 07:00:19 -07:00
2cca51c744 Issue 205: Make iostream support optional. 2015-10-16 08:04:53 +13:00
221eeda912 Remove diagnostics which is not working 2015-10-15 08:30:16 -07:00
d57c6204cd Try installing the stupid sphinx-rtd-theme explicitly 2015-10-15 08:26:44 -07:00
694bfb5309 sphinx-rtd-theme -> sphinx_rtd_theme 2015-10-15 08:19:33 -07:00
9daa774b5b Import pkg_resources after activating virtualenv 2015-10-15 08:13:32 -07:00
1554c9c6e5 Diagnose sphinx-build failure on Travis 2015-10-15 08:09:19 -07:00
2a4f98f474 Diagnose sphinx-build failure on Travis 2015-10-15 07:54:41 -07:00
39265a4288 Try the latest version of pip 2015-10-15 07:40:34 -07:00
a257d811d8 Check if pip has __version__ 2015-10-15 07:20:52 -07:00
238d6dc506 Try importing pip after activating virtualenv 2015-10-15 07:14:57 -07:00
a5b296a484 More diagnostics 2015-10-15 07:08:26 -07:00
e854c7d47e Check if pip is updated 2015-10-15 06:41:16 -07:00
e61f4d2bf6 Upgrade to pip 1.5.4 2015-10-14 08:36:58 -07:00
ee6f4e7aec Check pip version once and skip pip show for now 2015-10-14 08:31:54 -07:00
13c633223e Upgrade pip on Travis 2015-10-14 08:17:39 -07:00
a08bc864fb Add more diagnostics 2015-10-14 07:13:23 -07:00
95fa85cf04 Try uninstalling older version of sphinx 2015-10-14 07:06:13 -07:00
f4d38ce3ea Add more diagnostics 2015-10-14 06:52:07 -07:00
d6ecf3ae61 Add more diagnostics 2015-10-14 06:43:30 -07:00
6dae7f3ba6 Add more diagnostics 2015-10-14 06:39:07 -07:00
08bcf61fb2 Add --upgrade option to pip 2015-10-14 06:27:41 -07:00
bdbac0b78f More diagnostics 2015-10-13 08:55:05 -07:00
5bc908623c Add diagnostics to the documentation build script 2015-10-13 08:45:49 -07:00
7732688b80 If Sphinx is already installed but version doesn't match, reinstall it 2015-10-13 08:24:16 -07:00
9575e77e40 Merge pull request #207 from dean0x7d/udl-api
Update Sphinx with C++11 literals fix and add fmt::literals API docs
2015-10-13 07:26:25 -07:00
358ae822bb Update Sphinx with C++11 literals fix and add fmt::literals API docs 2015-10-13 00:35:22 +02:00
dd60ec673c Merge pull request #206 from dean0x7d/udl-docs
Document user-defined literals
2015-10-11 10:58:08 -07:00
47e26cdc37 Document user-defined literals 2015-10-11 02:34:20 +02:00
2eda8313af Merge branch 'udl' of github.com:dean0x7d/cppformat into udl 2015-10-09 08:20:46 -07:00
c0813c59f3 Work around UDL macro stringification bug on some versions of GCC
See bug report: https://gcc.gnu.org/ml/gcc-bugs/2015-04/msg02027.html
2015-10-09 11:55:36 +02:00
3b9765f858 Merge pull request #204 from dean0x7d/udl
User-defined literals for format and named arguments
2015-10-07 07:13:07 -07:00
bc6010cc21 Add _a literal for named arguments 2015-09-27 04:09:37 +02:00
a63a24f2d7 Add _format literal 2015-09-27 04:00:24 +02:00
50e9487e18 Merge branch 'master' of github.com:cppformat/cppformat 2015-09-18 16:26:53 -07:00
ef710dee6c Add sprintf overload for wide strings
and fix an issue in formatting user-defined objects.
Thanks to @ScottLangham
2015-09-18 16:26:41 -07:00
a12f49669c Add Stellar to the list of projects using C++ Format 2015-09-16 21:45:27 -07:00
42d8f5b994 Add redis-cerberus to the list of projects using cppformat 2015-09-16 21:33:51 -07:00
79d8f59906 Implement formatting of objects with (s)printf. 2015-09-08 08:36:20 -07:00
59155abbf3 Remove extra newline 2015-09-08 08:16:12 -07:00
d48047e4c0 Break long line 2015-08-31 08:22:25 -07:00
005379ac6f Don't include .buildinfo and .doctrees in the source package
Thanks to Dave Johansen.
2015-08-31 08:21:59 -07:00
75fdfe3e0e Make options that control target generation more consistent 2015-08-31 06:49:06 -07:00
6de8f4a416 Merge pull request #200 from maddinat0r/master
add CMake option to toggle doxygen documentation
2015-08-31 06:32:05 -07:00
06c1859420 add CMake option to toggle doxygen documentation 2015-08-30 14:23:54 +02:00
5bcd5ac6d6 Merge branch 'master' of github.com:cppformat/cppformat 2015-08-26 10:13:12 -07:00
4807f69ab4 Remove duplicate EXLUDE_SYMBOLS 2015-08-26 10:13:04 -07:00
c2ba9e191d Merge pull request #199 from maddinat0r/master
add generated "run-msbuild.bat" file to gitignore
2015-08-21 10:23:00 -07:00
edf5c26001 add generated "run-msbuild.bat" file to gitignore 2015-08-21 19:09:18 +02:00
b3714625c0 Fix compilation with FMT_PEDANTIC=ON 2015-08-19 08:03:17 -07:00
1bba22667e Fix build on CMake 2.6 2015-08-19 07:32:48 -07:00
d07fd577c3 FMT_SOURCE_FILES -> FMT_SOURCES 2015-08-19 07:27:34 -07:00
4274f15f0d Move test-specific stuff to test/CMakeLists.txt 2015-08-19 07:27:08 -07:00
0d99eb5d6b Merge pull request #198 from maddinat0r/master
add CMake option to toggle tests (on by default)
2015-08-19 06:49:53 -07:00
914b97859c add CMake option to toggle tests (on by default) 2015-08-19 10:41:37 +02:00
4150fa0f95 Fix formatting 2015-08-18 06:57:31 -07:00
4e2a0a7e1c Merge pull request #197 from maddinat0r/master
new CMake option to disable generating the install target
2015-08-18 06:34:09 -07:00
2161823559 add option to disable install 2015-08-17 18:48:16 +02:00
2923d7f588 Merge pull request #196 from jkflying/patch-1
Fix warnings
2015-08-17 06:24:47 -07:00
11395c4f09 Fix warnings
Child attribute was being instantiated before parent attribute, gives warnings under GCC 4.9.1
2015-08-17 13:59:45 +02:00
32fbc083b7 Add Touch Surgery to the list of projects using C++ Format 2015-08-08 18:58:25 -07:00
8c4483d3cb Try appveyor config without explicit platform 2015-08-07 07:39:56 -07:00
b247d81046 Fix warnings 2015-08-07 07:39:04 -07:00
c3ba615c65 Fix warnings 2015-08-07 07:34:58 -07:00
cdcdacef9c Handle undefined $PLATFORM 2015-08-07 07:21:43 -07:00
a8a2982b9a Fix test 2015-08-07 07:13:43 -07:00
2202541364 Disable configuration that doesn't work on appveyor 2015-08-07 07:12:22 -07:00
ca7478144d Fix warnings 2015-08-07 07:08:46 -07:00
43081b833a Build both on x86 and x64 2015-08-07 07:08:12 -07:00
2c6e32f6ff Simplify appveyor config 2015-08-07 06:41:07 -07:00
58fcf0c0da Optimize format_decimal 2015-08-05 07:50:29 -07:00
f6135df529 Merge the master branch 2015-08-04 20:59:24 -07:00
ecdc7ec1f1 Fix more warnings 2015-08-04 08:01:28 -07:00
7fa17fe772 Fix warnings 2015-08-04 07:55:33 -07:00
a8d12ade1c Append compile flags instead of overwriting 2015-08-04 07:46:15 -07:00
f9813c313d Merge pull request #191 from rpopescu/master
fixed #190 Argument shadowing and Clang pedantic support
2015-08-04 07:41:15 -07:00
5b8d0a7aa9 Make Coverity happy 2015-08-04 07:22:03 -07:00
64eb3d8bb2 Make Coverity happy 2015-08-04 07:09:00 -07:00
0affb23560 fixed #190 Argument shadowing and Clang pedantic support 2015-08-04 12:52:44 +02:00
1e8496da4a Keep our .travis.yml during merge
because it contains Coverity Scan configuration.
2015-07-31 09:38:08 -07:00
b634309a31 Merget the master branch 2015-07-31 08:58:32 -07:00
7e12c5c9df Use scoped_ptr instead of raw pointers in tests 2015-07-31 08:54:54 -07:00
2830cf65c9 Merge the master branch 2015-07-31 08:24:37 -07:00
d15e0d3e06 Use scoped_ptr instead of raw pointers in tests 2015-07-31 08:23:39 -07:00
b022790f3b Merge the master branch 2015-07-31 08:05:25 -07:00
922fe90ac3 Improve integer formatting performance
and fix bogus Coverity warning about uncaught exception in
format_error_code (via write_int).
2015-07-31 08:02:38 -07:00
fabd3a84c5 Don't build anything during coverity scan 2015-07-29 13:42:06 -07:00
611eb774ca Remove Coverity config from Travis
The config is now in the coverity_scan branch
2015-07-29 07:40:20 -07:00
45e7b5b672 Run Coverity scan on a single machine 2015-07-29 07:37:21 -07:00
4b6a52c6f8 Add Coverity scan to Travis CI 2015-07-29 07:18:43 -07:00
d02a5031f0 Use scoped_ptr instead of deprecated auto_ptr 2015-07-29 07:03:15 -07:00
200037683e Initialize next_arg_index_ in ctor (#187) 2015-07-28 08:10:46 -07:00
c4d0bc1ac9 Fix Coverity warnings 2015-07-28 07:18:14 -07:00
0eac037416 Get rid of the BasicFormatter::start_ 2015-07-28 06:46:41 -07:00
69a0317590 Merge pull request #189 from xentec/patch-1
Fixing doc building with newer pip versions
2015-07-26 13:55:35 -07:00
583f7e9e1c Fix build docs on with newer pip versions
A patch for 3b224e1813
2015-07-26 17:50:18 +02:00
0586a9e4ea Specify python version in doc build script
Some distros changed their default to python3 causing it to fail.
2015-07-26 17:48:26 +02:00
3b224e1813 Fix handling of pip show result when using new version of pip
which returns nonzero error code if the package is not installed.
2015-07-26 08:25:52 -07:00
76d1218345 Workaround a bug in MSVC2010 (#188)
Due to broken lookup rules, MSVC finds fmt::internal::check
instead of IsConvertibleToInt::check.
2015-07-10 07:58:27 -07:00
e498ffbb3d Fix rpmlint warning about unused dependency on libm.so.6 2015-07-10 07:02:50 -07:00
6cf24c7f92 Fix MSVC warnings 2015-07-08 08:04:32 -07:00
4f7ad14c2b Fix MSVC warning 2015-07-08 07:52:03 -07:00
f3bef7ac92 Fix open_buffered_file 2015-07-08 07:48:54 -07:00
b6c1c9233a Workaround an issue with VC2010 2015-07-08 07:36:36 -07:00
6484a15ca0 Fix MSVC warnings 2015-07-08 07:35:57 -07:00
c669cbedf8 Rename None to Null because of conflict with an xlib.h macro 2015-07-07 07:05:17 -07:00
7859f81233 Don't use pthreads if they are not available 2015-06-29 07:34:30 -07:00
0332284ce3 Fix MinGW build on Appveyor by changing search path order
C:\MinGW\bin should go first to prevent executables from older
version of MinGW in C:\MinGW\mingw32 being picked up.
2015-06-29 07:22:45 -07:00
7154238d45 Add terminating null character in UTF coverters 2015-06-27 09:11:15 -07:00
279749168a Try to work around an issue with msbuild caused by Appveyor update 2015-06-27 08:38:26 -07:00
ba09c1b56e Fix windows build 2015-06-26 09:23:11 -07:00
df0835ac27 Update docs 2015-06-26 09:09:23 -07:00
438bd9b0e6 Add BasicCStringRef to represent a null-termated string (#100)
and use it instead of BasicStringRef in cases that assume that the
string is null-terminated such as POSIX function and format string
parser.
2015-06-26 07:43:54 -07:00
88c7c20102 Fix posix-test on FreeBSD (#179) 2015-06-25 07:06:30 -07:00
761a0afb85 Correct path to doxyxml (#182) and break long line 2015-06-25 06:56:54 -07:00
5b9b485f57 Workaround a bug in MinGW 2015-06-24 11:36:28 -07:00
0a7e5141c1 Move posix tests from gtest-extra-test to a separate test 2015-06-24 09:16:03 -07:00
9769f4b9ed Refactor posix tests 2015-06-24 08:43:30 -07:00
e5b16e80cc Include sys/types.h for ssize_t 2015-06-24 07:59:19 -07:00
948317b6dd Fix FormatLongDouble test on PowerPC (#180) 2015-06-23 07:39:49 -07:00
958299dd7f Install format.h to '<prefix>/include/cppformat'
not to '<prefix>/include'. Thanks to Eugene V. Lyubimkin for the patch.
2015-06-23 06:49:35 -07:00
b88a17ad9e libformat.{a.so} -> libcppformat.{a.so}
as suggested by Eugene V. Lyubimkin to make the name less generic
2015-06-23 06:40:22 -07:00
abcc2d96f0 Fix assertion tests 2015-06-22 09:24:54 -07:00
8ab665afbc Only use death tests if available 2015-06-22 08:17:23 -07:00
8450f5e1d3 FormatIntTest: FormatDec: don't assume signedness of char type
Thanks to Eugene V. Lyubimkin for the patch.
2015-06-22 07:03:26 -07:00
2e874af293 Move CSS compilation to build.py for use by Travis 2015-06-22 06:54:29 -07:00
dd6a3bbc7c Fix out-of-tree documentation build (#177) 2015-06-22 06:40:21 -07:00
a0ed6bfe4f Break long line 2015-06-17 08:07:05 -07:00
e39490500c Replace implicit conversion to std::string with to_string 2015-06-17 07:59:41 -07:00
147e5ebbbc Move casts to CharTraits for custom character types 2015-06-17 07:21:16 -07:00
270069beda Use arg visitor when formatting printf argument
and get rid of ignore_incompatible_str.
2015-06-16 07:36:32 -07:00
9b6b3382e3 Don't use ignore_incompatible_str in ArgFormatter 2015-06-15 07:15:28 -07:00
63f6c10449 Suppress a warning about unused strerror_r. 2015-06-14 09:36:23 -07:00
8725d07d8b Place the anonymous namespace within the fmt namespace
for header-only configuration as suggested by Alf Steinbach.
2015-06-12 07:56:58 -07:00
24c309fbfa Don't use windows.h if FMT_USE_WINDOWS_H is set to 0 2015-06-12 07:15:57 -07:00
9d09214e7a Use textual representation for bool by default (#170) 2015-06-11 09:00:06 -07:00
fd5c2e909b Report error when using precision with char 2015-06-11 08:58:31 -07:00
fccff7be5f Minor tweaks to the named arguments support code
* Restore privacy of FormatterBase
* Pass BasicStringRef by value
* Comment on why some overloads of arg are deleted
* Set next_arg_index_ in check_no_auto_index
* A few minor stylistic changes for simplicity & consistency with other code
2015-06-11 07:19:00 -07:00
b83ab16676 Break long lines 2015-06-11 06:14:42 -07:00
e5005c98b0 Merge branch 'master' of github.com:cppformat/cppformat 2015-06-11 06:10:26 -07:00
834618ee28 Merge pull request #174 from jamboree/feature/named-arg
Fix name parsing
2015-06-11 06:03:34 -07:00
3c99ed4498 Fix name parsing 2015-06-11 12:03:22 +08:00
2e254ad19d arg_index -> arg_id 2015-06-10 09:08:49 -07:00
a98583dde3 Move ArgList::Map to the internal namespace and rename to ArgMap
since it shouldn't be a part of the public API. Also break long lines.
2015-06-10 08:49:22 -07:00
4325c155f7 Improve documentation
* Fix formatting in `fmt::arg` apidoc
* Use production syntax instead of regex
* Rename arg_field to arg_id because the term "field" denotes the whole replacement field
* Define `integer`
2015-06-10 07:33:17 -07:00
83659f425b Merge pull request #173 from jamboree/feature/named-arg
Support named arguments
2015-06-10 06:38:27 -07:00
7487bde587 Support named arguments 2015-06-10 09:32:59 +08:00
ed2dfe5124 Implement writing narrow strings into a wide writer 2015-06-09 08:20:44 -07:00
8949a2e941 Fix formatting 2015-06-08 06:53:18 -07:00
a5e7d08ad0 Merge branch 'master' of github.com:cppformat/cppformat 2015-06-04 12:52:49 -07:00
99edb141ec Don't try updating cppformat.github.io without permissions 2015-06-04 12:52:42 -07:00
03bf6dea67 Merge pull request #168 from jamboree/master
Support runtime width specification
2015-06-04 09:23:15 -07:00
54a6cb34c7 Support runtime width specification 2015-06-04 13:59:37 +08:00
d311927c64 Update Breathe and document BasicArrayWriter(Char (&array)[SIZE])
Fixes #125
2015-06-03 18:21:01 -07:00
4d521064cf Give an error if fill is not convertible to Char in StrFormatSpec 2015-06-03 08:39:43 -07:00
d8a3b74664 Simplify download with urllib.urlretrieve 2015-05-24 08:03:22 -07:00
ce5ab7d68f Exclude internal symbols from the docs 2015-05-24 07:48:22 -07:00
5a61d54eb7 Install newer version of Doxygen because of a bug in version 1.7.6.1 (#162) 2015-05-24 07:48:06 -07:00
3310849fa0 Don't use placeholder on the search page 2015-05-23 13:41:21 -07:00
f478f7f490 Comment 2015-05-23 13:34:44 -07:00
b902efd870 Update classes 2015-05-23 12:48:09 -07:00
921f1bae46 .container -> .tb-container (fixes #165) 2015-05-23 12:28:41 -07:00
079c6442e1 Fix HTML errors 2015-05-23 11:59:04 -07:00
9e83b8a6e0 Move Google analytics block to the top
because according to Google:

One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the section, and we recommend placing the snippet at the bottom of the section for best performance.
2015-05-23 11:42:57 -07:00
e1fcb0a2b5 Remove doctype and add meta tags 2015-05-23 11:38:36 -07:00
eaf30d5b0d Move "What users say" to the front page 2015-05-23 08:33:55 -07:00
9af6c41684 Use template comments because they are removed from output 2015-05-23 08:31:29 -07:00
9ca1ce293e Make instantiation of BasicData consistent with its definition 2015-05-23 08:04:06 -07:00
bfe9267d4d Bootstrapify 2015-05-22 19:21:55 -07:00
42001e541e Add basic-bootstrap theme 2015-05-22 19:12:45 -07:00
ba994e78ec Use dev instead of version for the development version 2015-05-22 07:50:46 -07:00
f5f9f50f87 Update links 2015-05-22 07:24:23 -07:00
63572da4e7 Fix formatting 2015-05-22 07:22:55 -07:00
78936ad6d7 Fix formatting 2015-05-22 07:08:16 -07:00
eb50269744 Update the documentation link 2015-05-22 06:50:46 -07:00
c389ec05a1 Redirect from RTD to GitHub Pages 2015-05-22 06:47:05 -07:00
e4c0046a99 Update documentation links 2015-05-22 06:41:03 -07:00
dfe2a65b5d Remove diagnostics and re-enable build configs 2015-05-21 20:25:15 -07:00
efba235246 Regenerate key and prevent leakage 2015-05-21 19:29:45 -07:00
0022e0b40f Update key 2015-05-21 19:11:32 -07:00
44fabfc803 Add diagnostics 2015-05-21 19:01:47 -07:00
e15eae012c Fix travis config 2015-05-21 09:13:35 -07:00
5d570d7ee9 Add a travis key 2015-05-21 09:05:34 -07:00
9f60609405 Customize search 2015-05-21 09:03:22 -07:00
37141a1e3f Install less-plugin-clean-css 2015-05-21 08:26:36 -07:00
719208c24b Now do the same as root 2015-05-21 08:14:47 -07:00
3e49279267 Add APT key 2015-05-21 08:03:00 -07:00
595845153d Fix nodesource.list creation 2015-05-21 07:20:26 -07:00
f77b00e1f7 Try installing new version of lessc 2015-05-21 07:04:56 -07:00
eb20f8aece Try installing lessc 2015-05-20 18:22:53 -07:00
1456a496f0 Hide the navbar search box on the Search page 2015-05-20 18:22:35 -07:00
fbc2fcb3e2 Create a link for node_modules 2015-05-20 12:29:47 -07:00
fca83df599 Support old version of pip installed on Travis, take 2 2015-05-20 11:45:16 -07:00
6955417236 Support old version of pip installed on Travis 2015-05-20 11:10:16 -07:00
469f3674cf Ignore build files and simplify building docs locally 2015-05-20 08:28:54 -07:00
702e53d7a8 Correct excludes 2015-05-20 08:07:46 -07:00
f9936c4859 Build docs on travis 2015-05-20 08:06:12 -07:00
abba1477a7 Remove duplicate namespace 2015-05-19 18:38:21 -07:00
183ce52c41 Improve style 2015-05-19 18:20:27 -07:00
86aa72f3d5 Fixed unresolved references 2015-05-19 18:04:32 -07:00
0ba61ffa6d Improve style 2015-05-19 17:58:04 -07:00
c17f4ec099 Make sure the navbar content is not shifted because of scrollbars
https://github.com/twbs/bootstrap/issues/1648
2015-05-19 08:30:16 -07:00
56d5335e3f Merge branch 'master' of github.com:cppformat/cppformat 2015-05-19 08:13:29 -07:00
18a55cdb27 Customize Sphinx theme 2015-05-19 08:13:13 -07:00
4c1a0303aa Create and keep virtualenv in the current (build) directory 2015-05-18 08:09:26 -07:00
0e28acdd05 Update Sphinx to 1.3.1 to fix local search 2015-05-18 07:24:33 -07:00
4d1bd5ac18 Merge pull request #161 from syohex/correct-misspelling
Correct misspellings
2015-05-15 08:05:05 -07:00
0ba03ee823 Correct misspellings 2015-05-15 15:57:22 +09:00
2c03e822b2 Add a link to API changes/compatibility report 2015-05-14 14:18:59 -07:00
804a74c998 Explicitly instantiate BasicData<void>
https://github.com/ampl/mp/issues/55#event-305206703
2015-05-14 12:58:42 -07:00
90a12b1bb2 Fix warnings 2015-05-12 08:57:21 -07:00
a5757c86df FMT_EXTRA_TESTS -> FMT_PEDANTIC and use it to control extra warnings 2015-05-12 07:35:29 -07:00
5517c8962e Use -std=gnu++11 if -std=c++11 is broken (for MinGW) 2015-05-12 07:13:12 -07:00
684495c887 Add header files to gmock target 2015-05-12 06:53:35 -07:00
640445fc48 FMT_CPP11_IO_H -> FMT_CPP11_UNISTD_H and enable all build configs 2015-05-11 19:48:30 -07:00
e17b743141 Workaround a MinGW bug 2015-05-11 19:37:40 -07:00
c8688576f2 Fix MinGW build 2015-05-11 19:10:31 -07:00
024f8c6a0a Disable MinGW build until the remaining issues are solved 2015-05-11 09:12:34 -07:00
8035c3eb30 Workaround a bug in the definition of fstat on some versions of MinGW 2015-05-11 08:44:40 -07:00
15de5f68b4 Enable debug MinGW build 2015-05-11 08:10:13 -07:00
3913f29ad7 Fix posix-test on MinGW 2015-05-11 07:57:08 -07:00
2da08f21dd Only run compile-test if FMT_EXTRA_TESTS is set
These tests can be quite time-consuming especially on Windows
2015-05-11 07:34:07 -07:00
0e5c8e5395 Move chat link to the end 2015-05-11 07:15:11 -07:00
ea9a31b225 Merge pull request #160 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.rst
2015-05-11 07:14:10 -07:00
dd8e6b9a72 Added Gitter badge 2015-05-11 01:02:26 +00:00
c150722945 Fix compiler warnings about unused parameter (#158)
Thanks to @fmatthew5876
2015-05-08 11:20:56 -07:00
f3fc8052ab Add a section on how to install the library using Homebrew
Thanks to @ortho for adding C++ Format support to Homebrew.
2015-05-08 08:19:15 -07:00
3e03934d15 If std::swprintf is broken, disable relevant test and warn about it 2015-05-08 07:57:43 -07:00
85b985e9f2 Workaround a bug in formatting long double in MinGW, take 3 2015-05-07 08:17:30 -07:00
3e379829a0 Workaround a bug in formatting long double in MinGW, take 2 2015-05-07 07:25:39 -07:00
4888000f32 Fix a warning 2015-05-07 07:19:28 -07:00
673a4525f6 Workaround a bug in formatting long double in MinGW 2015-05-07 07:18:46 -07:00
1c72e7062b Update the license section 2015-05-07 06:47:22 -07:00
6de2edf05b Link to rendered instead of raw license file 2015-05-07 06:45:13 -07:00
fde90aa551 Move license to a separate file
This is done to follow Fedora guidelines:
https://fedoraproject.org/wiki/Packaging:LicensingGuidelines#License_Text

Also rename the Python license used in the docs to python-license.txt to
avoid confusing extension.
2015-05-07 06:43:13 -07:00
40681e6037 Fix compilation of posix-test on MinGW 2015-05-06 07:29:58 -07:00
ca2cadb1c6 Fix compilation when fileno is a macro
This can happen on broken versions of MinGW.
2015-05-06 07:19:42 -07:00
11464343a9 Fix handling of exactly MAX_PACKED_ARGS arguments 2015-05-05 10:00:11 -07:00
3c388185c0 Remove old TODO 2015-05-05 07:25:42 -07:00
f5b3c9cbec Simplify construction of ArgList objects 2015-05-05 07:23:32 -07:00
de994a27a7 Remove internal::NonZero 2015-05-01 07:58:32 -07:00
e515e5f14e Simplify construction of argument lists 2015-05-01 07:35:28 -07:00
87cb2935f8 Test and fix handling of exactly MAX_PACKED_ARGS arguments 2015-05-01 06:55:26 -07:00
969d1cdbdc Break long line 2015-04-30 08:41:17 -07:00
67ce394256 Undefine Windows min/max macros (#152)
because they break std::min/max. This only affects non-default
header-only configuration and can be disabled by defining
FMT_WIN_MINMAX.
2015-04-30 07:48:36 -07:00
f44666aac6 Remove extra parentheses 2015-04-30 07:35:04 -07:00
001054c8a0 Update README.rst 2015-04-27 07:02:15 -07:00
926b7680ea Cleanup 2015-04-21 07:17:00 -07:00
8af48bbaf1 Merge pull request #149 from cppformat/compact-arglist
Compact arglist
2015-04-21 07:05:54 -07:00
8d2559bd96 Reduce compiled code size
If the number of arguments is less than MAX_PACKED_ARGS, pass
the arguments as a Value array rather than Arg array.
2015-04-20 10:02:41 -07:00
62c483c940 Test EnableIf 2015-04-20 08:08:02 -07:00
88f4be3d19 Merge branch 'master' of github.com:cppformat/cppformat 2015-04-18 19:16:16 -07:00
c3ebcce89d Make library install dir configurable via FMT_LIB_DIR CMake var 2015-04-18 19:15:36 -07:00
0963fd0a4d Workaround a bug in implementation of variadic templates in MSVC11 2015-04-12 14:33:11 -07:00
cea64132a2 Detect tuple 2015-04-12 07:02:49 -07:00
f6823221d3 Workaround broken tuple in MSVC11 2015-04-12 06:45:40 -07:00
f35a220536 Remove .gitmodules 2015-04-10 08:44:53 -07:00
8c24a42395 Make documentation builds more reproducible by using virtualenv 2015-04-10 08:39:09 -07:00
dc3039a40d Merge branch 'master' of github.com:cppformat/cppformat 2015-04-09 07:22:19 -07:00
d2ada77ccc Install documentation 2015-04-09 07:21:42 -07:00
3a0624ab2e Update README.rst 2015-04-08 09:11:25 -07:00
fb362ef880 Set .so version for libformat 2015-04-08 07:13:06 -07:00
fd53bb6fb8 Fix bogus "conditional expression is constant" MSVC warnings 2015-04-05 11:27:07 -07:00
aab64b55a4 Update README.rst
Compile code size is actually two times smaller compared to IOStreams
2015-04-02 08:49:28 -07:00
d2387999ec Try fixing a bogus MSVC warning about buffer overrun (#145) 2015-03-28 17:52:17 -07:00
60405cf693 Use /W4 in format-test and only if FMT_EXTRA_TESTS is set
as (1) we don't want to force /W4 on users of the library and (2) some of
the warnings only show up when the formatting functions are used.
2015-03-28 17:29:12 -07:00
9c75d0ccf7 Compile with /W4 in MSVC 2015-03-28 13:21:49 -07:00
3a5573ac6e Revert commit 3c3ae4e319 2015-03-27 07:36:26 -07:00
d4ea2d7fcb Add ArgVisitor::report_unhandled_arg
and get rid of FMT_RETURN_AFTER_THROW.
2015-03-26 08:55:20 -07:00
d618f8baac Fix NonZero 2015-03-25 09:29:40 -07:00
885d1a1c64 Simplify NonZero 2015-03-25 08:50:48 -07:00
2ba3988da3 Reduce compiled code size when using variadic templates 2015-03-25 08:29:55 -07:00
66915785dd Get rid of FMT_NORETURN because it breaks when FMT_EXCEPTIONS=0 2015-03-25 07:24:26 -07:00
3c3ae4e319 MakeValue -> MakeArg 2015-03-25 07:04:16 -07:00
00df5c91f3 Merge Value into Arg 2015-03-25 06:48:21 -07:00
cf04d98d06 Pass as many types as possible in a single integer to reduce code bloat 2015-03-24 08:55:40 -07:00
1addec97bc Rename _ERR to ERROR_STR
Identifiers beginning with an underscore and an uppercase letter are
reserved [17.4.3.2.1].
2015-03-21 20:16:36 -07:00
da052ae821 Fix bogus warnings 2015-03-21 07:53:39 -07:00
72aae04adf Merge pull request #141 from Shauren/master
Support formatting more than 16 arguments with printf API when using variadic templates
2015-03-21 06:29:53 -07:00
a445e727c2 Added support to format more than 16 arguments with printf API when using variadic templates 2015-03-20 21:31:10 +01:00
45bba4f129 Document protected members of Buffer 2015-03-20 06:46:39 -07:00
73ea170966 Document the Buffer class 2015-03-20 06:42:55 -07:00
906432161b Make Buffer part of the public API 2015-03-20 06:31:24 -07:00
b9f4668855 Add missing pragma diagnostic push for clang
Thanks to @ido
2015-03-19 08:04:31 -07:00
ba81f04bfa Turn verbose output off in travis 2015-03-19 08:03:20 -07:00
100bc30773 Reset CMAKE_REQUIRED_FLAGS 2015-03-19 07:59:12 -07:00
df477565f8 Diagnose clang failures 2015-03-19 07:51:10 -07:00
a53ac7ad5c Workaround mingw bugs 2015-03-19 07:39:24 -07:00
f49ab8e4a9 Detect broken cmath 2015-03-19 07:34:50 -07:00
0e8fcd47a0 Silence warnings about convering float to int 2015-03-18 18:59:09 -07:00
bf8636c959 Fix compile error on clang when formatting a C++11-style enum
Thanks to @Naios.
2015-03-18 11:08:34 -07:00
2adbfa4af7 Test IsConvertibleToInt with a C++11 enum 2015-03-18 11:02:37 -07:00
23b60f5735 Merge pull request #138 from Naios/build1
Fix build under g++-4.9, SunOS 5.11 i386 i86pc Solaris
2015-03-18 05:53:12 -07:00
ef7d4879e4 Fix build under g++-4.9, SunOS 5.11 i386 i86pc Solaris
* thanks @VolodymyrLavrenchuk for pointing this out.
2015-03-18 10:34:47 +01:00
33ec5b16d8 Don't match bool because it causes undesirable conversions 2015-03-17 20:51:29 -07:00
275d1ab423 Fix warnings on lesser compilers 2015-03-17 20:43:55 -07:00
107a95c9cc Merge branch 'master' of github.com:cppformat/cppformat 2015-03-17 20:12:44 -07:00
3d4af9cd65 Use `long double instead of int` to avoid warnings 2015-03-17 20:12:36 -07:00
ef5972e1ca Update README.rst 2015-03-17 19:43:47 -07:00
d99c49b970 Merge branch 'master' of github.com:cppformat/cppformat 2015-03-17 07:57:39 -07:00
538c2610cb Move FMT_USE_VARIADIC_TEMPLATES definition to macro-test.cc 2015-03-17 07:57:30 -07:00
8ed6031457 Add a comment describing the use of -std=c++11 2015-03-17 07:56:55 -07:00
a6aa789f4b Merge pull request #136 from Gachapen/fix_initializer_list_check
Fix CMake FMT_INITIALIZER_LIST check failing because of wrong include name.
2015-03-17 06:48:52 -07:00
b739ec893f Fix CMake FMT_INITIALIZER_LIST check failing because of wrong include name. 2015-03-17 10:15:54 +01:00
357950e06b Fix warnings on braindamaged compilers (aka MSVC) 2015-03-16 19:02:25 -07:00
df47d819b9 Suppress bogus MSVC warning 2015-03-16 18:53:14 -07:00
a530052b7e Only include crtdbg.h when compiling with MSVC 2015-03-16 18:05:45 -07:00
eccd5e8d15 Fix test 2015-03-16 09:17:18 -07:00
93ae73adbc Fix a typo 2015-03-16 09:05:46 -07:00
2b793d2d1e Merge branch 'master' of github.com:cppformat/cppformat 2015-03-16 08:52:31 -07:00
5aecd4947f Use GetFileSize instead of GetFileSizeEx on Windows 2015-03-16 08:52:23 -07:00
c6d3a73201 Workaround MinGW's braindamage 2015-03-16 08:43:59 -07:00
4825fb4a0d Add default value for None's template argument 2015-03-16 08:43:33 -07:00
eb6baf04ff Update README.rst 2015-03-15 06:39:03 -07:00
d08c4ba84a Merge branch 'master' of github.com:cppformat/cppformat 2015-03-15 06:35:06 -07:00
4547523e19 Make dummy strerror_r and strerror_s inline and remove old comment 2015-03-15 06:34:59 -07:00
e65e05b960 Merge pull request #134 from CarterLi/master
Improve behaviors when disabling exceptions
2015-03-15 06:21:28 -07:00
80d1dd29b7 Feedback 2015-03-15 09:31:13 +08:00
c97c0fbbc9 Merge remote-tracking branch 'upstream/master' 2015-03-15 09:23:19 +08:00
e1776acd19 Handle the result of XSI-complint version of strerror_r correctly 2015-03-14 14:05:02 -07:00
341b98c6e2 Detect safe strerror variants using function overloading instead of macros 2015-03-14 13:39:33 -07:00
2d4631a580 Silence -Wunused-parameter 2015-03-14 14:54:37 +08:00
593d3aef9e Improve behaviors when disabling exceptions 2015-03-14 14:37:02 +08:00
b8c36498f2 Temporarily disable mingw build 2015-03-12 09:06:50 -07:00
97b33fe069 More mingw fixes 2015-03-12 08:57:25 -07:00
82a3e78e04 Indent 2015-03-12 08:57:00 -07:00
9f19796ef0 Remove extra #endif 2015-03-12 08:37:07 -07:00
23b7bfead0 More mingw fixes 2015-03-12 08:29:28 -07:00
57f9f06619 More mingw fixes 2015-03-12 08:11:04 -07:00
03ee6a0295 Fix mingw build 2015-03-12 08:00:56 -07:00
6bca5ca109 Woraround a bug in MinGW 2015-03-12 07:49:01 -07:00
b2207f9d05 Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/ 2015-03-12 07:24:15 -07:00
752580a5c2 Move sys/types.h include to posix.h for MinGW 2015-03-12 07:09:44 -07:00
93cfe9951b Woraround for braindamaged versions of MinGW 2015-03-12 06:48:14 -07:00
6dd532b456 Add mingw bin directory to path and enable mingw build 2015-03-12 06:13:51 -07:00
3b259b5120 Disable mingw build again 2015-03-11 09:04:55 -07:00
870f42e1f0 Enable mingw build with extra diagnostics 2015-03-11 07:10:43 -07:00
e3a1da5a71 Temporarily disable mingw build 2015-03-10 10:17:08 -07:00
da547f5533 Fix mingw build, take 2 2015-03-10 09:43:12 -07:00
961097315c Fix mingw build 2015-03-10 09:18:31 -07:00
f9e1c2bd59 Use preinstalled mingw on appveyor 2015-03-10 08:52:39 -07:00
8c8826f749 Merge branch 'master' of github.com:cppformat/cppformat 2015-03-10 07:53:57 -07:00
5821aec7b9 Implement printing of values that are convertible to int such as enums 2015-03-10 07:53:46 -07:00
689ea8d3dd Merge pull request #130 from cstamford/master
Added the define FMT_SWPRINTF to allow compilation under TDM-gcc (and po...
2015-03-10 06:34:07 -07:00
55836caa8d Added the define FMT_SWPRINTF to allow compilation under TDM-gcc (and possibly other MinGW distributions). 2015-03-10 07:04:31 +00:00
a037a829f5 Update README.rst 2015-03-09 09:29:46 -07:00
7e251643db Update README.rst 2015-03-09 08:48:08 -07:00
08d759c425 Merge branch 'master' of github.com:cppformat/cppformat 2015-03-09 07:37:34 -07:00
6af3da1089 Merge website content into docs 2015-03-09 07:37:27 -07:00
eec6b29b64 Update ChangeLog.rst 2015-03-06 08:58:54 -08:00
0b097da31e Set release date 2015-03-06 08:33:25 -08:00
f9e98c2007 Merge branch 'master' of github.com:cppformat/cppformat 2015-03-06 08:30:38 -08:00
2d80bcc1cb Bump version 2015-03-06 08:30:30 -08:00
fa5b35e539 Update ChangeLog.rst 2015-03-06 08:17:13 -08:00
549b61e958 Update ChangeLog.rst 2015-03-06 08:15:11 -08:00
2d200e3caa Update ChangeLog.rst 2015-03-06 08:14:19 -08:00
3252eead94 Update ChangeLog.rst 2015-03-06 08:03:34 -08:00
d82b6c7e62 Update ChangeLog.rst 2015-03-06 08:03:11 -08:00
55ba812d12 Update ChangeLog.rst 2015-03-06 07:52:51 -08:00
5463a62d43 Update ChangeLog.rst 2015-03-06 07:52:06 -08:00
9350328086 Update ChangeLog.rst 2015-03-06 07:32:28 -08:00
9d1fc0ecd5 Update ChangeLog.rst 2015-03-06 07:18:44 -08:00
9c006520bd Break long lines 2015-03-05 08:15:26 -08:00
8ad6f93428 Update changelog 2015-03-05 08:04:27 -08:00
72c97ab4ab Add missing '>' 2015-03-05 07:31:27 -08:00
bcc2fd1dbe Fix markup 2015-03-05 07:30:50 -08:00
a89f578c14 Update changelog 2015-03-05 07:29:54 -08:00
6005907db6 Fix markup 2015-03-05 07:27:14 -08:00
53dd7d1583 Update changelog 2015-03-05 07:26:44 -08:00
65a8a7f85e Fix markup 2015-03-04 19:03:56 -08:00
89e0684da6 Update changelog 2015-03-04 19:02:59 -08:00
a5c6975118 Use issue numbers instead of links 2015-03-04 18:50:46 -08:00
ec7b006fab Update changelog 2015-03-04 18:49:23 -08:00
c1f8274701 Copy info from releases to changelog 2015-03-04 18:30:00 -08:00
91d9497911 Fix markup 2015-03-04 18:16:26 -08:00
3453df6d65 Add a changelog 2015-03-04 18:10:08 -08:00
648c730bd2 CMake should be now preinstalled on OS X
https://github.com/travis-ci/travis-ci/issues/2408
2015-03-04 15:15:31 -08:00
8abc15f85e Fix a reference 2015-03-04 14:04:10 -08:00
4ff6ab396c Fix biicode build script 2015-03-04 09:24:54 -08:00
14d1fb561f Don't run biicode on Travis 2015-03-04 09:22:52 -08:00
7ae6dfbcba Fix cmake command 2015-03-04 08:57:56 -08:00
bdada10c2c Only run biicode-build on Linux and print cmake version 2015-03-04 08:53:51 -08:00
65cf5414c9 Temporarily disable biicode build 2015-03-04 08:33:13 -08:00
cb40e7c60b Fix biicode-build script 2015-03-04 08:24:35 -08:00
3a9b7ad8b6 Pass env to bii 2015-03-04 08:07:26 -08:00
38b5f573dd Set CMAKE_ROOT 2015-03-04 08:01:56 -08:00
5ad6c6bd7f Use correct path to CMake bin directory, take 2 2015-03-04 07:51:09 -08:00
85ef48cb6d Use correct path to CMake bin directory 2015-03-04 07:36:30 -08:00
a6864a7264 Fix CMake installation and enable biicode build 2015-03-04 07:07:13 -08:00
0dd1f19281 Temporarily disable biicode build 2015-03-03 22:24:34 -08:00
7c8f915f0b Sudo make me a sandwich 2015-03-03 22:19:56 -08:00
e1b62a5d39 Install CMake in system dirs 2015-03-03 22:12:37 -08:00
4d208ae86f Install newer version of cmake 2015-03-03 22:07:20 -08:00
29451ea8e2 Update travis config 2015-03-03 21:49:33 -08:00
e6113fb9f5 Rewrite biicode build script in Python and simplify 2015-03-03 21:45:47 -08:00
7c0a23329e Update copyright notices 2015-03-03 21:04:45 -08:00
f1e77e41a5 Update breathe 2015-03-02 08:34:22 -08:00
267d4542bb Remove unnecessary stuff from biicode-build.sh 2015-03-02 07:54:13 -08:00
ee5443e920 Move biicode files to support/biicode 2015-03-02 07:48:57 -08:00
103530d407 Fix formatting 2015-03-01 20:58:45 -08:00
efc42fbd4e Temporary exclude fancy ctor from the docs 2015-03-01 18:25:40 -08:00
7c0d5756ff Fix clang build 2015-03-01 18:19:56 -08:00
91a7ee6c20 Add BasicArrayWriter to docs 2015-03-01 18:10:09 -08:00
74512aa282 Ignore bin directory 2015-03-01 18:09:03 -08:00
beaf6f7436 Add a fixed-size array writer 2015-03-01 18:08:24 -08:00
63b4f0ae1a build.py -> appveyor-build.py 2015-03-01 17:20:22 -08:00
5bea8a649b Move biicode C++ Format sample to support/biicode/sample.cc 2015-03-01 17:12:14 -08:00
2e3423b053 Update compile-test 2015-03-01 17:03:44 -08:00
1244f3d58f Move biicode.cmake to support/cmake 2015-03-01 17:00:53 -08:00
656f0895ed Add readme 2015-03-01 16:48:08 -08:00
5a51aac85e Move biicode build script to support/biicode-build.sh 2015-03-01 16:46:44 -08:00
c3e845ab7e Only enable doc target if breathe is available 2015-03-01 16:35:29 -08:00
ce4d3e175c Fix biicode build 2015-03-01 16:23:47 -08:00
fb86e4f6fa Remove conf.py from .gitignore 2015-03-01 16:16:18 -08:00
da6ac7fb26 Fix tests 2015-03-01 16:12:26 -08:00
07754c047c Place executables in the bin dir 2015-03-01 16:07:18 -08:00
67089022bf Run test commands during CI builds 2015-03-01 15:21:33 -08:00
4df5d10e3c Check if initializer lists are supported 2015-03-01 14:14:06 -08:00
8a915b9b8d Update compile-test 2015-03-01 14:13:45 -08:00
8f1e5df672 Merge branch 'master' of github.com:cppformat/cppformat 2015-03-01 09:43:44 -08:00
c09c42f9a7 Don't do explicit instantiation in the header-only mode 2015-03-01 09:43:33 -08:00
86a7d856fa Update README.rst 2015-02-26 09:05:20 -08:00
391d6430e5 Update README.rst 2015-02-26 08:10:36 -08:00
a8a7534f78 Reorder function declarations
Obey your inner OCD
2015-02-26 06:54:12 -08:00
110d4c0ab0 Replace CharTraits::UnsupportedStrType with WCharHelper::Unsupported 2015-02-26 06:32:00 -08:00
17b9e4db8c Improve error reporting when trying to write wchar_t with a char writer 2015-02-26 06:21:54 -08:00
52f44bf114 Fix clang warning
warning: unknown warning group '-Wdocumentation-unknown-command',
ignored [-Wunknown-pragmas]
2015-02-25 17:32:32 -08:00
fede517b22 Don't define _CRT_SECURE_NO_WARNINGS if it is already defined
This is done to avoid warnings.
2015-02-25 17:20:26 -08:00
c746122623 Remove extra whitespace 2015-02-25 16:23:11 -08:00
ed490145d8 Improve error reporting when trying to format wide char into narrow string 2015-02-25 16:03:00 -08:00
f3fe82415d Merge branch 'master' of github.com:cppformat/cppformat 2015-02-25 09:50:53 -08:00
d5602d9fb6 Remove unnecessary call to convert 2015-02-25 09:50:39 -08:00
7716157bdb Update README.rst 2015-02-25 09:00:31 -08:00
e70af5b99e Merge branch 'better-errors' 2015-02-25 08:00:46 -08:00
f014d32147 Improve error reporting when formatting wide into narrow strings 2015-02-25 07:58:49 -08:00
bf14b2c41b Try improving error reporting
when formatting wide strings into narrow.
2015-02-25 07:43:47 -08:00
f6cffb5eeb Indent 2015-02-25 06:17:12 -08:00
c634a5bf2b Merge branch 'master' of github.com:cppformat/cppformat 2015-02-25 06:16:08 -08:00
f8fd34ac30 Merge pull request #121 from objectx/VC2013
Avoid error C2156 under VC++2013
2015-02-25 06:15:09 -08:00
c2bcb31354 Avoid error C2156 under VC++2013 2015-02-25 20:40:28 +09:00
7215c3446b Break long lines 2015-02-24 16:44:01 -08:00
642b72cd91 Fix StringRef test 2015-02-24 09:52:16 -08:00
89fed501d4 Merge branch 'master' of github.com:cppformat/cppformat 2015-02-24 08:32:12 -08:00
28fd7fb159 Fix formatting (-Gangnam- Google style) 2015-02-24 08:31:56 -08:00
85833c90ee Merge pull request #119 from TrentHouliston/master
Add an install command to the cmake file (to allow make install)
2015-02-24 05:55:46 -08:00
4da1fa391e Add an install command to the cmake file (to allow make install) 2015-02-24 17:31:30 +11:00
de92f5d8a7 Update README.rst 2015-02-22 11:46:58 -08:00
d06ff7a7e8 Fix internal::clzll on Win64 2015-02-22 06:31:55 -08:00
a81baf2904 Merge branch 'master' of github.com:cppformat/cppformat 2015-02-22 06:29:33 -08:00
810c734c3f Merge pull request #118 from CarterLi/master
Emulate _BitScanForward64 on WIN32
2015-02-22 06:29:19 -08:00
524222f094 Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
Implementation used: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/support.h?view=markup#l135
2015-02-22 17:48:19 +08:00
016adee06c Simplify sample 2015-02-21 16:15:47 -08:00
2b35c9e8e7 Move CMake files to support 2015-02-21 16:02:44 -08:00
cbc46d9e78 Use __builtin_clz whenever it is available 2015-02-21 06:21:29 -08:00
e87a24633b Don't use builtin_ in function names as they are not builtins 2015-02-21 06:16:49 -08:00
14eae59c6a Correct FMT_BUILTIN_CLZ definition 2015-02-20 08:58:16 -08:00
2418a84f02 Cleanup 2015-02-20 08:51:01 -08:00
27e0bf72c0 Use correct intrinsics for count_digits 2015-02-20 08:49:06 -08:00
939193be21 Merge pull request #116 from CarterLi/master
Use MSVC intrinsics for better performance
2015-02-20 08:22:06 -08:00
00e3ae508e Use MSVC intrinsics for better performance 2015-02-20 11:19:01 +08:00
bc33d17ce3 Update README.rst 2015-02-19 08:40:40 -08:00
65cd4835cd Update README.rst 2015-02-19 08:26:03 -08:00
53010624a0 Move Windows implementation of print_colored to a separate branch
as it needs further testing.
2015-02-19 07:54:59 -08:00
a92205be9c Remove unused policy setting 2015-02-17 14:42:11 -08:00
a16ca84346 Use mirror 2015-02-17 09:19:49 -08:00
f40f790159 Merge branch 'master' of github.com:cppformat/cppformat 2015-02-17 09:17:21 -08:00
88835f8468 Fix mingw download URL 2015-02-17 09:16:50 -08:00
5b0a9bbe85 Improve StringRef test 2015-02-17 06:45:45 -08:00
6a52fc164a Merge pull request #114 from CarterLi/master
Silence warnings on Windows
2015-02-17 06:39:21 -08:00
b4df6cb2fa Add libstdc++ version 2015-02-17 06:24:40 -08:00
932eb9777e Fix formatting, take 2 2015-02-17 06:15:44 -08:00
4a1974577f Fix formatting 2015-02-17 06:14:32 -08:00
dfad5f1d39 Update README.rst 2015-02-17 06:12:44 -08:00
3f574c1611 Silence warnings on Windows 2015-02-17 10:11:42 +08:00
8d07db0e0e Break long line 2015-02-16 14:33:04 -08:00
bd133382f0 Fix BasicWriter::write without formatting arguments on C++11 (#109) 2015-02-16 14:32:38 -08:00
040b8e7e06 Link to Android NDK 2015-02-16 07:25:45 -08:00
d9ef0e0a44 Minor correction 2015-02-16 07:11:57 -08:00
6c656663f3 Merge branch 'master' of github.com:cppformat/cppformat 2015-02-16 07:09:33 -08:00
291e43abac Add Android NDK section 2015-02-16 07:09:25 -08:00
a85d5e962b Update README.rst 2015-02-15 09:32:13 -08:00
11fab458c4 Merge pull request #107 from newnon/master
Android.mk
2015-02-15 09:12:49 -08:00
829cd70cd2 Merge pull request #112 from CarterLi/master
Detect static assertion support
2015-02-15 08:43:59 -08:00
1d49443405 fix android.mk 2015-02-15 19:21:32 +03:00
9fd566412d Refine 2015-02-15 15:25:56 +08:00
9331533309 Use __GXX_EXPERIMENTAL_CXX0X__ for better C++11 detection 2015-02-15 04:16:23 +01:00
43b9fefbd2 Use static_assert more actively 2015-02-15 03:55:21 +01:00
0fc15d48f3 Merge pull request #111 from CarterLi/master
Use explicitly deleted functions to make types non-copyable
2015-02-14 08:33:37 -08:00
2eef573656 Use explicitly deleted functions to make types non-copyable 2015-02-14 23:22:14 +08:00
f77350f8fa Disable unnecessary CMake check and comment 2015-02-14 06:18:19 -08:00
5282bebbd7 Merge pull request #110 from CarterLi/master
Use throw() when noexcept is not supported
2015-02-14 06:10:11 -08:00
e2583ab5f3 Use throw() when noexcept is not supported 2015-02-14 09:58:29 +08:00
950e6b9753 Fix downloader 2015-02-12 21:34:36 -08:00
c110f7b8d3 Move the code from appveyor config to a Python script
No more PowerShell rubbish, yay!
2015-02-12 17:53:39 -08:00
86fee707fb Update MinGW URL 2015-02-12 16:48:17 -08:00
c643fdae53 Fix CMake warning 2015-02-12 15:55:21 -08:00
609f33c94a Fix appveyor script 2015-02-12 15:41:30 -08:00
2f05eaa07d Correct filename in Biicode config 2015-02-12 15:39:06 -08:00
2ced92529d Move logic from travis.yml to a Python script 2015-02-12 15:34:38 -08:00
dd2e8b98de Fix RST markup 2015-02-12 12:46:28 -08:00
f79c88c190 Android.mk 2015-02-12 23:34:56 +03:00
4f51033aa9 Workaround PowerShell idiocy 2015-02-12 12:27:32 -08:00
503e87f153 Report CMake version for debugging 2015-02-12 11:41:45 -08:00
3822241d99 Use policy check instead of CMake version check 2015-02-12 11:27:55 -08:00
e392eea160 Fix CMake warning 2015-02-12 10:12:26 -08:00
8273855067 Remove extra newline mostly to check for linguist updates 2015-02-12 06:23:58 -08:00
8bd1953094 Minor changes to follow C++ Format's coding conventions 2015-02-11 14:16:22 -08:00
33f85efb55 Merge pull request #104 from franramirez688/master
Adapted to biicode via biicode.conf, ignore.bii and CMakeLists.txt
2015-02-11 14:02:27 -08:00
7b77eb61b5 adapted to biicode via biicode.conf, ignore.bii and CMakeLists.txt; mixed Travis
(original and biicode building)
2015-02-11 22:52:00 +01:00
50151ff804 Update README.rst 2015-02-10 19:37:54 -08:00
4a11f70408 Update README.rst
D'oh.
2015-02-10 19:36:29 -08:00
01b00e6dfb Update README.rst 2015-02-10 19:34:03 -08:00
a32f9148fc Update README.rst 2015-02-10 19:32:33 -08:00
a95b3f7ee1 Update README.rst 2015-02-10 19:31:22 -08:00
04a21bbb2e Merge branch 'fallthrough' of github.com:cppformat/cppformat 2015-02-09 08:02:14 -08:00
618dd9d6af Remove the fallthrough attribute detection 2015-02-09 07:54:03 -08:00
a92c179a6d Fix warnings on clang 2015-02-09 07:37:26 -08:00
267382af39 Revert the experimental fix for print_colored that didn't work 2015-02-09 06:53:05 -08:00
cfd476bb8b Temporarily disable the test as the fix didn't work. 2015-02-08 20:41:13 -08:00
e875e3145f Fix print_colored on Windows 2015-02-08 20:24:07 -08:00
9368b6a4ee Fix error handling in print_colored 2015-02-08 20:06:45 -08:00
7004d1edf6 Update the contributed code to the used coding conventions 2015-02-08 19:54:39 -08:00
d5ab6ba728 Merge pull request #102 from Ryuuke/master
added color support for windows
2015-02-08 18:25:31 -08:00
bc78ca42a9 remove global variables 2015-02-08 23:10:13 +00:00
4806f75469 remove unused define 2015-02-08 16:14:46 +00:00
5a9dc8f991 windows cli colors revision and test case 2015-02-08 16:08:29 +00:00
viz
26c151c5e4 Detect [[clang::fallthrough]] even __has_cpp_attribute is not supported 2015-02-08 07:57:05 -08:00
bce73e2bd8 remove forward enum declaration 2015-02-07 22:47:42 +00:00
51ceef3dee added color support for windows 2015-02-07 22:39:08 +00:00
326ade7698 Document what happens if you pass an invalid error code
to SystemError or WindowsError
2015-02-07 09:46:42 -08:00
502d2ede8a Bump version 2015-02-07 08:53:30 -08:00
81dc04dd48 Update README.rst
Add POL to the list of projects using cppformat
2015-02-07 08:31:17 -08:00
fe2b5351be Merge pull request #101 from cppformat/fallthrough
Try detecting clang::fallthrough using __has_cpp_attribute
2015-02-07 06:57:20 -08:00
d7fea1ba0c Try detecting clang::fallthrough using __has_cpp_attribute
and use it to silence one of the warnings in #96.
2015-02-07 06:51:47 -08:00
37ad436068 Fix by @dixlorenz for clang warnings "'return' will never be executed" (#96) 2015-02-06 21:27:31 -08:00
45d70b71ec Fix by @dixlorenz for clang warning about unknown Doxygen tags 2015-02-06 21:25:30 -08:00
d930f6956f Update README.rst
Add a link to GitHub search for projects using the library
2015-02-06 14:03:44 -08:00
38a7406318 Update README.rst
Add 0 A.D. to the list of projects using C++ Format and reorder projects lexicographically
2015-02-06 13:46:19 -08:00
83f5085551 Remove RTD theme 2015-02-06 09:01:49 -08:00
554abb12f1 Fix formatting 2015-02-06 08:45:43 -08:00
f2c16957f7 Provide examples of using SystemError and WindowsError (#54) 2015-02-06 08:43:02 -08:00
48e6df117a Merge branch 'master' of github.com:cppformat/cppformat 2015-02-06 07:27:29 -08:00
59254410da Fix a warning (#95) 2015-02-06 07:27:19 -08:00
58a300c82a Merge pull request #98 from MariadeAnton/master
Update README.rst
2015-02-06 07:07:14 -08:00
710817befb Update README.rst
Added biicode badge
2015-02-06 15:19:30 +01:00
ba17cca432 Fix link 2015-02-05 11:18:16 -08:00
f82f4bd79b Merge branch 'master' of github.com:cppformat/cppformat 2015-02-05 11:16:47 -08:00
589b73f646 Update links 2015-02-05 11:16:39 -08:00
afba2422ae Fix packaging 2015-02-05 08:50:47 -08:00
58683f5376 Version 1.0 🎆 2015-02-05 08:42:25 -08:00
bc6fcd90cf Fix CSS 2015-02-05 08:41:19 -08:00
402f5f3178 Documentation fixes 2015-02-05 08:36:46 -08:00
bdeffc3fdc Fix build on Android NDK
where XSI-compliant version of strerror_r is used violating the docs at
http://linux.die.net/man/3/strerror_r
2015-02-05 07:04:22 -08:00
b4eef59100 Only add the doc target if doxygen and sphinx-build are available 2015-01-30 12:53:52 -08:00
90bc8dd3ed Don't track the dependencies of the doc target as Sphinx does it itself 2015-01-30 08:49:48 -08:00
237eaa53e1 Replace exclude_trees with exclude_patterns
exclude_trees was removed in Sphinx 1.3b1
2015-01-30 07:15:00 -08:00
531ee615af Switch to the main breathe repo 2015-01-21 14:46:29 -08:00
fae27d262c Switch to the main breathe repo 2015-01-21 14:44:05 -08:00
0bd32f3f29 Merge branch 'master' of github.com:cppformat/cppformat 2015-01-08 07:56:19 -08:00
43aebf51d6 Allow precision specifier for non-float arguments 2015-01-08 07:56:08 -08:00
757a523195 Merge pull request #89 from mparaniak/master
Add format linking to tests
2015-01-06 09:12:37 -08:00
7f706171a9 Add format linking to tests 2015-01-06 16:57:07 +01:00
cd828a8691 Add a test for https://github.com/cppformat/cppformat/issues/86 2015-01-05 07:16:26 -08:00
6080108802 Merge pull request #87 from aruhan/issue/86
Fix format using wostream produces wrong results
2015-01-05 07:13:04 -08:00
e8febf7f4b Fix format using wostream produces wrong results 2015-01-05 22:33:18 +09:00
130bccbcbf Update README.rst 2014-12-19 07:50:41 -08:00
01414ac6ec Update README.rst 2014-12-19 07:49:54 -08:00
3cb004d0d3 Update README.rst 2014-12-19 07:48:38 -08:00
a7d7e0daec Restore bootstrap theme 2014-12-19 07:42:46 -08:00
67e196eac4 Make test libraries static 2014-12-19 07:39:13 -08:00
fdecd5b40f Remove FMT_SHARED in favor of BUILD_SHARED_LIBS 2014-12-19 07:37:49 -08:00
a8b1769803 Use default namespace 2014-12-18 08:46:25 -08:00
8d89e56d2c Set primary domain to cpp 2014-12-18 08:36:53 -08:00
fb12cfd196 Suppress more bogus warnings 2014-12-17 06:53:32 -08:00
ecd2b80e8f Get rid of using declarations for header-only config 2014-12-17 06:42:26 -08:00
c95908bd8c Disable bogus MSVC warnings 2014-12-17 06:41:21 -08:00
c630d1f236 Disable "secure" warnings in posix. 2014-12-16 07:07:09 -08:00
0d1eb8b1ea Don't undefine "secure" warnings 2014-12-16 07:02:59 -08:00
dff2137405 Don't define/undefine macros without FMT_ prefix 2014-12-16 07:01:01 -08:00
2523f3b939 Fix more -Wshadow warnings 2014-12-10 07:24:05 -08:00
f9fc8fd09d Fix -Wshadow warnings 2014-12-09 07:45:54 -08:00
b49a1b4a52 Fix linkage errors on Windows in header-only config 2014-12-09 06:32:07 -08:00
df580969f7 Add a test for header-only configuration 2014-12-09 06:22:55 -08:00
f9c3ff244d Merge branch 'header-only' of github.com:cppformat/cppformat 2014-12-09 06:14:04 -08:00
6e3d7d9a6a Update README.rst
Add spdlog
2014-12-08 06:15:31 -08:00
54f19ff7b2 Simplify append_float_length 2014-12-03 06:33:31 -08:00
f3bd9d4241 Remove extra space 2014-12-03 06:20:12 -08:00
6f3c095ed6 Use FMT_DISALLOW_COPY_AND_ASSIGN instead of undefined assignment operators 2014-12-03 06:16:52 -08:00
0fea89ec8f Merge pull request #81 from Queueless/master
Fixed Level 4 warnings on Windows
2014-12-03 06:04:06 -08:00
7706e1054d Update README.rst
Fix formatting
2014-12-02 12:55:13 -08:00
a23fbbb9a3 Update README.rst
Add Analytics Cloud to the list of projects using C++ Format.
Source: https://help.salesforce.com/servlet/servlet.FileDownload?file=015300000035w3yAAA
2014-12-02 12:54:12 -08:00
838dc1e189 move append_float_length specialization to the header 2014-12-02 10:20:27 -05:00
820c03a473 Update README.rst
Add readpe to projects using cppformat
2014-12-02 06:39:16 -08:00
311251eb91 Complete header-only configuration support 2014-11-29 06:58:00 -08:00
c2a6903e19 Define FMT_FUNC to nothing if FMT_HEADER_ONLY is not defined 2014-11-28 15:30:03 -08:00
d9c605c61f Initial support for header-only configuration 2014-11-28 06:40:57 -08:00
334fc54b5d removed unused code 2014-11-25 18:03:54 -05:00
bd0067ee76 made code compile under windows with level 4 warnings 2014-11-25 18:01:09 -05:00
4c59aa8780 Link to stable docs 2014-11-24 16:20:07 -08:00
aca49379a5 Fix a few minor issues detected by CppCheck
Thanks to Dmitry Andriyankov for reporting.
2014-11-24 07:38:26 -08:00
615c1eef6b Fix error handling in fmt::fprintf. 2014-11-14 09:40:01 -08:00
8ea9f068c7 Convert tabs to spaces 2014-11-07 07:58:49 -08:00
97ea39cf79 Remove no longer needed highlight directives 2014-11-07 07:26:04 -08:00
43d3c0a110 Set highlight language to c++ in config 2014-11-07 07:24:51 -08:00
f02e4100db Undo highlight since it's not working and simplify markup 2014-11-07 07:04:03 -08:00
e41ca7b951 Try setting highlight to c++ 2014-11-07 06:56:53 -08:00
6527551d43 Simplify markup 2014-11-05 07:39:34 -08:00
9cbb25e43f Simplify markup 2014-11-05 07:36:55 -08:00
10698cc44d Update theme 2014-11-04 08:31:07 -08:00
aa78f6155b Add theme alias 2014-11-04 08:17:59 -08:00
6bcfb377b2 Link to docs 2014-11-04 07:44:07 -08:00
bbd7681a33 Add ReadTheDocs badge 2014-11-04 07:42:56 -08:00
8f93e84a1a Switch to ReadTheDocs theme 2014-11-04 07:37:25 -08:00
ed92af29b3 Add missing ')' 2014-10-30 13:58:16 -07:00
14984acd27 Fix UTF conversion tests 2014-10-30 13:00:44 -07:00
daca48cb15 Fix MSVC build 2014-10-30 12:20:08 -07:00
cabe5bddb4 Fix util-test 2014-10-30 08:07:28 -07:00
5a5870d3ca n -> size 2014-10-30 07:10:43 -07:00
5c4b6678e4 Compute StringRef size in ctor 2014-10-30 07:05:42 -07:00
10d83aaa52 Test that StringRef size computation 2014-10-30 06:27:44 -07:00
d5a6316d5c Update breathe 2014-10-25 10:27:49 -07:00
9501ca0e68 Update theme 2014-10-24 07:43:53 -07:00
06ae9a6de0 Update breathe 2014-10-24 07:09:56 -07:00
c50e7781fc Remove old bootstrap theme 2014-10-24 07:09:46 -07:00
e3263a341e Update theme 2014-10-23 07:25:54 -07:00
adca25913c Indent descriptions of macros 2014-10-23 07:22:37 -07:00
99ff512b32 Use sphinx bootstrap theme from subproject 2014-10-23 07:17:56 -07:00
0019793786 Add bootstrap theme as a module 2014-10-21 08:28:27 -07:00
e640e458c1 Align navbar content with the main content 2014-10-20 08:56:27 -07:00
fb6ed7590b Align footer with the main content 2014-10-17 09:39:43 -07:00
e9bf788bd5 Add side margins if screen is too wide 2014-10-17 09:20:21 -07:00
4a818ac785 Move CSS override to theme because RTD ignores layout.html
RTD bug: https://github.com/rtfd/readthedocs.org/issues/152
2014-10-17 09:15:47 -07:00
c90c6805a2 Add side margins if screen is too wide 2014-10-17 07:53:56 -07:00
7d2c3ac0f2 Add styles 2014-10-17 07:24:49 -07:00
32392597aa Move Usage section to a separate file 2014-10-16 07:12:43 -07:00
2b17d47372 Merge branch 'master' of github.com:cppformat/cppformat 2014-10-16 06:51:04 -07:00
ca94e4d27f Update breathe 2014-10-16 06:50:48 -07:00
c752b6d489 Merge pull request #78 from amorozov/issue/76
sign-compare warnings fixes
2014-10-14 06:46:20 -07:00
4d3126c567 sign-compare warnings fixes 2014-10-14 03:28:47 +07:00
755ecb0311 Fix warnings 2014-10-13 08:39:38 -07:00
d707adce5c Fix warning in clang 2014-10-13 06:59:18 -07:00
0d732cf5d3 Merge branch 'master' of github.com:cppformat/cppformat 2014-10-13 06:46:17 -07:00
5189274797 Fix warnings 2014-10-13 06:46:07 -07:00
73ec6504c7 Update README.rst 2014-10-12 14:18:17 -07:00
88f3f53870 Fix Sphinx config 2014-10-10 08:47:36 -07:00
709465197a Switch to bootstrap theme 2014-10-10 08:40:35 -07:00
76a2ea56ce Add bootstrap Sphinx theme 2014-10-10 08:39:54 -07:00
a7520f164a Restore theme 2014-10-10 06:18:50 -07:00
bb1926753d Try using the default theme 2014-10-10 06:10:52 -07:00
f05e856017 Fix example 2014-10-09 11:25:39 -07:00
4865950649 Update links 2014-10-09 09:10:12 -07:00
8cab5909e0 Improve PDF output 2014-10-09 07:57:26 -07:00
80f5cbb9e5 Add missing quote 2014-10-09 07:57:03 -07:00
833fd47f83 Change the next version number to 0.12.0 2014-10-06 08:49:33 -07:00
8b76e97062 Support compilation with exceptions disabled 2014-10-06 08:30:55 -07:00
55c61d1abd Update project name 2014-10-06 08:27:42 -07:00
b6afd93879 Split long line 2014-10-06 08:20:52 -07:00
1e63fc7ca0 Comment 2014-10-05 09:34:46 -07:00
32c5dca733 Update breathe 2014-10-03 07:14:56 -07:00
43b389f358 Update README.rst 2014-10-02 06:44:34 -07:00
fae3ae67b9 Fix util-test 2014-10-01 09:32:31 -07:00
ae413ebf7a Add a section on custom allocators 2014-10-01 08:49:20 -07:00
04d38a8b14 Update docs 2014-10-01 08:32:01 -07:00
03f7f99f4c Fix build on pre-C++11 compilers 2014-10-01 08:24:47 -07:00
8b9a6e03f6 Test buffer 2014-10-01 08:12:10 -07:00
74dc571ba0 Support signed char and unsigned char strings 2014-09-30 08:15:56 -07:00
98a25ec7cb Test Buffer 2014-09-30 07:30:27 -07:00
313b259891 Use type_traits to test if copyable/assignable
Replace compile tests that check if types are copy constructible and copy assignable with normal tests that use type_traits (if available).
2014-09-30 07:30:05 -07:00
d00f689c40 Fix type_traits check 2014-09-29 11:03:18 -07:00
b79d06a5da Escape quotes 2014-09-29 10:44:48 -07:00
2846a9eb38 Check if is_copy_assignable is working
is_copy_assignable is broken in MSVC.
2014-09-29 10:42:16 -07:00
810f42c0c7 Fix util-test on Windows, take 2 2014-09-29 09:59:49 -07:00
55a16eaec7 Fix util-test on Windows 2014-09-29 09:37:33 -07:00
a309c4bbed Fix posix-test on Windows 2014-09-29 09:28:44 -07:00
e1c046c984 Fix open check 2014-09-29 09:27:32 -07:00
8c4db5081b Fix Windows build 2014-09-29 09:17:02 -07:00
dd90129066 Check if type_traits actually work. 2014-09-29 09:15:41 -07:00
d1ded569ff Separate memory management and formatting
Array is split into an abstract Buffer class and a concrete MemoryBuffer class. BasicWriter now does all memory allocation through a Buffer object. Subclasses of BasicWriter may use different buffer types. The new BasicMemoryBuffer class uses the default MemoryBuffer.
2014-09-29 08:48:16 -07:00
5ca3d00e26 Mind the lifetime 2014-09-25 12:15:16 -07:00
a9da3d3852 Fix ArgList::operator[] 2014-09-25 09:31:36 -07:00
b2bd63d2d9 Test ArgList 2014-09-25 09:11:51 -07:00
65cb43a484 Store type info in uint64_t instead of ULongLong 2014-09-25 07:42:29 -07:00
c2f02df2f5 Fix warning in clang 2014-09-25 07:38:16 -07:00
f43caef311 Fix linkage 2014-09-25 07:21:48 -07:00
098a8fdef8 Simplify make_type 2014-09-25 07:14:08 -07:00
75a2ea03a7 Reduce code bloat
Special case C strings because there is no need to handle size for them. Add support for pre-C++11 compilers to make_type.
2014-09-25 07:10:44 -07:00
163178eee1 Make print non-inline 2014-09-25 07:08:25 -07:00
ae8bc36e57 MakeArg -> MakeValue 2014-09-24 08:07:50 -07:00
93b314d3ab Comments 2014-09-24 07:59:23 -07:00
ec1aea34e6 Refactor type processing 2014-09-24 07:48:45 -07:00
ab6e759291 pointer_value -> pointer 2014-09-23 08:21:58 -07:00
d2973766ea ArgBase -> Value 2014-09-23 08:11:03 -07:00
beb00edf73 Store types in ArgList instead of Arg 2014-09-23 07:59:43 -07:00
49222dc0c7 Improve allocator test 2014-09-23 07:58:23 -07:00
13bbb0db7a Update docs 2014-09-21 14:12:21 -07:00
eac25ad1c7 Update readme 2014-09-21 08:13:35 -07:00
1d4640415d Pass ArgList by value
This improve bloat test results:
Old stripped size: 67680 (optimized)
New stripped size: 59488 (optimized)
2014-09-21 08:08:52 -07:00
14f2577569 Fix linkage 2014-09-19 08:45:05 -07:00
b9a568b1dd Add support for custom memory allocator to BasicWriter 2014-09-19 07:51:42 -07:00
70205edd6e Fix build with ancient CMake 2014-09-18 09:29:51 -07:00
a734f67978 Check if variadic templates are working 2014-09-18 09:18:18 -07:00
6a98f42336 Add support for custom allocators 2014-09-18 09:07:40 -07:00
a4998accf6 Fix travis build 2014-09-17 08:26:07 -07:00
c76b22405d Replace GTest with GMock (includes GTest) 2014-09-17 08:01:42 -07:00
2938a92d64 Add KBEngine to projects that use cppformat 2014-09-13 08:44:49 -07:00
b54d6e7124 Fix posix-test, take 3. 2014-09-12 18:22:45 -07:00
94daf27c9d Fix posix-test, take 2. 2014-09-12 17:41:04 -07:00
886ad20a9d Remove unused size argument from Array's ctor. 2014-09-12 17:20:36 -07:00
434e83a192 Fix posix-test. 2014-09-12 17:16:22 -07:00
ddd95965e1 Fix MaxSize test. 2014-09-12 16:52:15 -07:00
a3062f6647 Disambiguate a call 2014-09-12 16:18:04 -07:00
352b6ae496 Workaround more Windows crap. 2014-09-12 15:18:11 -07:00
74169e4b5d Add a portable getpagesize() implementation 2014-09-12 13:53:52 -07:00
1e9ca17b9d Workaround Windows crap. 2014-09-12 13:42:22 -07:00
225b757b50 Handy fix for handling of handles. 2014-09-12 12:37:32 -07:00
cb7caa540f Move FMT_STATIC_ASSERT to header and test. 2014-09-12 12:05:32 -07:00
ea9989b254 Add missing include. 2014-09-12 11:57:33 -07:00
949c3c5df4 Test if File::size can handle maximum file size. 2014-09-12 11:12:22 -07:00
e34e9fa0c7 Add File::size and make File's ctor take StringRef. 2014-09-12 10:50:16 -07:00
f175591923 Return size_t instead of streamsize in File::read and File::write
File::read and File::write throw exception on error, so they don't need to return a negative value to indicate error.
2014-09-12 09:38:37 -07:00
6cd9be2c06 Bump version. 2014-09-12 08:29:38 -07:00
3269fce2dc Fix https://github.com/cppformat/cppformat/issues/61 2014-09-12 08:27:23 -07:00
d59fbdcd4a Increase the maximum number of formatting arguments on compilers without variadic templates to 15. 2014-09-11 21:18:36 -07:00
445663fade Fix windows build. 2014-09-05 10:56:00 -07:00
f2c9df8e9f Move safe_strerror to anonymous namespace. 2014-09-05 08:44:41 -07:00
b33d2aa825 Workaround Windows braindamage. 2014-09-05 08:06:07 -07:00
88e0db8486 Test format_error_code. 2014-09-05 08:04:26 -07:00
d4916d9271 Add missing file. 2014-09-05 07:35:00 -07:00
fe9888a1e2 Move implementation tests to format-impl-test. 2014-09-05 07:12:20 -07:00
93bcad6d8e Fix Windows build. 2014-09-03 08:10:20 -07:00
22f75d8b6d Don't throw exceptions from error formatting functions. Gracefully fallback to a less descriptive message instead. 2014-09-03 08:03:05 -07:00
82d4d11c11 format -> cppformat 2014-08-29 09:18:53 -07:00
5debb2aa86 Refactor error reporting to reduce duplication. 2014-08-29 08:16:10 -07:00
605d2600f8 Improve error reporting. 2014-08-29 07:45:55 -07:00
271fa8c908 Improve handling of format strings in custom arguments. 2014-08-29 07:23:54 -07:00
3947a7a98c Move check_sign to anonymous namespace. 2014-08-29 06:57:53 -07:00
ab35af53c5 Check result of fread. 2014-08-29 06:57:26 -07:00
e62354a190 Fix build. 2014-08-28 14:51:01 -07:00
eab0b577f8 Report filename in exception. 2014-08-28 13:42:07 -07:00
e44619707e Fix Windows build. 2014-08-28 12:46:30 -07:00
2dad1690c8 Fix BufferefFile test on Windows. 2014-08-28 12:13:03 -07:00
564da25932 Add ctor & print method to BufferedFile. 2014-08-28 11:53:05 -07:00
108cd1d1a0 Fix anchor. 2014-08-28 10:18:13 -07:00
32344d9b14 Comment 2014-08-28 08:11:21 -07:00
c57d7a506f Factor out argument processing logic common between format and printf to FormatterBase::{next_arg,get_arg}. 2014-08-28 08:05:47 -07:00
56fc525e98 Get rid of FormatterBase::error_. 2014-08-28 07:48:55 -07:00
279c7a6e6a Change "number is too big in format" to "number is too big" because the error can occur not only in the format function. 2014-08-28 06:50:52 -07:00
526b7fc91d Throw exception in parse_nonnegative_int if the number is too big. 2014-08-28 06:42:59 -07:00
9646e38c3b Don't use error_ in parse_arg_index. 2014-08-27 09:13:42 -07:00
da0f7c0a51 Improve error reporting in parse_arg_index. 2014-08-27 09:04:51 -07:00
42de4f1f7d Get rid of FormatErrorReporter. 2014-08-27 08:24:31 -07:00
8cc0d21124 Move the Crash Reporter fix to Google Test where it belongs. 2014-08-23 10:25:21 -07:00
59a462c67d Make sure that Crash Reporter is not invoked on death tests. 2014-08-23 10:04:06 -07:00
45397e5046 Add dependency from CMakeLists.txt since it is used to get version. 2014-08-21 08:51:45 -07:00
034aedb6d4 Bump version. 2014-08-21 08:49:58 -07:00
dd4323f31c Add fprintf and write docs. 2014-08-21 08:49:13 -07:00
f9561671cf Write docs. 2014-08-21 07:30:00 -07:00
da0293c4dd Add missing include. 2014-08-21 07:29:23 -07:00
03cdf1235a Test printf. 2014-08-21 07:14:02 -07:00
f1ac0a19e9 Test float. 2014-08-20 08:21:06 -07:00
be00d8b272 Convert integer argument like printf does. 2014-08-19 08:49:10 -07:00
406c6123fb Cleanup 2014-08-19 08:47:38 -07:00
c4a4a05d12 Improve handling of char in printf. 2014-08-19 08:14:21 -07:00
f2be7851cc Fix a warning. 2014-08-19 07:29:30 -07:00
e0f92d675e Fix a warning. 2014-08-19 07:14:25 -07:00
39ac84f01e Comment. 2014-08-18 07:03:22 -07:00
186734cf8b Fix warnings. 2014-08-18 07:03:12 -07:00
61857356ea Fix appveyor config. 2014-08-17 08:01:00 -07:00
2462c61d05 Enable output for test failures. 2014-08-17 07:56:48 -07:00
adce0245dc Fix a warning. 2014-08-17 07:53:55 -07:00
366e852f00 Fix a warning. 2014-08-15 16:35:41 -07:00
bb01633d19 Fix a warning. 2014-08-15 09:03:59 -07:00
c978d88183 Test ArgConverter. 2014-08-15 08:40:13 -07:00
fb32161fa4 Move implementation specific stuff from format.h to format.cc. 2014-08-15 08:40:03 -07:00
c7cfa7d4e7 More tests. 2014-08-15 06:58:24 -07:00
d4412a01f0 Simplify isinfinity. 2014-08-13 08:01:51 -07:00
1a0c76a81a Fix formatting of long double. 2014-08-13 07:51:02 -07:00
18f1e08685 Test 'll' specifier. 2014-08-13 06:59:29 -07:00
e488a28601 Fix a warning. 2014-08-13 06:53:43 -07:00
ddd087d8d1 Test more length specifiers. 2014-08-13 06:42:15 -07:00
d3a7039e31 Implement 'll' specifier. 2014-08-12 08:36:19 -07:00
5614295aa1 Test 'l' specifier. 2014-08-12 08:15:39 -07:00
7c14431211 Enable 'h' speciffier tests. 2014-08-12 06:49:27 -07:00
adbf3f8b86 Rewrite length specifier tests without using printf to workaround broken MSVC implementation. 2014-08-11 08:34:17 -07:00
137153b9f0 Take integer promotion into account. 2014-08-11 06:54:58 -07:00
910dec5ed3 Fix 'l' specifier test. 2014-08-11 06:33:40 -07:00
028d12dacd Disable 'l' specifier tests. 2014-08-09 10:12:36 -07:00
316ae7e244 Implement more printf length specifiers. 2014-08-09 10:04:35 -07:00
6a8becb5bf Rearrange tests to simplify inclusion in other projects, part 2. 2014-08-09 09:07:15 -07:00
56fb75c2ec Rearrange tests to simplify inclusion in other projects. 2014-08-09 09:04:38 -07:00
bdbacde659 Test 'h' specifier. 2014-08-09 08:53:14 -07:00
3465d056e7 Test hh specifier with unsigned char. 2014-08-08 06:59:17 -07:00
e22d657202 Fix MSVC warnings. 2014-08-08 06:51:09 -07:00
44e23c39f1 Implement GetThreadCount on Linux. 2014-08-07 09:30:46 -07:00
431b556951 Add FMT_ prefix to SPECIALIZE_MAKE_UNSIGNED. 2014-08-07 07:42:55 -07:00
6a37965710 Replace gtest with fused version. 2014-08-07 06:47:51 -07:00
566061d1f1 Fix formatting of signed ints in test. 2014-08-06 08:21:12 -07:00
6cd1563eac Add a size argument to Array ctor. 2014-08-06 07:17:03 -07:00
e04b07921f Debug length specifier test. 2014-08-06 07:16:49 -07:00
8b41b09add Test 'hh' and 'h' printf specifiers. 2014-08-06 07:00:04 -07:00
86bbd3c238 Test hh length. 2014-08-05 08:21:47 -07:00
b797d39dd1 Test printf length. 2014-08-05 07:52:59 -07:00
fc10d10b6b Disable hh specifier tests for now because broken MSVC's printf causes test failures. 2014-08-01 08:50:09 -07:00
58dfe5c9f7 Make format_decimal inline. 2014-08-01 08:49:16 -07:00
3390a9510e Markup 2014-08-01 07:36:08 -07:00
5ccbc9bb53 Acknowledge Boris Kaul. 2014-08-01 07:35:02 -07:00
a259c941e2 Implement 'l' length specifier. 2014-08-01 07:15:27 -07:00
be9356b651 Specialize MakeUnsigned for all signed integer types. 2014-07-31 21:23:49 -07:00
d81fafc295 Fix tests on MSVC, take 2. 2014-07-31 07:43:14 -07:00
3f444fe3e2 Fix tests on MSVC. 2014-07-31 06:47:24 -07:00
e2f0408b69 Print format string on failure. 2014-07-30 10:59:23 -07:00
f4156b57f0 Implement 'hh' length specifier in printf. 2014-07-30 08:39:07 -07:00
39b0930aee Improve handling of 'h' length specifier in printf. 2014-07-30 08:08:08 -07:00
eeca22357b Handle 'h' length specifier in printf. 2014-07-30 07:37:16 -07:00
e4c4e4e944 Improve handling of dynamic precision in printf. 2014-07-30 06:51:35 -07:00
be785a8a43 Fix MSVC build. 2014-07-29 09:14:07 -07:00
d346a4120d FormatDec -> format_decimal 2014-07-29 08:45:29 -07:00
bf5b246717 fmt_isinf -> isinfinity 2014-07-29 08:22:52 -07:00
138c3dccdc Fix tests. 2014-07-29 08:11:49 -07:00
8f8fd769ee Fix Fix https://github.com/cppformat/cppformat/issues/50 in tests too. 2014-07-29 07:50:05 -07:00
24d6baa60f Fix Clang build. 2014-07-29 07:49:34 -07:00
481c313df5 Fix the build. 2014-07-29 07:19:54 -07:00
d8b9f413fe Fix https://github.com/cppformat/cppformat/issues/50. 2014-07-29 06:38:05 -07:00
ad9c830282 format -> format_str to avoid confusion with function name. 2014-07-29 06:26:44 -07:00
7a83dcd23e Mind the lifetime. 2014-07-28 13:30:09 -07:00
7e40ca6a9c Fix a warning. 2014-07-28 09:08:21 -07:00
4d049cf598 More fixes for https://github.com/cppformat/cppformat/issues/50. 2014-07-28 08:41:50 -07:00
75b5eb4b9d More fixes for https://github.com/cppformat/cppformat/issues/50. 2014-07-27 15:09:05 -07:00
5d4803a567 More fixes for https://github.com/cppformat/cppformat/issues/50. 2014-07-27 12:53:42 -07:00
4c563de76f Use stock version of sphinx build. 2014-07-27 10:07:20 -07:00
82652f4ee2 Experiment with appveyor. 2014-07-27 09:24:22 -07:00
b9c40c6af5 Experiment with appveyor. 2014-07-27 09:03:59 -07:00
7b44b0113b Remove sphinx submodule. 2014-07-27 08:51:33 -07:00
8e0bfb5714 Debug appveyor config. 2014-07-27 08:42:03 -07:00
2ebfa7b53d Fix appveyor config, take 2. 2014-07-27 08:30:37 -07:00
721d95adf2 Fix appveyor config. 2014-07-27 08:13:39 -07:00
af90b08b76 Remove sphinx submodule as we can now use the stock version. 2014-07-27 08:08:16 -07:00
d658c835d4 Update breathe. 2014-07-26 21:34:50 -07:00
a8cef1d987 FormatDecimal -> format_decimal (https://github.com/cppformat/cppformat/issues/50) 2014-07-26 21:31:40 -07:00
1a6cdb53ac Use custom version of breathe. 2014-07-26 21:30:36 -07:00
33cde15334 Fix version. 2014-07-26 21:23:50 -07:00
533b9cf24f Add missing import. 2014-07-26 21:14:40 -07:00
46b6e4b52c Run doxygen on ReadTheDocs. 2014-07-26 21:12:48 -07:00
d91a66e1c5 Read version from CMakeLists.txt instead of using configure for compatibility with ReadTheDocs. 2014-07-26 21:05:42 -07:00
2a1c0c9969 Obey line length limit. 2014-07-26 09:45:03 -07:00
f634ccb344 ReportUnknownType -> report_unknown_type (https://github.com/cppformat/cppformat/issues/50) 2014-07-26 08:42:19 -07:00
b498ba0bc5 FormatFloat -> format_float (https://github.com/cppformat/cppformat/issues/50) 2014-07-26 08:03:03 -07:00
37356c3f5e Comment. 2014-07-26 07:26:04 -07:00
aa6aa4207e Edit readme. 2014-07-26 07:25:31 -07:00
2a747b19e0 CheckPtr -> make_ptr (https://github.com/cppformat/cppformat/issues/50) 2014-07-25 08:41:22 -07:00
d142e3b55f Simplify handling of flags. 2014-07-25 08:29:06 -07:00
d699c2a0d9 Don't duplicate integer format specifiers when formatting char as integer. 2014-07-25 08:24:27 -07:00
a997de90eb Fix https://github.com/cppformat/cppformat/issues/57. 2014-07-25 07:10:33 -07:00
89468c2a23 Update breathe. 2014-07-24 14:48:20 -07:00
ee24839cbd Fix tests. 2014-07-24 09:07:43 -07:00
ca0dcce2a6 CountDigits -> count_digits 2014-07-24 08:59:52 -07:00
c1db293518 Don't use Writer's buffer directly in formatters. Unfriend BasicFormatter. 2014-07-24 08:53:27 -07:00
a7d94f0c61 Fix https://github.com/cppformat/cppformat/issues/55. 2014-07-22 12:37:10 -07:00
177715d8f9 Update breathe. 2014-07-21 12:27:52 -07:00
f1dfd59a41 HandleArgIndex -> handle_arg_index. Use error_ instead of a local. 2014-07-16 08:49:23 -07:00
f86c812e1a Remove unused SimpleErrorReporter. 2014-07-16 08:48:27 -07:00
4edc88f609 Add FormatterBase. 2014-07-16 08:38:15 -07:00
9144a8fbbe PrintfParser -> PrintfFormatter. 2014-07-16 07:59:45 -07:00
e2a66c58e5 Simplify and test ArgVisitor. 2014-07-16 07:55:31 -07:00
9d74f9542b IsNegative -> is_negative. Simplify WidthHandler and ArgFormatter. 2014-07-16 07:27:54 -07:00
512e2ced93 Rewrite argument formatting using ArgVisitor. 2014-07-14 08:47:03 -07:00
e3a2ac8725 Move StringValue to Arg & simplify StringTraits. 2014-07-14 08:04:17 -07:00
8a66bb89b2 Complete ArgVisitor test. 2014-07-14 07:27:07 -07:00
a7a18fac89 Fix util-test. 2014-07-14 07:17:58 -07:00
591ad0a64a Add ArgVisitor. 2014-07-14 06:55:29 -07:00
979561cc00 Clean appveyor config. 2014-07-10 11:23:06 -07:00
4ecfdd50b6 Suppress error dialogs on assertion failures in MinGW. 2014-07-10 11:05:26 -07:00
c3a6e01f52 Try a fix for $env:Configuration not expanding. 2014-07-10 10:43:21 -07:00
308ee8a7eb Clean appveyor config. 2014-07-10 09:34:26 -07:00
eb04e9abd3 Report build type. 2014-07-10 09:14:24 -07:00
c0d55e6308 Remove WriteArrayOfUnknownSize because it shouldn't compile according to standard. 2014-07-10 08:42:33 -07:00
47f2e7aa02 Clean appveyor config. 2014-07-10 08:41:33 -07:00
6eaee58679 Fix appveyor config. 2014-07-10 08:26:20 -07:00
b119b9ad71 Debug appveyor config. 2014-07-10 08:18:24 -07:00
59ed28274c Remove Git bin directory from the path because it breaks mingw config. 2014-07-10 07:58:42 -07:00
f29a3fadbf Fix appveyor config, take 2. 2014-07-10 07:38:55 -07:00
8cfe4e2266 Fix appveyor config. 2014-07-10 07:31:54 -07:00
0a26914e42 Debug appveyor config. 2014-07-10 07:27:14 -07:00
472e6107bb Fix appveyor config. 2014-07-10 07:02:59 -07:00
307c207351 Split long line. 2014-07-10 07:00:26 -07:00
dfadea8345 Fix 7z invocation. 2014-07-10 06:50:14 -07:00
b1c89e37bf Add support for MinGW build. 2014-07-10 06:39:10 -07:00
dac1aa0d23 Don't install MinGW for MSVC build. 2014-07-10 06:33:20 -07:00
f7e0fb8a58 Try build matrix in appveyor. 2014-07-09 19:44:32 -07:00
f739978fbb Clean appveyor config. 2014-07-09 17:32:32 -07:00
cac3656b78 Suppress output from 7z. 2014-07-09 17:24:23 -07:00
18b4abff0b Specify user agent when downloading from SF. 2014-07-09 17:13:27 -07:00
2fb88aaa08 Debug appveyor config. 2014-07-09 17:06:05 -07:00
bd8f8b5525 Try fixing download. 2014-07-09 15:16:24 -07:00
5e42eaca0d Install mingw in appveyor. 2014-07-09 13:16:39 -07:00
e839608dcf Try installing mingw in appveyor. 2014-07-09 12:07:24 -07:00
83c2b37673 Check if 7zip installed in appveyor. 2014-07-09 11:16:28 -07:00
16985f4764 Fix one more test failure on MinGW. 2014-07-09 10:13:44 -07:00
d3a7a4c209 Fix StrError test. 2014-07-09 10:11:10 -07:00
53a475ac94 Do fix a test. 2014-07-09 10:01:36 -07:00
897397760c Fix a test. 2014-07-09 09:55:13 -07:00
9c47f3e057 Fix MinGW issues, take 2. 2014-07-09 09:45:18 -07:00
0ffcec0090 Fix MinGW issues. 2014-07-09 09:35:36 -07:00
8321d0ecf9 Fix warnings on MinGW. 2014-07-09 08:39:01 -07:00
e3a44c11f6 Add an overload of print that accepts std::ostream. 2014-07-09 06:56:36 -07:00
ed421848b3 Test passing an array of unknown size as an argument. 2014-07-09 06:45:20 -07:00
1d7bd5d073 Add c_str functions. 2014-07-08 16:44:24 -07:00
b9a06bafd8 internal::FormatParser -> BasicFormatter. 2014-07-08 16:38:50 -07:00
e825156add Move FormatParser to the internal namespace. 2014-07-08 16:20:33 -07:00
f711266244 Test MakeArg. Clean the API. 2014-07-04 07:18:44 -07:00
144e1fbb7c Disallow formatting of wide strings when using a narrow string formatter. 2014-07-04 06:56:19 -07:00
270ed1cb92 Add printf example. 2014-07-03 09:40:34 -07:00
4e260e8599 Test MakeArg and fix formatting. 2014-07-03 08:50:57 -07:00
43a873f7ff Typo 2014-07-02 09:12:25 -07:00
9fbdc32adc Test MakeArg and handle bool, signed char and unsigned char. 2014-07-02 08:38:31 -07:00
6e5551e77a ArgInfo -> Arg 2014-07-02 06:33:25 -07:00
c494c980b6 Clean. 2014-07-01 21:01:15 -07:00
b827a97fd6 Correct example. 2014-07-01 16:59:25 -07:00
5d15bdd5a5 Clean. 2014-07-01 16:23:50 -07:00
530479bd07 Don't exclude PrepareBufferForInt to demonstrate an issue with docs. 2014-07-01 13:12:44 -07:00
b8174bec30 Use Kill-o-Zap 2014-07-01 09:17:37 -07:00
39166f9aa9 Remove more deprecated code. 2014-07-01 09:15:20 -07:00
2dc108b31f Remove deprecated code 🎆 🎆 🎆 2014-07-01 09:10:43 -07:00
251 changed files with 81412 additions and 64707 deletions

14
.clang-format Normal file
View File

@ -0,0 +1,14 @@
# Run manually to reformat a file:
# clang-format -i --style=file <file>
Language: Cpp
BasedOnStyle: Google
IndentPPDirectives: AfterHash
IndentCaseLabels: false
AlwaysBreakTemplateDeclarations: false
DerivePointerAlignment: false
AllowShortCaseLabelsOnASingleLine: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false

8
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions" # Necessary to update action hashes.
directory: "/"
schedule:
interval: "monthly"
# Allow up to 3 opened pull requests for github-actions versions.
open-pull-requests-limit: 3

6
.github/issue_template.md vendored Normal file
View File

@ -0,0 +1,6 @@
<!--
Please make sure that the problem reproduces on the current master before
submitting an issue.
If possible please provide a repro on Compiler Explorer:
https://godbolt.org/z/fxccbh53W.
-->

7
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,7 @@
<!--
Please read the contribution guidelines before submitting a pull request:
https://github.com/fmtlib/fmt/blob/master/CONTRIBUTING.md.
By submitting this pull request, you agree to license your contribution(s)
under the terms outlined in LICENSE.rst and represent that you have the right
to do so.
-->

32
.github/workflows/cifuzz.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: CIFuzz
on: [pull_request]
permissions:
contents: read
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@92182553173581f871130c71c71b17f003d47b0a
with:
oss-fuzz-project-name: 'fmt'
dry-run: false
language: c++
- name: Run fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@92182553173581f871130c71c71b17f003d47b0a
with:
oss-fuzz-project-name: 'fmt'
fuzz-seconds: 300
dry-run: false
language: c++
- name: Upload crash
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

43
.github/workflows/doc.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: doc
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
# Use Ubuntu 20.04 because doxygen 1.8.13 from Ubuntu 18.04 is broken.
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Add Ubuntu mirrors
run: |
# Github Actions caching proxy is at times unreliable
# see https://github.com/actions/runner-images/issues/7048
printf 'http://azure.archive.ubuntu.com/ubuntu\tpriority:1\n' | sudo tee /etc/apt/mirrors.txt
curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list
- name: Create build environment
run: |
sudo apt update
sudo apt install doxygen
pip install mkdocs-material==9.5.25 mkdocstrings==0.25.1 mike==2.1.1
cmake -E make_directory ${{runner.workspace}}/build
# Workaround https://github.com/actions/checkout/issues/13:
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
- name: Build
working-directory: ${{runner.workspace}}/build
run: $GITHUB_WORKSPACE/support/mkdocs deploy dev
- name: Deploy
env:
KEY: "${{secrets.KEY}}"
if: env.KEY != '' && github.ref == 'refs/heads/master'
working-directory: ${{runner.workspace}}/fmt/build/fmt.dev
run: git push https://$KEY@github.com/fmtlib/fmt.dev.git

28
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: lint
on:
pull_request:
paths:
- '**.h'
- '**.cc'
permissions:
contents: read
jobs:
format_code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install clang-format
run: |
wget https://apt.llvm.org/llvm.sh
sudo bash ./llvm.sh 17
sudo apt install clang-format-17
- name: Run clang-format
run: |
find include src -name '*.h' -o -name '*.cc' | \
xargs clang-format-17 -i -style=file -fallback-style=none
git diff --exit-code

118
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,118 @@
name: linux
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
cxx: [g++-4.9, g++-10, clang++-9]
build_type: [Debug, Release]
std: [11]
shared: [""]
include:
- cxx: g++-4.9
install: sudo apt install g++-4.9
- cxx: g++-8
build_type: Debug
std: 14
install: sudo apt install g++-8
- cxx: g++-8
build_type: Debug
std: 17
install: sudo apt install g++-8
- cxx: g++-9
build_type: Debug
std: 17
- cxx: g++-10
build_type: Debug
std: 17
- cxx: g++-11
build_type: Debug
std: 20
install: sudo apt install g++-11
- cxx: clang++-8
build_type: Debug
std: 17
cxxflags: -stdlib=libc++
install: sudo apt install clang-8 libc++-8-dev libc++abi-8-dev
- cxx: clang++-9
install: sudo apt install clang-9
- cxx: clang++-9
build_type: Debug
fuzz: -DFMT_FUZZ=ON -DFMT_FUZZ_LINKMAIN=ON
std: 17
install: sudo apt install clang-9
- cxx: clang++-11
build_type: Debug
std: 20
- cxx: clang++-11
build_type: Debug
std: 20
cxxflags: -stdlib=libc++
install: sudo apt install libc++-11-dev libc++abi-11-dev
- cxx: g++-13
build_type: Release
std: 23
install: sudo apt install g++-13
shared: -DBUILD_SHARED_LIBS=ON
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set timezone
run: sudo timedatectl set-timezone 'Asia/Yekaterinburg'
- name: Add repositories for older GCC
run: |
# Below repo provides GCC 4.9.
sudo apt-add-repository 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial main'
sudo apt-add-repository 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'
if: ${{ matrix.cxx == 'g++-4.9' }}
- name: Add repositories for newer GCC
run: |
sudo apt-add-repository ppa:ubuntu-toolchain-r/test
if: ${{ matrix.cxx == 'g++-11' || matrix.cxx == 'g++-13' }}
- name: Add Ubuntu mirrors
run: |
# Github Actions caching proxy is at times unreliable
# see https://github.com/actions/runner-images/issues/7048
printf 'http://azure.archive.ubuntu.com/ubuntu\tpriority:1\n' | sudo tee /etc/apt/mirrors.txt
curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list
- name: Create Build Environment
run: |
sudo apt update
${{matrix.install}}
sudo apt install locales-all
cmake -E make_directory ${{runner.workspace}}/build
- name: Configure
working-directory: ${{runner.workspace}}/build
env:
CXX: ${{matrix.cxx}}
CXXFLAGS: ${{matrix.cxxflags}}
run: |
cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.fuzz}} ${{matrix.shared}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} -DFMT_DOC=OFF \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE
- name: Build
working-directory: ${{runner.workspace}}/build
run: |
threads=`nproc`
cmake --build . --config ${{matrix.build_type}} --parallel $threads
- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True

58
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: macos
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [macos-13, macos-14]
build_type: [Debug, Release]
std: [11, 17, 20]
shared: [""]
exclude:
- { os: macos-13, std: 11 }
- { os: macos-13, std: 17 }
include:
- os: macos-14
std: 23
build_type: Release
shared: -DBUILD_SHARED_LIBS=ON
runs-on: '${{ matrix.os }}'
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set timezone
run: sudo systemsetup -settimezone 'Asia/Yekaterinburg'
- name: Select Xcode 14.3 (macOS 13)
run: sudo xcode-select -s "/Applications/Xcode_14.3.app"
if: ${{ matrix.os == 'macos-13' }}
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure
working-directory: ${{runner.workspace}}/build
run: |
cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
-DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE
- name: Build
working-directory: ${{runner.workspace}}/build
run: |
threads=`sysctl -n hw.logicalcpu`
cmake --build . --config ${{matrix.build_type}} --parallel $threads
- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True

65
.github/workflows/scorecard.yml vendored Normal file
View File

@ -0,0 +1,65 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '26 14 * * 5'
push:
branches: [ "master" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
steps:
- name: "Checkout code"
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
with:
sarif_file: results.sarif

95
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,95 @@
name: windows
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: ${{matrix.os}}
strategy:
matrix:
# windows-2019 has MSVC 2019 installed;
# windows-2022 has MSVC 2022 installed:
# https://github.com/actions/virtual-environments.
os: [windows-2019]
platform: [Win32, x64]
toolset: [v141, v142]
standard: [14, 17, 20]
shared: ["", -DBUILD_SHARED_LIBS=ON]
build_type: [Debug, Release]
exclude:
- { toolset: v141, standard: 20 }
- { toolset: v142, standard: 14 }
- { platform: Win32, toolset: v141 }
- { platform: Win32, standard: 14 }
- { platform: Win32, standard: 20 }
- { platform: x64, toolset: v141, shared: -DBUILD_SHARED_LIBS=ON }
- { platform: x64, standard: 14, shared: -DBUILD_SHARED_LIBS=ON }
- { platform: x64, standard: 20, shared: -DBUILD_SHARED_LIBS=ON }
include:
- os: windows-2022
platform: x64
toolset: v143
build_type: Debug
standard: 20
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set timezone
run: tzutil /s "Ekaterinburg Standard Time"
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure
# Use a bash shell for $GITHUB_WORKSPACE.
shell: bash
working-directory: ${{runner.workspace}}/build
run: |
cmake -A ${{matrix.platform}} -T ${{matrix.toolset}} \
-DCMAKE_CXX_STANDARD=${{matrix.standard}} \
${{matrix.shared}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
$GITHUB_WORKSPACE
- name: Build
working-directory: ${{runner.workspace}}/build
run: |
$threads = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
cmake --build . --config ${{matrix.build_type}} --parallel $threads
- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}} -V
env:
CTEST_OUTPUT_ON_FAILURE: True
mingw:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
sys: [ mingw64, ucrt64 ]
steps:
- name: Set timezone
run: tzutil /s "Ekaterinburg Standard Time"
shell: cmd
- uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2.25.0
with:
release: false
msystem: ${{matrix.sys}}
pacboy: cc:p cmake:p ninja:p lld:p
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Configure
run: cmake -B ../build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug
env: { LDFLAGS: -fuse-ld=lld }
- name: Build
run: cmake --build ../build
- name: Test
run: ctest -j `nproc` --test-dir ../build
env:
CTEST_OUTPUT_ON_FAILURE: True

29
.gitignore vendored
View File

@ -1,17 +1,20 @@
/_CPack_Packages
/doc/conf.py
/doc/doxyxml
/doc/html
/Testing
/*-test
/install_manifest.txt
/tinyformat_speed_test
*~
*.a
*.zip
cmake_install.cmake
CPack*Config.cmake
CTestTestfile.cmake
*.so*
*.xcodeproj
*~
.vscode/
/CMakeScripts
/Testing
/_CPack_Packages
/install_manifest.txt
CMakeCache.txt
CMakeFiles
CPack*.cmake
CTestTestfile.cmake
FMT.build
Makefile
bin/
build/
cmake_install.cmake
fmt-*.cmake
fmt.pc

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "sphinx"]
path = sphinx
url = git://github.com/cppformat/sphinx.git
[submodule "breathe"]
path = breathe
url = git://github.com/michaeljones/breathe.git

View File

@ -1,23 +0,0 @@
language: cpp
os:
- linux
- osx
before_install:
- if [ $TRAVIS_OS_NAME == osx ]; then curl http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Darwin64-universal.tar.gz -o cmake.tar.gz; fi
- if [ $TRAVIS_OS_NAME == osx ]; then tar xzf cmake.tar.gz; fi
- if [ $TRAVIS_OS_NAME == osx ]; then export PATH=$PATH:"cmake-2.8.12.2-Darwin64-universal/CMake 2.8-12.app/Contents/bin"; fi
- git submodule update --init
env:
- BUILD_TYPE=Debug
- BUILD_TYPE=Release
script:
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFMT_EXTRA_TESTS=ON .
- make -j4
- make test
after_failure:
- cat Testing/Temporary/LastTest.log

View File

@ -1,34 +1,276 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.8...3.28)
# Fallback for using newer policies on CMake <3.12.
if (${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif ()
# Determine if fmt is built as a subproject (using add_subdirectory)
# or if it is the master project.
if (NOT DEFINED FMT_MASTER_PROJECT)
set(FMT_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FMT_MASTER_PROJECT ON)
message(STATUS "CMake version: ${CMAKE_VERSION}")
endif ()
endif ()
# Joins arguments and places the results in ${result_var}.
function(join result_var)
set(result "")
foreach (arg ${ARGN})
set(result "${result}${arg}")
endforeach ()
set(${result_var} "${result}" PARENT_SCOPE)
endfunction()
# DEPRECATED! Should be merged into add_module_library.
function(enable_module target)
if (MSVC)
set(BMI ${CMAKE_CURRENT_BINARY_DIR}/${target}.ifc)
target_compile_options(${target}
PRIVATE /interface /ifcOutput ${BMI}
INTERFACE /reference fmt=${BMI})
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
set_source_files_properties(${BMI} PROPERTIES GENERATED ON)
endif ()
endfunction()
set(FMT_USE_CMAKE_MODULES FALSE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND
CMAKE_GENERATOR STREQUAL "Ninja")
set(FMT_USE_CMAKE_MODULES TRUE)
endif ()
# Adds a library compiled with C++20 module support.
# `enabled` is a CMake variables that specifies if modules are enabled.
# If modules are disabled `add_module_library` falls back to creating a
# non-modular library.
#
# Usage:
# add_module_library(<name> [sources...] FALLBACK [sources...] [IF enabled])
function(add_module_library name)
cmake_parse_arguments(AML "" "IF" "FALLBACK" ${ARGN})
set(sources ${AML_UNPARSED_ARGUMENTS})
add_library(${name})
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
if (NOT ${${AML_IF}})
# Create a non-modular library.
target_sources(${name} PRIVATE ${AML_FALLBACK})
set_target_properties(${name} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
return()
endif ()
# Modules require C++20.
target_compile_features(${name} PUBLIC cxx_std_20)
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(${name} PUBLIC -fmodules-ts)
endif ()
target_compile_definitions(${name} PRIVATE FMT_MODULE)
if (FMT_USE_CMAKE_MODULES)
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES
FILES ${sources})
else()
# `std` is affected by CMake options and may be higher than C++20.
get_target_property(std ${name} CXX_STANDARD)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(pcms)
foreach (src ${sources})
get_filename_component(pcm ${src} NAME_WE)
set(pcm ${pcm}.pcm)
# Propagate -fmodule-file=*.pcm to targets that link with this library.
target_compile_options(
${name} PUBLIC -fmodule-file=${CMAKE_CURRENT_BINARY_DIR}/${pcm})
# Use an absolute path to prevent target_link_libraries prepending -l
# to it.
set(pcms ${pcms} ${CMAKE_CURRENT_BINARY_DIR}/${pcm})
add_custom_command(
OUTPUT ${pcm}
COMMAND ${CMAKE_CXX_COMPILER}
-std=c++${std} -x c++-module --precompile -c
-o ${pcm} ${CMAKE_CURRENT_SOURCE_DIR}/${src}
"-I$<JOIN:$<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>,;-I>"
# Required by the -I generator expression above.
COMMAND_EXPAND_LISTS
DEPENDS ${src})
endforeach ()
# Add .pcm files as sources to make sure they are built before the library.
set(sources)
foreach (pcm ${pcms})
get_filename_component(pcm_we ${pcm} NAME_WE)
set(obj ${pcm_we}.o)
# Use an absolute path to prevent target_link_libraries prepending -l.
set(sources ${sources} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})
add_custom_command(
OUTPUT ${obj}
COMMAND ${CMAKE_CXX_COMPILER} $<TARGET_PROPERTY:${name},COMPILE_OPTIONS>
-c -o ${obj} ${pcm}
DEPENDS ${pcm})
endforeach ()
endif ()
target_sources(${name} PRIVATE ${sources})
endif()
endfunction()
include(CMakeParseArguments)
# Sets a cache variable with a docstring joined from multiple arguments:
# set(<variable> <value>... CACHE <type> <docstring>...)
# This allows splitting a long docstring for readability.
function(set_verbose)
# cmake_parse_arguments is broken in CMake 3.4 (cannot parse CACHE) so use
# list instead.
list(GET ARGN 0 var)
list(REMOVE_AT ARGN 0)
list(GET ARGN 0 val)
list(REMOVE_AT ARGN 0)
list(REMOVE_AT ARGN 0)
list(GET ARGN 0 type)
list(REMOVE_AT ARGN 0)
join(doc ${ARGN})
set(${var} ${val} CACHE ${type} ${doc})
endfunction()
# Set the default CMAKE_BUILD_TYPE to Release.
# This should be done before the project command since the latter can set
# CMAKE_BUILD_TYPE itself (it does so for nmake).
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
if (FMT_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE)
set_verbose(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or "
"CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif ()
option(FMT_EXTRA_TESTS "Enable extra tests." OFF)
project(FMT CXX)
include(GNUInstallDirs)
set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING
"Installation directory for include files, a relative path that "
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")
project(FORMAT)
option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF)
option(FMT_WERROR "Halt the compilation with an error on compiler warnings."
OFF)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11_FLAG)
if (HAVE_STD_CPP11_FLAG)
set(CPP11_FLAG -std=c++11)
else ()
check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0X_FLAG)
if (HAVE_STD_CPP0X_FLAG)
set(CPP11_FLAG -std=c++0x)
endif ()
# Options that control generation of various targets.
option(FMT_DOC "Generate the doc target." ${FMT_MASTER_PROJECT})
option(FMT_INSTALL "Generate the install target." ON)
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT})
option(FMT_FUZZ "Generate the fuzz target." OFF)
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
option(FMT_OS "Include OS-specific APIs." ON)
option(FMT_MODULE "Build a module instead of a traditional library." OFF)
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF)
option(FMT_UNICODE "Enable Unicode support." ON)
if (FMT_TEST AND FMT_MODULE)
# The tests require {fmt} to be compiled as traditional library
message(STATUS "Testing is incompatible with build mode 'module'.")
endif ()
set(FMT_SYSTEM_HEADERS_ATTRIBUTE "")
if (FMT_SYSTEM_HEADERS)
set(FMT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "MSDOS")
set(FMT_TEST OFF)
message(STATUS "MSDOS is incompatible with gtest")
endif ()
# Get version from base.h
file(READ include/fmt/base.h base_h)
if (NOT base_h MATCHES "FMT_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])")
message(FATAL_ERROR "Cannot get FMT_VERSION from base.h.")
endif ()
# Use math to skip leading zeros if any.
math(EXPR CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
math(EXPR CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
math(EXPR CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
join(FMT_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.
${CPACK_PACKAGE_VERSION_PATCH})
message(STATUS "{fmt} version: ${FMT_VERSION}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
"${CMAKE_CURRENT_SOURCE_DIR}/support/cmake")
if (CMAKE_GENERATOR MATCHES "Visual Studio")
include(CheckCXXCompilerFlag)
include(JoinPaths)
if (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
set_verbose(CMAKE_CXX_VISIBILITY_PRESET hidden CACHE STRING
"Preset for the export of private symbols")
set_property(CACHE CMAKE_CXX_VISIBILITY_PRESET PROPERTY STRINGS
hidden default)
endif ()
if (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
set_verbose(CMAKE_VISIBILITY_INLINES_HIDDEN ON CACHE BOOL
"Whether to add a compile flag to hide symbols of inline functions")
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(PEDANTIC_COMPILE_FLAGS -pedantic-errors -Wall -Wextra -pedantic
-Wold-style-cast -Wundef
-Wredundant-decls -Wwrite-strings -Wpointer-arith
-Wcast-qual -Wformat=2 -Wmissing-include-dirs
-Wcast-align
-Wctor-dtor-privacy -Wdisabled-optimization
-Winvalid-pch -Woverloaded-virtual
-Wconversion -Wundef
-Wno-ctor-dtor-privacy -Wno-format-nonliteral)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS}
-Wno-dangling-else -Wno-unused-local-typedefs)
endif ()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wdouble-promotion
-Wtrampolines -Wzero-as-null-pointer-constant -Wuseless-cast
-Wvector-operation-performance -Wsized-deallocation -Wshadow)
endif ()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wshift-overflow=2
-Wduplicated-cond)
# Workaround for GCC regression
# [12/13/14/15 regression] New (since gcc 12) false positive null-dereference in vector.resize
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108860
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnull-dereference)
endif ()
endif ()
set(WERROR_FLAG -Werror)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(PEDANTIC_COMPILE_FLAGS -Wall -Wextra -pedantic -Wconversion -Wundef
-Wdeprecated -Wweak-vtables -Wshadow
-Wno-gnu-zero-variadic-macro-arguments)
check_cxx_compiler_flag(-Wzero-as-null-pointer-constant HAS_NULLPTR_WARNING)
if (HAS_NULLPTR_WARNING)
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS}
-Wzero-as-null-pointer-constant)
endif ()
set(WERROR_FLAG -Werror)
endif ()
if (MSVC)
set(PEDANTIC_COMPILE_FLAGS /W3)
set(WERROR_FLAG /WX)
endif ()
if (FMT_MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio")
# If Microsoft SDK is installed create script run-msbuild.bat that
# calls SetEnv.cmd to to set up build environment and runs msbuild.
# calls SetEnv.cmd to set up build environment and runs msbuild.
# It is useful when building Visual Studio projects with the SDK
# toolchain rather than Visual Studio.
include(FindSetEnv)
@ -36,124 +278,254 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
set(MSBUILD_SETUP "call \"${WINSDK_SETENV}\"")
endif ()
# Set FrameworkPathOverride to get rid of MSB3644 warnings.
join(netfxpath
"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\"
".NETFramework\\v4.0")
file(WRITE run-msbuild.bat "
${MSBUILD_SETUP}
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\" %*")
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*")
endif ()
option(FMT_SHARED "Build shared library instead of static one" OFF)
if (FMT_SHARED)
set(shared SHARED)
function(add_headers VAR)
set(headers ${${VAR}})
foreach (header ${ARGN})
set(headers ${headers} include/fmt/${header})
endforeach()
set(${VAR} ${headers} PARENT_SCOPE)
endfunction()
# Define the fmt library, its includes and the needed defines.
add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
format-inl.h os.h ostream.h printf.h ranges.h std.h
xchar.h)
set(FMT_SOURCES src/format.cc)
add_module_library(fmt src/fmt.cc FALLBACK
${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md
IF FMT_MODULE)
add_library(fmt::fmt ALIAS fmt)
if (FMT_MODULE)
enable_module(fmt)
elseif (FMT_OS)
target_sources(fmt PRIVATE src/os.cc)
else()
target_compile_definitions(fmt PRIVATE FMT_OS=0)
endif ()
set(FMT_SOURCES format.cc format.h)
if (FMT_WERROR)
target_compile_options(fmt PRIVATE ${WERROR_FLAG})
endif ()
if (FMT_PEDANTIC)
target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})
endif ()
include(CheckSymbolExists)
if (WIN32)
check_symbol_exists(open io.h HAVE_OPEN)
if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
target_compile_features(fmt PUBLIC cxx_std_11)
else ()
check_symbol_exists(open fcntl.h HAVE_OPEN)
endif ()
if (HAVE_OPEN)
add_definitions(-DFMT_USE_FILE_DESCRIPTORS=1)
set(FMT_SOURCES ${FMT_SOURCES} posix.cc posix.h)
message(WARNING "Feature cxx_std_11 is unknown for the CXX compiler")
endif ()
add_library(format ${shared} ${FMT_SOURCES})
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(format PROPERTIES COMPILE_FLAGS
"-Wall -Wextra -pedantic")
endif ()
if (CPP11_FLAG AND FMT_EXTRA_TESTS)
set_target_properties(format PROPERTIES COMPILE_FLAGS ${CPP11_FLAG})
# Test compilation with default flags.
file(GLOB src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cc test/*.h)
add_library(testformat ${FMT_SOURCES} ${src})
target_include_directories(fmt ${FMT_SYSTEM_HEADERS_ATTRIBUTE} BEFORE PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${FMT_INC_DIR}>)
set(FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.")
set_target_properties(fmt PROPERTIES
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
PUBLIC_HEADER "${FMT_HEADERS}"
DEBUG_POSTFIX "${FMT_DEBUG_POSTFIX}"
# Workaround for Visual Studio 2017:
# Ensure the .pdb is created with the same name and in the same directory
# as the .lib. Newer VS versions already do this by default, but there is no
# harm in setting it for those too. Ignored by other generators.
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
COMPILE_PDB_NAME "fmt"
COMPILE_PDB_NAME_DEBUG "fmt${FMT_DEBUG_POSTFIX}")
# Set FMT_LIB_NAME for pkg-config fmt.pc. We cannot use the OUTPUT_NAME target
# property because it's not set by default.
set(FMT_LIB_NAME fmt)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(FMT_LIB_NAME ${FMT_LIB_NAME}${FMT_DEBUG_POSTFIX})
endif ()
add_subdirectory(doc)
# We compile Google Test ourselves instead of using pre-compiled libraries.
# See the Google Test FAQ "Why is it not recommended to install a
# pre-compiled copy of Google Test (for example, into /usr/local)?"
# at http://code.google.com/p/googletest/wiki/FAQ for more details.
# GTest doesn't detect <tuple> with clang.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
if (BUILD_SHARED_LIBS)
target_compile_definitions(fmt PRIVATE FMT_LIB_EXPORT INTERFACE FMT_SHARED)
endif ()
if (FMT_SAFE_DURATION_CAST)
target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST)
endif ()
include_directories(gtest/include)
add_subdirectory(gtest)
add_library(fmt-header-only INTERFACE)
add_library(fmt::fmt-header-only ALIAS fmt-header-only)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
if (NOT MSVC)
# Unicode is always supported on compilers other than MSVC.
elseif (FMT_UNICODE)
# Unicode support requires compiling with /utf-8.
target_compile_options(fmt PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
target_compile_options(fmt-header-only INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
else ()
target_compile_definitions(fmt PUBLIC FMT_UNICODE=0)
endif ()
enable_testing()
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
target_compile_features(fmt-header-only INTERFACE cxx_std_11)
include_directories(.)
target_include_directories(fmt-header-only
${FMT_SYSTEM_HEADERS_ATTRIBUTE} BEFORE INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${FMT_INC_DIR}>)
set(TEST_MAIN_SRC
test/test-main.cc test/gtest-extra.cc test/gtest-extra.h test/util.cc)
add_library(test-main ${TEST_MAIN_SRC})
target_link_libraries(test-main gtest format)
# Install targets.
if (FMT_INSTALL)
include(CMakePackageConfigHelpers)
set_verbose(FMT_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/fmt CACHE STRING
"Installation directory for cmake files, a relative path that "
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute "
"path.")
set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake)
set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake)
set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc)
set(targets_export_name fmt-targets)
cxx_test(gtest-extra-test test-main)
cxx_test(format-test test-main)
cxx_test(printf-test test-main)
foreach (target format-test printf-test)
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS
"-Wall -Wextra -pedantic -Wno-long-long -Wno-variadic-macros")
set_verbose(FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING
"Installation directory for libraries, a relative path that "
"will be joined to ${CMAKE_INSTALL_PREFIX} or an absolute path.")
set_verbose(FMT_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE STRING
"Installation directory for pkgconfig (.pc) files, a relative "
"path that will be joined with ${CMAKE_INSTALL_PREFIX} or an "
"absolute path.")
# Generate the version, config and target files into the build directory.
write_basic_package_version_file(
${version_config}
VERSION ${FMT_VERSION}
COMPATIBILITY AnyNewerVersion)
join_paths(libdir_for_pc_file "\${exec_prefix}" "${FMT_LIB_DIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${FMT_INC_DIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in"
"${pkgconfig}"
@ONLY)
configure_package_config_file(
${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in
${project_config}
INSTALL_DESTINATION ${FMT_CMAKE_DIR})
set(INSTALL_TARGETS fmt fmt-header-only)
set(INSTALL_FILE_SET)
if (FMT_USE_CMAKE_MODULES)
set(INSTALL_FILE_SET FILE_SET fmt DESTINATION "${FMT_INC_DIR}/fmt")
endif()
# Install the library and headers.
install(TARGETS ${INSTALL_TARGETS}
COMPONENT fmt-core
EXPORT ${targets_export_name}
LIBRARY DESTINATION ${FMT_LIB_DIR}
ARCHIVE DESTINATION ${FMT_LIB_DIR}
PUBLIC_HEADER DESTINATION "${FMT_INC_DIR}/fmt"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
${INSTALL_FILE_SET})
# Use a namespace because CMake provides better diagnostics for namespaced
# imported targets.
export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt::
FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake)
# Install version, config and target files.
install(FILES ${project_config} ${version_config}
DESTINATION ${FMT_CMAKE_DIR}
COMPONENT fmt-core)
install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR}
NAMESPACE fmt::
COMPONENT fmt-core)
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}"
COMPONENT fmt-core)
endif ()
function(add_doc_target)
find_program(DOXYGEN doxygen
PATHS "$ENV{ProgramFiles}/doxygen/bin"
"$ENV{ProgramFiles\(x86\)}/doxygen/bin")
if (NOT DOXYGEN)
message(STATUS "Target 'doc' disabled because doxygen not found")
return ()
endif ()
if (CPP11_FLAG)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS ${CPP11_FLAG})
find_program(MKDOCS mkdocs)
if (NOT MKDOCS)
message(STATUS "Target 'doc' disabled because mkdocs not found")
return ()
endif ()
endforeach ()
cxx_test(util-test test-main)
add_executable(macro-test test/macro-test.cc ${FMT_SOURCES} ${TEST_MAIN_SRC})
set_target_properties(macro-test
PROPERTIES COMPILE_DEFINITIONS "FMT_USE_VARIADIC_TEMPLATES=0")
target_link_libraries(macro-test gtest)
set(sources )
foreach (source api.md index.md syntax.md get-started.md fmt.css fmt.js)
set(sources ${sources} doc/${source})
endforeach()
if (HAVE_OPEN)
add_executable(posix-test test/posix-test.cc ${FMT_SOURCES} ${TEST_MAIN_SRC})
set_target_properties(posix-test
PROPERTIES COMPILE_DEFINITIONS "FMT_INCLUDE_POSIX_TEST=1")
target_link_libraries(posix-test gtest)
add_test(posix-test posix-test)
add_custom_target(
doc
COMMAND
${CMAKE_COMMAND}
-E env PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/support/python
${MKDOCS} build -f ${CMAKE_CURRENT_SOURCE_DIR}/support/mkdocs.yml
# MkDocs requires the site dir to be outside of the doc dir.
--site-dir ${CMAKE_CURRENT_BINARY_DIR}/doc-html
--no-directory-urls
SOURCES ${sources})
include(GNUInstallDirs)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc-html/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt
COMPONENT fmt-doc OPTIONAL)
endfunction()
if (FMT_DOC)
add_doc_target()
endif ()
add_test(compile-test ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_SOURCE_DIR}/test"
"${CMAKE_CURRENT_BINARY_DIR}/test"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM})
if (FMT_TEST)
enable_testing()
add_subdirectory(test)
endif ()
if (EXISTS .gitignore)
# Control fuzzing independent of the unit tests.
if (FMT_FUZZ)
add_subdirectory(test/fuzzing)
# The FMT_FUZZ macro is used to prevent resource exhaustion in fuzzing
# mode and make fuzzing practically possible. It is similar to
# FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION but uses a different name to
# avoid interfering with fuzzing of projects that use {fmt}.
# See also https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode.
target_compile_definitions(fmt PUBLIC FMT_FUZZ)
endif ()
set(gitignore ${PROJECT_SOURCE_DIR}/.gitignore)
if (FMT_MASTER_PROJECT AND EXISTS ${gitignore})
# Get the list of ignored files from .gitignore.
file (STRINGS ".gitignore" lines)
LIST(REMOVE_ITEM lines /doc/html)
file (STRINGS ${gitignore} lines)
list(REMOVE_ITEM lines /doc/html)
foreach (line ${lines})
string(REPLACE "." "[.]" line "${line}")
string(REPLACE "*" ".*" line "${line}")
set(ignored_files ${ignored_files} "${line}$" "${line}/")
endforeach ()
set(ignored_files ${ignored_files} /.git /breathe /format-benchmark sphinx/)
set(ignored_files ${ignored_files} /.git /build/doxyxml .vagrant)
set(CPACK_SOURCE_GENERATOR ZIP)
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 10)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPPFORMAT_VERSION
${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(CPACK_SOURCE_PACKAGE_FILE_NAME cppformat-${CPPFORMAT_VERSION})
set(CPACK_RESOURCE_FILE_README ${FORMAT_SOURCE_DIR}/README.rst)
set(CPACK_SOURCE_PACKAGE_FILE_NAME fmt-${FMT_VERSION})
set(CPACK_PACKAGE_NAME fmt)
set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)
include(CPack)
endif ()
configure_file(doc/conf.py.in doc/conf.py @ONLY)

20
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,20 @@
Contributing to {fmt}
=====================
By submitting a pull request or a patch, you represent that you have the right
to license your contribution to the {fmt} project owners and the community,
agree that your contributions are licensed under the {fmt} license, and agree
to future changes to the licensing.
All C++ code must adhere to [Google C++ Style Guide](
https://google.github.io/styleguide/cppguide.html) with the following
exceptions:
* Exceptions are permitted
* snake_case should be used instead of UpperCamelCase for function and type
names
All documentation must adhere to the [Google Developer Documentation Style
Guide](https://developers.google.com/style).
Thanks for contributing!

2891
ChangeLog.md Normal file

File diff suppressed because it is too large Load Diff

27
LICENSE Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- Optional exception to the license ---
As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.

485
README.md Normal file
View File

@ -0,0 +1,485 @@
<img src="https://user-images.githubusercontent.com/576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png" alt="{fmt}" width="25%"/>
[![image](https://github.com/fmtlib/fmt/workflows/linux/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux)
[![image](https://github.com/fmtlib/fmt/workflows/macos/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos)
[![image](https://github.com/fmtlib/fmt/workflows/windows/badge.svg)](https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows)
[![fmt is continuously fuzzed at oss-fuzz](https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?\%0Acolspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\%0ASummary&q=proj%3Dfmt&can=1)
[![Ask questions at StackOverflow with the tag fmt](https://img.shields.io/badge/stackoverflow-fmt-blue.svg)](https://stackoverflow.com/questions/tagged/fmt)
[![image](https://api.securityscorecards.dev/projects/github.com/fmtlib/fmt/badge)](https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt)
**{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams.
If you like this project, please consider donating to one of the funds
that help victims of the war in Ukraine: <https://www.stopputin.net/>.
[Documentation](https://fmt.dev)
[Cheat Sheets](https://hackingcpp.com/cpp/libs/fmt.html)
Q&A: ask questions on [StackOverflow with the tag
fmt](https://stackoverflow.com/questions/tagged/fmt).
Try {fmt} in [Compiler Explorer](https://godbolt.org/z/8Mx1EW73v).
# Features
- Simple [format API](https://fmt.dev/latest/api/) with positional
arguments for localization
- Implementation of [C++20
std::format](https://en.cppreference.com/w/cpp/utility/format) and
[C++23 std::print](https://en.cppreference.com/w/cpp/io/print)
- [Format string syntax](https://fmt.dev/latest/syntax/) similar
to Python\'s
[format](https://docs.python.org/3/library/stdtypes.html#str.format)
- Fast IEEE 754 floating-point formatter with correct rounding,
shortness and round-trip guarantees using the
[Dragonbox](https://github.com/jk-jeon/dragonbox) algorithm
- Portable Unicode support
- Safe [printf
implementation](https://fmt.dev/latest/api/#printf-formatting)
including the POSIX extension for positional arguments
- Extensibility: [support for user-defined
types](https://fmt.dev/latest/api/#formatting-user-defined-types)
- High performance: faster than common standard library
implementations of `(s)printf`, iostreams, `to_string` and
`to_chars`, see [Speed tests](#speed-tests) and [Converting a
hundred million integers to strings per
second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html)
- Small code size both in terms of source code with the minimum
configuration consisting of just three files, `core.h`, `format.h`
and `format-inl.h`, and compiled code; see [Compile time and code
bloat](#compile-time-and-code-bloat)
- Reliability: the library has an extensive set of
[tests](https://github.com/fmtlib/fmt/tree/master/test) and is
[continuously fuzzed](https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1)
- Safety: the library is fully type-safe, errors in format strings can
be reported at compile time, automatic memory management prevents
buffer overflow errors
- Ease of use: small self-contained code base, no external
dependencies, permissive MIT
[license](https://github.com/fmtlib/fmt/blob/master/LICENSE)
- [Portability](https://fmt.dev/latest/#portability) with
consistent output across platforms and support for older compilers
- Clean warning-free codebase even on high warning levels such as
`-Wall -Wextra -pedantic`
- Locale independence by default
- Optional header-only configuration enabled with the
`FMT_HEADER_ONLY` macro
See the [documentation](https://fmt.dev) for more details.
# Examples
**Print to stdout** ([run](https://godbolt.org/z/Tevcjh))
``` c++
#include <fmt/core.h>
int main() {
fmt::print("Hello, world!\n");
}
```
**Format a string** ([run](https://godbolt.org/z/oK8h33))
``` c++
std::string s = fmt::format("The answer is {}.", 42);
// s == "The answer is 42."
```
**Format a string using positional arguments**
([run](https://godbolt.org/z/Yn7Txe))
``` c++
std::string s = fmt::format("I'd rather be {1} than {0}.", "right", "happy");
// s == "I'd rather be happy than right."
```
**Print dates and times** ([run](https://godbolt.org/z/c31ExdY3W))
``` c++
#include <fmt/chrono.h>
int main() {
auto now = std::chrono::system_clock::now();
fmt::print("Date and time: {}\n", now);
fmt::print("Time: {:%H:%M}\n", now);
}
```
Output:
Date and time: 2023-12-26 19:10:31.557195597
Time: 19:10
**Print a container** ([run](https://godbolt.org/z/MxM1YqjE7))
``` c++
#include <vector>
#include <fmt/ranges.h>
int main() {
std::vector<int> v = {1, 2, 3};
fmt::print("{}\n", v);
}
```
Output:
[1, 2, 3]
**Check a format string at compile time**
``` c++
std::string s = fmt::format("{:d}", "I am not a number");
```
This gives a compile-time error in C++20 because `d` is an invalid
format specifier for a string.
**Write a file from a single thread**
``` c++
#include <fmt/os.h>
int main() {
auto out = fmt::output_file("guide.txt");
out.print("Don't {}", "Panic");
}
```
This can be [5 to 9 times faster than
fprintf](http://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html).
**Print with colors and text styles**
``` c++
#include <fmt/color.h>
int main() {
fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,
"Hello, {}!\n", "world");
fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |
fmt::emphasis::underline, "Olá, {}!\n", "Mundo");
fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,
"你好{}\n", "世界");
}
```
Output on a modern terminal with Unicode support:
![image](https://github.com/fmtlib/fmt/assets/%0A576385/2a93c904-d6fa-4aa6-b453-2618e1c327d7)
# Benchmarks
## Speed tests
| Library | Method | Run Time, s |
|-------------------|---------------|-------------|
| libc | printf | 0.91 |
| libc++ | std::ostream | 2.49 |
| {fmt} 9.1 | fmt::print | 0.74 |
| Boost Format 1.80 | boost::format | 6.26 |
| Folly Format | folly::format | 1.87 |
{fmt} is the fastest of the benchmarked methods, \~20% faster than
`printf`.
The above results were generated by building `tinyformat_test.cpp` on
macOS 12.6.1 with `clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT`, and
taking the best of three runs. In the test, the format string
`"%0.10f:%04d:%+g:%s:%p:%c:%%\n"` or equivalent is filled 2,000,000
times with output sent to `/dev/null`; for further details refer to the
[source](https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc).
{fmt} is up to 20-30x faster than `std::ostringstream` and `sprintf` on
IEEE754 `float` and `double` formatting
([dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark)) and faster
than [double-conversion](https://github.com/google/double-conversion)
and [ryu](https://github.com/ulfjack/ryu):
[![image](https://user-images.githubusercontent.com/576385/95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png)](https://fmt.dev/unknown_mac64_clang12.0.html)
## Compile time and code bloat
The script [bloat-test.py][test] from [format-benchmark][bench] tests compile
time and code bloat for nontrivial projects. It generates 100 translation units
and uses `printf()` or its alternative five times in each to simulate a
medium-sized project. The resulting executable size and compile time (Apple
clang version 15.0.0 (clang-1500.1.0.2.5), macOS Sonoma, best of three) is shown
in the following tables.
[test]: https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py
[bench]: https://github.com/fmtlib/format-benchmark
**Optimized build (-O3)**
| Method | Compile Time, s | Executable size, KiB | Stripped size, KiB |
|---------------|-----------------|----------------------|--------------------|
| printf | 1.6 | 54 | 50 |
| IOStreams | 25.9 | 98 | 84 |
| fmt 83652df | 4.8 | 54 | 50 |
| tinyformat | 29.1 | 161 | 136 |
| Boost Format | 55.0 | 530 | 317 |
{fmt} is fast to compile and is comparable to `printf` in terms of per-call
binary size (within a rounding error on this system).
**Non-optimized build**
| Method | Compile Time, s | Executable size, KiB | Stripped size, KiB |
|---------------|-----------------|----------------------|--------------------|
| printf | 1.4 | 54 | 50 |
| IOStreams | 23.4 | 92 | 68 |
| {fmt} 83652df | 4.4 | 89 | 85 |
| tinyformat | 24.5 | 204 | 161 |
| Boost Format | 36.4 | 831 | 462 |
`libc`, `lib(std)c++`, and `libfmt` are all linked as shared libraries
to compare formatting function overhead only. Boost Format is a
header-only library so it doesn\'t provide any linkage options.
## Running the tests
Please refer to [Building the
library](https://fmt.dev/latest/get-started/#building-from-source) for
instructions on how to build the library and run the unit tests.
Benchmarks reside in a separate repository,
[format-benchmarks](https://github.com/fmtlib/format-benchmark), so to
run the benchmarks you first need to clone this repository and generate
Makefiles with CMake:
$ git clone --recursive https://github.com/fmtlib/format-benchmark.git
$ cd format-benchmark
$ cmake .
Then you can run the speed test:
$ make speed-test
or the bloat test:
$ make bloat-test
# Migrating code
[clang-tidy](https://clang.llvm.org/extra/clang-tidy/) v18 provides the
[modernize-use-std-print](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-print.html)
check that is capable of converting occurrences of `printf` and
`fprintf` to `fmt::print` if configured to do so. (By default it
converts to `std::print`.)
# Notable projects using this library
- [0 A.D.](https://play0ad.com/): a free, open-source, cross-platform
real-time strategy game
- [AMPL/MP](https://github.com/ampl/mp): an open-source library for
mathematical programming
- [Apple's FoundationDB](https://github.com/apple/foundationdb): an open-source,
distributed, transactional key-value store
- [Aseprite](https://github.com/aseprite/aseprite): animated sprite
editor & pixel art tool
- [AvioBook](https://www.aviobook.aero/en): a comprehensive aircraft
operations suite
- [Blizzard Battle.net](https://battle.net/): an online gaming
platform
- [Celestia](https://celestia.space/): real-time 3D visualization of
space
- [Ceph](https://ceph.com/): a scalable distributed storage system
- [ccache](https://ccache.dev/): a compiler cache
- [ClickHouse](https://github.com/ClickHouse/ClickHouse): an
analytical database management system
- [ContextVision](https://www.contextvision.com/): medical imaging software
- [Contour](https://github.com/contour-terminal/contour/): a modern
terminal emulator
- [CUAUV](https://cuauv.org/): Cornell University\'s autonomous
underwater vehicle
- [Drake](https://drake.mit.edu/): a planning, control, and analysis
toolbox for nonlinear dynamical systems (MIT)
- [Envoy](https://github.com/envoyproxy/envoy): C++ L7 proxy and
communication bus (Lyft)
- [FiveM](https://fivem.net/): a modification framework for GTA V
- [fmtlog](https://github.com/MengRao/fmtlog): a performant
fmtlib-style logging library with latency in nanoseconds
- [Folly](https://github.com/facebook/folly): Facebook open-source
library
- [GemRB](https://gemrb.org/): a portable open-source implementation
of Bioware's Infinity Engine
- [Grand Mountain
Adventure](https://store.steampowered.com/app/1247360/Grand_Mountain_Adventure/):
a beautiful open-world ski & snowboarding game
- [HarpyWar/pvpgn](https://github.com/pvpgn/pvpgn-server): Player vs
Player Gaming Network with tweaks
- [KBEngine](https://github.com/kbengine/kbengine): an open-source
MMOG server engine
- [Keypirinha](https://keypirinha.com/): a semantic launcher for
Windows
- [Kodi](https://kodi.tv/) (formerly xbmc): home theater software
- [Knuth](https://kth.cash/): high-performance Bitcoin full-node
- [libunicode](https://github.com/contour-terminal/libunicode/): a
modern C++17 Unicode library
- [MariaDB](https://mariadb.org/): relational database management
system
- [Microsoft Verona](https://github.com/microsoft/verona): research
programming language for concurrent ownership
- [MongoDB](https://mongodb.com/): distributed document database
- [MongoDB Smasher](https://github.com/duckie/mongo_smasher): a small
tool to generate randomized datasets
- [OpenSpace](https://openspaceproject.com/): an open-source
astrovisualization framework
- [PenUltima Online (POL)](https://www.polserver.com/): an MMO server,
compatible with most Ultima Online clients
- [PyTorch](https://github.com/pytorch/pytorch): an open-source
machine learning library
- [quasardb](https://www.quasardb.net/): a distributed,
high-performance, associative database
- [Quill](https://github.com/odygrd/quill): asynchronous low-latency
logging library
- [QKW](https://github.com/ravijanjam/qkw): generalizing aliasing to
simplify navigation, and execute complex multi-line terminal
command sequences
- [redis-cerberus](https://github.com/HunanTV/redis-cerberus): a Redis
cluster proxy
- [redpanda](https://vectorized.io/redpanda): a 10x faster Kafka®
replacement for mission-critical systems written in C++
- [rpclib](http://rpclib.net/): a modern C++ msgpack-RPC server and
client library
- [Salesforce Analytics
Cloud](https://www.salesforce.com/analytics-cloud/overview/):
business intelligence software
- [Scylla](https://www.scylladb.com/): a Cassandra-compatible NoSQL
data store that can handle 1 million transactions per second on a
single server
- [Seastar](http://www.seastar-project.org/): an advanced, open-source
C++ framework for high-performance server applications on modern
hardware
- [spdlog](https://github.com/gabime/spdlog): super fast C++ logging
library
- [Stellar](https://www.stellar.org/): financial platform
- [Touch Surgery](https://www.touchsurgery.com/): surgery simulator
- [TrinityCore](https://github.com/TrinityCore/TrinityCore):
open-source MMORPG framework
- [🐙 userver framework](https://userver.tech/): open-source
asynchronous framework with a rich set of abstractions and database
drivers
- [Windows Terminal](https://github.com/microsoft/terminal): the new
Windows terminal
[More\...](https://github.com/search?q=fmtlib&type=Code)
If you are aware of other projects using this library, please let me
know by [email](mailto:victor.zverovich@gmail.com) or by submitting an
[issue](https://github.com/fmtlib/fmt/issues).
# Motivation
So why yet another formatting library?
There are plenty of methods for doing this task, from standard ones like
the printf family of function and iostreams to Boost Format and
FastFormat libraries. The reason for creating a new library is that
every existing solution that I found either had serious issues or
didn\'t provide all the features I needed.
## printf
The good thing about `printf` is that it is pretty fast and readily
available being a part of the C standard library. The main drawback is
that it doesn\'t support user-defined types. `printf` also has safety
issues although they are somewhat mitigated with [\_\_attribute\_\_
((format (printf,
\...))](https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html) in
GCC. There is a POSIX extension that adds positional arguments required
for
[i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization)
to `printf` but it is not a part of C99 and may not be available on some
platforms.
## iostreams
The main issue with iostreams is best illustrated with an example:
``` c++
std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
```
which is a lot of typing compared to printf:
``` c++
printf("%.2f\n", 1.23456);
```
Matthew Wilson, the author of FastFormat, called this \"chevron hell\".
iostreams don\'t support positional arguments by design.
The good part is that iostreams support user-defined types and are safe
although error handling is awkward.
## Boost Format
This is a very powerful library that supports both `printf`-like format
strings and positional arguments. Its main drawback is performance.
According to various benchmarks, it is much slower than other methods
considered here. Boost Format also has excessive build times and severe
code bloat issues (see [Benchmarks](#benchmarks)).
## FastFormat
This is an interesting library that is fast, safe and has positional
arguments. However, it has significant limitations, citing its author:
> Three features that have no hope of being accommodated within the
> current design are:
>
> - Leading zeros (or any other non-space padding)
> - Octal/hexadecimal encoding
> - Runtime width/alignment specification
It is also quite big and has a heavy dependency, on STLSoft, which might be
too restrictive for use in some projects.
## Boost Spirit.Karma
This is not a formatting library but I decided to include it here for
completeness. As iostreams, it suffers from the problem of mixing
verbatim text with arguments. The library is pretty fast, but slower on
integer formatting than `fmt::format_to` with format string compilation
on Karma\'s own benchmark, see [Converting a hundred million integers to
strings per
second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html).
# License
{fmt} is distributed under the MIT
[license](https://github.com/fmtlib/fmt/blob/master/LICENSE).
# Documentation License
The [Format String Syntax](https://fmt.dev/latest/syntax/) section
in the documentation is based on the one from Python [string module
documentation](https://docs.python.org/3/library/string.html#module-string).
For this reason, the documentation is distributed under the Python
Software Foundation license available in
[doc/python-license.txt](https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt).
It only applies if you distribute the documentation of {fmt}.
# Maintainers
The {fmt} library is maintained by Victor Zverovich
([vitaut](https://github.com/vitaut)) with contributions from many other
people. See
[Contributors](https://github.com/fmtlib/fmt/graphs/contributors) and
[Releases](https://github.com/fmtlib/fmt/releases) for some of the
names. Let us know if your contribution is not listed or mentioned
incorrectly and we\'ll make it right.
# Security Policy
To report a security issue, please disclose it at [security
advisory](https://github.com/fmtlib/fmt/security/advisories/new).
This project is maintained by a team of volunteers on a
reasonable-effort basis. As such, please give us at least *90* days to
work on a fix before public exposure.

View File

@ -1,401 +0,0 @@
C++ Format
==========
.. image:: https://travis-ci.org/cppformat/cppformat.png?branch=master
:target: https://travis-ci.org/cppformat/cppformat
.. image:: https://ci.appveyor.com/api/projects/status/qk0bhyhqp1ekpat8
:target: https://ci.appveyor.com/project/vitaut/cppformat
C++ Format is an open-source formatting library for C++.
It can be used as a safe alternative to printf or as a fast
alternative to IOStreams.
Features
--------
* Two APIs: faster concatenation-based write API and slower (but still
very fast) replacement-based format API with positional arguments for
localization.
* Write API similar to the one used by IOStreams but much faster and more
consistent.
* Format API with `format string syntax
<http://cppformat.github.io/doc/latest#format-string-syntax>`__
similar to the one used by `str.format
<http://docs.python.org/2/library/stdtypes.html#str.format>`__ in Python.
* Support for user-defined types.
* High speed: performance of the format API is close to that of
glibc's `printf <http://en.cppreference.com/w/cpp/io/c/fprintf>`__
and better than performance of IOStreams. See `Speed tests`_ and
`Fast integer to string conversion in C++
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
* Small code size both in terms of source code (format consists of a single
header file and a single source file) and compiled code.
See `Compile time and code bloat`_.
* Reliability: the library has an extensive set of `unit tests
<https://github.com/cppformat/cppformat/tree/master/test>`__.
* Safety: the library is fully type safe, errors in format strings are
reported using exceptions, automatic memory management prevents buffer
overflow errors.
* Ease of use: small self-contained code base, no external dependencies,
permissive BSD `license`_.
* `Portability <http://cppformat.github.io#portability>`__ with consistent output
across platforms and support for older compilers.
* Clean warning-free codebase even on high warning levels
(-Wall -Wextra -pedantic).
* Support for wide strings.
See the `documentation <http://cppformat.github.io/doc/latest>`__ for more details.
Examples
--------
This prints ``Hello, world!`` to stdout:
.. code-block:: c++
fmt::print("Hello, {}!", "world");
Arguments can be accessed by position and arguments' indices can be repeated:
.. code-block:: c++
std::string s = fmt::format("{0}{1}{0}", "abra", "cad");
// s == "abracadabra"
C++ Format can be used as a safe portable replacement for ``itoa``:
.. code-block:: c++
fmt::Writer w;
w << 42; // replaces itoa(42, buffer, 10)
w << fmt::hex(42); // replaces itoa(42, buffer, 16)
// access the string using w.str() or w.c_str()
An object of any user-defined type for which there is an overloaded
:code:`std::ostream` insertion operator (``operator<<``) can be formatted:
.. code-block:: c++
class Date {
int year_, month_, day_;
public:
Date(int year, int month, int day) : year_(year), month_(month), day_(day) {}
friend std::ostream &operator<<(std::ostream &os, const Date &d) {
return os << d.year_ << '-' << d.month_ << '-' << d.day_;
}
};
std::string s = fmt::format("The date is {}", Date(2012, 12, 9));
// s == "The date is 2012-12-9"
You can use the `FMT_VARIADIC
<http://cppformat.github.io/doc/latest/#project0format_8h_1a65215c7dfcc0e942cd0798860877e86b>`__
macro to create your own functions similar to `format
<http://cppformat.github.io/doc/latest#fmt::format__StringRef.ArgListCR>`__ and
`print <http://cppformat.github.io/doc/latest#fmt::print__StringRef.ArgListCR>`__
which take arbitrary arguments:
.. code-block:: c++
// Prints formatted error message.
void report_error(const char *format, const fmt::ArgList &args) {
fmt::print("Error: {}");
fmt::print(format, args);
}
FMT_VARIADIC(void, report_error, const char *)
report_error("file not found: {}", path);
Note that you only need to define one function that takes ``const fmt::ArgList &``
argument and ``FMT_VARIADIC`` automatically defines necessary wrappers that
accept variable number of arguments. These wrappers are simple inline functions
that are very fast and don't result in code bloat.
Projects using this library
---------------------------
* `AMPL <https://github.com/ampl/ampl>`__:
Open-source AMPL solver interface, solver connections, table handlers
and examples
* `Saddy <https://code.google.com/p/saddy/>`__:
Small crossplatform 2D graphic engine
* `HarpyWar/pvpgn <https://github.com/HarpyWar/pvpgn>`__:
Player vs Player Gaming Network with tweaks
If you are aware of other projects using this library, please let me know
by `email <mailto:victor.zverovich@gmail.com>`__ or by submitting an
`issue <https://github.com/cppformat/cppformat/issues>`__.
Motivation
----------
So why yet another formatting library?
There are plenty of methods for doing this task, from standard ones like
the printf family of function and IOStreams to Boost Format library and
FastFormat. The reason for creating a new library is that every existing
solution that I found either had serious issues or didn't provide
all the features I needed.
Printf
~~~~~~
The good thing about printf is that it is very fast and readily available
being a part of the C standard library. The main drawback is that it
doesn't support user-defined types. Printf also has safety issues although
they are mostly solved with `__attribute__ ((format (printf, ...))
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`__ in GCC.
There is a POSIX extension that adds positional arguments required for
`i18n <http://en.wikipedia.org/wiki/Internationalization_and_localization>`__
to printf but it is not a part of C99 and may not be available on some
platforms.
IOStreams
~~~~~~~~~
The main issue with IOStreams is best illustrated with an example:
.. code-block:: c++
std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
which is a lot of typing compared to printf:
.. code-block:: c++
printf("%.2f\n", 1.23456);
Matthew Wilson, the author of FastFormat, referred to this situation with
IOStreams as "chevron hell". IOStreams doesn't support positional arguments
by design.
The good part is that IOStreams supports user-defined types and is safe
although error reporting is awkward.
Boost Format library
~~~~~~~~~~~~~~~~~~~~
This is a very powerful library which supports both printf-like format
strings and positional arguments. The main its drawback is performance.
According to various benchmarks it is much slower than other methods
considered here. Boost Format also has excessive build times and severe
code bloat issues (see `Benchmarks`_).
FastFormat
~~~~~~~~~~
This is an interesting library which is fast, safe and has positional
arguments. However it has significant limitations, citing its author:
Three features that have no hope of being accommodated within the
current design are:
* Leading zeros (or any other non-space padding)
* Octal/hexadecimal encoding
* Runtime width/alignment specification
It is also quite big and has a heavy dependency, STLSoft, which might be
too restrictive for using it in some projects.
Loki SafeFormat
~~~~~~~~~~~~~~~
SafeFormat is a formatting library which uses printf-like format strings
and is type safe. It doesn't support user-defined types or positional
arguments. It makes unconventional use of ``operator()`` for passing
format arguments.
Tinyformat
~~~~~~~~~~
This library supports printf-like format strings and is very small and
fast. Unfortunately it doesn't support positional arguments and wrapping
it in C++98 is somewhat difficult. However if you only need a type-safe
printf replacement with support for user-defined types, I highly recommend
this library.
Boost Spirit.Karma
~~~~~~~~~~~~~~~~~~
This is not really a formatting library but I decided to include it here
for completeness. As IOStreams it suffers from the problem of mixing
verbatim text with arguments. The library is pretty fast, but slower
on integer formatting than ``fmt::Writer`` on Karma's own benchmark,
see `Fast integer to string conversion in C++
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`__.
Benchmarks
----------
Speed tests
~~~~~~~~~~~
The following speed tests results were generated by building
``tinyformat_test.cpp`` on Ubuntu GNU/Linux 12.10 with
``g++-4.7.2 -O3 -DSPEED_TEST -DHAVE_FORMAT``, and taking the best of three
runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"`` or
equivalent is filled 2000000 times with output sent to ``/dev/null``; for
further details see the `source
<https://github.com/cppformat/format-benchmark/blob/master/tinyformat_test.cpp>`__.
============== ========
test name run time
============== ========
libc printf 1.28s
std::ostream 2.09s
format 1.32s
tinyformat 2.55s
boost::format 10.42s
============== ========
As you can see boost::format is much slower than the alternative methods; this
is confirmed by `other tests <http://accu.org/index.php/journals/1539>`__.
Tinyformat is quite good coming close to IOStreams. Unfortunately tinyformat
cannot be faster than the IOStreams because it uses them internally.
Performance of format is close to that of printf.
Compile time and code bloat
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The script `bloat-test.py
<https://github.com/cppformat/format-benchmark/blob/master/bloat-test.py>`__
from `format-benchmark <https://github.com/cppformat/format-benchmark>`__
tests compile time and code bloat for nontrivial projects.
It generates 100 translation units and uses ``printf()`` or its alternative
five times in each to simulate a medium sized project. The resulting
executable size and compile time (g++-4.8.1, Ubuntu GNU/Linux 13.10,
best of three) is shown in the following tables.
**Optimized build (-O3)**
============ =============== ==================== ==================
Method Compile Time, s Executable size, KiB Stripped size, KiB
============ =============== ==================== ==================
printf 2.6 41 30
IOStreams 19.4 92 70
C++ Format 46.8 46 34
tinyformat 64.6 418 386
Boost Format 222.8 990 923
============ =============== ==================== ==================
As you can see, C++ Format has 80% less overhead in terms of resulting
code size compared to IOStreams and comes pretty close to ``printf``.
Boost Format has by far the largest overheads.
**Non-optimized build**
============ =============== ==================== ==================
Method Compile Time, s Executable size, KiB Stripped size, KiB
============ =============== ==================== ==================
printf 2.1 41 30
IOStreams 19.7 86 62
C++ Format 47.9 108 86
tinyformat 27.7 234 190
Boost Format 122.6 884 763
============ =============== ==================== ==================
``libc``, ``libstdc++`` and ``libformat`` are all linked as shared
libraries to compare formatting function overhead only. Boost Format
and tinyformat are header-only libraries so they don't provide any
linkage options.
Running the tests
~~~~~~~~~~~~~~~~~
To run the unit tests first get the source code by cloning the repository::
$ git clone https://github.com/cppformat/cppformat.git
or downloading a package from
`Releases <https://github.com/cppformat/cppformat/releases>`__.
Then go to the cppformat directory, generate Makefiles with
`CMake <http://www.cmake.org/>`__ and build the project::
$ cd cppformat
$ cmake .
$ make
Now you can run the unit tests::
$ make test
Benchmarks reside in a separate repository,
`format-benchmarks <https://github.com/cppformat/format-benchmark>`__,
so to run the benchmarks you first need to clone this repository and
generate Makefiles with CMake::
$ git clone --recursive https://github.com/cppformat/format-benchmark.git
$ cd format-benchmark
$ cmake .
Then you can run the speed test::
$ make speed-test
or the bloat test::
$ make bloat-test
License
-------
Copyright (c) 2012, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Documentation License
---------------------
The `Format String Syntax
<http://cppformat.github.io/doc/latest#format-string-syntax>`__
section in the documentation is based on the one from Python `string module
documentation <http://docs.python.org/3/library/string.html#module-string>`__
adapted for the current library. For this reason the documentation is
distributed under the Python Software Foundation license available in
`doc/LICENSE.python
<https://raw.github.com/cppformat/cppformat/master/doc/LICENSE.python>`__.
Acknowledgments
---------------
The benchmark section of this readme file and the performance tests are taken
from the excellent `tinyformat <https://github.com/c42f/tinyformat>`__ library
written by Chris Foster. Boost Format library is acknowledged transitively
since it had some influence on tinyformat.
Some ideas used in the implementation are borrowed from `Loki
<http://loki-lib.sourceforge.net/>`__ SafeFormat and `Diagnostic API
<http://clang.llvm.org/doxygen/classclang_1_1Diagnostic.html>`__ in
`Clang <http://clang.llvm.org/>`__.
Format string syntax and the documentation are based on Python's `str.format
<http://docs.python.org/2/library/stdtypes.html#str.format>`__.
Thanks `Doug Turnbull <https://github.com/softwaredoug>`__ for his valuable
comments and contribution to the design of the type-safe API and
`Gregory Czajkowski <https://github.com/gcflymoto>`__ for implementing binary
formatting. Thanks `Ruslan Baratov <https://github.com/ruslo>`__ for comprehensive
`comparison of integer formatting algorithms <https://github.com/ruslo/int-dec-format-tests>`__
and useful comments regarding performance.

View File

@ -1,18 +0,0 @@
configuration:
- Debug
- Release
install:
- set PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
before_build: cmake -DFMT_EXTRA_TESTS=ON .
build_script:
- msbuild /m:4 FORMAT.sln
test_script:
- msbuild RUN_TESTS.vcxproj
on_failure:
- appveyor PushArtifact Testing/Temporary/LastTest.log
- appveyor AddTest test

Submodule breathe deleted from f94ac34d7a

View File

@ -1,11 +0,0 @@
@echo on
rem This scripts configures build environment and runs CMake.
rem Use it instead of running CMake directly when building with
rem the Microsoft SDK toolchain rather than Visual Studio.
rem It is used in the same way as cmake, for example:
rem
rem run-cmake -G "Visual Studio 10 Win64" .
for /F "delims=" %%i IN ('cmake "-DPRINT_PATH=1" -P %~dp0/FindSetEnv.cmake') DO set setenv=%%i
if NOT "%setenv%" == "" call "%setenv%"
cmake %*

View File

@ -1,6 +0,0 @@
add_custom_command(OUTPUT html/index.html
COMMAND doxygen
COMMAND rm -rf html
COMMAND ../sphinx/sphinx-build.py -b html . html
DEPENDS ../format.h Doxyfile conf.py index.rst _templates/layout.html)
add_custom_target(doc DEPENDS html/index.html)

3290
doc/ChangeLog-old.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
PROJECT_NAME = Format
GENERATE_LATEX = NO
GENERATE_MAN = NO
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = ../format.h
QUIET = YES
JAVADOC_AUTOBRIEF = YES
AUTOLINK_SUPPORT = NO
GENERATE_HTML = NO
GENERATE_XML = YES
XML_OUTPUT = doxyxml
ALIASES = "rst=\verbatim embed:rst"
ALIASES += "endrst=\endverbatim"
PREDEFINED = _WIN32=1 \
FMT_NO_DEPRECATED=1 \
FMT_USE_VARIADIC_TEMPLATES=1 \
FMT_USE_RVALUE_REFERENCES=1
EXCLUDE_SYMBOLS = fmt::internal::* BasicArg FormatParser StringValue \
write_str PrepareBufferForInt

View File

@ -1,14 +0,0 @@
{% extends "!layout.html" %}
{% block footer %}
{{ super() }}
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-20116650-4', 'cppformat.github.io');
ga('send', 'pageview');
</script>
{% endblock %}

673
doc/api.md Normal file
View File

@ -0,0 +1,673 @@
# API Reference
The {fmt} library API consists of the following components:
- [`fmt/base.h`](#base-api): the base API providing main formatting functions
for `char`/UTF-8 with C++20 compile-time checks and minimal dependencies
- [`fmt/format.h`](#format-api): `fmt::format` and other formatting functions
as well as locale support
- [`fmt/ranges.h`](#ranges-api): formatting of ranges and tuples
- [`fmt/chrono.h`](#chrono-api): date and time formatting
- [`fmt/std.h`](#std-api): formatters for standard library types
- [`fmt/compile.h`](#compile-api): format string compilation
- [`fmt/color.h`](#color-api): terminal colors and text styles
- [`fmt/os.h`](#os-api): system APIs
- [`fmt/ostream.h`](#ostream-api): `std::ostream` support
- [`fmt/args.h`](#args-api): dynamic argument lists
- [`fmt/printf.h`](#printf-api): safe `printf`
- [`fmt/xchar.h`](#xchar-api): optional `wchar_t` support
All functions and types provided by the library reside in namespace `fmt`
and macros have prefix `FMT_`.
## Base API
`fmt/base.h` defines the base API which provides main formatting functions
for `char`/UTF-8 with C++20 compile-time checks. It has minimal include
dependencies for better compile times. This header is only beneficial when
using {fmt} as a library (the default) and not in the header-only mode.
It also provides `formatter` specializations for the following types:
- `int`, `long long`,
- `unsigned`, `unsigned long long`
- `float`, `double`, `long double`
- `bool`
- `char`
- `const char*`, [`fmt::string_view`](#basic_string_view)
- `const void*`
The following functions use [format string syntax](syntax.md) similar to that
of [str.format](https://docs.python.org/3/library/stdtypes.html#str.format)
in Python. They take *fmt* and *args* as arguments.
*fmt* is a format string that contains literal text and replacement fields
surrounded by braces `{}`. The fields are replaced with formatted arguments
in the resulting string. [`fmt::format_string`](#format_string) is a format
string which can be implicitly constructed from a string literal or a
`constexpr` string and is checked at compile time in C++20. To pass a runtime
format string wrap it in [`fmt::runtime`](#runtime).
*args* is an argument list representing objects to be formatted.
I/O errors are reported as [`std::system_error`](
https://en.cppreference.com/w/cpp/error/system_error) exceptions unless
specified otherwise.
::: print(format_string<T...>, T&&...)
::: print(FILE*, format_string<T...>, T&&...)
::: println(format_string<T...>, T&&...)
::: println(FILE*, format_string<T...>, T&&...)
::: format_to(OutputIt&&, format_string<T...>, T&&...)
::: format_to_n(OutputIt, size_t, format_string<T...>, T&&...)
::: format_to_n_result
::: formatted_size(format_string<T...>, T&&...)
<a id="udt"></a>
### Formatting User-Defined Types
The {fmt} library provides formatters for many standard C++ types.
See [`fmt/ranges.h`](#ranges-api) for ranges and tuples including standard
containers such as `std::vector`, [`fmt/chrono.h`](#chrono-api) for date and
time formatting and [`fmt/std.h`](#std-api) for other standard library types.
There are two ways to make a user-defined type formattable: providing a
`format_as` function or specializing the `formatter` struct template.
Use `format_as` if you want to make your type formattable as some other
type with the same format specifiers. The `format_as` function should
take an object of your type and return an object of a formattable type.
It should be defined in the same namespace as your type.
Example ([run](https://godbolt.org/z/nvME4arz8)):
#include <fmt/format.h>
namespace kevin_namespacy {
enum class film {
house_of_cards, american_beauty, se7en = 7
};
auto format_as(film f) { return fmt::underlying(f); }
}
int main() {
fmt::print("{}\n", kevin_namespacy::film::se7en); // Output: 7
}
Using specialization is more complex but gives you full control over
parsing and formatting. To use this method specialize the `formatter`
struct template for your type and implement `parse` and `format`
methods.
The recommended way of defining a formatter is by reusing an existing
one via inheritance or composition. This way you can support standard
format specifiers without implementing them yourself. For example:
```c++
// color.h:
#include <fmt/base.h>
enum class color {red, green, blue};
template <> struct fmt::formatter<color>: formatter<string_view> {
// parse is inherited from formatter<string_view>.
auto format(color c, format_context& ctx) const
-> format_context::iterator;
};
```
```c++
// color.cc:
#include "color.h"
#include <fmt/format.h>
auto fmt::formatter<color>::format(color c, format_context& ctx) const
-> format_context::iterator {
string_view name = "unknown";
switch (c) {
case color::red: name = "red"; break;
case color::green: name = "green"; break;
case color::blue: name = "blue"; break;
}
return formatter<string_view>::format(name, ctx);
}
```
Note that `formatter<string_view>::format` is defined in `fmt/format.h`
so it has to be included in the source file. Since `parse` is inherited
from `formatter<string_view>` it will recognize all string format
specifications, for example
```c++
fmt::format("{:>10}", color::blue)
```
will return `" blue"`.
<!-- The experimental `nested_formatter` provides an easy way of applying a
formatter to one or more subobjects.
For example:
#include <fmt/format.h>
struct point {
double x, y;
};
template <>
struct fmt::formatter<point> : nested_formatter<double> {
auto format(point p, format_context& ctx) const {
return write_padded(ctx, [=](auto out) {
return format_to(out, "({}, {})", this->nested(p.x),
this->nested(p.y));
});
}
};
int main() {
fmt::print("[{:>20.2f}]", point{1, 2});
}
prints:
[ (1.00, 2.00)]
Notice that fill, align and width are applied to the whole object which
is the recommended behavior while the remaining specifiers apply to
elements. -->
In general the formatter has the following form:
template <> struct fmt::formatter<T> {
// Parses format specifiers and stores them in the formatter.
//
// [ctx.begin(), ctx.end()) is a, possibly empty, character range that
// contains a part of the format string starting from the format
// specifications to be parsed, e.g. in
//
// fmt::format("{:f} continued", ...);
//
// the range will contain "f} continued". The formatter should parse
// specifiers until '}' or the end of the range. In this example the
// formatter should parse the 'f' specifier and return an iterator
// pointing to '}'.
constexpr auto parse(format_parse_context& ctx)
-> format_parse_context::iterator;
// Formats value using the parsed format specification stored in this
// formatter and writes the output to ctx.out().
auto format(const T& value, format_context& ctx) const
-> format_context::iterator;
};
It is recommended to at least support fill, align and width that apply
to the whole object and have the same semantics as in standard
formatters.
You can also write a formatter for a hierarchy of classes:
```c++
// demo.h:
#include <type_traits>
#include <fmt/core.h>
struct A {
virtual ~A() {}
virtual std::string name() const { return "A"; }
};
struct B : A {
virtual std::string name() const { return "B"; }
};
template <typename T>
struct fmt::formatter<T, std::enable_if_t<std::is_base_of_v<A, T>, char>> :
fmt::formatter<std::string> {
auto format(const A& a, format_context& ctx) const {
return formatter<std::string>::format(a.name(), ctx);
}
};
```
```c++
// demo.cc:
#include "demo.h"
#include <fmt/format.h>
int main() {
B b;
A& a = b;
fmt::print("{}", a); // Output: B
}
```
Providing both a `formatter` specialization and a `format_as` overload is
disallowed.
::: basic_format_parse_context
::: context
::: format_context
### Compile-Time Checks
Compile-time format string checks are enabled by default on compilers
that support C++20 `consteval`. On older compilers you can use the
[FMT_STRING](#legacy-checks) macro defined in `fmt/format.h` instead.
Unused arguments are allowed as in Python's `str.format` and ordinary functions.
See [Type Erasure](#type-erasure) for an example of how to enable compile-time
checks in your own functions with `fmt::format_string` while avoiding template
bloat.
::: fstring
::: format_string
::: runtime(string_view)
### Type Erasure
You can create your own formatting function with compile-time checks and
small binary footprint, for example ([run](https://godbolt.org/z/b9Pbasvzc)):
```c++
#include <fmt/format.h>
void vlog(const char* file, int line,
fmt::string_view fmt, fmt::format_args args) {
fmt::print("{}: {}: {}", file, line, fmt::vformat(fmt, args));
}
template <typename... T>
void log(const char* file, int line,
fmt::format_string<T...> fmt, T&&... args) {
vlog(file, line, fmt, fmt::make_format_args(args...));
}
#define MY_LOG(fmt, ...) log(__FILE__, __LINE__, fmt, __VA_ARGS__)
MY_LOG("invalid squishiness: {}", 42);
```
Note that `vlog` is not parameterized on argument types which improves
compile times and reduces binary code size compared to a fully
parameterized version.
::: make_format_args(T&...)
::: basic_format_args
::: format_args
::: basic_format_arg
### Named Arguments
::: arg(const Char*, const T&)
Named arguments are not supported in compile-time checks at the moment.
### Compatibility
::: basic_string_view
::: string_view
## Format API
`fmt/format.h` defines the full format API providing additional
formatting functions and locale support.
<a id="format"></a>
::: format(format_string<T...>, T&&...)
::: vformat(string_view, format_args)
::: operator""_a()
### Utilities
::: ptr(T)
::: underlying(Enum)
::: to_string(const T&)
::: group_digits(T)
::: detail::buffer
::: basic_memory_buffer
### System Errors
{fmt} does not use `errno` to communicate errors to the user, but it may
call system functions which set `errno`. Users should not make any
assumptions about the value of `errno` being preserved by library
functions.
::: system_error
::: format_system_error
### Custom Allocators
The {fmt} library supports custom dynamic memory allocators. A custom
allocator class can be specified as a template argument to
[`fmt::basic_memory_buffer`](#basic_memory_buffer):
using custom_memory_buffer =
fmt::basic_memory_buffer<char, fmt::inline_buffer_size, custom_allocator>;
It is also possible to write a formatting function that uses a custom
allocator:
using custom_string =
std::basic_string<char, std::char_traits<char>, custom_allocator>;
auto vformat(custom_allocator alloc, fmt::string_view fmt,
fmt::format_args args) -> custom_string {
auto buf = custom_memory_buffer(alloc);
fmt::vformat_to(std::back_inserter(buf), fmt, args);
return custom_string(buf.data(), buf.size(), alloc);
}
template <typename ...Args>
auto format(custom_allocator alloc, fmt::string_view fmt,
const Args& ... args) -> custom_string {
return vformat(alloc, fmt, fmt::make_format_args(args...));
}
The allocator will be used for the output container only. Formatting
functions normally don't do any allocations for built-in and string
types except for non-default floating-point formatting that occasionally
falls back on `sprintf`.
### Locale
All formatting is locale-independent by default. Use the `'L'` format
specifier to insert the appropriate number separator characters from the
locale:
#include <fmt/core.h>
#include <locale>
std::locale::global(std::locale("en_US.UTF-8"));
auto s = fmt::format("{:L}", 1000000); // s == "1,000,000"
`fmt/format.h` provides the following overloads of formatting functions
that take `std::locale` as a parameter. The locale type is a template
parameter to avoid the expensive `<locale>` include.
::: format(const Locale&, format_string<T...>, T&&...)
::: format_to(OutputIt, const Locale&, format_string<T...>, T&&...)
::: formatted_size(const Locale&, format_string<T...>, T&&...)
<a id="legacy-checks"></a>
### Legacy Compile-Time Checks
`FMT_STRING` enables compile-time checks on older compilers. It requires
C++14 or later and is a no-op in C++11.
::: FMT_STRING
To force the use of legacy compile-time checks, define the preprocessor
variable `FMT_ENFORCE_COMPILE_STRING`. When set, functions accepting
`FMT_STRING` will fail to compile with regular strings.
<a id="ranges-api"></a>
## Range and Tuple Formatting
`fmt/ranges.h` provides formatting support for ranges and tuples:
#include <fmt/ranges.h>
fmt::print("{}", std::tuple<char, int>{'a', 42});
// Output: ('a', 42)
Using `fmt::join`, you can separate tuple elements with a custom separator:
#include <fmt/ranges.h>
auto t = std::tuple<int, char>{1, 'a'};
fmt::print("{}", fmt::join(t, ", "));
// Output: 1, a
::: join(Range&&, string_view)
::: join(It, Sentinel, string_view)
::: join(std::initializer_list<T>, string_view)
<a id="chrono-api"></a>
## Date and Time Formatting
`fmt/chrono.h` provides formatters for
- [`std::chrono::duration`](https://en.cppreference.com/w/cpp/chrono/duration)
- [`std::chrono::time_point`](
https://en.cppreference.com/w/cpp/chrono/time_point)
- [`std::tm`](https://en.cppreference.com/w/cpp/chrono/c/tm)
The format syntax is described in [Chrono Format Specifications](syntax.md#
chrono-format-specifications).
**Example**:
#include <fmt/chrono.h>
int main() {
std::time_t t = std::time(nullptr);
fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
// Output: The date is 2020-11-07.
// (with 2020-11-07 replaced by the current date)
using namespace std::literals::chrono_literals;
fmt::print("Default format: {} {}\n", 42s, 100ms);
// Output: Default format: 42s 100ms
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
// Output: strftime-like format: 03:15:30
}
::: localtime(std::time_t)
::: gmtime(std::time_t)
<a id="std-api"></a>
## Standard Library Types Formatting
`fmt/std.h` provides formatters for:
- [`std::atomic`](https://en.cppreference.com/w/cpp/atomic/atomic)
- [`std::atomic_flag`](https://en.cppreference.com/w/cpp/atomic/atomic_flag)
- [`std::bitset`](https://en.cppreference.com/w/cpp/utility/bitset)
- [`std::error_code`](https://en.cppreference.com/w/cpp/error/error_code)
- [`std::exception`](https://en.cppreference.com/w/cpp/error/exception)
- [`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path)
- [`std::monostate`](
https://en.cppreference.com/w/cpp/utility/variant/monostate)
- [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional)
- [`std::source_location`](
https://en.cppreference.com/w/cpp/utility/source_location)
- [`std::thread::id`](https://en.cppreference.com/w/cpp/thread/thread/id)
- [`std::variant`](https://en.cppreference.com/w/cpp/utility/variant/variant)
::: ptr(const std::unique_ptr<T, Deleter>&)
::: ptr(const std::shared_ptr<T>&)
### Variants
A `std::variant` is only formattable if every variant alternative is
formattable, and requires the `__cpp_lib_variant` [library
feature](https://en.cppreference.com/w/cpp/feature_test).
**Example**:
#include <fmt/std.h>
fmt::print("{}", std::variant<char, float>('x'));
// Output: variant('x')
fmt::print("{}", std::variant<std::monostate, char>());
// Output: variant(monostate)
## Bit-Fields and Packed Structs
To format a bit-field or a field of a struct with `__attribute__((packed))`
applied to it, you need to convert it to the underlying or compatible type via
a cast or a unary `+` ([godbolt](https://www.godbolt.org/z/3qKKs6T5Y)):
```c++
struct smol {
int bit : 1;
};
auto s = smol();
fmt::print("{}", +s.bit);
```
This is a known limitation of "perfect" forwarding in C++.
<a id="compile-api"></a>
## Format String Compilation
`fmt/compile.h` provides format string compilation and compile-time
(`constexpr`) formatting enabled via the `FMT_COMPILE` macro or the `_cf`
user-defined literal defined in namespace `fmt::literals`. Format strings
marked with `FMT_COMPILE` or `_cf` are parsed, checked and converted into
efficient formatting code at compile-time. This supports arguments of built-in
and string types as well as user-defined types with `format` functions taking
the format context type as a template parameter in their `formatter`
specializations. For example:
template <> struct fmt::formatter<point> {
constexpr auto parse(format_parse_context& ctx);
template <typename FormatContext>
auto format(const point& p, FormatContext& ctx) const;
};
Format string compilation can generate more binary code compared to the
default API and is only recommended in places where formatting is a
performance bottleneck.
::: FMT_COMPILE
::: operator""_cf
<a id="color-api"></a>
## Terminal Colors and Text Styles
`fmt/color.h` provides support for terminal color and text style output.
::: print(const text_style&, format_string<T...>, T&&...)
::: fg(detail::color_type)
::: bg(detail::color_type)
::: styled(const T&, text_style)
<a id="os-api"></a>
## System APIs
::: ostream
::: windows_error
<a id="ostream-api"></a>
## `std::ostream` Support
`fmt/ostream.h` provides `std::ostream` support including formatting of
user-defined types that have an overloaded insertion operator
(`operator<<`). In order to make a type formattable via `std::ostream`
you should provide a `formatter` specialization inherited from
`ostream_formatter`:
#include <fmt/ostream.h>
struct date {
int year, month, day;
friend std::ostream& operator<<(std::ostream& os, const date& d) {
return os << d.year << '-' << d.month << '-' << d.day;
}
};
template <> struct fmt::formatter<date> : ostream_formatter {};
std::string s = fmt::format("The date is {}", date{2012, 12, 9});
// s == "The date is 2012-12-9"
::: streamed(const T&)
::: print(std::ostream&, format_string<T...>, T&&...)
<a id="args-api"></a>
## Dynamic Argument Lists
The header `fmt/args.h` provides `dynamic_format_arg_store`, a builder-like API
that can be used to construct format argument lists dynamically.
::: dynamic_format_arg_store
<a id="printf-api"></a>
## Safe `printf`
The header `fmt/printf.h` provides `printf`-like formatting
functionality. The following functions use [printf format string
syntax](https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html)
with the POSIX extension for positional arguments. Unlike their standard
counterparts, the `fmt` functions are type-safe and throw an exception
if an argument type doesn't match its format specification.
::: printf(string_view, const T&...)
::: fprintf(std::FILE*, const S&, const T&...)
::: sprintf(const S&, const T&...)
<a id="xchar-api"></a>
## Wide Strings
The optional header `fmt/xchar.h` provides support for `wchar_t` and
exotic character types.
::: is_char
::: wstring_view
::: wformat_context
::: to_wstring(const T&)
## Compatibility with C++20 `std::format`
{fmt} implements nearly all of the [C++20 formatting
library](https://en.cppreference.com/w/cpp/utility/format) with the
following differences:
- Names are defined in the `fmt` namespace instead of `std` to avoid
collisions with standard library implementations.
- Width calculation doesn't use grapheme clusterization. The latter has
been implemented in a separate branch but hasn't been integrated yet.

View File

@ -1,248 +0,0 @@
# -*- coding: utf-8 -*-
#
# format documentation build configuration file, created by
# sphinx-quickstart on Tue Dec 18 06:46:16 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
sys.path.append("../breathe")
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.ifconfig', 'breathe']
breathe_projects = { "format": "doxyxml" }
breathe_default_project = "format"
breathe_domain_by_extension = {"h" : "cpp"}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'C++ Format'
copyright = u'2012-2014, Victor Zverovich'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '@CPPFORMAT_VERSION@'
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinxdoc'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'formatdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'format.tex', u'format Documentation',
u'Victor Zverovich', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'format', u'format Documentation',
[u'Victor Zverovich'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'format', u'format Documentation',
u'Victor Zverovich', 'format', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

61
doc/fmt.css Normal file
View File

@ -0,0 +1,61 @@
:root {
--md-primary-fg-color: #0050D0;
}
.md-grid {
max-width: 960px;
}
@media (min-width: 400px) {
.md-tabs {
display: block;
}
}
.docblock {
border-left: .05rem solid var(--md-primary-fg-color);
}
.docblock-desc {
margin-left: 1em;
}
pre > code.decl {
white-space: pre-wrap;
}
code.decl > div {
text-indent: -2ch; /* Negative indent to counteract the indent on the first line */
padding-left: 2ch; /* Add padding to the left to create an indent */
}
.features-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: center; /* Center the items horizontally */
}
.feature {
flex: 1 1 calc(50% - 20px); /* Two columns with space between */
max-width: 600px; /* Set the maximum width for the feature boxes */
box-sizing: border-box;
padding: 10px;
overflow: hidden; /* Hide overflow content */
text-overflow: ellipsis; /* Handle text overflow */
white-space: normal; /* Allow text wrapping */
}
.feature h2 {
margin-top: 0px;
font-weight: bold;
}
@media (max-width: 768px) {
.feature {
flex: 1 1 100%; /* Stack columns on smaller screens */
max-width: 100%; /* Allow full width on smaller screens */
white-space: normal; /* Allow text wrapping on smaller screens */
}
}

4
doc/fmt.js Normal file
View File

@ -0,0 +1,4 @@
document$.subscribe(() => {
hljs.highlightAll(),
{ language: 'c++' }
})

222
doc/get-started.md Normal file
View File

@ -0,0 +1,222 @@
# Get Started
Compile and run {fmt} examples online with [Compiler Explorer](
https://godbolt.org/z/P7h6cd6o3).
{fmt} is compatible with any build system. The next section describes its usage
with CMake, while the [Build Systems](#build-systems) section covers the rest.
## CMake
{fmt} provides two CMake targets: `fmt::fmt` for the compiled library and
`fmt::fmt-header-only` for the header-only library. It is recommended to use
the compiled library for improved build times.
There are three primary ways to use {fmt} with CMake:
* **FetchContent**: Starting from CMake 3.11, you can use [`FetchContent`](
https://cmake.org/cmake/help/v3.30/module/FetchContent.html) to automatically
download {fmt} as a dependency at configure time:
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG e69e5f977d458f2650bb346dadf2ad30c5320281) # 10.2.1
FetchContent_MakeAvailable(fmt)
target_link_libraries(<your-target> fmt::fmt)
* **Installed**: You can find and use an [installed](#installation) version of
{fmt} in your `CMakeLists.txt` file as follows:
find_package(fmt)
target_link_libraries(<your-target> fmt::fmt)
* **Embedded**: You can add the {fmt} source tree to your project and include it
in your `CMakeLists.txt` file:
add_subdirectory(fmt)
target_link_libraries(<your-target> fmt::fmt)
## Installation
### Debian/Ubuntu
To install {fmt} on Debian, Ubuntu, or any other Debian-based Linux
distribution, use the following command:
apt install libfmt-dev
### Homebrew
Install {fmt} on macOS using [Homebrew](https://brew.sh/):
brew install fmt
### Conda
Install {fmt} on Linux, macOS, and Windows with [Conda](
https://docs.conda.io/en/latest/), using its [conda-forge package](
https://github.com/conda-forge/fmt-feedstock):
conda install -c conda-forge fmt
### vcpkg
Download and install {fmt} using the vcpkg package manager:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install fmt
<!-- The fmt package in vcpkg is kept up to date by Microsoft team members and
community contributors. If the version is out of date, please [create an
issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg
repository. -->
## Building from Source
CMake works by generating native makefiles or project files that can be
used in the compiler environment of your choice. The typical workflow
starts with:
mkdir build # Create a directory to hold the build output.
cd build
cmake .. # Generate native build scripts.
run in the `fmt` repository.
If you are on a Unix-like system, you should now see a Makefile in the
current directory. Now you can build the library by running `make`.
Once the library has been built you can invoke `make test` to run the tests.
You can control generation of the make `test` target with the `FMT_TEST`
CMake option. This can be useful if you include fmt as a subdirectory in
your project but don't want to add fmt's tests to your `test` target.
To build a shared library set the `BUILD_SHARED_LIBS` CMake variable to `TRUE`:
cmake -DBUILD_SHARED_LIBS=TRUE ..
To build a static library with position-independent code (e.g. for
linking it into another shared library such as a Python extension), set the
`CMAKE_POSITION_INDEPENDENT_CODE` CMake variable to `TRUE`:
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ..
After building the library you can install it on a Unix-like system by
running `sudo make install`.
### Building the Docs
To build the documentation you need the following software installed on
your system:
- [Python](https://www.python.org/)
- [Doxygen](http://www.stack.nl/~dimitri/doxygen/)
- [MkDocs](https://www.mkdocs.org/) with `mkdocs-material`, `mkdocstrings`,
`pymdown-extensions` and `mike`
First generate makefiles or project files using CMake as described in
the previous section. Then compile the `doc` target/project, for example:
make doc
This will generate the HTML documentation in `doc/html`.
## Build Systems
### build2
You can use [build2](https://build2.org), a dependency manager and a build
system, to use {fmt}.
Currently this package is available in these package repositories:
- <https://cppget.org/fmt/> for released and published versions.
- <https://github.com/build2-packaging/fmt> for unreleased or custom versions.
**Usage:**
- `build2` package name: `fmt`
- Library target name: `lib{fmt}`
To make your `build2` project depend on `fmt`:
- Add one of the repositories to your configurations, or in your
`repositories.manifest`, if not already there:
:
role: prerequisite
location: https://pkg.cppget.org/1/stable
- Add this package as a dependency to your `manifest` file (example
for version 10):
depends: fmt ~10.0.0
- Import the target and use it as a prerequisite to your own target
using `fmt` in the appropriate `buildfile`:
import fmt = fmt%lib{fmt}
lib{mylib} : cxx{**} ... $fmt
Then build your project as usual with `b` or `bdep update`.
### Meson
[Meson WrapDB](https://mesonbuild.com/Wrapdb-projects.html) includes an `fmt`
package.
**Usage:**
- Install the `fmt` subproject from the WrapDB by running:
meson wrap install fmt
from the root of your project.
- In your project's `meson.build` file, add an entry for the new subproject:
fmt = subproject('fmt')
fmt_dep = fmt.get_variable('fmt_dep')
- Include the new dependency object to link with fmt:
my_build_target = executable(
'name', 'src/main.cc', dependencies: [fmt_dep])
**Options:**
If desired, {fmt} can be built as a static library, or as a header-only library.
For a static build, use the following subproject definition:
fmt = subproject('fmt', default_options: 'default_library=static')
fmt_dep = fmt.get_variable('fmt_dep')
For the header-only version, use:
fmt = subproject('fmt', default_options: ['header-only=true'])
fmt_dep = fmt.get_variable('fmt_header_only_dep')
### Android NDK
{fmt} provides [Android.mk file](
https://github.com/fmtlib/fmt/blob/master/support/Android.mk) that can be used
to build the library with [Android NDK](
https://developer.android.com/tools/sdk/ndk/index.html).
### Other
To use the {fmt} library with any other build system, add
`include/fmt/base.h`, `include/fmt/format.h`, `include/fmt/format-inl.h`,
`src/format.cc` and optionally other headers from a [release archive](
https://github.com/fmtlib/fmt/releases) or the [git repository](
https://github.com/fmtlib/fmt) to your project, add `include` to include
directories and make sure `src/format.cc` is compiled and linked with your code.

151
doc/index.md Normal file
View File

@ -0,0 +1,151 @@
---
hide:
- navigation
- toc
---
# A modern formatting library
<div class="features-container">
<div class="feature">
<h2>Safety</h2>
<p>
Inspired by Python's formatting facility, {fmt} provides a safe replacement
for the <code>printf</code> family of functions. Errors in format strings,
which are a common source of vulnerabilities in C, are <b>reported at
compile time</b>. For example:
<pre><code class="language-cpp"
>fmt::format("{:d}", "I am not a number");</code></pre>
will give a compile-time error because <code>d</code> is not a valid
format specifier for strings. APIs like <a href="api/#format">
<code>fmt::format</code></a> <b>prevent buffer overflow errors</b> via
automatic memory management.
</p>
<a href="api#compile-time-checks">→ Learn more</a>
</div>
<div class="feature">
<h2>Extensibility</h2>
<p>
Formatting of most <b>standard types</b>, including all containers, dates,
and times is <b>supported out-of-the-box</b>. For example:
<pre><code class="language-cpp"
>fmt::print("{}", std::vector{1, 2, 3});</code></pre>
prints the vector in a JSON-like format:
<pre><code>[1, 2, 3]</code></pre>
You can <b>make your own types formattable</b> and even make compile-time
checks work for them.
</p>
<a href="api#udt">→ Learn more</a>
</div>
<div class="feature">
<h2>Performance</h2>
<p>
{fmt} can be anywhere from <b>tens of percent to 20-30 times faster</b> than
iostreams and <code>sprintf</code>, especially for numeric formatting.
<a href="https://github.com/fmtlib/fmt?tab=readme-ov-file#benchmarks">
<img src="perf.svg">
</a>
The library <b>minimizes dynamic memory allocations</b> and can optionally
<a href="api#compile-api">compile format strings</a> to optimal code.
</p>
</div>
<div class="feature">
<h2>Unicode support</h2>
<p>
{fmt} provides <b>portable Unicode support</b> on major operating systems
with UTF-8 and <code>char</code> strings. For example:
<pre><code class="language-cpp"
>fmt::print("Слава Україні!");</code></pre>
will be printed correctly on Linux, macOS, and even Windows console,
irrespective of the codepages.
</p>
<p>
The default is <b>locale-independent</b>, but you can opt into localized
formatting and {fmt} makes it work with Unicode, addressing issues in the
standard libary.
</p>
</div>
<div class="feature">
<h2>Fast compilation</h2>
<p>
The library makes extensive use of <b>type erasure</b> to achieve fast
compilation. <code>fmt/base.h</code> provides a subset of the API with
<b>minimal include dependencies</b> and enough functionality to replace
all uses of <code>*printf</code>.
</p>
<p>
Code using {fmt} is usually several times faster to compile than the
equivalent iostreams code, and while <code>printf</code> compiles faster
still, the gap is narrowing.
</p>
<a href=
"https://github.com/fmtlib/fmt?tab=readme-ov-file#compile-time-and-code-bloat">
→ Learn more</a>
</div>
<div class="feature">
<h2>Small binary footprint</h2>
<p>
Type erasure is also used to prevent template bloat, resulting in <b>compact
per-call binary code</b>. For example, a call to <code>fmt::print</code> with
a single argument is just <a href="https://godbolt.org/g/TZU4KF">a few
instructions</a>, comparable to <code>printf</code> despite adding
runtime safety, and much smaller than the equivalent iostreams code.
</p>
<p>
The library itself has small binary footprint and some components such as
floating-point formatting can be disabled to make it even smaller for
resource-constrained devices.
</p>
</div>
<div class="feature">
<h2>Portability</h2>
<p>
{fmt} has a <b>small self-contained codebase</b> with the core consisting of
just three headers and no external dependencies.
</p>
<p>
The library is highly portable and requires only a minimal <b>subset of
C++11</b> features which are available in GCC 4.9, Clang 3.4, MSVC 19.10
(2017) and later. Newer compiler and standard library features are used
if available, and enable additional functionality.
</p>
<p>
Where possible, the output of formatting functions is <b>consistent across
platforms</b>.
</p>
</p>
</div>
<div class="feature">
<h2>Open source</h2>
<p>
{fmt} is in the top hundred open-source C++ libraries on GitHub and has
<a href="https://github.com/fmtlib/fmt/graphs/contributors">hundreds of
all-time contributors</a>.
</p>
<p>
The library is distributed under a permissive MIT
<a href="https://github.com/fmtlib/fmt#license">license</a> and is
<b>relied upon by many open-source projects</b>, including Blender, PyTorch,
Apple's FoundationDB, Windows Terminal, MongoDB, and others.
</p>
</div>
</div>

View File

@ -1,461 +0,0 @@
.. highlight:: c++
.. _string-formatting-api:
Usage
-----
To use the C++ Format library, add ``format.h`` and ``format.cc`` from
a `release archive <https://github.com/cppformat/cppformat/releases/latest>`__
or the `Git repository <https://github.com/cppformat/cppformat>`__ to your project.
If you are using Visual C++ with precompiled headers, you might need to add
the line
::
#include "stdafx.h"
before other includes in ``format.cc``.
C++ Format Library API
----------------------
All functions and classes provided by the C++ Format library reside
in namespace ``fmt`` and macros have prefix ``FMT_``. For brevity the
namespace is usually omitted in examples.
.. doxygenfunction:: fmt::format(StringRef, const ArgList &)
.. doxygenfunction:: fmt::print(StringRef, const ArgList &)
.. doxygenfunction:: fmt::print(std::FILE *, StringRef, const ArgList &)
.. doxygendefine:: FMT_VARIADIC
.. doxygenclass:: fmt::BasicWriter
:members:
.. doxygenclass:: fmt::ArgList
:members:
.. doxygenclass:: fmt::BasicStringRef
:members:
Write API
---------
.. doxygenfunction:: fmt::bin
.. doxygenfunction:: fmt::oct
.. doxygenfunction:: fmt::hex
.. doxygenfunction:: fmt::hexu
.. doxygenfunction:: fmt::pad(int, unsigned, Char)
.. _formatstrings:
System Errors
-------------
.. doxygenclass:: fmt::SystemError
:members:
.. doxygenclass:: fmt::WindowsError
:members:
Format String Syntax
--------------------
Formatting functions such as :cpp:func:`fmt::format()` and :cpp:func:`fmt::print()`
use the same format string syntax described in this section.
Format strings contain "replacement fields" surrounded by curly braces ``{}``.
Anything that is not contained in braces is considered literal text, which is
copied unchanged to the output. If you need to include a brace character in the
literal text, it can be escaped by doubling: ``{{`` and ``}}``.
The grammar for a replacement field is as follows:
.. productionlist:: sf
replacement_field: "{" [`arg_index`] [":" `format_spec`] "}"
arg_index: `integer`
In less formal terms, the replacement field can start with an *arg_index*
that specifies the argument whose value is to be formatted and inserted into
the output instead of the replacement field.
The *arg_index* is optionally followed by a *format_spec*, which is preceded
by a colon ``':'``. These specify a non-default format for the replacement value.
See also the :ref:`formatspec` section.
If the numerical arg_indexes in a format string are 0, 1, 2, ... in sequence,
they can all be omitted (not just some) and the numbers 0, 1, 2, ... will be
automatically inserted in that order.
Some simple format string examples::
"First, thou shalt count to {0}" // References the first argument
"Bring me a {}" // Implicitly references the first argument
"From {} to {}" // Same as "From {0} to {1}"
The *format_spec* field contains a specification of how the value should be
presented, including such details as field width, alignment, padding, decimal
precision and so on. Each value type can define its own "formatting
mini-language" or interpretation of the *format_spec*.
Most built-in types support a common formatting mini-language, which is
described in the next section.
A *format_spec* field can also include nested replacement fields within it.
These nested replacement fields can contain only an argument index;
format specifications are not allowed. Formatting is performed as if the
replacement fields within the format_spec are substituted before the
*format_spec* string is interpreted. This allows the formatting of a value
to be dynamically specified.
See the :ref:`formatexamples` section for some examples.
.. _formatspec:
Format Specification Mini-Language
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"Format specifications" are used within replacement fields contained within a
format string to define how individual values are presented (see
:ref:`formatstrings`). Each formattable type may define how the format
specification is to be interpreted.
..
They can also be passed directly to the :func:`format` function.
Most built-in types implement the following options for format specifications,
although some of the formatting options are only supported by the numeric types.
The general form of a *standard format specifier* is:
.. productionlist:: sf
format_spec: [[`fill`]`align`][`sign`]["#"]["0"][`width`]["." `precision`][`type`]
fill: <a character other than '{' or '}'>
align: "<" | ">" | "=" | "^"
sign: "+" | "-" | " "
width: `integer`
precision: `integer` | "{" `arg_index` "}"
type: `int_type` | "c" | "e" | "E" | "f" | "F" | "g" | "G" | "p" | s"
int_type: "b" | "B" | "d" | "o" | "x" | "X"
The *fill* character can be any character other than '{' or '}'. The presence
of a fill character is signaled by the character following it, which must be
one of the alignment options. If the second character of *format_spec* is not
a valid alignment option, then it is assumed that both the fill character and
the alignment option are absent.
The meaning of the various alignment options is as follows:
+---------+----------------------------------------------------------+
| Option | Meaning |
+=========+==========================================================+
| ``'<'`` | Forces the field to be left-aligned within the available |
| | space (this is the default for most objects). |
+---------+----------------------------------------------------------+
| ``'>'`` | Forces the field to be right-aligned within the |
| | available space (this is the default for numbers). |
+---------+----------------------------------------------------------+
| ``'='`` | Forces the padding to be placed after the sign (if any) |
| | but before the digits. This is used for printing fields |
| | in the form '+000000120'. This alignment option is only |
| | valid for numeric types. |
+---------+----------------------------------------------------------+
| ``'^'`` | Forces the field to be centered within the available |
| | space. |
+---------+----------------------------------------------------------+
Note that unless a minimum field width is defined, the field width will always
be the same size as the data to fill it, so that the alignment option has no
meaning in this case.
The *sign* option is only valid for number types, and can be one of the
following:
+---------+----------------------------------------------------------+
| Option | Meaning |
+=========+==========================================================+
| ``'+'`` | indicates that a sign should be used for both |
| | positive as well as negative numbers. |
+---------+----------------------------------------------------------+
| ``'-'`` | indicates that a sign should be used only for negative |
| | numbers (this is the default behavior). |
+---------+----------------------------------------------------------+
| space | indicates that a leading space should be used on |
| | positive numbers, and a minus sign on negative numbers. |
+---------+----------------------------------------------------------+
The ``'#'`` option causes the "alternate form" to be used for the
conversion. The alternate form is defined differently for different
types. This option is only valid for integer and floating-point types.
For integers, when binary, octal, or hexadecimal output is used, this
option adds the prefix respective ``"0b"`` (``"0B"``), ``"0"``, or
``"0x"`` (``"0X"``) to the output value. Whether the prefix is
lower-case or upper-case is determined by the case of the type
specifier, for example, the prefix ``"0x"`` is used for the type ``'x'``
and ``"0X"`` is used for ``'X'``. For floating-point numbers the
alternate form causes the result of the conversion to always contain a
decimal-point character, even if no digits follow it. Normally, a
decimal-point character appears in the result of these conversions
only if a digit follows it. In addition, for ``'g'`` and ``'G'``
conversions, trailing zeros are not removed from the result.
.. ifconfig:: False
The ``','`` option signals the use of a comma for a thousands separator.
For a locale aware separator, use the ``'n'`` integer presentation type
instead.
*width* is a decimal integer defining the minimum field width. If not
specified, then the field width will be determined by the content.
Preceding the *width* field by a zero (``'0'``) character enables
sign-aware zero-padding for numeric types. This is equivalent to a *fill*
character of ``'0'`` with an *alignment* type of ``'='``.
The *precision* is a decimal number indicating how many digits should be
displayed after the decimal point for a floating-point value formatted with
``'f'`` and ``'F'``, or before and after the decimal point for a floating-point
value formatted with ``'g'`` or ``'G'``. For non-number types the field
indicates the maximum field size - in other words, how many characters will be
used from the field content. The *precision* is not allowed for integer values.
Finally, the *type* determines how the data should be presented.
The available string presentation types are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| ``'s'`` | String format. This is the default type for strings and |
| | may be omitted. |
+---------+----------------------------------------------------------+
| none | The same as ``'s'``. |
+---------+----------------------------------------------------------+
The available character presentation types are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| ``'c'`` | Character format. This is the default type for |
| | characters and may be omitted. |
+---------+----------------------------------------------------------+
| none | The same as ``'c'``. |
+---------+----------------------------------------------------------+
The available integer presentation types are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| ``'b'`` | Binary format. Outputs the number in base 2. Using the |
| | ``'#'`` option with this type adds the prefix ``"0b"`` |
| | to the output value. |
+---------+----------------------------------------------------------+
| ``'B'`` | Binary format. Outputs the number in base 2. Using the |
| | ``'#'`` option with this type adds the prefix ``"0B"`` |
| | to the output value. |
+---------+----------------------------------------------------------+
| ``'d'`` | Decimal integer. Outputs the number in base 10. |
+---------+----------------------------------------------------------+
| ``'o'`` | Octal format. Outputs the number in base 8. |
+---------+----------------------------------------------------------+
| ``'x'`` | Hex format. Outputs the number in base 16, using |
| | lower-case letters for the digits above 9. Using the |
| | ``'#'`` option with this type adds the prefix ``"0x"`` |
| | to the output value. |
+---------+----------------------------------------------------------+
| ``'X'`` | Hex format. Outputs the number in base 16, using |
| | upper-case letters for the digits above 9. Using the |
| | ``'#'`` option with this type adds the prefix ``"0X"`` |
| | to the output value. |
+---------+----------------------------------------------------------+
| none | The same as ``'d'``. |
+---------+----------------------------------------------------------+
The available presentation types for floating-point values are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| ``'a'`` | Hexadecimal floating point format. Prints the number in |
| | base 16 with prefix ``"0x"`` and lower-case letters for |
| | digits above 9. Uses 'p' to indicate the exponent. |
+---------+----------------------------------------------------------+
| ``'A'`` | Same as ``'a'`` except it uses upper-case letters for |
| | the prefix, digits above 9 and to indicate the exponent. |
+---------+----------------------------------------------------------+
| ``'e'`` | Exponent notation. Prints the number in scientific |
| | notation using the letter 'e' to indicate the exponent. |
+---------+----------------------------------------------------------+
| ``'E'`` | Exponent notation. Same as ``'e'`` except it uses an |
| | upper-case 'E' as the separator character. |
+---------+----------------------------------------------------------+
| ``'f'`` | Fixed point. Displays the number as a fixed-point |
| | number. |
+---------+----------------------------------------------------------+
| ``'F'`` | Fixed point. Same as ``'f'``, but converts ``nan`` to |
| | ``NAN`` and ``inf`` to ``INF``. |
+---------+----------------------------------------------------------+
| ``'g'`` | General format. For a given precision ``p >= 1``, |
| | this rounds the number to ``p`` significant digits and |
| | then formats the result in either fixed-point format |
| | or in scientific notation, depending on its magnitude. |
| | |
| | A precision of ``0`` is treated as equivalent to a |
| | precision of ``1``. |
+---------+----------------------------------------------------------+
| ``'G'`` | General format. Same as ``'g'`` except switches to |
| | ``'E'`` if the number gets too large. The |
| | representations of infinity and NaN are uppercased, too. |
+---------+----------------------------------------------------------+
| none | The same as ``'g'``. |
+---------+----------------------------------------------------------+
.. ifconfig:: False
+---------+----------------------------------------------------------+
| | The precise rules are as follows: suppose that the |
| | result formatted with presentation type ``'e'`` and |
| | precision ``p-1`` would have exponent ``exp``. Then |
| | if ``-4 <= exp < p``, the number is formatted |
| | with presentation type ``'f'`` and precision |
| | ``p-1-exp``. Otherwise, the number is formatted |
| | with presentation type ``'e'`` and precision ``p-1``. |
| | In both cases insignificant trailing zeros are removed |
| | from the significand, and the decimal point is also |
| | removed if there are no remaining digits following it. |
| | |
| | Positive and negative infinity, positive and negative |
| | zero, and nans, are formatted as ``inf``, ``-inf``, |
| | ``0``, ``-0`` and ``nan`` respectively, regardless of |
| | the precision. |
| | |
+---------+----------------------------------------------------------+
The available presentation types for pointers are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| ``'p'`` | Pointer format. This is the default type for |
| | pointers and may be omitted. |
+---------+----------------------------------------------------------+
| none | The same as ``'p'``. |
+---------+----------------------------------------------------------+
.. _formatexamples:
Format examples
^^^^^^^^^^^^^^^
This section contains examples of the format syntax and comparison with
the printf formatting.
In most of the cases the syntax is similar to the printf formatting, with the
addition of the ``{}`` and with ``:`` used instead of ``%``.
For example, ``"%03.2f"`` can be translated to ``"{:03.2f}"``.
The new format syntax also supports new and different options, shown in the
following examples.
Accessing arguments by position::
format("{0}, {1}, {2}", 'a', 'b', 'c');
// Result: "a, b, c"
format("{}, {}, {}", 'a', 'b', 'c)';
// Result: "a, b, c"
format("{2}, {1}, {0}", 'a', 'b', 'c');
// Result: "c, b, a"
format("{0}{1}{0}", "abra", "cad"); // arguments' indices can be repeated
// Result: "abracadabra"
Aligning the text and specifying a width::
format("{:<30}", "left aligned");
// Result: "left aligned "
format("{:>30}", "right aligned");
// Result: " right aligned"
format("{:^30}", "centered");
// Result: " centered "
format("{:*^30}", "centered"); // use '*' as a fill char
// Result: "***********centered***********"
Replacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign::
format("{:+f}; {:+f}", 3.14, -3.14); // show it always
// Result: "+3.140000; -3.140000"
format("{: f}; {: f}", 3.14, -3.14); // show a space for positive numbers
// Result: " 3.140000; -3.140000"
format("{:-f}; {:-f}", 3.14, -3.14); // show only the minus -- same as '{:f}; {:f}'
// Result: "3.140000; -3.140000"
Replacing ``%x`` and ``%o`` and converting the value to different bases::
format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
// Result: "int: 42; hex: 2a; oct: 52; bin: 101010"
// with 0x or 0 or 0b as prefix:
format("int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}", 42);
// Result: "int: 42; hex: 0x2a; oct: 052; bin: 0b101010"
.. ifconfig:: False
Using the comma as a thousands separator::
format("{:,}", 1234567890);
'1,234,567,890'
Expressing a percentage::
>>> points = 19
>>> total = 22
Format("Correct answers: {:.2%}") << points/total)
'Correct answers: 86.36%'
Using type-specific formatting::
>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
Format("{:%Y-%m-%d %H:%M:%S}") << d)
'2010-07-04 12:15:58'
Nesting arguments and more complex examples::
>>> for align, text in zip('<^>', ['left', 'center', 'right']):
... '{0:{fill}{align}16}") << text, fill=align, align=align)
...
'left<<<<<<<<<<<<'
'^^^^^center^^^^^'
'>>>>>>>>>>>right'
>>>
>>> octets = [192, 168, 0, 1]
Format("{:02X}{:02X}{:02X}{:02X}") << *octets)
'C0A80001'
>>> int(_, 16)
3232235521
>>>
>>> width = 5
>>> for num in range(5,12):
... for base in 'dXob':
... print('{0:{width}{base}}") << num, base=base, width=width), end=' ')
... print()
...
5 5 5 101
6 6 6 110
7 7 7 111
8 8 10 1000
9 9 11 1001
10 A 12 1010
11 B 13 1011

1
doc/perf.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="20 0 550 300" aria-label="A chart." style="overflow: hidden;"><defs id="_ABSTRACT_RENDERER_ID_0"><clipPath id="_ABSTRACT_RENDERER_ID_1"><rect x="120" y="45" width="560" height="210"></rect></clipPath></defs><rect x="0" y="0" width="800" height="300" stroke="none" stroke-width="0" fill="#ffffff"></rect><g><text text-anchor="start" x="120" y="27.05" font-family="Arial" font-size="13" font-weight="bold" stroke="none" stroke-width="0" fill="#000000">double to string</text><rect x="120" y="16" width="560" height="13" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g><g><rect x="120" y="45" width="560" height="210" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect><g clip-path="url(#_ABSTRACT_RENDERER_ID_1)"><g><rect x="120" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="213" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="306" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="400" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="493" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="586" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="679" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#cccccc"></rect></g><g><rect x="121" y="53" width="450" height="26" stroke="#ff9900" stroke-width="1" fill="#ff9900"></rect><rect x="121" y="95" width="421" height="26" stroke="#109618" stroke-width="1" fill="#109618"></rect><rect x="121" y="137" width="341" height="26" stroke="#990099" stroke-width="1" fill="#990099"></rect><rect x="121" y="179" width="31" height="26" stroke="#3366cc" stroke-width="1" fill="#3366cc"></rect><rect x="121" y="221" width="15" height="26" stroke="#dc3912" stroke-width="1" fill="#dc3912"></rect></g><g><rect x="120" y="45" width="1" height="210" stroke="none" stroke-width="0" fill="#333333"></rect></g></g><g></g><g><g><text text-anchor="middle" x="120.5" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">0</text></g><g><text text-anchor="middle" x="213.6667" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">250</text></g><g><text text-anchor="middle" x="306.8333" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">500</text></g><g><text text-anchor="middle" x="400" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">750</text></g><g><text text-anchor="middle" x="493.1667" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">1,000</text></g><g><text text-anchor="middle" x="586.3333" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">1,250</text></g><g><text text-anchor="middle" x="679.5" y="272.3833333333333" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#444444">1,500</text></g><g><text text-anchor="end" x="107" y="70.95" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#222222">ostringstream</text></g><g><text text-anchor="end" x="107" y="112.74999999999999" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#222222">ostrstream</text></g><g><text text-anchor="end" x="107" y="154.55" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#222222">sprintf</text></g><g><text text-anchor="end" x="107" y="196.35" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#222222">doubleconv</text></g><g><text text-anchor="end" x="107" y="238.15" font-family="Arial" font-size="13" stroke="none" stroke-width="0" fill="#222222">fmt</text></g></g></g><g><g><text text-anchor="middle" x="300" y="291.71666666666664" font-family="Arial" font-size="13" font-style="italic" stroke="none" stroke-width="0" fill="#222222">Time (ns), smaller is better</text><rect x="120" y="280.66666666666663" width="560" height="13" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g></g><g></g></svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

886
doc/syntax.md Normal file
View File

@ -0,0 +1,886 @@
# Format String Syntax
Formatting functions such as [`fmt::format`](api.md#format) and [`fmt::print`](
api.md#print) use the same format string syntax described in this section.
Format strings contain "replacement fields" surrounded by curly braces `{}`.
Anything that is not contained in braces is considered literal text, which is
copied unchanged to the output. If you need to include a brace character in
the literal text, it can be escaped by doubling: `{{` and `}}`.
The grammar for a replacement field is as follows:
<a id="replacement-field"></a>
<pre><code class="language-json"
>replacement_field ::= "{" [arg_id] [":" (<a href="#format-spec"
>format_spec</a> | <a href="#chrono-format-spec">chrono_format_spec</a>)] "}"
arg_id ::= integer | identifier
integer ::= digit+
digit ::= "0"..."9"
identifier ::= id_start id_continue*
id_start ::= "a"..."z" | "A"..."Z" | "_"
id_continue ::= id_start | digit</code>
</pre>
In less formal terms, the replacement field can start with an *arg_id* that
specifies the argument whose value is to be formatted and inserted into the
output instead of the replacement field. The *arg_id* is optionally followed
by a *format_spec*, which is preceded by a colon `':'`. These specify a
non-default format for the replacement value.
See also the [Format Specification
Mini-Language](#format-specification-mini-language) section.
If the numerical arg_ids in a format string are 0, 1, 2, ... in sequence,
they can all be omitted (not just some) and the numbers 0, 1, 2, ... will be
automatically inserted in that order.
Named arguments can be referred to by their names or indices.
Some simple format string examples:
```c++
"First, thou shalt count to {0}" // References the first argument
"Bring me a {}" // Implicitly references the first argument
"From {} to {}" // Same as "From {0} to {1}"
```
The *format_spec* field contains a specification of how the value should
be presented, including such details as field width, alignment, padding,
decimal precision and so on. Each value type can define its own
"formatting mini-language" or interpretation of the *format_spec*.
Most built-in types support a common formatting mini-language, which is
described in the next section.
A *format_spec* field can also include nested replacement fields in
certain positions within it. These nested replacement fields can contain
only an argument id; format specifications are not allowed. This allows
the formatting of a value to be dynamically specified.
See the [Format Examples](#format-examples) section for some examples.
## Format Specification Mini-Language
"Format specifications" are used within replacement fields contained within a
format string to define how individual values are presented. Each formattable
type may define how the format specification is to be interpreted.
Most built-in types implement the following options for format
specifications, although some of the formatting options are only
supported by the numeric types.
The general form of a *standard format specifier* is:
<a id="format-spec"></a>
<pre><code class="language-json"
>format_spec ::= [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type]
fill ::= &lt;a character other than '{' or '}'>
align ::= "<" | ">" | "^"
sign ::= "+" | "-" | " "
width ::= <a href="#replacement-field">integer</a> | "{" [<a
href="#replacement-field">arg_id</a>] "}"
precision ::= <a href="#replacement-field">integer</a> | "{" [<a
href="#replacement-field">arg_id</a>] "}"
type ::= "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" |
"g" | "G" | "o" | "p" | "s" | "x" | "X" | "?"</code>
</pre>
The *fill* character can be any Unicode code point other than `'{'` or `'}'`.
The presence of a fill character is signaled by the character following it,
which must be one of the alignment options. If the second character of
*format_spec* is not a valid alignment option, then it is assumed that both
the fill character and the alignment option are absent.
The meaning of the various alignment options is as follows:
<table>
<tr>
<th>Option</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'<'</code></td>
<td>
Forces the field to be left-aligned within the available space (this is the
default for most objects).
</td>
</tr>
<tr>
<td><code>'>'</code></td>
<td>
Forces the field to be right-aligned within the available space (this is
the default for numbers).
</td>
</tr>
<tr>
<td><code>'^'</code></td>
<td>Forces the field to be centered within the available space.</td>
</tr>
</table>
Note that unless a minimum field width is defined, the field width will
always be the same size as the data to fill it, so that the alignment
option has no meaning in this case.
The *sign* option is only valid for floating point and signed integer types,
and can be one of the following:
<table>
<tr>
<th>Option</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'+'</code></td>
<td>
Indicates that a sign should be used for both nonnegative as well as
negative numbers.
</td>
</tr>
<tr>
<td><code>'-'</code></td>
<td>
Indicates that a sign should be used only for negative numbers (this is the
default behavior).
</td>
</tr>
<tr>
<td>space</td>
<td>
Indicates that a leading space should be used on nonnegative numbers, and a
minus sign on negative numbers.
</td>
</tr>
</table>
The `'#'` option causes the "alternate form" to be used for the
conversion. The alternate form is defined differently for different
types. This option is only valid for integer and floating-point types.
For integers, when binary, octal, or hexadecimal output is used, this
option adds the prefix respective `"0b"` (`"0B"`), `"0"`, or `"0x"`
(`"0X"`) to the output value. Whether the prefix is lower-case or
upper-case is determined by the case of the type specifier, for example,
the prefix `"0x"` is used for the type `'x'` and `"0X"` is used for
`'X'`. For floating-point numbers the alternate form causes the result
of the conversion to always contain a decimal-point character, even if
no digits follow it. Normally, a decimal-point character appears in the
result of these conversions only if a digit follows it. In addition, for
`'g'` and `'G'` conversions, trailing zeros are not removed from the
result.
*width* is a decimal integer defining the minimum field width. If not
specified, then the field width will be determined by the content.
Preceding the *width* field by a zero (`'0'`) character enables
sign-aware zero-padding for numeric types. It forces the padding to be
placed after the sign or base (if any) but before the digits. This is
used for printing fields in the form "+000000120". This option is only
valid for numeric types and it has no effect on formatting of infinity
and NaN. This option is ignored when any alignment specifier is present.
The *precision* is a decimal number indicating how many digits should be
displayed after the decimal point for a floating-point value formatted
with `'f'` and `'F'`, or before and after the decimal point for a
floating-point value formatted with `'g'` or `'G'`. For non-number types
the field indicates the maximum field size - in other words, how many
characters will be used from the field content. The *precision* is not
allowed for integer, character, Boolean, and pointer values. Note that a
C string must be null-terminated even if precision is specified.
The `'L'` option uses the current locale setting to insert the appropriate
number separator characters. This option is only valid for numeric types.
Finally, the *type* determines how the data should be presented.
The available string presentation types are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'s'</code></td>
<td>
String format. This is the default type for strings and may be omitted.
</td>
</tr>
<tr>
<td><code>'?'</code></td>
<td>Debug format. The string is quoted and special characters escaped.</td>
</tr>
<tr>
<td>none</td>
<td>The same as <code>'s'</code>.</td>
</tr>
</table>
The available character presentation types are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'c'</code></td>
<td>
Character format. This is the default type for characters and may be
omitted.
</td>
</tr>
<tr>
<td><code>'?'</code></td>
<td>Debug format. The character is quoted and special characters escaped.</td>
</tr>
<tr>
<td>none</td>
<td>The same as <code>'c'</code>.</td>
</tr>
</table>
The available integer presentation types are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'b'</code></td>
<td>
Binary format. Outputs the number in base 2. Using the <code>'#'</code>
option with this type adds the prefix <code>"0b"</code> to the output value.
</td>
</tr>
<tr>
<td><code>'B'</code></td>
<td>
Binary format. Outputs the number in base 2. Using the <code>'#'</code>
option with this type adds the prefix <code>"0B"</code> to the output value.
</td>
</tr>
<tr>
<td><code>'c'</code></td>
<td>Character format. Outputs the number as a character.</td>
</tr>
<tr>
<td><code>'d'</code></td>
<td>Decimal integer. Outputs the number in base 10.</td>
</tr>
<tr>
<td><code>'o'</code></td>
<td>Octal format. Outputs the number in base 8.</td>
</tr>
<tr>
<td><code>'x'</code></td>
<td>
Hex format. Outputs the number in base 16, using lower-case letters for the
digits above 9. Using the <code>'#'</code> option with this type adds the
prefix <code>"0x"</code> to the output value.
</td>
</tr>
<tr>
<td><code>'X'</code></td>
<td>
Hex format. Outputs the number in base 16, using upper-case letters for the
digits above 9. Using the <code>'#'</code> option with this type adds the
prefix <code>"0X"</code> to the output value.
</td>
</tr>
<tr>
<td>none</td>
<td>The same as <code>'d'</code>.</td>
</tr>
</table>
Integer presentation types can also be used with character and Boolean values
with the only exception that `'c'` cannot be used with `bool`. Boolean values
are formatted using textual representation, either `true` or `false`, if the
presentation type is not specified.
The available presentation types for floating-point values are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'a'</code></td>
<td>
Hexadecimal floating point format. Prints the number in base 16 with
prefix <code>"0x"</code> and lower-case letters for digits above 9.
Uses <code>'p'</code> to indicate the exponent.
</td>
</tr>
<tr>
<td><code>'A'</code></td>
<td>
Same as <code>'a'</code> except it uses upper-case letters for the
prefix, digits above 9 and to indicate the exponent.
</td>
</tr>
<tr>
<td><code>'e'</code></td>
<td>
Exponent notation. Prints the number in scientific notation using
the letter 'e' to indicate the exponent.
</td>
</tr>
<tr>
<td><code>'E'</code></td>
<td>
Exponent notation. Same as <code>'e'</code> except it uses an
upper-case <code>'E'</code> as the separator character.
</td>
</tr>
<tr>
<td><code>'f'</code></td>
<td>Fixed point. Displays the number as a fixed-point number.</td>
</tr>
<tr>
<td><code>'F'</code></td>
<td>
Fixed point. Same as <code>'f'</code>, but converts <code>nan</code>
to <code>NAN</code> and <code>inf</code> to <code>INF</code>.
</td>
</tr>
<tr>
<td><code>'g'</code></td>
<td>
<p>General format. For a given precision <code>p &gt;= 1</code>,
this rounds the number to <code>p</code> significant digits and then
formats the result in either fixed-point format or in scientific
notation, depending on its magnitude.</p>
<p>A precision of <code>0</code> is treated as equivalent to a precision
of <code>1</code>.</p>
</td>
</tr>
<tr>
<td><code>'G'</code></td>
<td>
General format. Same as <code>'g'</code> except switches to
<code>'E'</code> if the number gets too large. The representations of
infinity and NaN are uppercased, too.
</td>
</tr>
<tr>
<td>none</td>
<td>
Similar to <code>'g'</code>, except that the default precision is as
high as needed to represent the particular value.
</td>
</tr>
</table>
The available presentation types for pointers are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'p'</code></td>
<td>
Pointer format. This is the default type for pointers and may be omitted.
</td>
</tr>
<tr>
<td>none</td>
<td>The same as <code>'p'</code>.</td>
</tr>
</table>
## Chrono Format Specifications
Format specifications for chrono duration and time point types as well as
`std::tm` have the following syntax:
<a id="chrono-format-spec"></a>
<pre><code class="language-json"
>chrono_format_spec ::= [[<a href="#format-spec">fill</a>]<a href="#format-spec"
>align</a>][<a href="#format-spec">width</a>]["." <a href="#format-spec"
>precision</a>][chrono_specs]
chrono_specs ::= conversion_spec |
chrono_specs (conversion_spec | literal_char)
conversion_spec ::= "%" [padding_modifier] [locale_modifier] chrono_type
literal_char ::= &lt;a character other than '{', '}' or '%'>
padding_modifier ::= "-" | "_" | "0"
locale_modifier ::= "E" | "O"
chrono_type ::= "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" |
"F" | "g" | "G" | "h" | "H" | "I" | "j" | "m" | "M" |
"n" | "p" | "q" | "Q" | "r" | "R" | "S" | "t" | "T" |
"u" | "U" | "V" | "w" | "W" | "x" | "X" | "y" | "Y" |
"z" | "Z" | "%"</code>
</pre>
Literal chars are copied unchanged to the output. Precision is valid only
for `std::chrono::duration` types with a floating-point representation type.
The available presentation types (*chrono_type*) are:
<table>
<tr>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td><code>'a'</code></td>
<td>
The abbreviated weekday name, e.g. "Sat". If the value does not contain a
valid weekday, an exception of type <code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'A'</code></td>
<td>
The full weekday name, e.g. "Saturday". If the value does not contain a
valid weekday, an exception of type <code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'b'</code></td>
<td>
The abbreviated month name, e.g. "Nov". If the value does not contain a
valid month, an exception of type <code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'B'</code></td>
<td>
The full month name, e.g. "November". If the value does not contain a valid
month, an exception of type <code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'c'</code></td>
<td>
The date and time representation, e.g. "Sat Nov 12 22:04:00 1955". The
modified command <code>%Ec</code> produces the locale's alternate date and
time representation.
</td>
</tr>
<tr>
<td><code>'C'</code></td>
<td>
The year divided by 100 using floored division, e.g. "19". If the result
is a single decimal digit, it is prefixed with 0. The modified command
<code>%EC</code> produces the locale's alternative representation of the
century.
</td>
</tr>
<tr>
<td><code>'d'</code></td>
<td>
The day of month as a decimal number. If the result is a single decimal
digit, it is prefixed with 0. The modified command <code>%Od</code>
produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'D'</code></td>
<td>Equivalent to <code>%m/%d/%y</code>, e.g. "11/12/55".</td>
</tr>
<tr>
<td><code>'e'</code></td>
<td>
The day of month as a decimal number. If the result is a single decimal
digit, it is prefixed with a space. The modified command <code>%Oe</code>
produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'F'</code></td>
<td>Equivalent to <code>%Y-%m-%d</code>, e.g. "1955-11-12".</td>
</tr>
<tr>
<td><code>'g'</code></td>
<td>
The last two decimal digits of the ISO week-based year. If the result is a
single digit it is prefixed by 0.
</td>
</tr>
<tr>
<td><code>'G'</code></td>
<td>
The ISO week-based year as a decimal number. If the result is less than
four digits it is left-padded with 0 to four digits.
</td>
</tr>
<tr>
<td><code>'h'</code></td>
<td>Equivalent to <code>%b</code>, e.g. "Nov".</td>
</tr>
<tr>
<td><code>'H'</code></td>
<td>
The hour (24-hour clock) as a decimal number. If the result is a single
digit, it is prefixed with 0. The modified command <code>%OH</code>
produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'I'</code></td>
<td>
The hour (12-hour clock) as a decimal number. If the result is a single
digit, it is prefixed with 0. The modified command <code>%OI</code>
produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'j'</code></td>
<td>
If the type being formatted is a specialization of duration, the decimal
number of days without padding. Otherwise, the day of the year as a decimal
number. Jan 1 is 001. If the result is less than three digits, it is
left-padded with 0 to three digits.
</td>
</tr>
<tr>
<td><code>'m'</code></td>
<td>
The month as a decimal number. Jan is 01. If the result is a single digit,
it is prefixed with 0. The modified command <code>%Om</code> produces the
locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'M'</code></td>
<td>
The minute as a decimal number. If the result is a single digit, it
is prefixed with 0. The modified command <code>%OM</code> produces the
locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'n'</code></td>
<td>A new-line character.</td>
</tr>
<tr>
<td><code>'p'</code></td>
<td>The AM/PM designations associated with a 12-hour clock.</td>
</tr>
<tr>
<td><code>'q'</code></td>
<td>The duration's unit suffix.</td>
</tr>
<tr>
<td><code>'Q'</code></td>
<td>
The duration's numeric value (as if extracted via <code>.count()</code>).
</td>
</tr>
<tr>
<td><code>'r'</code></td>
<td>The 12-hour clock time, e.g. "10:04:00 PM".</td>
</tr>
<tr>
<td><code>'R'</code></td>
<td>Equivalent to <code>%H:%M</code>, e.g. "22:04".</td>
</tr>
<tr>
<td><code>'S'</code></td>
<td>
Seconds as a decimal number. If the number of seconds is less than 10, the
result is prefixed with 0. If the precision of the input cannot be exactly
represented with seconds, then the format is a decimal floating-point number
with a fixed format and a precision matching that of the precision of the
input (or to a microseconds precision if the conversion to floating-point
decimal seconds cannot be made within 18 fractional digits). The modified
command <code>%OS</code> produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'t'</code></td>
<td>A horizontal-tab character.</td>
</tr>
<tr>
<td><code>'T'</code></td>
<td>Equivalent to <code>%H:%M:%S</code>.</td>
</tr>
<tr>
<td><code>'u'</code></td>
<td>
The ISO weekday as a decimal number (1-7), where Monday is 1. The modified
command <code>%Ou</code> produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'U'</code></td>
<td>
The week number of the year as a decimal number. The first Sunday of the
year is the first day of week 01. Days of the same year prior to that are
in week 00. If the result is a single digit, it is prefixed with 0.
The modified command <code>%OU</code> produces the locale's alternative
representation.
</td>
</tr>
<tr>
<td><code>'V'</code></td>
<td>
The ISO week-based week number as a decimal number. If the result is a
single digit, it is prefixed with 0. The modified command <code>%OV</code>
produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'w'</code></td>
<td>
The weekday as a decimal number (0-6), where Sunday is 0. The modified
command <code>%Ow</code> produces the locale's alternative representation.
</td>
</tr>
<tr>
<td><code>'W'</code></td>
<td>
The week number of the year as a decimal number. The first Monday of the
year is the first day of week 01. Days of the same year prior to that are
in week 00. If the result is a single digit, it is prefixed with 0.
The modified command <code>%OW</code> produces the locale's alternative
representation.
</td>
</tr>
<tr>
<td><code>'x'</code></td>
<td>
The date representation, e.g. "11/12/55". The modified command
<code>%Ex</code> produces the locale's alternate date representation.
</td>
</tr>
<tr>
<td><code>'X'</code></td>
<td>
The time representation, e.g. "10:04:00". The modified command
<code>%EX</code> produces the locale's alternate time representation.
</td>
</tr>
<tr>
<td><code>'y'</code></td>
<td>
The last two decimal digits of the year. If the result is a single digit
it is prefixed by 0. The modified command <code>%Oy</code> produces the
locale's alternative representation. The modified command <code>%Ey</code>
produces the locale's alternative representation of offset from
<code>%EC</code> (year only).
</td>
</tr>
<tr>
<td><code>'Y'</code></td>
<td>
The year as a decimal number. If the result is less than four digits it is
left-padded with 0 to four digits. The modified command <code>%EY</code>
produces the locale's alternative full year representation.
</td>
</tr>
<tr>
<td><code>'z'</code></td>
<td>
The offset from UTC in the ISO 8601:2004 format. For example -0430 refers
to 4 hours 30 minutes behind UTC. If the offset is zero, +0000 is used.
The modified commands <code>%Ez</code> and <code>%Oz</code> insert a
<code>:</code> between the hours and minutes: -04:30. If the offset
information is not available, an exception of type
<code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'Z'</code></td>
<td>
The time zone abbreviation. If the time zone abbreviation is not available,
an exception of type <code>format_error</code> is thrown.
</td>
</tr>
<tr>
<td><code>'%'</code></td>
<td>A % character.</td>
</tr>
</table>
Specifiers that have a calendaric component such as `'d'` (the day of month)
are valid only for `std::tm` and time points but not durations.
The available padding modifiers (*padding_modifier*) are:
| Type | Meaning |
|-------|-----------------------------------------|
| `'_'` | Pad a numeric result with spaces. |
| `'-'` | Do not pad a numeric result string. |
| `'0'` | Pad a numeric result string with zeros. |
These modifiers are only supported for the `'H'`, `'I'`, `'M'`, `'S'`, `'U'`,
`'V'`, `'W'`, `'Y'`, `'d'`, `'j'` and `'m'` presentation types.
## Range Format Specifications
Format specifications for range types have the following syntax:
<pre><code class="language-json"
>range_format_spec ::= ["n"][range_type][range_underlying_spec]</code>
</pre>
The `'n'` option formats the range without the opening and closing brackets.
The available presentation types for `range_type` are:
| Type | Meaning |
|--------|------------------------------------------------------------|
| none | Default format. |
| `'s'` | String format. The range is formatted as a string. |
| `'?s'` | Debug format. The range is formatted as an escaped string. |
If `range_type` is `'s'` or `'?s'`, the range element type must be a character
type. The `'n'` option and `range_underlying_spec` are mutually exclusive with
`'s'` and `'?s'`.
The `range_underlying_spec` is parsed based on the formatter of the range's
element type.
By default, a range of characters or strings is printed escaped and quoted.
But if any `range_underlying_spec` is provided (even if it is empty), then the
characters or strings are printed according to the provided specification.
Examples:
```c++
fmt::print("{}", std::vector{10, 20, 30});
// Output: [10, 20, 30]
fmt::print("{::#x}", std::vector{10, 20, 30});
// Output: [0xa, 0x14, 0x1e]
fmt::print("{}", std::vector{'h', 'e', 'l', 'l', 'o'});
// Output: ['h', 'e', 'l', 'l', 'o']
fmt::print("{:n}", std::vector{'h', 'e', 'l', 'l', 'o'});
// Output: 'h', 'e', 'l', 'l', 'o'
fmt::print("{:s}", std::vector{'h', 'e', 'l', 'l', 'o'});
// Output: "hello"
fmt::print("{:?s}", std::vector{'h', 'e', 'l', 'l', 'o', '\n'});
// Output: "hello\n"
fmt::print("{::}", std::vector{'h', 'e', 'l', 'l', 'o'});
// Output: [h, e, l, l, o]
fmt::print("{::d}", std::vector{'h', 'e', 'l', 'l', 'o'});
// Output: [104, 101, 108, 108, 111]
```
## Format Examples
This section contains examples of the format syntax and comparison with
the printf formatting.
In most of the cases the syntax is similar to the printf formatting,
with the addition of the `{}` and with `:` used instead of `%`. For
example, `"%03.2f"` can be translated to `"{:03.2f}"`.
The new format syntax also supports new and different options, shown in
the following examples.
Accessing arguments by position:
```c++
fmt::format("{0}, {1}, {2}", 'a', 'b', 'c');
// Result: "a, b, c"
fmt::format("{}, {}, {}", 'a', 'b', 'c');
// Result: "a, b, c"
fmt::format("{2}, {1}, {0}", 'a', 'b', 'c');
// Result: "c, b, a"
fmt::format("{0}{1}{0}", "abra", "cad"); // arguments' indices can be repeated
// Result: "abracadabra"
```
Aligning the text and specifying a width:
```c++
fmt::format("{:<30}", "left aligned");
// Result: "left aligned "
fmt::format("{:>30}", "right aligned");
// Result: " right aligned"
fmt::format("{:^30}", "centered");
// Result: " centered "
fmt::format("{:*^30}", "centered"); // use '*' as a fill char
// Result: "***********centered***********"
```
Dynamic width:
```c++
fmt::format("{:<{}}", "left aligned", 30);
// Result: "left aligned "
```
Dynamic precision:
```c++
fmt::format("{:.{}f}", 3.14, 1);
// Result: "3.1"
```
Replacing `%+f`, `%-f`, and `% f` and specifying a sign:
```c++
fmt::format("{:+f}; {:+f}", 3.14, -3.14); // show it always
// Result: "+3.140000; -3.140000"
fmt::format("{: f}; {: f}", 3.14, -3.14); // show a space for positive numbers
// Result: " 3.140000; -3.140000"
fmt::format("{:-f}; {:-f}", 3.14, -3.14); // show only the minus -- same as '{:f}; {:f}'
// Result: "3.140000; -3.140000"
```
Replacing `%x` and `%o` and converting the value to different bases:
```c++
fmt::format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
// Result: "int: 42; hex: 2a; oct: 52; bin: 101010"
// with 0x or 0 or 0b as prefix:
fmt::format("int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}", 42);
// Result: "int: 42; hex: 0x2a; oct: 052; bin: 0b101010"
```
Padded hex byte with prefix and always prints both hex characters:
```c++
fmt::format("{:#04x}", 0);
// Result: "0x00"
```
Box drawing using Unicode fill:
```c++
fmt::print(
"┌{0:─^{2}}┐\n"
"│{1: ^{2}}│\n"
"└{0:─^{2}}┘\n", "", "Hello, world!", 20);
```
prints:
```
┌────────────────────┐
│ Hello, world! │
└────────────────────┘
```
Using type-specific formatting:
```c++
#include <fmt/chrono.h>
auto t = tm();
t.tm_year = 2010 - 1900;
t.tm_mon = 7;
t.tm_mday = 4;
t.tm_hour = 12;
t.tm_min = 15;
t.tm_sec = 58;
fmt::print("{:%Y-%m-%d %H:%M:%S}", t);
// Prints: 2010-08-04 12:15:58
```
Using the comma as a thousands separator:
```c++
#include <fmt/format.h>
auto s = fmt::format(std::locale("en_US.UTF-8"), "{:L}", 1234567890);
// s == "1,234,567,890"
```

1162
format.cc

File diff suppressed because it is too large Load Diff

2320
format.h

File diff suppressed because it is too large Load Diff

View File

@ -1,246 +0,0 @@
########################################################################
# CMake build script for Google Test.
#
# To run the tests for Google Test itself on Linux, use 'make test' or
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
# When other libraries are using a shared version of runtime libraries,
# Google Test also has to use one.
option(
gtest_force_shared_crt
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
ON)
option(gtest_build_tests "Build all of gtest's own tests." OFF)
option(gtest_build_samples "Build gtest's sample programs." OFF)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include(cmake/hermetic_build.cmake OPTIONAL)
if (COMMAND pre_project_set_up_hermetic_build)
pre_project_set_up_hermetic_build()
endif()
########################################################################
#
# Project-wide settings
# Name of the project.
#
# CMake files in this project can refer to the root source directory
# as ${gtest_SOURCE_DIR} and to the root binary directory as
# ${gtest_BINARY_DIR}.
# Language "C" is required for find_package(Threads).
project(gtest CXX C)
cmake_minimum_required(VERSION 2.6.2)
if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()
# Define helper functions and macros used by Google Test.
include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.
# Where Google Test's .h files can be found.
include_directories(
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR})
# Where Google Test's libraries can be found.
link_directories(${gtest_BINARY_DIR}/src)
########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
# Google Test libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that gtest can be compiled by a user
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
target_link_libraries(gtest_main gtest)
########################################################################
#
# Samples on how to link user tests with gtest or gtest_main.
#
# They are not built by default. To build them, set the
# gtest_build_samples option to ON. You can do it by running ccmake
# or specifying the -Dbuild_gtest_samples=ON flag when running cmake.
if (gtest_build_samples)
cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
cxx_executable(sample3_unittest samples gtest_main)
cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)
cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)
cxx_executable(sample6_unittest samples gtest_main)
cxx_executable(sample7_unittest samples gtest_main)
cxx_executable(sample8_unittest samples gtest_main)
cxx_executable(sample9_unittest samples gtest)
cxx_executable(sample10_unittest samples gtest)
endif()
########################################################################
#
# Google Test's own tests.
#
# You can skip this section if you aren't interested in testing
# Google Test itself.
#
# The tests are not built by default. To build them, set the
# gtest_build_tests option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_tests=ON flag when running cmake.
if (gtest_build_tests)
# This must be set in the root directory for the tests to be run by
# 'make test' or ctest.
enable_testing()
############################################################
# C++ tests built with standard compiler flags.
cxx_test(gtest-death-test_test gtest_main)
cxx_test(gtest_environment_test gtest)
cxx_test(gtest-filepath_test gtest_main)
cxx_test(gtest-linked_ptr_test gtest_main)
cxx_test(gtest-listener_test gtest_main)
cxx_test(gtest_main_unittest gtest_main)
cxx_test(gtest-message_test gtest_main)
cxx_test(gtest_no_test_unittest gtest)
cxx_test(gtest-options_test gtest_main)
cxx_test(gtest-param-test_test gtest
test/gtest-param-test2_test.cc)
cxx_test(gtest-port_test gtest_main)
cxx_test(gtest_pred_impl_unittest gtest_main)
cxx_test(gtest-printers_test gtest_main)
cxx_test(gtest_prod_test gtest_main
test/production.cc)
cxx_test(gtest_repeat_test gtest)
cxx_test(gtest_sole_header_test gtest_main)
cxx_test(gtest_stress_test gtest)
cxx_test(gtest-test-part_test gtest_main)
cxx_test(gtest_throw_on_failure_ex_test gtest)
cxx_test(gtest-typed-test_test gtest_main
test/gtest-typed-test2_test.cc)
cxx_test(gtest_unittest gtest_main)
cxx_test(gtest-unittest-api_test gtest)
############################################################
# C++ tests built with non-standard compiler flags.
cxx_library(gtest_no_exception "${cxx_no_exception}"
src/gtest-all.cc)
cxx_library(gtest_main_no_exception "${cxx_no_exception}"
src/gtest-all.cc src/gtest_main.cc)
cxx_library(gtest_main_no_rtti "${cxx_no_rtti}"
src/gtest-all.cc src/gtest_main.cc)
cxx_test_with_flags(gtest-death-test_ex_nocatch_test
"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
gtest test/gtest-death-test_ex_test.cc)
cxx_test_with_flags(gtest-death-test_ex_catch_test
"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
gtest test/gtest-death-test_ex_test.cc)
cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
gtest_main_no_rtti test/gtest_unittest.cc)
cxx_shared_library(gtest_dll "${cxx_default}"
src/gtest-all.cc src/gtest_main.cc)
cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}"
gtest_dll test/gtest_all_test.cc)
set_target_properties(gtest_dll_test_
PROPERTIES
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)
# The C++ Standard specifies tuple_element<int, class>.
# Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
# That declaration conflicts with our own standard-conforming
# tuple implementation. Therefore using our own tuple with
# MSVC 10 doesn't compile.
cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
src/gtest-all.cc src/gtest_main.cc)
cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
gtest_main_use_own_tuple test/gtest-tuple_test.cc)
cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
gtest_main_use_own_tuple
test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
endif()
# VC11 contains std::tuple with variadic templates emulation macro.
# _VARIADIC_MAX defaulted to 5 but gtest requires 10.
if (MSVC AND MSVC_VERSION EQUAL 1700)
add_definitions(-D_VARIADIC_MAX=10)
endif()
############################################################
# Python tests.
cxx_executable(gtest_break_on_failure_unittest_ test gtest)
py_test(gtest_break_on_failure_unittest)
cxx_executable_with_flags(
gtest_catch_exceptions_no_ex_test_
"${cxx_no_exception}"
gtest_main_no_exception
test/gtest_catch_exceptions_test_.cc)
cxx_executable_with_flags(
gtest_catch_exceptions_ex_test_
"${cxx_exception}"
gtest_main
test/gtest_catch_exceptions_test_.cc)
py_test(gtest_catch_exceptions_test)
cxx_executable(gtest_color_test_ test gtest)
py_test(gtest_color_test)
cxx_executable(gtest_env_var_test_ test gtest)
py_test(gtest_env_var_test)
cxx_executable(gtest_filter_unittest_ test gtest)
py_test(gtest_filter_unittest)
cxx_executable(gtest_help_test_ test gtest_main)
py_test(gtest_help_test)
cxx_executable(gtest_list_tests_unittest_ test gtest)
py_test(gtest_list_tests_unittest)
cxx_executable(gtest_output_test_ test gtest)
py_test(gtest_output_test)
cxx_executable(gtest_shuffle_test_ test gtest)
py_test(gtest_shuffle_test)
cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
set_target_properties(gtest_throw_on_failure_test_
PROPERTIES
COMPILE_FLAGS "${cxx_no_exception}")
py_test(gtest_throw_on_failure_test)
cxx_executable(gtest_uninitialized_test_ test gtest)
py_test(gtest_uninitialized_test)
cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
py_test(gtest_xml_outfiles_test)
cxx_executable(gtest_xml_output_unittest_ test gtest)
py_test(gtest_xml_output_unittest)
endif()

View File

@ -1,37 +0,0 @@
# This file contains a list of people who've made non-trivial
# contribution to the Google C++ Testing Framework project. People
# who commit code to the project are encouraged to add their names
# here. Please keep the list sorted by first names.
Ajay Joshi <jaj@google.com>
Balázs Dán <balazs.dan@gmail.com>
Bharat Mediratta <bharat@menalto.com>
Chandler Carruth <chandlerc@google.com>
Chris Prince <cprince@google.com>
Chris Taylor <taylorc@google.com>
Dan Egnor <egnor@google.com>
Eric Roman <eroman@chromium.org>
Hady Zalek <hady.zalek@gmail.com>
Jeffrey Yasskin <jyasskin@google.com>
Jói Sigurðsson <joi@google.com>
Keir Mierle <mierle@gmail.com>
Keith Ray <keith.ray@gmail.com>
Kenton Varda <kenton@google.com>
Manuel Klimek <klimek@google.com>
Markus Heule <markus.heule@gmail.com>
Mika Raento <mikie@iki.fi>
Miklós Fazekas <mfazekas@szemafor.com>
Pasi Valminen <pasi.valminen@gmail.com>
Patrick Hanna <phanna@google.com>
Patrick Riley <pfr@google.com>
Peter Kaminski <piotrk@google.com>
Preston Jackson <preston.a.jackson@gmail.com>
Rainer Klaffenboeck <rainer.klaffenboeck@dynatrace.com>
Russ Cox <rsc@google.com>
Russ Rufer <russ@pentad.com>
Sean Mcafee <eefacm@gmail.com>
Sigurður Ásgeirsson <siggi@google.com>
Tracy Bialik <tracy@pentad.com>
Vadim Berman <vadimb@google.com>
Vlad Losev <vladl@google.com>
Zhanyong Wan <wan@google.com>

View File

@ -1,28 +0,0 @@
Copyright 2008, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,424 +0,0 @@
Google C++ Testing Framework
============================
http://code.google.com/p/googletest/
Overview
--------
Google's framework for writing C++ tests on a variety of platforms
(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the
xUnit architecture. Supports automatic test discovery, a rich set of
assertions, user-defined assertions, death tests, fatal and non-fatal
failures, various options for running the tests, and XML test report
generation.
Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
join us!
Requirements for End Users
--------------------------
Google Test is designed to have fairly minimal requirements to build
and use with your projects, but there are some. Currently, we support
Linux, Windows, Mac OS X, and Cygwin. We will also make our best
effort to support other platforms (e.g. Solaris, AIX, and z/OS).
However, since core members of the Google Test project have no access
to these platforms, Google Test may have outstanding issues there. If
you notice any problems on your platform, please notify
googletestframework@googlegroups.com. Patches for fixing them are
even more welcome!
### Linux Requirements ###
These are the base requirements to build and use Google Test from a source
package (as described below):
* GNU-compatible Make or gmake
* POSIX-standard shell
* POSIX(-2) Regular Expressions (regex.h)
* A C++98-standard-compliant compiler
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
### Mac OS X Requirements ###
* Mac OS X 10.4 Tiger or newer
* Developer Tools Installed
Also, you'll need CMake 2.6.4 or higher if you want to build the
samples using the provided CMake script, regardless of the platform.
Requirements for Contributors
-----------------------------
We welcome patches. If you plan to contribute a patch, you need to
build Google Test and its own tests from an SVN checkout (described
below), which has further requirements:
* Python version 2.3 or newer (for running some of the tests and
re-generating certain source files from templates)
* CMake 2.6.4 or newer
Getting the Source
------------------
There are two primary ways of getting Google Test's source code: you
can download a stable source release in your preferred archive format,
or directly check out the source from our Subversion (SVN) repositary.
The SVN checkout requires a few extra steps and some extra software
packages on your system, but lets you track the latest development and
make patches much more easily, so we highly encourage it.
### Source Package ###
Google Test is released in versioned source packages which can be
downloaded from the download page [1]. Several different archive
formats are provided, but the only difference is the tools used to
manipulate them, and the size of the resulting file. Download
whichever you are most comfortable with.
[1] http://code.google.com/p/googletest/downloads/list
Once the package is downloaded, expand it using whichever tools you
prefer for that type. This will result in a new directory with the
name "gtest-X.Y.Z" which contains all of the source code. Here are
some examples on Linux:
tar -xvzf gtest-X.Y.Z.tar.gz
tar -xvjf gtest-X.Y.Z.tar.bz2
unzip gtest-X.Y.Z.zip
### SVN Checkout ###
To check out the main branch (also known as the "trunk") of Google
Test, run the following Subversion command:
svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
Setting up the Build
--------------------
To build Google Test and your tests that use it, you need to tell your
build system where to find its headers and source files. The exact
way to do it depends on which build system you use, and is usually
straightforward.
### Generic Build Instructions ###
Suppose you put Google Test in directory ${GTEST_DIR}. To build it,
create a library build target (or a project as called by Visual Studio
and Xcode) to compile
${GTEST_DIR}/src/gtest-all.cc
with
${GTEST_DIR}/include and ${GTEST_DIR}
in the header search path. Assuming a Linux-like system and gcc,
something like the following will do:
g++ -I${GTEST_DIR}/include -I${GTEST_DIR} -c ${GTEST_DIR}/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
Next, you should compile your test source file with
${GTEST_DIR}/include in the header search path, and link it with gtest
and any other necessary libraries:
g++ -I${GTEST_DIR}/include path/to/your_test.cc libgtest.a -o your_test
As an example, the make/ directory contains a Makefile that you can
use to build Google Test on systems where GNU make is available
(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google
Test's own tests. Instead, it just builds the Google Test library and
a sample test. You can use it as a starting point for your own build
script.
If the default settings are correct for your environment, the
following commands should succeed:
cd ${GTEST_DIR}/make
make
./sample1_unittest
If you see errors, try to tweak the contents of make/Makefile to make
them go away. There are instructions in make/Makefile on how to do
it.
### Using CMake ###
Google Test comes with a CMake build script (CMakeLists.txt) that can
be used on a wide range of platforms ("C" stands for cross-platofrm.).
If you don't have CMake installed already, you can download it for
free from http://www.cmake.org/.
CMake works by generating native makefiles or build projects that can
be used in the compiler environment of your choice. The typical
workflow starts with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test's samples, you should replace the
last command with
cmake -Dgtest_build_samples=ON ${GTEST_DIR}
If you are on a *nix system, you should now see a Makefile in the
current directory. Just type 'make' to build gtest.
If you use Windows and have Vistual Studio installed, a gtest.sln file
and several .vcproj files will be created. You can then build them
using Visual Studio.
On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
### Legacy Build Scripts ###
Before settling on CMake, we have been providing hand-maintained build
projects/scripts for Visual Studio, Xcode, and Autotools. While we
continue to provide them for convenience, they are not actively
maintained any more. We highly recommend that you follow the
instructions in the previous two sections to integrate Google Test
with your existing build system.
If you still need to use the legacy build scripts, here's how:
The msvc\ folder contains two solutions with Visual C++ projects.
Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
are ready to build Google Test the same way you build any Visual
Studio project. Files that have names ending with -md use DLL
versions of Microsoft runtime libraries (the /MD or the /MDd compiler
option). Files without that suffix use static versions of the runtime
libraries (the /MT or the /MTd option). Please note that one must use
the same option to compile both gtest and the test code. If you use
Visual Studio 2005 or above, we recommend the -md version as /MD is
the default for new projects in these versions of Visual Studio.
On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
Xcode. Build the "gtest" target. The universal binary framework will
end up in your selected build directory (selected in the Xcode
"Preferences..." -> "Building" pane and defaults to xcode/build).
Alternatively, at the command line, enter:
xcodebuild
This will build the "Release" configuration of gtest.framework in your
default build location. See the "xcodebuild" man page for more
information about building different configurations and building in
different locations.
Tweaking Google Test
--------------------
Google Test can be used in diverse environments. The default
configuration may not work (or may not work well) out of the box in
some environments. However, you can easily tweak Google Test by
defining control macros on the compiler command line. Generally,
these macros are named like GTEST_XYZ and you define them to either 1
or 0 to enable or disable a certain feature.
We list the most frequently used macros below. For a complete list,
see file include/gtest/internal/gtest-port.h.
### Choosing a TR1 Tuple Library ###
Some Google Test features require the C++ Technical Report 1 (TR1)
tuple library, which is not yet available with all compilers. The
good news is that Google Test implements a subset of TR1 tuple that's
enough for its own need, and will automatically use this when the
compiler doesn't provide TR1 tuple.
Usually you don't need to care about which tuple library Google Test
uses. However, if your project already uses TR1 tuple, you need to
tell Google Test to use the same TR1 tuple library the rest of your
project uses, or the two tuple implementations will clash. To do
that, add
-DGTEST_USE_OWN_TR1_TUPLE=0
to the compiler flags while compiling Google Test and your tests. If
you want to force Google Test to use its own tuple library, just add
-DGTEST_USE_OWN_TR1_TUPLE=1
to the compiler flags instead.
If you don't want Google Test to use tuple at all, add
-DGTEST_HAS_TR1_TUPLE=0
and all features using tuple will be disabled.
### Multi-threaded Tests ###
Google Test is thread-safe where the pthread library is available.
After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
macro to see whether this is the case (yes if the macro is #defined to
1, no if it's undefined.).
If Google Test doesn't correctly detect whether pthread is available
in your environment, you can force it with
-DGTEST_HAS_PTHREAD=1
or
-DGTEST_HAS_PTHREAD=0
When Google Test uses pthread, you may need to add flags to your
compiler and/or linker to select the pthread library, or you'll get
link errors. If you use the CMake script or the deprecated Autotools
script, this is taken care of for you. If you use your own build
script, you'll need to read your compiler and linker's manual to
figure out what flags to add.
### As a Shared Library (DLL) ###
Google Test is compact, so most users can build and link it as a
static library for the simplicity. You can choose to use Google Test
as a shared library (known as a DLL on Windows) if you prefer.
To compile *gtest* as a shared library, add
-DGTEST_CREATE_SHARED_LIBRARY=1
to the compiler flags. You'll also need to tell the linker to produce
a shared library instead - consult your linker's manual for how to do
it.
To compile your *tests* that use the gtest shared library, add
-DGTEST_LINKED_AS_SHARED_LIBRARY=1
to the compiler flags.
Note: while the above steps aren't technically necessary today when
using some compilers (e.g. GCC), they may become necessary in the
future, if we decide to improve the speed of loading the library (see
http://gcc.gnu.org/wiki/Visibility for details). Therefore you are
recommended to always add the above flags when using Google Test as a
shared library. Otherwise a future release of Google Test may break
your build script.
### Avoiding Macro Name Clashes ###
In C++, macros don't obey namespaces. Therefore two libraries that
both define a macro of the same name will clash if you #include both
definitions. In case a Google Test macro clashes with another
library, you can force Google Test to rename its macro to avoid the
conflict.
Specifically, if both Google Test and some other code define macro
FOO, you can add
-DGTEST_DONT_DEFINE_FOO=1
to the compiler flags to tell Google Test to change the macro's name
from FOO to GTEST_FOO. Currently FOO can be FAIL, SUCCEED, or TEST.
For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write
GTEST_TEST(SomeTest, DoesThis) { ... }
instead of
TEST(SomeTest, DoesThis) { ... }
in order to define a test.
Upgrating from an Earlier Version
---------------------------------
We strive to keep Google Test releases backward compatible.
Sometimes, though, we have to make some breaking changes for the
users' long-term benefits. This section describes what you'll need to
do if you are upgrading from an earlier version of Google Test.
### Upgrading from 1.3.0 or Earlier ###
You may need to explicitly enable or disable Google Test's own TR1
tuple library. See the instructions in section "Choosing a TR1 Tuple
Library".
### Upgrading from 1.4.0 or Earlier ###
The Autotools build script (configure + make) is no longer officially
supportted. You are encouraged to migrate to your own build system or
use CMake. If you still need to use Autotools, you can find
instructions in the README file from Google Test 1.4.0.
On platforms where the pthread library is available, Google Test uses
it in order to be thread-safe. See the "Multi-threaded Tests" section
for what this means to your build script.
If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google
Test will no longer compile. This should affect very few people, as a
large portion of STL (including <string>) doesn't compile in this mode
anyway. We decided to stop supporting it in order to greatly simplify
Google Test's implementation.
Developing Google Test
----------------------
This section discusses how to make your own changes to Google Test.
### Testing Google Test Itself ###
To make sure your changes work as intended and don't break existing
functionality, you'll want to compile and run Google Test's own tests.
For that you can use CMake:
mkdir mybuild
cd mybuild
cmake -Dgtest_build_tests=ON ${GTEST_DIR}
Make sure you have Python installed, as some of Google Test's tests
are written in Python. If the cmake command complains about not being
able to find Python ("Could NOT find PythonInterp (missing:
PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
executable can be found:
cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
Next, you can build Google Test and all of its own tests. On *nix,
this is usually done by 'make'. To run the tests, do
make test
All tests should pass.
### Regenerating Source Files ###
Some of Google Test's source files are generated from templates (not
in the C++ sense) using a script. A template file is named FOO.pump,
where FOO is the name of the file it will generate. For example, the
file include/gtest/internal/gtest-type-util.h.pump is used to generate
gtest-type-util.h in the same directory.
Normally you don't need to worry about regenerating the source files,
unless you need to modify them. In that case, you should modify the
corresponding .pump files instead and run the pump.py Python script to
regenerate them. You can find pump.py in the scripts/ directory.
Read the Pump manual [2] for how to use it.
[2] http://code.google.com/p/googletest/wiki/PumpManual
### Contributing a Patch ###
We welcome patches. Please read the Google Test developer's guide [3]
for how you can contribute. In particular, make sure you have signed
the Contributor License Agreement, or we won't be able to accept the
patch.
[3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
Happy testing!

View File

@ -1,216 +0,0 @@
# Defines functions and macros useful for building Google Test and
# Google Mock.
#
# Note:
#
# - This file will be run twice when building Google Mock (once via
# Google Test's CMakeLists.txt, and once via Google Mock's).
# Therefore it shouldn't have any side effects other than defining
# the functions and macros.
#
# - The functions/macros defined in this file may depend on Google
# Test and Google Mock's option() definitions, and thus must be
# called *after* the options have been defined.
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
#
# This must be a macro(), as inside a function string() can only
# update variables in the function scope.
macro(fix_default_compiler_settings_)
if (MSVC)
# For MSVC, CMake sets certain flags to defaults we want to override.
# This replacement code is taken from sample in the CMake Wiki at
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
# When Google Test is built as a shared library, it should also use
# shared runtime libraries. Otherwise, it may end up with multiple
# copies of runtime library data in different modules, resulting in
# hard-to-find crashes. When it is built as a static library, it is
# preferable to use CRT as static libraries, as we don't have to rely
# on CRT DLLs being available. CMake always defaults to using shared
# CRT libraries, so we override that default here.
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
endif()
# We prefer more strict warning checking for building Google Test.
# Replaces /W3 with /W4 in defaults.
string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
endforeach()
endif()
endmacro()
# Defines the compiler/linker flags used to build Google Test and
# Google Mock. You can tweak these definitions to suit your need. A
# variable's value is empty before it's explicitly assigned to.
macro(config_compiler_and_linker)
if (NOT gtest_disable_pthreads)
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
find_package(Threads)
endif()
fix_default_compiler_settings_()
if (MSVC)
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set(cxx_base_flags "-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
set(cxx_no_rtti_flags "-GR-")
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow")
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
# Until version 4.3.2, GCC doesn't define a macro to indicate
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
set(cxx_strict_flags "-Wextra")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(cxx_exception_flags "-features=except")
# Sun Pro doesn't provide macros to indicate whether exceptions and
# RTTI are enabled, so we define GTEST_HAS_* explicitly.
set(cxx_no_exception_flags "-features=no%except -DGTEST_HAS_EXCEPTIONS=0")
set(cxx_no_rtti_flags "-features=no%rtti -DGTEST_HAS_RTTI=0")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
CMAKE_CXX_COMPILER_ID STREQUAL "XL")
# CMake 2.8 changes Visual Age's compiler ID to "XL".
set(cxx_exception_flags "-qeh")
set(cxx_no_exception_flags "-qnoeh")
# Until version 9.0, Visual Age doesn't define a macro to indicate
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
set(cxx_base_flags "-AA -mt")
set(cxx_exception_flags "-DGTEST_HAS_EXCEPTIONS=1")
set(cxx_no_exception_flags "+noeh -DGTEST_HAS_EXCEPTIONS=0")
# RTTI can not be disabled in HP aCC compiler.
set(cxx_no_rtti_flags "")
endif()
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available and allowed.
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
else()
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=0")
endif()
# For building gtest's own tests and samples.
set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
set(cxx_no_exception
"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
set(cxx_default "${cxx_exception}")
set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
# For building the gtest libraries.
set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
endmacro()
# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
function(cxx_library_with_type name type cxx_flags)
# type can be either STATIC or SHARED to denote a static or shared library.
# ARGN refers to additional arguments after 'cxx_flags'.
add_library(${name} ${type} ${ARGN})
set_target_properties(${name}
PROPERTIES
COMPILE_FLAGS "${cxx_flags}")
if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
set_target_properties(${name}
PROPERTIES
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
endif()
if (CMAKE_USE_PTHREADS_INIT)
target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
endif()
endfunction()
########################################################################
#
# Helper functions for creating build targets.
function(cxx_shared_library name cxx_flags)
cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
endfunction()
function(cxx_library name cxx_flags)
cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
endfunction()
# cxx_executable_with_flags(name cxx_flags libs srcs...)
#
# creates a named C++ executable that depends on the given libraries and
# is built from the given source files with the given compiler flags.
function(cxx_executable_with_flags name cxx_flags libs)
add_executable(${name} ${ARGN})
if (cxx_flags)
set_target_properties(${name}
PROPERTIES
COMPILE_FLAGS "${cxx_flags}")
endif()
if (BUILD_SHARED_LIBS)
set_target_properties(${name}
PROPERTIES
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
endif()
# To support mixing linking in static and dynamic libraries, link each
# library in with an extra call to target_link_libraries.
foreach (lib "${libs}")
target_link_libraries(${name} ${lib})
endforeach()
endfunction()
# cxx_executable(name dir lib srcs...)
#
# creates a named target that depends on the given libs and is built
# from the given source files. dir/name.cc is implicitly included in
# the source file list.
function(cxx_executable name dir libs)
cxx_executable_with_flags(
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
endfunction()
# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
find_package(PythonInterp)
# cxx_test_with_flags(name cxx_flags libs srcs...)
#
# creates a named C++ test that depends on the given libs and is built
# from the given source files with the given compiler flags.
function(cxx_test_with_flags name cxx_flags libs)
cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
add_test(${name} ${name})
endfunction()
# cxx_test(name libs srcs...)
#
# creates a named test target that depends on the given libs and is
# built from the given source files. Unlike cxx_test_with_flags,
# test/name.cc is already implicitly included in the source file list.
function(cxx_test name libs)
cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
"test/${name}.cc" ${ARGN})
endfunction()
# py_test(name)
#
# creates a Python test with the given name whose main module is in
# test/name.py. It does nothing if Python is not installed.
function(py_test name)
# We are not supporting Python tests on Linux yet as they consider
# all Linux environments to be google3 and try to use google3 features.
if (PYTHONINTERP_FOUND)
# ${CMAKE_BINARY_DIR} is known at configuration time, so we can
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
# only at ctest runtime (by calling ctest -c <Configuration>), so
# we have to escape $ to delay variable substitution here.
add_test(${name}
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
endif()
endfunction()

View File

@ -1,283 +0,0 @@
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file defines the public API for death tests. It is
// #included by gtest.h so a user doesn't need to include this
// directly.
#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
#include "gtest/internal/gtest-death-test-internal.h"
namespace testing {
// This flag controls the style of death tests. Valid values are "threadsafe",
// meaning that the death test child process will re-execute the test binary
// from the start, running only a single death test, or "fast",
// meaning that the child process will execute the test logic immediately
// after forking.
GTEST_DECLARE_string_(death_test_style);
#if GTEST_HAS_DEATH_TEST
// The following macros are useful for writing death tests.
// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
// executed:
//
// 1. It generates a warning if there is more than one active
// thread. This is because it's safe to fork() or clone() only
// when there is a single thread.
//
// 2. The parent process clone()s a sub-process and runs the death
// test in it; the sub-process exits with code 0 at the end of the
// death test, if it hasn't exited already.
//
// 3. The parent process waits for the sub-process to terminate.
//
// 4. The parent process checks the exit code and error message of
// the sub-process.
//
// Examples:
//
// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
// for (int i = 0; i < 5; i++) {
// EXPECT_DEATH(server.ProcessRequest(i),
// "Invalid request .* in ProcessRequest()")
// << "Failed to die on request " << i);
// }
//
// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
//
// bool KilledBySIGHUP(int exit_code) {
// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
// }
//
// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
//
// On the regular expressions used in death tests:
//
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
// which uses the POSIX extended regex syntax.
//
// On other platforms (e.g. Windows), we only support a simple regex
// syntax implemented as part of Google Test. This limited
// implementation should be enough most of the time when writing
// death tests; though it lacks many features you can find in PCRE
// or POSIX extended regex syntax. For example, we don't support
// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
// repetition count ("x{5,7}"), among others.
//
// Below is the syntax that we do support. We chose it to be a
// subset of both PCRE and POSIX extended regex, so it's easy to
// learn wherever you come from. In the following: 'A' denotes a
// literal character, period (.), or a single \\ escape sequence;
// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
// natural numbers.
//
// c matches any literal character c
// \\d matches any decimal digit
// \\D matches any character that's not a decimal digit
// \\f matches \f
// \\n matches \n
// \\r matches \r
// \\s matches any ASCII whitespace, including \n
// \\S matches any character that's not a whitespace
// \\t matches \t
// \\v matches \v
// \\w matches any letter, _, or decimal digit
// \\W matches any character that \\w doesn't match
// \\c matches any literal character c, which must be a punctuation
// . matches any single character except \n
// A? matches 0 or 1 occurrences of A
// A* matches 0 or many occurrences of A
// A+ matches 1 or many occurrences of A
// ^ matches the beginning of a string (not that of each line)
// $ matches the end of a string (not that of each line)
// xy matches x followed by y
//
// If you accidentally use PCRE or POSIX extended regex features
// not implemented by us, you will get a run-time failure. In that
// case, please try to rewrite your regular expression within the
// above syntax.
//
// This implementation is *not* meant to be as highly tuned or robust
// as a compiled regex library, but should perform well enough for a
// death test, which already incurs significant overhead by launching
// a child process.
//
// Known caveats:
//
// A "threadsafe" style death test obtains the path to the test
// program from argv[0] and re-executes it in the sub-process. For
// simplicity, the current implementation doesn't search the PATH
// when launching the sub-process. This means that the user must
// invoke the test program via a path that contains at least one
// path separator (e.g. path/to/foo_test and
// /absolute/path/to/bar_test are fine, but foo_test is not). This
// is rarely a problem as people usually don't put the test binary
// directory in PATH.
//
// TODO(wan@google.com): make thread-safe death tests search the PATH.
// Asserts that a given statement causes the program to exit, with an
// integer exit status that satisfies predicate, and emitting error output
// that matches regex.
# define ASSERT_EXIT(statement, predicate, regex) \
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
// Like ASSERT_EXIT, but continues on to successive tests in the
// test case, if any:
# define EXPECT_EXIT(statement, predicate, regex) \
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
// Asserts that a given statement causes the program to exit, either by
// explicitly exiting with a nonzero exit code or being killed by a
// signal, and emitting error output that matches regex.
# define ASSERT_DEATH(statement, regex) \
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Like ASSERT_DEATH, but continues on to successive tests in the
// test case, if any:
# define EXPECT_DEATH(statement, regex) \
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
// Tests that an exit code describes a normal exit with a given exit code.
class GTEST_API_ ExitedWithCode {
public:
explicit ExitedWithCode(int exit_code);
bool operator()(int exit_status) const;
private:
// No implementation - assignment is unsupported.
void operator=(const ExitedWithCode& other);
const int exit_code_;
};
# if !GTEST_OS_WINDOWS
// Tests that an exit code describes an exit due to termination by a
// given signal.
class GTEST_API_ KilledBySignal {
public:
explicit KilledBySignal(int signum);
bool operator()(int exit_status) const;
private:
const int signum_;
};
# endif // !GTEST_OS_WINDOWS
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
// The death testing framework causes this to have interesting semantics,
// since the sideeffects of the call are only visible in opt mode, and not
// in debug mode.
//
// In practice, this can be used to test functions that utilize the
// LOG(DFATAL) macro using the following style:
//
// int DieInDebugOr12(int* sideeffect) {
// if (sideeffect) {
// *sideeffect = 12;
// }
// LOG(DFATAL) << "death";
// return 12;
// }
//
// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
// int sideeffect = 0;
// // Only asserts in dbg.
// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
//
// #ifdef NDEBUG
// // opt-mode has sideeffect visible.
// EXPECT_EQ(12, sideeffect);
// #else
// // dbg-mode no visible sideeffect.
// EXPECT_EQ(0, sideeffect);
// #endif
// }
//
// This will assert that DieInDebugReturn12InOpt() crashes in debug
// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
// appropriate fallback value (12 in this case) in opt mode. If you
// need to test that a function has appropriate side-effects in opt
// mode, include assertions against the side-effects. A general
// pattern for this is:
//
// EXPECT_DEBUG_DEATH({
// // Side-effects here will have an effect after this statement in
// // opt mode, but none in debug mode.
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
// }, "death");
//
# ifdef NDEBUG
# define EXPECT_DEBUG_DEATH(statement, regex) \
do { statement; } while (::testing::internal::AlwaysFalse())
# define ASSERT_DEBUG_DEATH(statement, regex) \
do { statement; } while (::testing::internal::AlwaysFalse())
# else
# define EXPECT_DEBUG_DEATH(statement, regex) \
EXPECT_DEATH(statement, regex)
# define ASSERT_DEBUG_DEATH(statement, regex) \
ASSERT_DEATH(statement, regex)
# endif // NDEBUG for EXPECT_DEBUG_DEATH
#endif // GTEST_HAS_DEATH_TEST
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
// death tests are supported; otherwise they just issue a warning. This is
// useful when you are combining death test assertions with normal test
// assertions in one test.
#if GTEST_HAS_DEATH_TEST
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
EXPECT_DEATH(statement, regex)
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
ASSERT_DEATH(statement, regex)
#else
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
#endif
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_

View File

@ -1,230 +0,0 @@
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file defines the Message class.
//
// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
// leave some internal implementation details in this header file.
// They are clearly marked by comments like this:
//
// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
//
// Such code is NOT meant to be used by a user directly, and is subject
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
// program!
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#include <limits>
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-internal.h"
namespace testing {
// The Message class works like an ostream repeater.
//
// Typical usage:
//
// 1. You stream a bunch of values to a Message object.
// It will remember the text in a stringstream.
// 2. Then you stream the Message object to an ostream.
// This causes the text in the Message to be streamed
// to the ostream.
//
// For example;
//
// testing::Message foo;
// foo << 1 << " != " << 2;
// std::cout << foo;
//
// will print "1 != 2".
//
// Message is not intended to be inherited from. In particular, its
// destructor is not virtual.
//
// Note that stringstream behaves differently in gcc and in MSVC. You
// can stream a NULL char pointer to it in the former, but not in the
// latter (it causes an access violation if you do). The Message
// class hides this difference by treating a NULL char pointer as
// "(null)".
class GTEST_API_ Message {
private:
// The type of basic IO manipulators (endl, ends, and flush) for
// narrow streams.
typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
public:
// Constructs an empty Message.
// We allocate the stringstream separately because otherwise each use of
// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
// stack frame leading to huge stack frames in some cases; gcc does not reuse
// the stack space.
Message() : ss_(new ::std::stringstream) {
// By default, we want there to be enough precision when printing
// a double to a Message.
*ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
}
// Copy constructor.
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
*ss_ << msg.GetString();
}
// Constructs a Message from a C-string.
explicit Message(const char* str) : ss_(new ::std::stringstream) {
*ss_ << str;
}
#if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object.
template <typename T>
inline Message& operator <<(const T& value) {
StreamHelper(typename internal::is_pointer<T>::type(), value);
return *this;
}
#else
// Streams a non-pointer value to this object.
template <typename T>
inline Message& operator <<(const T& val) {
::GTestStreamToHelper(ss_.get(), val);
return *this;
}
// Streams a pointer value to this object.
//
// This function is an overload of the previous one. When you
// stream a pointer to a Message, this definition will be used as it
// is more specialized. (The C++ Standard, section
// [temp.func.order].) If you stream a non-pointer, then the
// previous definition will be used.
//
// The reason for this overload is that streaming a NULL pointer to
// ostream is undefined behavior. Depending on the compiler, you
// may get "0", "(nil)", "(null)", or an access violation. To
// ensure consistent result across compilers, we always treat NULL
// as "(null)".
template <typename T>
inline Message& operator <<(T* const& pointer) { // NOLINT
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
}
return *this;
}
#endif // GTEST_OS_SYMBIAN
// Since the basic IO manipulators are overloaded for both narrow
// and wide streams, we have to provide this specialized definition
// of operator <<, even though its body is the same as the
// templatized version above. Without this definition, streaming
// endl or other basic IO manipulators to Message will confuse the
// compiler.
Message& operator <<(BasicNarrowIoManip val) {
*ss_ << val;
return *this;
}
// Instead of 1/0, we want to see true/false for bool values.
Message& operator <<(bool b) {
return *this << (b ? "true" : "false");
}
// These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding.
Message& operator <<(const wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
Message& operator <<(wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::std::wstring& wstr);
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::wstring& wstr);
#endif // GTEST_HAS_GLOBAL_WSTRING
// Gets the text streamed to this object so far as a String.
// Each '\0' character in the buffer is replaced with "\\0".
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::String GetString() const {
return internal::StringStreamToString(ss_.get());
}
private:
#if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_
// decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T>
inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
}
}
template <typename T>
inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
::GTestStreamToHelper(ss_.get(), value);
}
#endif // GTEST_OS_SYMBIAN
// We'll hold the text streamed to this object here.
const internal::scoped_ptr< ::std::stringstream> ss_;
// We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator.
void operator=(const Message&);
};
// Streams a Message to an ostream.
inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
return os << sb.GetString();
}
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,487 +0,0 @@
$$ -*- mode: c++; -*-
$var n = 50 $$ Maximum length of Values arguments we want to support.
$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: vladl@google.com (Vlad Losev)
//
// Macros and functions for implementing parameterized tests
// in Google C++ Testing Framework (Google Test)
//
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
//
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
// Value-parameterized tests allow you to test your code with different
// parameters without writing multiple copies of the same test.
//
// Here is how you use value-parameterized tests:
#if 0
// To write value-parameterized tests, first you should define a fixture
// class. It is usually derived from testing::TestWithParam<T> (see below for
// another inheritance scheme that's sometimes useful in more complicated
// class hierarchies), where the type of your parameter values.
// TestWithParam<T> is itself derived from testing::Test. T can be any
// copyable type. If it's a raw pointer, you are responsible for managing the
// lifespan of the pointed values.
class FooTest : public ::testing::TestWithParam<const char*> {
// You can implement all the usual class fixture members here.
};
// Then, use the TEST_P macro to define as many parameterized tests
// for this fixture as you want. The _P suffix is for "parameterized"
// or "pattern", whichever you prefer to think.
TEST_P(FooTest, DoesBlah) {
// Inside a test, access the test parameter with the GetParam() method
// of the TestWithParam<T> class:
EXPECT_TRUE(foo.Blah(GetParam()));
...
}
TEST_P(FooTest, HasBlahBlah) {
...
}
// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
// case with any set of parameters you want. Google Test defines a number
// of functions for generating test parameters. They return what we call
// (surprise!) parameter generators. Here is a summary of them, which
// are all in the testing namespace:
//
//
// Range(begin, end [, step]) - Yields values {begin, begin+step,
// begin+step+step, ...}. The values do not
// include end. step defaults to 1.
// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
// ValuesIn(container) - Yields values from a C-style array, an STL
// ValuesIn(begin,end) container, or an iterator range [begin, end).
// Bool() - Yields sequence {false, true}.
// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
// for the math savvy) of the values generated
// by the N generators.
//
// For more details, see comments at the definitions of these functions below
// in this file.
//
// The following statement will instantiate tests from the FooTest test case
// each with parameter values "meeny", "miny", and "moe".
INSTANTIATE_TEST_CASE_P(InstantiationName,
FooTest,
Values("meeny", "miny", "moe"));
// To distinguish different instances of the pattern, (yes, you
// can instantiate it more then once) the first argument to the
// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
// actual test case name. Remember to pick unique prefixes for different
// instantiations. The tests from the instantiation above will have
// these names:
//
// * InstantiationName/FooTest.DoesBlah/0 for "meeny"
// * InstantiationName/FooTest.DoesBlah/1 for "miny"
// * InstantiationName/FooTest.DoesBlah/2 for "moe"
// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
// * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
// * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
//
// You can use these names in --gtest_filter.
//
// This statement will instantiate all tests from FooTest again, each
// with parameter values "cat" and "dog":
const char* pets[] = {"cat", "dog"};
INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
// The tests from the instantiation above will have these names:
//
// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
//
// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
// in the given test case, whether their definitions come before or
// AFTER the INSTANTIATE_TEST_CASE_P statement.
//
// Please also note that generator expressions (including parameters to the
// generators) are evaluated in InitGoogleTest(), after main() has started.
// This allows the user on one hand, to adjust generator parameters in order
// to dynamically determine a set of tests to run and on the other hand,
// give the user a chance to inspect the generated tests with Google Test
// reflection API before RUN_ALL_TESTS() is executed.
//
// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
// for more examples.
//
// In the future, we plan to publish the API for defining new parameter
// generators. But for now this interface remains part of the internal
// implementation and is subject to change.
//
//
// A parameterized test fixture must be derived from testing::Test and from
// testing::WithParamInterface<T>, where T is the type of the parameter
// values. Inheriting from TestWithParam<T> satisfies that requirement because
// TestWithParam<T> inherits from both Test and WithParamInterface. In more
// complicated hierarchies, however, it is occasionally useful to inherit
// separately from Test and WithParamInterface. For example:
class BaseTest : public ::testing::Test {
// You can inherit all the usual members for a non-parameterized test
// fixture here.
};
class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
// The usual test fixture members go here too.
};
TEST_F(BaseTest, HasFoo) {
// This is an ordinary non-parameterized test.
}
TEST_P(DerivedTest, DoesBlah) {
// GetParam works just the same here as if you inherit from TestWithParam.
EXPECT_TRUE(foo.Blah(GetParam()));
}
#endif // 0
#include "gtest/internal/gtest-port.h"
#if !GTEST_OS_SYMBIAN
# include <utility>
#endif
// scripts/fuse_gtest.py depends on gtest's own header being #included
// *unconditionally*. Therefore these #includes cannot be moved
// inside #if GTEST_HAS_PARAM_TEST.
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-param-util.h"
#include "gtest/internal/gtest-param-util-generated.h"
#if GTEST_HAS_PARAM_TEST
namespace testing {
// Functions producing parameter generators.
//
// Google Test uses these generators to produce parameters for value-
// parameterized tests. When a parameterized test case is instantiated
// with a particular generator, Google Test creates and runs tests
// for each element in the sequence produced by the generator.
//
// In the following sample, tests from test case FooTest are instantiated
// each three times with parameter values 3, 5, and 8:
//
// class FooTest : public TestWithParam<int> { ... };
//
// TEST_P(FooTest, TestThis) {
// }
// TEST_P(FooTest, TestThat) {
// }
// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
//
// Range() returns generators providing sequences of values in a range.
//
// Synopsis:
// Range(start, end)
// - returns a generator producing a sequence of values {start, start+1,
// start+2, ..., }.
// Range(start, end, step)
// - returns a generator producing a sequence of values {start, start+step,
// start+step+step, ..., }.
// Notes:
// * The generated sequences never include end. For example, Range(1, 5)
// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
// returns a generator producing {1, 3, 5, 7}.
// * start and end must have the same type. That type may be any integral or
// floating-point type or a user defined type satisfying these conditions:
// * It must be assignable (have operator=() defined).
// * It must have operator+() (operator+(int-compatible type) for
// two-operand version).
// * It must have operator<() defined.
// Elements in the resulting sequences will also have that type.
// * Condition start < end must be satisfied in order for resulting sequences
// to contain any elements.
//
template <typename T, typename IncrementT>
internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
return internal::ParamGenerator<T>(
new internal::RangeGenerator<T, IncrementT>(start, end, step));
}
template <typename T>
internal::ParamGenerator<T> Range(T start, T end) {
return Range(start, end, 1);
}
// ValuesIn() function allows generation of tests with parameters coming from
// a container.
//
// Synopsis:
// ValuesIn(const T (&array)[N])
// - returns a generator producing sequences with elements from
// a C-style array.
// ValuesIn(const Container& container)
// - returns a generator producing sequences with elements from
// an STL-style container.
// ValuesIn(Iterator begin, Iterator end)
// - returns a generator producing sequences with elements from
// a range [begin, end) defined by a pair of STL-style iterators. These
// iterators can also be plain C pointers.
//
// Please note that ValuesIn copies the values from the containers
// passed in and keeps them to generate tests in RUN_ALL_TESTS().
//
// Examples:
//
// This instantiates tests from test case StringTest
// each with C-string values of "foo", "bar", and "baz":
//
// const char* strings[] = {"foo", "bar", "baz"};
// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
//
// This instantiates tests from test case StlStringTest
// each with STL strings with values "a" and "b":
//
// ::std::vector< ::std::string> GetParameterStrings() {
// ::std::vector< ::std::string> v;
// v.push_back("a");
// v.push_back("b");
// return v;
// }
//
// INSTANTIATE_TEST_CASE_P(CharSequence,
// StlStringTest,
// ValuesIn(GetParameterStrings()));
//
//
// This will also instantiate tests from CharTest
// each with parameter values 'a' and 'b':
//
// ::std::list<char> GetParameterChars() {
// ::std::list<char> list;
// list.push_back('a');
// list.push_back('b');
// return list;
// }
// ::std::list<char> l = GetParameterChars();
// INSTANTIATE_TEST_CASE_P(CharSequence2,
// CharTest,
// ValuesIn(l.begin(), l.end()));
//
template <typename ForwardIterator>
internal::ParamGenerator<
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
ValuesIn(ForwardIterator begin, ForwardIterator end) {
typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
::value_type ParamType;
return internal::ParamGenerator<ParamType>(
new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
}
template <typename T, size_t N>
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
return ValuesIn(array, array + N);
}
template <class Container>
internal::ParamGenerator<typename Container::value_type> ValuesIn(
const Container& container) {
return ValuesIn(container.begin(), container.end());
}
// Values() allows generating tests from explicitly specified list of
// parameters.
//
// Synopsis:
// Values(T v1, T v2, ..., T vN)
// - returns a generator producing sequences with elements v1, v2, ..., vN.
//
// For example, this instantiates tests from test case BarTest each
// with values "one", "two", and "three":
//
// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
//
// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
// The exact type of values will depend on the type of parameter in BazTest.
//
// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
//
// Currently, Values() supports from 1 to $n parameters.
//
$range i 1..n
$for i [[
$range j 1..i
template <$for j, [[typename T$j]]>
internal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) {
return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]);
}
]]
// Bool() allows generating tests with parameters in a set of (false, true).
//
// Synopsis:
// Bool()
// - returns a generator producing sequences with elements {false, true}.
//
// It is useful when testing code that depends on Boolean flags. Combinations
// of multiple flags can be tested when several Bool()'s are combined using
// Combine() function.
//
// In the following example all tests in the test case FlagDependentTest
// will be instantiated twice with parameters false and true.
//
// class FlagDependentTest : public testing::TestWithParam<bool> {
// virtual void SetUp() {
// external_flag = GetParam();
// }
// }
// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
//
inline internal::ParamGenerator<bool> Bool() {
return Values(false, true);
}
# if GTEST_HAS_COMBINE
// Combine() allows the user to combine two or more sequences to produce
// values of a Cartesian product of those sequences' elements.
//
// Synopsis:
// Combine(gen1, gen2, ..., genN)
// - returns a generator producing sequences with elements coming from
// the Cartesian product of elements from the sequences generated by
// gen1, gen2, ..., genN. The sequence elements will have a type of
// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// of elements from sequences produces by gen1, gen2, ..., genN.
//
// Combine can have up to $maxtuple arguments. This number is currently limited
// by the maximum number of elements in the tuple implementation used by Google
// Test.
//
// Example:
//
// This will instantiate tests in test case AnimalTest each one with
// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
// tuple("dog", BLACK), and tuple("dog", WHITE):
//
// enum Color { BLACK, GRAY, WHITE };
// class AnimalTest
// : public testing::TestWithParam<tuple<const char*, Color> > {...};
//
// TEST_P(AnimalTest, AnimalLooksNice) {...}
//
// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
// Combine(Values("cat", "dog"),
// Values(BLACK, WHITE)));
//
// This will instantiate tests in FlagDependentTest with all variations of two
// Boolean flags:
//
// class FlagDependentTest
// : public testing::TestWithParam<tuple(bool, bool)> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
// }
// };
//
// TEST_P(FlagDependentTest, TestFeature1) {
// // Test your code using external_flag_1 and external_flag_2 here.
// }
// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
// Combine(Bool(), Bool()));
//
$range i 2..maxtuple
$for i [[
$range j 1..i
template <$for j, [[typename Generator$j]]>
internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
$for j, [[const Generator$j& g$j]]) {
return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>(
$for j, [[g$j]]);
}
]]
# endif // GTEST_HAS_COMBINE
# define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
: public test_case_name { \
public: \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
virtual void TestBody(); \
private: \
static int AddToRegistry() { \
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
GetTestCasePatternHolder<test_case_name>(\
#test_case_name, __FILE__, __LINE__)->AddTestPattern(\
#test_case_name, \
#test_name, \
new ::testing::internal::TestMetaFactory< \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
return 0; \
} \
static int gtest_registering_dummy_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
}; \
int GTEST_TEST_CLASS_NAME_(test_case_name, \
test_name)::gtest_registering_dummy_ = \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
::testing::internal::ParamGenerator<test_case_name::ParamType> \
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
int gtest_##prefix##test_case_name##_dummy_ = \
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
GetTestCasePatternHolder<test_case_name>(\
#test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\
#prefix, \
&gtest_##prefix##test_case_name##_EvalGenerator_, \
__FILE__, __LINE__)
} // namespace testing
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_

View File

@ -1,796 +0,0 @@
// Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Test - The Google C++ Testing Framework
//
// This file implements a universal value printer that can print a
// value of any type T:
//
// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
//
// A user can teach this function how to print a class type T by
// defining either operator<<() or PrintTo() in the namespace that
// defines T. More specifically, the FIRST defined function in the
// following list will be used (assuming T is defined in namespace
// foo):
//
// 1. foo::PrintTo(const T&, ostream*)
// 2. operator<<(ostream&, const T&) defined in either foo or the
// global namespace.
//
// If none of the above is defined, it will print the debug string of
// the value if it is a protocol buffer, or print the raw bytes in the
// value otherwise.
//
// To aid debugging: when T is a reference type, the address of the
// value is also printed; when T is a (const) char pointer, both the
// pointer value and the NUL-terminated string it points to are
// printed.
//
// We also provide some convenient wrappers:
//
// // Prints a value to a string. For a (const or not) char
// // pointer, the NUL-terminated string (but not the pointer) is
// // printed.
// std::string ::testing::PrintToString(const T& value);
//
// // Prints a value tersely: for a reference type, the referenced
// // value (but not the address) is printed; for a (const or not) char
// // pointer, the NUL-terminated string (but not the pointer) is
// // printed.
// void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
//
// // Prints value using the type inferred by the compiler. The difference
// // from UniversalTersePrint() is that this function prints both the
// // pointer and the NUL-terminated string for a (const or not) char pointer.
// void ::testing::internal::UniversalPrint(const T& value, ostream*);
//
// // Prints the fields of a tuple tersely to a string vector, one
// // element for each field. Tuple support must be enabled in
// // gtest-port.h.
// std::vector<string> UniversalTersePrintTupleFieldsToStrings(
// const Tuple& value);
//
// Known limitation:
//
// The print primitives print the elements of an STL-style container
// using the compiler-inferred type of *iter where iter is a
// const_iterator of the container. When const_iterator is an input
// iterator but not a forward iterator, this inferred type may not
// match value_type, and the print output may be incorrect. In
// practice, this is rarely a problem as for most containers
// const_iterator is a forward iterator. We'll fix this if there's an
// actual need for it. Note that this fix cannot rely on value_type
// being defined as many user-defined container types don't have
// value_type.
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
#include <ostream> // NOLINT
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-internal.h"
namespace testing {
// Definitions in the 'internal' and 'internal2' name spaces are
// subject to change without notice. DO NOT USE THEM IN USER CODE!
namespace internal2 {
// Prints the given number of bytes in the given object to the given
// ostream.
GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
size_t count,
::std::ostream* os);
// For selecting which printer to use when a given type has neither <<
// nor PrintTo().
enum TypeKind {
kProtobuf, // a protobuf type
kConvertibleToInteger, // a type implicitly convertible to BiggestInt
// (e.g. a named or unnamed enum type)
kOtherType // anything else
};
// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
// by the universal printer to print a value of type T when neither
// operator<< nor PrintTo() is defined for T, where kTypeKind is the
// "kind" of T as defined by enum TypeKind.
template <typename T, TypeKind kTypeKind>
class TypeWithoutFormatter {
public:
// This default version is called when kTypeKind is kOtherType.
static void PrintValue(const T& value, ::std::ostream* os) {
PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
sizeof(value), os);
}
};
// We print a protobuf using its ShortDebugString() when the string
// doesn't exceed this many characters; otherwise we print it using
// DebugString() for better readability.
const size_t kProtobufOneLinerMaxLength = 50;
template <typename T>
class TypeWithoutFormatter<T, kProtobuf> {
public:
static void PrintValue(const T& value, ::std::ostream* os) {
const ::testing::internal::string short_str = value.ShortDebugString();
const ::testing::internal::string pretty_str =
short_str.length() <= kProtobufOneLinerMaxLength ?
short_str : ("\n" + value.DebugString());
*os << ("<" + pretty_str + ">");
}
};
template <typename T>
class TypeWithoutFormatter<T, kConvertibleToInteger> {
public:
// Since T has no << operator or PrintTo() but can be implicitly
// converted to BiggestInt, we print it as a BiggestInt.
//
// Most likely T is an enum type (either named or unnamed), in which
// case printing it as an integer is the desired behavior. In case
// T is not an enum, printing it as an integer is the best we can do
// given that it has no user-defined printer.
static void PrintValue(const T& value, ::std::ostream* os) {
const internal::BiggestInt kBigInt = value;
*os << kBigInt;
}
};
// Prints the given value to the given ostream. If the value is a
// protocol message, its debug string is printed; if it's an enum or
// of a type implicitly convertible to BiggestInt, it's printed as an
// integer; otherwise the bytes in the value are printed. This is
// what UniversalPrinter<T>::Print() does when it knows nothing about
// type T and T has neither << operator nor PrintTo().
//
// A user can override this behavior for a class type Foo by defining
// a << operator in the namespace where Foo is defined.
//
// We put this operator in namespace 'internal2' instead of 'internal'
// to simplify the implementation, as much code in 'internal' needs to
// use << in STL, which would conflict with our own << were it defined
// in 'internal'.
//
// Note that this operator<< takes a generic std::basic_ostream<Char,
// CharTraits> type instead of the more restricted std::ostream. If
// we define it to take an std::ostream instead, we'll get an
// "ambiguous overloads" compiler error when trying to print a type
// Foo that supports streaming to std::basic_ostream<Char,
// CharTraits>, as the compiler cannot tell whether
// operator<<(std::ostream&, const T&) or
// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
// specific.
template <typename Char, typename CharTraits, typename T>
::std::basic_ostream<Char, CharTraits>& operator<<(
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
TypeWithoutFormatter<T,
(internal::IsAProtocolMessage<T>::value ? kProtobuf :
internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
return os;
}
} // namespace internal2
} // namespace testing
// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
// magic needed for implementing UniversalPrinter won't work.
namespace testing_internal {
// Used to print a value that is not an STL-style container when the
// user doesn't define PrintTo() for it.
template <typename T>
void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
// With the following statement, during unqualified name lookup,
// testing::internal2::operator<< appears as if it was declared in
// the nearest enclosing namespace that contains both
// ::testing_internal and ::testing::internal2, i.e. the global
// namespace. For more details, refer to the C++ Standard section
// 7.3.4-1 [namespace.udir]. This allows us to fall back onto
// testing::internal2::operator<< in case T doesn't come with a <<
// operator.
//
// We cannot write 'using ::testing::internal2::operator<<;', which
// gcc 3.3 fails to compile due to a compiler bug.
using namespace ::testing::internal2; // NOLINT
// Assuming T is defined in namespace foo, in the next statement,
// the compiler will consider all of:
//
// 1. foo::operator<< (thanks to Koenig look-up),
// 2. ::operator<< (as the current namespace is enclosed in ::),
// 3. testing::internal2::operator<< (thanks to the using statement above).
//
// The operator<< whose type matches T best will be picked.
//
// We deliberately allow #2 to be a candidate, as sometimes it's
// impossible to define #1 (e.g. when foo is ::std, defining
// anything in it is undefined behavior unless you are a compiler
// vendor.).
*os << value;
}
} // namespace testing_internal
namespace testing {
namespace internal {
// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
// value to the given ostream. The caller must ensure that
// 'ostream_ptr' is not NULL, or the behavior is undefined.
//
// We define UniversalPrinter as a class template (as opposed to a
// function template), as we need to partially specialize it for
// reference types, which cannot be done with function templates.
template <typename T>
class UniversalPrinter;
template <typename T>
void UniversalPrint(const T& value, ::std::ostream* os);
// Used to print an STL-style container when the user doesn't define
// a PrintTo() for it.
template <typename C>
void DefaultPrintTo(IsContainer /* dummy */,
false_type /* is not a pointer */,
const C& container, ::std::ostream* os) {
const size_t kMaxCount = 32; // The maximum number of elements to print.
*os << '{';
size_t count = 0;
for (typename C::const_iterator it = container.begin();
it != container.end(); ++it, ++count) {
if (count > 0) {
*os << ',';
if (count == kMaxCount) { // Enough has been printed.
*os << " ...";
break;
}
}
*os << ' ';
// We cannot call PrintTo(*it, os) here as PrintTo() doesn't
// handle *it being a native array.
internal::UniversalPrint(*it, os);
}
if (count > 0) {
*os << ' ';
}
*os << '}';
}
// Used to print a pointer that is neither a char pointer nor a member
// pointer, when the user doesn't define PrintTo() for it. (A member
// variable pointer or member function pointer doesn't really point to
// a location in the address space. Their representation is
// implementation-defined. Therefore they will be printed as raw
// bytes.)
template <typename T>
void DefaultPrintTo(IsNotContainer /* dummy */,
true_type /* is a pointer */,
T* p, ::std::ostream* os) {
if (p == NULL) {
*os << "NULL";
} else {
// C++ doesn't allow casting from a function pointer to any object
// pointer.
//
// IsTrue() silences warnings: "Condition is always true",
// "unreachable code".
if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
// T is not a function type. We just call << to print p,
// relying on ADL to pick up user-defined << for their pointer
// types, if any.
*os << p;
} else {
// T is a function type, so '*os << p' doesn't do what we want
// (it just prints p as bool). We want to print p as a const
// void*. However, we cannot cast it to const void* directly,
// even using reinterpret_cast, as earlier versions of gcc
// (e.g. 3.4.5) cannot compile the cast when p is a function
// pointer. Casting to UInt64 first solves the problem.
*os << reinterpret_cast<const void*>(
reinterpret_cast<internal::UInt64>(p));
}
}
}
// Used to print a non-container, non-pointer value when the user
// doesn't define PrintTo() for it.
template <typename T>
void DefaultPrintTo(IsNotContainer /* dummy */,
false_type /* is not a pointer */,
const T& value, ::std::ostream* os) {
::testing_internal::DefaultPrintNonContainerTo(value, os);
}
// Prints the given value using the << operator if it has one;
// otherwise prints the bytes in it. This is what
// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
// or overloaded for type T.
//
// A user can override this behavior for a class type Foo by defining
// an overload of PrintTo() in the namespace where Foo is defined. We
// give the user this option as sometimes defining a << operator for
// Foo is not desirable (e.g. the coding style may prevent doing it,
// or there is already a << operator but it doesn't do what the user
// wants).
template <typename T>
void PrintTo(const T& value, ::std::ostream* os) {
// DefaultPrintTo() is overloaded. The type of its first two
// arguments determine which version will be picked. If T is an
// STL-style container, the version for container will be called; if
// T is a pointer, the pointer version will be called; otherwise the
// generic version will be called.
//
// Note that we check for container types here, prior to we check
// for protocol message types in our operator<<. The rationale is:
//
// For protocol messages, we want to give people a chance to
// override Google Mock's format by defining a PrintTo() or
// operator<<. For STL containers, other formats can be
// incompatible with Google Mock's format for the container
// elements; therefore we check for container types here to ensure
// that our format is used.
//
// The second argument of DefaultPrintTo() is needed to bypass a bug
// in Symbian's C++ compiler that prevents it from picking the right
// overload between:
//
// PrintTo(const T& x, ...);
// PrintTo(T* x, ...);
DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
}
// The following list of PrintTo() overloads tells
// UniversalPrinter<T>::Print() how to print standard types (built-in
// types, strings, plain arrays, and pointers).
// Overloads for various char types.
GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
inline void PrintTo(char c, ::std::ostream* os) {
// When printing a plain char, we always treat it as unsigned. This
// way, the output won't be affected by whether the compiler thinks
// char is signed or not.
PrintTo(static_cast<unsigned char>(c), os);
}
// Overloads for other simple built-in types.
inline void PrintTo(bool x, ::std::ostream* os) {
*os << (x ? "true" : "false");
}
// Overload for wchar_t type.
// Prints a wchar_t as a symbol if it is printable or as its internal
// code otherwise and also as its decimal code (except for L'\0').
// The L'\0' char is printed as "L'\\0'". The decimal code is printed
// as signed integer when wchar_t is implemented by the compiler
// as a signed type and is printed as an unsigned integer when wchar_t
// is implemented as an unsigned type.
GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
// Overloads for C strings.
GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
inline void PrintTo(char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const char*>(s), os);
}
// signed/unsigned char is often used for representing binary data, so
// we print pointers to it as void* to be safe.
inline void PrintTo(const signed char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
inline void PrintTo(signed char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
inline void PrintTo(unsigned char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
// MSVC can be configured to define wchar_t as a typedef of unsigned
// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
// type. When wchar_t is a typedef, defining an overload for const
// wchar_t* would cause unsigned short* be printed as a wide string,
// possibly causing invalid memory accesses.
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
// Overloads for wide C strings
GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
inline void PrintTo(wchar_t* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const wchar_t*>(s), os);
}
#endif
// Overload for C arrays. Multi-dimensional arrays are printed
// properly.
// Prints the given number of elements in an array, without printing
// the curly braces.
template <typename T>
void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
UniversalPrint(a[0], os);
for (size_t i = 1; i != count; i++) {
*os << ", ";
UniversalPrint(a[i], os);
}
}
// Overloads for ::string and ::std::string.
#if GTEST_HAS_GLOBAL_STRING
GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
inline void PrintTo(const ::string& s, ::std::ostream* os) {
PrintStringTo(s, os);
}
#endif // GTEST_HAS_GLOBAL_STRING
GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
PrintStringTo(s, os);
}
// Overloads for ::wstring and ::std::wstring.
#if GTEST_HAS_GLOBAL_WSTRING
GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
PrintWideStringTo(s, os);
}
#endif // GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_WSTRING
GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
PrintWideStringTo(s, os);
}
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_TR1_TUPLE
// Overload for ::std::tr1::tuple. Needed for printing function arguments,
// which are packed as tuples.
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
template <typename T>
void PrintTupleTo(const T& t, ::std::ostream* os);
// Overloaded PrintTo() for tuples of various arities. We support
// tuples of up-to 10 fields. The following implementation works
// regardless of whether tr1::tuple is implemented using the
// non-standard variadic template feature or not.
inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1>
void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2>
void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
void PrintTo(
const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
#endif // GTEST_HAS_TR1_TUPLE
// Overload for std::pair.
template <typename T1, typename T2>
void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
*os << '(';
// We cannot use UniversalPrint(value.first, os) here, as T1 may be
// a reference type. The same for printing value.second.
UniversalPrinter<T1>::Print(value.first, os);
*os << ", ";
UniversalPrinter<T2>::Print(value.second, os);
*os << ')';
}
// Implements printing a non-reference type T by letting the compiler
// pick the right overload of PrintTo() for T.
template <typename T>
class UniversalPrinter {
public:
// MSVC warns about adding const to a function type, so we want to
// disable the warning.
#ifdef _MSC_VER
# pragma warning(push) // Saves the current warning state.
# pragma warning(disable:4180) // Temporarily disables warning 4180.
#endif // _MSC_VER
// Note: we deliberately don't call this PrintTo(), as that name
// conflicts with ::testing::internal::PrintTo in the body of the
// function.
static void Print(const T& value, ::std::ostream* os) {
// By default, ::testing::internal::PrintTo() is used for printing
// the value.
//
// Thanks to Koenig look-up, if T is a class and has its own
// PrintTo() function defined in its namespace, that function will
// be visible here. Since it is more specific than the generic ones
// in ::testing::internal, it will be picked by the compiler in the
// following statement - exactly what we want.
PrintTo(value, os);
}
#ifdef _MSC_VER
# pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER
};
// UniversalPrintArray(begin, len, os) prints an array of 'len'
// elements, starting at address 'begin'.
template <typename T>
void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
if (len == 0) {
*os << "{}";
} else {
*os << "{ ";
const size_t kThreshold = 18;
const size_t kChunkSize = 8;
// If the array has more than kThreshold elements, we'll have to
// omit some details by printing only the first and the last
// kChunkSize elements.
// TODO(wan@google.com): let the user control the threshold using a flag.
if (len <= kThreshold) {
PrintRawArrayTo(begin, len, os);
} else {
PrintRawArrayTo(begin, kChunkSize, os);
*os << ", ..., ";
PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
}
*os << " }";
}
}
// This overload prints a (const) char array compactly.
GTEST_API_ void UniversalPrintArray(const char* begin,
size_t len,
::std::ostream* os);
// Implements printing an array type T[N].
template <typename T, size_t N>
class UniversalPrinter<T[N]> {
public:
// Prints the given array, omitting some elements when there are too
// many.
static void Print(const T (&a)[N], ::std::ostream* os) {
UniversalPrintArray(a, N, os);
}
};
// Implements printing a reference type T&.
template <typename T>
class UniversalPrinter<T&> {
public:
// MSVC warns about adding const to a function type, so we want to
// disable the warning.
#ifdef _MSC_VER
# pragma warning(push) // Saves the current warning state.
# pragma warning(disable:4180) // Temporarily disables warning 4180.
#endif // _MSC_VER
static void Print(const T& value, ::std::ostream* os) {
// Prints the address of the value. We use reinterpret_cast here
// as static_cast doesn't compile when T is a function type.
*os << "@" << reinterpret_cast<const void*>(&value) << " ";
// Then prints the value itself.
UniversalPrint(value, os);
}
#ifdef _MSC_VER
# pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER
};
// Prints a value tersely: for a reference type, the referenced value
// (but not the address) is printed; for a (const) char pointer, the
// NUL-terminated string (but not the pointer) is printed.
template <typename T>
void UniversalTersePrint(const T& value, ::std::ostream* os) {
UniversalPrint(value, os);
}
inline void UniversalTersePrint(const char* str, ::std::ostream* os) {
if (str == NULL) {
*os << "NULL";
} else {
UniversalPrint(string(str), os);
}
}
inline void UniversalTersePrint(char* str, ::std::ostream* os) {
UniversalTersePrint(static_cast<const char*>(str), os);
}
// Prints a value using the type inferred by the compiler. The
// difference between this and UniversalTersePrint() is that for a
// (const) char pointer, this prints both the pointer and the
// NUL-terminated string.
template <typename T>
void UniversalPrint(const T& value, ::std::ostream* os) {
UniversalPrinter<T>::Print(value, os);
}
#if GTEST_HAS_TR1_TUPLE
typedef ::std::vector<string> Strings;
// This helper template allows PrintTo() for tuples and
// UniversalTersePrintTupleFieldsToStrings() to be defined by
// induction on the number of tuple fields. The idea is that
// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
// fields in tuple t, and can be defined in terms of
// TuplePrefixPrinter<N - 1>.
// The inductive case.
template <size_t N>
struct TuplePrefixPrinter {
// Prints the first N fields of a tuple.
template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
*os << ", ";
UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
::Print(::std::tr1::get<N - 1>(t), os);
}
// Tersely prints the first N fields of a tuple to a string vector,
// one element for each field.
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
::std::stringstream ss;
UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
strings->push_back(ss.str());
}
};
// Base cases.
template <>
struct TuplePrefixPrinter<0> {
template <typename Tuple>
static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
};
// We have to specialize the entire TuplePrefixPrinter<> class
// template here, even though the definition of
// TersePrintPrefixToStrings() is the same as the generic version, as
// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't
// support specializing a method template of a class template.
template <>
struct TuplePrefixPrinter<1> {
template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
Print(::std::tr1::get<0>(t), os);
}
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
::std::stringstream ss;
UniversalTersePrint(::std::tr1::get<0>(t), &ss);
strings->push_back(ss.str());
}
};
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
template <typename T>
void PrintTupleTo(const T& t, ::std::ostream* os) {
*os << "(";
TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
PrintPrefixTo(t, os);
*os << ")";
}
// Prints the fields of a tuple tersely to a string vector, one
// element for each field. See the comment before
// UniversalTersePrint() for how we define "tersely".
template <typename Tuple>
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
Strings result;
TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
TersePrintPrefixToStrings(value, &result);
return result;
}
#endif // GTEST_HAS_TR1_TUPLE
} // namespace internal
template <typename T>
::std::string PrintToString(const T& value) {
::std::stringstream ss;
internal::UniversalTersePrint(value, &ss);
return ss.str();
}
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_

View File

@ -1,176 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
#include <iosfwd>
#include <vector>
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-string.h"
namespace testing {
// A copyable object representing the result of a test part (i.e. an
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
//
// Don't inherit from TestPartResult as its destructor is not virtual.
class GTEST_API_ TestPartResult {
public:
// The possible outcomes of a test part (i.e. an assertion or an
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
enum Type {
kSuccess, // Succeeded.
kNonFatalFailure, // Failed but the test can continue.
kFatalFailure // Failed and the test should be terminated.
};
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestPartResult object.
TestPartResult(Type a_type,
const char* a_file_name,
int a_line_number,
const char* a_message)
: type_(a_type),
file_name_(a_file_name),
line_number_(a_line_number),
summary_(ExtractSummary(a_message)),
message_(a_message) {
}
// Gets the outcome of the test part.
Type type() const { return type_; }
// Gets the name of the source file where the test part took place, or
// NULL if it's unknown.
const char* file_name() const { return file_name_.c_str(); }
// Gets the line in the source file where the test part took place,
// or -1 if it's unknown.
int line_number() const { return line_number_; }
// Gets the summary of the failure message.
const char* summary() const { return summary_.c_str(); }
// Gets the message associated with the test part.
const char* message() const { return message_.c_str(); }
// Returns true iff the test part passed.
bool passed() const { return type_ == kSuccess; }
// Returns true iff the test part failed.
bool failed() const { return type_ != kSuccess; }
// Returns true iff the test part non-fatally failed.
bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
// Returns true iff the test part fatally failed.
bool fatally_failed() const { return type_ == kFatalFailure; }
private:
Type type_;
// Gets the summary of the failure message by omitting the stack
// trace in it.
static internal::String ExtractSummary(const char* message);
// The name of the source file where the test part took place, or
// NULL if the source file is unknown.
internal::String file_name_;
// The line in the source file where the test part took place, or -1
// if the line number is unknown.
int line_number_;
internal::String summary_; // The test failure summary.
internal::String message_; // The test failure message.
};
// Prints a TestPartResult object.
std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
// An array of TestPartResult objects.
//
// Don't inherit from TestPartResultArray as its destructor is not
// virtual.
class GTEST_API_ TestPartResultArray {
public:
TestPartResultArray() {}
// Appends the given TestPartResult to the array.
void Append(const TestPartResult& result);
// Returns the TestPartResult at the given index (0-based).
const TestPartResult& GetTestPartResult(int index) const;
// Returns the number of TestPartResult objects in the array.
int size() const;
private:
std::vector<TestPartResult> array_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
};
// This interface knows how to report a test part result.
class TestPartResultReporterInterface {
public:
virtual ~TestPartResultReporterInterface() {}
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
};
namespace internal {
// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
// statement generates new fatal failures. To do so it registers itself as the
// current test part result reporter. Besides checking if fatal failures were
// reported, it only delegates the reporting to the former result reporter.
// The original result reporter is restored in the destructor.
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
class GTEST_API_ HasNewFatalFailureHelper
: public TestPartResultReporterInterface {
public:
HasNewFatalFailureHelper();
virtual ~HasNewFatalFailureHelper();
virtual void ReportTestPartResult(const TestPartResult& result);
bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
private:
bool has_new_fatal_failure_;
TestPartResultReporterInterface* original_reporter_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
};
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_

View File

@ -1,259 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
// This header implements typed tests and type-parameterized tests.
// Typed (aka type-driven) tests repeat the same test for types in a
// list. You must know which types you want to test with when writing
// typed tests. Here's how you do it:
#if 0
// First, define a fixture class template. It should be parameterized
// by a type. Remember to derive it from testing::Test.
template <typename T>
class FooTest : public testing::Test {
public:
...
typedef std::list<T> List;
static T shared_;
T value_;
};
// Next, associate a list of types with the test case, which will be
// repeated for each type in the list. The typedef is necessary for
// the macro to parse correctly.
typedef testing::Types<char, int, unsigned int> MyTypes;
TYPED_TEST_CASE(FooTest, MyTypes);
// If the type list contains only one type, you can write that type
// directly without Types<...>:
// TYPED_TEST_CASE(FooTest, int);
// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
// tests for this test case as you want.
TYPED_TEST(FooTest, DoesBlah) {
// Inside a test, refer to TypeParam to get the type parameter.
// Since we are inside a derived class template, C++ requires use to
// visit the members of FooTest via 'this'.
TypeParam n = this->value_;
// To visit static members of the fixture, add the TestFixture::
// prefix.
n += TestFixture::shared_;
// To refer to typedefs in the fixture, add the "typename
// TestFixture::" prefix.
typename TestFixture::List values;
values.push_back(n);
...
}
TYPED_TEST(FooTest, HasPropertyA) { ... }
#endif // 0
// Type-parameterized tests are abstract test patterns parameterized
// by a type. Compared with typed tests, type-parameterized tests
// allow you to define the test pattern without knowing what the type
// parameters are. The defined pattern can be instantiated with
// different types any number of times, in any number of translation
// units.
//
// If you are designing an interface or concept, you can define a
// suite of type-parameterized tests to verify properties that any
// valid implementation of the interface/concept should have. Then,
// each implementation can easily instantiate the test suite to verify
// that it conforms to the requirements, without having to write
// similar tests repeatedly. Here's an example:
#if 0
// First, define a fixture class template. It should be parameterized
// by a type. Remember to derive it from testing::Test.
template <typename T>
class FooTest : public testing::Test {
...
};
// Next, declare that you will define a type-parameterized test case
// (the _P suffix is for "parameterized" or "pattern", whichever you
// prefer):
TYPED_TEST_CASE_P(FooTest);
// Then, use TYPED_TEST_P() to define as many type-parameterized tests
// for this type-parameterized test case as you want.
TYPED_TEST_P(FooTest, DoesBlah) {
// Inside a test, refer to TypeParam to get the type parameter.
TypeParam n = 0;
...
}
TYPED_TEST_P(FooTest, HasPropertyA) { ... }
// Now the tricky part: you need to register all test patterns before
// you can instantiate them. The first argument of the macro is the
// test case name; the rest are the names of the tests in this test
// case.
REGISTER_TYPED_TEST_CASE_P(FooTest,
DoesBlah, HasPropertyA);
// Finally, you are free to instantiate the pattern with the types you
// want. If you put the above code in a header file, you can #include
// it in multiple C++ source files and instantiate it multiple times.
//
// To distinguish different instances of the pattern, the first
// argument to the INSTANTIATE_* macro is a prefix that will be added
// to the actual test case name. Remember to pick unique prefixes for
// different instances.
typedef testing::Types<char, int, unsigned int> MyTypes;
INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
// If the type list contains only one type, you can write that type
// directly without Types<...>:
// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
#endif // 0
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-type-util.h"
// Implements typed tests.
#if GTEST_HAS_TYPED_TEST
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Expands to the name of the typedef for the type parameters of the
// given test case.
# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
// The 'Types' template argument below must have spaces around it
// since some compilers may choke on '>>' when passing a template
// instance (e.g. Types<int>)
# define TYPED_TEST_CASE(CaseName, Types) \
typedef ::testing::internal::TypeList< Types >::type \
GTEST_TYPE_PARAMS_(CaseName)
# define TYPED_TEST(CaseName, TestName) \
template <typename gtest_TypeParam_> \
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
: public CaseName<gtest_TypeParam_> { \
private: \
typedef CaseName<gtest_TypeParam_> TestFixture; \
typedef gtest_TypeParam_ TypeParam; \
virtual void TestBody(); \
}; \
bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
::testing::internal::TypeParameterizedTest< \
CaseName, \
::testing::internal::TemplateSel< \
GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
GTEST_TYPE_PARAMS_(CaseName)>::Register(\
"", #CaseName, #TestName, 0); \
template <typename gtest_TypeParam_> \
void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
#endif // GTEST_HAS_TYPED_TEST
// Implements type-parameterized tests.
#if GTEST_HAS_TYPED_TEST_P
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Expands to the namespace name that the type-parameterized tests for
// the given type-parameterized test case are defined in. The exact
// name of the namespace is subject to change without notice.
# define GTEST_CASE_NAMESPACE_(TestCaseName) \
gtest_case_##TestCaseName##_
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Expands to the name of the variable used to remember the names of
// the defined tests in the given test case.
# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
gtest_typed_test_case_p_state_##TestCaseName##_
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
//
// Expands to the name of the variable used to remember the names of
// the registered tests in the given test case.
# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
gtest_registered_test_names_##TestCaseName##_
// The variables defined in the type-parameterized test macros are
// static as typically these macros are used in a .h file that can be
// #included in multiple translation units linked together.
# define TYPED_TEST_CASE_P(CaseName) \
static ::testing::internal::TypedTestCasePState \
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
# define TYPED_TEST_P(CaseName, TestName) \
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
template <typename gtest_TypeParam_> \
class TestName : public CaseName<gtest_TypeParam_> { \
private: \
typedef CaseName<gtest_TypeParam_> TestFixture; \
typedef gtest_TypeParam_ TypeParam; \
virtual void TestBody(); \
}; \
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
__FILE__, __LINE__, #CaseName, #TestName); \
} \
template <typename gtest_TypeParam_> \
void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
} \
static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
__FILE__, __LINE__, #__VA_ARGS__)
// The 'Types' template argument below must have spaces around it
// since some compilers may choke on '>>' when passing a template
// instance (e.g. Types<int>)
# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
::testing::internal::TypeParameterizedTestCase<CaseName, \
GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
::testing::internal::TypeList< Types >::type>::Register(\
#Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,358 +0,0 @@
// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file is AUTOMATICALLY GENERATED on 09/24/2010 by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
//
// Implements a family of generic predicate assertion macros.
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
// Makes sure this header is not included before gtest.h.
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
# error Do not include gtest_pred_impl.h directly. Include gtest.h instead.
#endif // GTEST_INCLUDE_GTEST_GTEST_H_
// This header implements a family of generic predicate assertion
// macros:
//
// ASSERT_PRED_FORMAT1(pred_format, v1)
// ASSERT_PRED_FORMAT2(pred_format, v1, v2)
// ...
//
// where pred_format is a function or functor that takes n (in the
// case of ASSERT_PRED_FORMATn) values and their source expression
// text, and returns a testing::AssertionResult. See the definition
// of ASSERT_EQ in gtest.h for an example.
//
// If you don't care about formatting, you can use the more
// restrictive version:
//
// ASSERT_PRED1(pred, v1)
// ASSERT_PRED2(pred, v1, v2)
// ...
//
// where pred is an n-ary function or functor that returns bool,
// and the values v1, v2, ..., must support the << operator for
// streaming to std::ostream.
//
// We also define the EXPECT_* variations.
//
// For now we only support predicates whose arity is at most 5.
// Please email googletestframework@googlegroups.com if you need
// support for higher arities.
// GTEST_ASSERT_ is the basic statement to which all of the assertions
// in this file reduce. Don't use this in your code.
#define GTEST_ASSERT_(expression, on_failure) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const ::testing::AssertionResult gtest_ar = (expression)) \
; \
else \
on_failure(gtest_ar.failure_message())
// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
// this in your code.
template <typename Pred,
typename T1>
AssertionResult AssertPred1Helper(const char* pred_text,
const char* e1,
Pred pred,
const T1& v1) {
if (pred(v1)) return AssertionSuccess();
return AssertionFailure() << pred_text << "("
<< e1 << ") evaluates to false, where"
<< "\n" << e1 << " evaluates to " << v1;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
// Don't use this in your code.
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
GTEST_ASSERT_(pred_format(#v1, v1),\
on_failure)
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
// this in your code.
#define GTEST_PRED1_(pred, v1, on_failure)\
GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
#v1, \
pred, \
v1), on_failure)
// Unary predicate assertion macros.
#define EXPECT_PRED_FORMAT1(pred_format, v1) \
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
#define EXPECT_PRED1(pred, v1) \
GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
#define ASSERT_PRED_FORMAT1(pred_format, v1) \
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
#define ASSERT_PRED1(pred, v1) \
GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
// this in your code.
template <typename Pred,
typename T1,
typename T2>
AssertionResult AssertPred2Helper(const char* pred_text,
const char* e1,
const char* e2,
Pred pred,
const T1& v1,
const T2& v2) {
if (pred(v1, v2)) return AssertionSuccess();
return AssertionFailure() << pred_text << "("
<< e1 << ", "
<< e2 << ") evaluates to false, where"
<< "\n" << e1 << " evaluates to " << v1
<< "\n" << e2 << " evaluates to " << v2;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
// Don't use this in your code.
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\
on_failure)
// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
// this in your code.
#define GTEST_PRED2_(pred, v1, v2, on_failure)\
GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
#v1, \
#v2, \
pred, \
v1, \
v2), on_failure)
// Binary predicate assertion macros.
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
#define EXPECT_PRED2(pred, v1, v2) \
GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
#define ASSERT_PRED2(pred, v1, v2) \
GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
// this in your code.
template <typename Pred,
typename T1,
typename T2,
typename T3>
AssertionResult AssertPred3Helper(const char* pred_text,
const char* e1,
const char* e2,
const char* e3,
Pred pred,
const T1& v1,
const T2& v2,
const T3& v3) {
if (pred(v1, v2, v3)) return AssertionSuccess();
return AssertionFailure() << pred_text << "("
<< e1 << ", "
<< e2 << ", "
<< e3 << ") evaluates to false, where"
<< "\n" << e1 << " evaluates to " << v1
<< "\n" << e2 << " evaluates to " << v2
<< "\n" << e3 << " evaluates to " << v3;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
// Don't use this in your code.
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3),\
on_failure)
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
// this in your code.
#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
#v1, \
#v2, \
#v3, \
pred, \
v1, \
v2, \
v3), on_failure)
// Ternary predicate assertion macros.
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
#define EXPECT_PRED3(pred, v1, v2, v3) \
GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
#define ASSERT_PRED3(pred, v1, v2, v3) \
GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
// this in your code.
template <typename Pred,
typename T1,
typename T2,
typename T3,
typename T4>
AssertionResult AssertPred4Helper(const char* pred_text,
const char* e1,
const char* e2,
const char* e3,
const char* e4,
Pred pred,
const T1& v1,
const T2& v2,
const T3& v3,
const T4& v4) {
if (pred(v1, v2, v3, v4)) return AssertionSuccess();
return AssertionFailure() << pred_text << "("
<< e1 << ", "
<< e2 << ", "
<< e3 << ", "
<< e4 << ") evaluates to false, where"
<< "\n" << e1 << " evaluates to " << v1
<< "\n" << e2 << " evaluates to " << v2
<< "\n" << e3 << " evaluates to " << v3
<< "\n" << e4 << " evaluates to " << v4;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
// Don't use this in your code.
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
on_failure)
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
// this in your code.
#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
#v1, \
#v2, \
#v3, \
#v4, \
pred, \
v1, \
v2, \
v3, \
v4), on_failure)
// 4-ary predicate assertion macros.
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
// this in your code.
template <typename Pred,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
AssertionResult AssertPred5Helper(const char* pred_text,
const char* e1,
const char* e2,
const char* e3,
const char* e4,
const char* e5,
Pred pred,
const T1& v1,
const T2& v2,
const T3& v3,
const T4& v4,
const T5& v5) {
if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
return AssertionFailure() << pred_text << "("
<< e1 << ", "
<< e2 << ", "
<< e3 << ", "
<< e4 << ", "
<< e5 << ") evaluates to false, where"
<< "\n" << e1 << " evaluates to " << v1
<< "\n" << e2 << " evaluates to " << v2
<< "\n" << e3 << " evaluates to " << v3
<< "\n" << e4 << " evaluates to " << v4
<< "\n" << e5 << " evaluates to " << v5;
}
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
// Don't use this in your code.
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
on_failure)
// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
// this in your code.
#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
#v1, \
#v2, \
#v3, \
#v4, \
#v5, \
pred, \
v1, \
v2, \
v3, \
v4, \
v5), on_failure)
// 5-ary predicate assertion macros.
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_

View File

@ -1,58 +0,0 @@
// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// Google C++ Testing Framework definitions useful in production code.
#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
// When you need to test the private or protected members of a class,
// use the FRIEND_TEST macro to declare your tests as friends of the
// class. For example:
//
// class MyClass {
// private:
// void MyMethod();
// FRIEND_TEST(MyClassTest, MyMethod);
// };
//
// class MyClassTest : public testing::Test {
// // ...
// };
//
// TEST_F(MyClassTest, MyMethod) {
// // Can call MyClass::MyMethod() here.
// }
#define FRIEND_TEST(test_case_name, test_name)\
friend class test_case_name##_##test_name##_Test
#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_

View File

@ -1,308 +0,0 @@
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file defines internal utilities needed for implementing
// death tests. They are subject to change without notice.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#include "gtest/internal/gtest-internal.h"
#include <stdio.h>
namespace testing {
namespace internal {
GTEST_DECLARE_string_(internal_run_death_test);
// Names of the flags (needed for parsing Google Test flags).
const char kDeathTestStyleFlag[] = "death_test_style";
const char kDeathTestUseFork[] = "death_test_use_fork";
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
#if GTEST_HAS_DEATH_TEST
// DeathTest is a class that hides much of the complexity of the
// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
// returns a concrete class that depends on the prevailing death test
// style, as defined by the --gtest_death_test_style and/or
// --gtest_internal_run_death_test flags.
// In describing the results of death tests, these terms are used with
// the corresponding definitions:
//
// exit status: The integer exit information in the format specified
// by wait(2)
// exit code: The integer code passed to exit(3), _exit(2), or
// returned from main()
class GTEST_API_ DeathTest {
public:
// Create returns false if there was an error determining the
// appropriate action to take for the current death test; for example,
// if the gtest_death_test_style flag is set to an invalid value.
// The LastMessage method will return a more detailed message in that
// case. Otherwise, the DeathTest pointer pointed to by the "test"
// argument is set. If the death test should be skipped, the pointer
// is set to NULL; otherwise, it is set to the address of a new concrete
// DeathTest object that controls the execution of the current test.
static bool Create(const char* statement, const RE* regex,
const char* file, int line, DeathTest** test);
DeathTest();
virtual ~DeathTest() { }
// A helper class that aborts a death test when it's deleted.
class ReturnSentinel {
public:
explicit ReturnSentinel(DeathTest* test) : test_(test) { }
~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
private:
DeathTest* const test_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
} GTEST_ATTRIBUTE_UNUSED_;
// An enumeration of possible roles that may be taken when a death
// test is encountered. EXECUTE means that the death test logic should
// be executed immediately. OVERSEE means that the program should prepare
// the appropriate environment for a child process to execute the death
// test, then wait for it to complete.
enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
// An enumeration of the three reasons that a test might be aborted.
enum AbortReason {
TEST_ENCOUNTERED_RETURN_STATEMENT,
TEST_THREW_EXCEPTION,
TEST_DID_NOT_DIE
};
// Assumes one of the above roles.
virtual TestRole AssumeRole() = 0;
// Waits for the death test to finish and returns its status.
virtual int Wait() = 0;
// Returns true if the death test passed; that is, the test process
// exited during the test, its exit status matches a user-supplied
// predicate, and its stderr output matches a user-supplied regular
// expression.
// The user-supplied predicate may be a macro expression rather
// than a function pointer or functor, or else Wait and Passed could
// be combined.
virtual bool Passed(bool exit_status_ok) = 0;
// Signals that the death test did not die as expected.
virtual void Abort(AbortReason reason) = 0;
// Returns a human-readable outcome message regarding the outcome of
// the last death test.
static const char* LastMessage();
static void set_last_death_test_message(const String& message);
private:
// A string containing a description of the outcome of the last death test.
static String last_death_test_message_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
};
// Factory interface for death tests. May be mocked out for testing.
class DeathTestFactory {
public:
virtual ~DeathTestFactory() { }
virtual bool Create(const char* statement, const RE* regex,
const char* file, int line, DeathTest** test) = 0;
};
// A concrete DeathTestFactory implementation for normal use.
class DefaultDeathTestFactory : public DeathTestFactory {
public:
virtual bool Create(const char* statement, const RE* regex,
const char* file, int line, DeathTest** test);
};
// Returns true if exit_status describes a process that was terminated
// by a signal, or exited normally with a nonzero exit code.
GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
// Traps C++ exceptions escaping statement and reports them as test
// failures. Note that trapping SEH exceptions is not implemented here.
# if GTEST_HAS_EXCEPTIONS
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} catch (const ::std::exception& gtest_exception) { \
fprintf(\
stderr, \
"\n%s: Caught std::exception-derived exception escaping the " \
"death test statement. Exception message: %s\n", \
::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
gtest_exception.what()); \
fflush(stderr); \
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
} catch (...) { \
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
}
# else
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
# endif
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
// ASSERT_EXIT*, and EXPECT_EXIT*.
# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AlwaysTrue()) { \
const ::testing::internal::RE& gtest_regex = (regex); \
::testing::internal::DeathTest* gtest_dt; \
if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
__FILE__, __LINE__, &gtest_dt)) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
} \
if (gtest_dt != NULL) { \
::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
gtest_dt_ptr(gtest_dt); \
switch (gtest_dt->AssumeRole()) { \
case ::testing::internal::DeathTest::OVERSEE_TEST: \
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
} \
break; \
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
::testing::internal::DeathTest::ReturnSentinel \
gtest_sentinel(gtest_dt); \
GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
break; \
} \
default: \
break; \
} \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
fail(::testing::internal::DeathTest::LastMessage())
// The symbol "fail" here expands to something into which a message
// can be streamed.
// A class representing the parsed contents of the
// --gtest_internal_run_death_test flag, as it existed when
// RUN_ALL_TESTS was called.
class InternalRunDeathTestFlag {
public:
InternalRunDeathTestFlag(const String& a_file,
int a_line,
int an_index,
int a_write_fd)
: file_(a_file), line_(a_line), index_(an_index),
write_fd_(a_write_fd) {}
~InternalRunDeathTestFlag() {
if (write_fd_ >= 0)
posix::Close(write_fd_);
}
String file() const { return file_; }
int line() const { return line_; }
int index() const { return index_; }
int write_fd() const { return write_fd_; }
private:
String file_;
int line_;
int index_;
int write_fd_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
};
// Returns a newly created InternalRunDeathTestFlag object with fields
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
#else // GTEST_HAS_DEATH_TEST
// This macro is used for implementing macros such as
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
// death tests are not supported. Those macros must compile on such systems
// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
// systems that support death tests. This allows one to write such a macro
// on a system that does not support death tests and be sure that it will
// compile on a death-test supporting system.
//
// Parameters:
// statement - A statement that a macro such as EXPECT_DEATH would test
// for program termination. This macro has to make sure this
// statement is compiled but not executed, to ensure that
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
// parameter iff EXPECT_DEATH compiles with it.
// regex - A regex that a macro such as EXPECT_DEATH would use to test
// the output of statement. This parameter has to be
// compiled but not evaluated by this macro, to ensure that
// this macro only accepts expressions that a macro such as
// EXPECT_DEATH would accept.
// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
// compile inside functions where ASSERT_DEATH doesn't
// compile.
//
// The branch that has an always false condition is used to ensure that
// statement and regex are compiled (and thus syntactically correct) but
// never executed. The unreachable code macro protects the terminator
// statement from generating an 'unreachable code' warning in case
// statement unconditionally returns or throws. The Message constructor at
// the end allows the syntax of streaming additional messages into the
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AlwaysTrue()) { \
GTEST_LOG_(WARNING) \
<< "Death tests are not supported on this platform.\n" \
<< "Statement '" #statement "' cannot be verified."; \
} else if (::testing::internal::AlwaysFalse()) { \
::testing::internal::RE::PartialMatch(".*", (regex)); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
terminator; \
} else \
::testing::Message()
#endif // GTEST_HAS_DEATH_TEST
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_

View File

@ -1,210 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: keith.ray@gmail.com (Keith Ray)
//
// Google Test filepath utilities
//
// This header file declares classes and functions used internally by
// Google Test. They are subject to change without notice.
//
// This file is #included in <gtest/internal/gtest-internal.h>.
// Do not include this header file separately!
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#include "gtest/internal/gtest-string.h"
namespace testing {
namespace internal {
// FilePath - a class for file and directory pathname manipulation which
// handles platform-specific conventions (like the pathname separator).
// Used for helper functions for naming files in a directory for xml output.
// Except for Set methods, all methods are const or static, which provides an
// "immutable value object" -- useful for peace of mind.
// A FilePath with a value ending in a path separator ("like/this/") represents
// a directory, otherwise it is assumed to represent a file. In either case,
// it may or may not represent an actual file or directory in the file system.
// Names are NOT checked for syntax correctness -- no checking for illegal
// characters, malformed paths, etc.
class GTEST_API_ FilePath {
public:
FilePath() : pathname_("") { }
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
explicit FilePath(const char* pathname) : pathname_(pathname) {
Normalize();
}
explicit FilePath(const String& pathname) : pathname_(pathname) {
Normalize();
}
FilePath& operator=(const FilePath& rhs) {
Set(rhs);
return *this;
}
void Set(const FilePath& rhs) {
pathname_ = rhs.pathname_;
}
String ToString() const { return pathname_; }
const char* c_str() const { return pathname_.c_str(); }
// Returns the current working directory, or "" if unsuccessful.
static FilePath GetCurrentDir();
// Given directory = "dir", base_name = "test", number = 0,
// extension = "xml", returns "dir/test.xml". If number is greater
// than zero (e.g., 12), returns "dir/test_12.xml".
// On Windows platform, uses \ as the separator rather than /.
static FilePath MakeFileName(const FilePath& directory,
const FilePath& base_name,
int number,
const char* extension);
// Given directory = "dir", relative_path = "test.xml",
// returns "dir/test.xml".
// On Windows, uses \ as the separator rather than /.
static FilePath ConcatPaths(const FilePath& directory,
const FilePath& relative_path);
// Returns a pathname for a file that does not currently exist. The pathname
// will be directory/base_name.extension or
// directory/base_name_<number>.extension if directory/base_name.extension
// already exists. The number will be incremented until a pathname is found
// that does not already exist.
// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
// There could be a race condition if two or more processes are calling this
// function at the same time -- they could both pick the same filename.
static FilePath GenerateUniqueFileName(const FilePath& directory,
const FilePath& base_name,
const char* extension);
// Returns true iff the path is NULL or "".
bool IsEmpty() const { return c_str() == NULL || *c_str() == '\0'; }
// If input name has a trailing separator character, removes it and returns
// the name, otherwise return the name string unmodified.
// On Windows platform, uses \ as the separator, other platforms use /.
FilePath RemoveTrailingPathSeparator() const;
// Returns a copy of the FilePath with the directory part removed.
// Example: FilePath("path/to/file").RemoveDirectoryName() returns
// FilePath("file"). If there is no directory part ("just_a_file"), it returns
// the FilePath unmodified. If there is no file part ("just_a_dir/") it
// returns an empty FilePath ("").
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath RemoveDirectoryName() const;
// RemoveFileName returns the directory path with the filename removed.
// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath RemoveFileName() const;
// Returns a copy of the FilePath with the case-insensitive extension removed.
// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
// FilePath("dir/file"). If a case-insensitive extension is not
// found, returns a copy of the original FilePath.
FilePath RemoveExtension(const char* extension) const;
// Creates directories so that path exists. Returns true if successful or if
// the directories already exist; returns false if unable to create
// directories for any reason. Will also return false if the FilePath does
// not represent a directory (that is, it doesn't end with a path separator).
bool CreateDirectoriesRecursively() const;
// Create the directory so that path exists. Returns true if successful or
// if the directory already exists; returns false if unable to create the
// directory for any reason, including if the parent directory does not
// exist. Not named "CreateDirectory" because that's a macro on Windows.
bool CreateFolder() const;
// Returns true if FilePath describes something in the file-system,
// either a file, directory, or whatever, and that something exists.
bool FileOrDirectoryExists() const;
// Returns true if pathname describes a directory in the file-system
// that exists.
bool DirectoryExists() const;
// Returns true if FilePath ends with a path separator, which indicates that
// it is intended to represent a directory. Returns false otherwise.
// This does NOT check that a directory (or file) actually exists.
bool IsDirectory() const;
// Returns true if pathname describes a root directory. (Windows has one
// root directory per disk drive.)
bool IsRootDirectory() const;
// Returns true if pathname describes an absolute path.
bool IsAbsolutePath() const;
private:
// Replaces multiple consecutive separators with a single separator.
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..".
//
// A pathname with multiple consecutive separators may occur either through
// user error or as a result of some scripts or APIs that generate a pathname
// with a trailing separator. On other platforms the same API or script
// may NOT generate a pathname with a trailing "/". Then elsewhere that
// pathname may have another "/" and pathname components added to it,
// without checking for the separator already being there.
// The script language and operating system may allow paths like "foo//bar"
// but some of the functions in FilePath will not handle that correctly. In
// particular, RemoveTrailingPathSeparator() only removes one separator, and
// it is called in CreateDirectoriesRecursively() assuming that it will change
// a pathname from directory syntax (trailing separator) to filename syntax.
//
// On Windows this method also replaces the alternate path separator '/' with
// the primary path separator '\\', so that for example "bar\\/\\foo" becomes
// "bar\\foo".
void Normalize();
// Returns a pointer to the last occurence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
const char* FindLastPathSeparator() const;
String pathname_;
}; // class FilePath
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,233 +0,0 @@
// Copyright 2003 Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: Dan Egnor (egnor@google.com)
//
// A "smart" pointer type with reference tracking. Every pointer to a
// particular object is kept on a circular linked list. When the last pointer
// to an object is destroyed or reassigned, the object is deleted.
//
// Used properly, this deletes the object when the last reference goes away.
// There are several caveats:
// - Like all reference counting schemes, cycles lead to leaks.
// - Each smart pointer is actually two pointers (8 bytes instead of 4).
// - Every time a pointer is assigned, the entire list of pointers to that
// object is traversed. This class is therefore NOT SUITABLE when there
// will often be more than two or three pointers to a particular object.
// - References are only tracked as long as linked_ptr<> objects are copied.
// If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
// will happen (double deletion).
//
// A good use of this class is storing object references in STL containers.
// You can safely put linked_ptr<> in a vector<>.
// Other uses may not be as good.
//
// Note: If you use an incomplete type with linked_ptr<>, the class
// *containing* linked_ptr<> must have a constructor and destructor (even
// if they do nothing!).
//
// Bill Gibbons suggested we use something like this.
//
// Thread Safety:
// Unlike other linked_ptr implementations, in this implementation
// a linked_ptr object is thread-safe in the sense that:
// - it's safe to copy linked_ptr objects concurrently,
// - it's safe to copy *from* a linked_ptr and read its underlying
// raw pointer (e.g. via get()) concurrently, and
// - it's safe to write to two linked_ptrs that point to the same
// shared object concurrently.
// TODO(wan@google.com): rename this to safe_linked_ptr to avoid
// confusion with normal linked_ptr.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
#include <stdlib.h>
#include <assert.h>
#include "gtest/internal/gtest-port.h"
namespace testing {
namespace internal {
// Protects copying of all linked_ptr objects.
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
// This is used internally by all instances of linked_ptr<>. It needs to be
// a non-template class because different types of linked_ptr<> can refer to
// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
// So, it needs to be possible for different types of linked_ptr to participate
// in the same circular linked list, so we need a single class type here.
//
// DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
class linked_ptr_internal {
public:
// Create a new circle that includes only this instance.
void join_new() {
next_ = this;
}
// Many linked_ptr operations may change p.link_ for some linked_ptr
// variable p in the same circle as this object. Therefore we need
// to prevent two such operations from occurring concurrently.
//
// Note that different types of linked_ptr objects can coexist in a
// circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
// linked_ptr<Derived2>). Therefore we must use a single mutex to
// protect all linked_ptr objects. This can create serious
// contention in production code, but is acceptable in a testing
// framework.
// Join an existing circle.
// L < g_linked_ptr_mutex
void join(linked_ptr_internal const* ptr) {
MutexLock lock(&g_linked_ptr_mutex);
linked_ptr_internal const* p = ptr;
while (p->next_ != ptr) p = p->next_;
p->next_ = this;
next_ = ptr;
}
// Leave whatever circle we're part of. Returns true if we were the
// last member of the circle. Once this is done, you can join() another.
// L < g_linked_ptr_mutex
bool depart() {
MutexLock lock(&g_linked_ptr_mutex);
if (next_ == this) return true;
linked_ptr_internal const* p = next_;
while (p->next_ != this) p = p->next_;
p->next_ = next_;
return false;
}
private:
mutable linked_ptr_internal const* next_;
};
template <typename T>
class linked_ptr {
public:
typedef T element_type;
// Take over ownership of a raw pointer. This should happen as soon as
// possible after the object is created.
explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
~linked_ptr() { depart(); }
// Copy an existing linked_ptr<>, adding ourselves to the list of references.
template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
linked_ptr(linked_ptr const& ptr) { // NOLINT
assert(&ptr != this);
copy(&ptr);
}
// Assignment releases the old value and acquires the new.
template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
depart();
copy(&ptr);
return *this;
}
linked_ptr& operator=(linked_ptr const& ptr) {
if (&ptr != this) {
depart();
copy(&ptr);
}
return *this;
}
// Smart pointer members.
void reset(T* ptr = NULL) {
depart();
capture(ptr);
}
T* get() const { return value_; }
T* operator->() const { return value_; }
T& operator*() const { return *value_; }
bool operator==(T* p) const { return value_ == p; }
bool operator!=(T* p) const { return value_ != p; }
template <typename U>
bool operator==(linked_ptr<U> const& ptr) const {
return value_ == ptr.get();
}
template <typename U>
bool operator!=(linked_ptr<U> const& ptr) const {
return value_ != ptr.get();
}
private:
template <typename U>
friend class linked_ptr;
T* value_;
linked_ptr_internal link_;
void depart() {
if (link_.depart()) delete value_;
}
void capture(T* ptr) {
value_ = ptr;
link_.join_new();
}
template <typename U> void copy(linked_ptr<U> const* ptr) {
value_ = ptr->get();
if (value_)
link_.join(&ptr->link_);
else
link_.join_new();
}
};
template<typename T> inline
bool operator==(T* ptr, const linked_ptr<T>& x) {
return ptr == x.get();
}
template<typename T> inline
bool operator!=(T* ptr, const linked_ptr<T>& x) {
return ptr != x.get();
}
// A function to convert T* into linked_ptr<T>
// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
template <typename T>
linked_ptr<T> make_linked_ptr(T* ptr) {
return linked_ptr<T>(ptr);
}
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,301 +0,0 @@
$$ -*- mode: c++; -*-
$var n = 50 $$ Maximum length of Values arguments we want to support.
$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// Type and function utilities for implementing parameterized tests.
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
//
// Currently Google Test supports at most $n arguments in Values,
// and at most $maxtuple arguments in Combine. Please contact
// googletestframework@googlegroups.com if you need more.
// Please note that the number of arguments to Combine is limited
// by the maximum arity of the implementation of tr1::tuple which is
// currently set at $maxtuple.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
// scripts/fuse_gtest.py depends on gtest's own header being #included
// *unconditionally*. Therefore these #includes cannot be moved
// inside #if GTEST_HAS_PARAM_TEST.
#include "gtest/internal/gtest-param-util.h"
#include "gtest/internal/gtest-port.h"
#if GTEST_HAS_PARAM_TEST
namespace testing {
// Forward declarations of ValuesIn(), which is implemented in
// include/gtest/gtest-param-test.h.
template <typename ForwardIterator>
internal::ParamGenerator<
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
ValuesIn(ForwardIterator begin, ForwardIterator end);
template <typename T, size_t N>
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
template <class Container>
internal::ParamGenerator<typename Container::value_type> ValuesIn(
const Container& container);
namespace internal {
// Used in the Values() function to provide polymorphic capabilities.
template <typename T1>
class ValueArray1 {
public:
explicit ValueArray1(T1 v1) : v1_(v1) {}
template <typename T>
operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray1& other);
const T1 v1_;
};
$range i 2..n
$for i [[
$range j 1..i
template <$for j, [[typename T$j]]>
class ValueArray$i {
public:
ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}
template <typename T>
operator ParamGenerator<T>() const {
const T array[] = {$for j, [[v$(j)_]]};
return ValuesIn(array);
}
private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray$i& other);
$for j [[
const T$j v$(j)_;
]]
};
]]
# if GTEST_HAS_COMBINE
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Generates values from the Cartesian product of values produced
// by the argument generators.
//
$range i 2..maxtuple
$for i [[
$range j 1..i
$range k 2..i
template <$for j, [[typename T$j]]>
class CartesianProductGenerator$i
: public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > {
public:
typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType;
CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
: $for j, [[g$(j)_(g$j)]] {}
virtual ~CartesianProductGenerator$i() {}
virtual ParamIteratorInterface<ParamType>* Begin() const {
return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
}
virtual ParamIteratorInterface<ParamType>* End() const {
return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
}
private:
class Iterator : public ParamIteratorInterface<ParamType> {
public:
Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[
const ParamGenerator<T$j>& g$j,
const typename ParamGenerator<T$j>::iterator& current$(j)]])
: base_(base),
$for j, [[
begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)
]] {
ComputeCurrentValue();
}
virtual ~Iterator() {}
virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
return base_;
}
// Advance should not be called on beyond-of-range iterators
// so no component iterators must be beyond end of range, either.
virtual void Advance() {
assert(!AtEnd());
++current$(i)_;
$for k [[
if (current$(i+2-k)_ == end$(i+2-k)_) {
current$(i+2-k)_ = begin$(i+2-k)_;
++current$(i+2-k-1)_;
}
]]
ComputeCurrentValue();
}
virtual ParamIteratorInterface<ParamType>* Clone() const {
return new Iterator(*this);
}
virtual const ParamType* Current() const { return &current_value_; }
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
// Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
<< "The program attempted to compare iterators "
<< "from different generators." << std::endl;
const Iterator* typed_other =
CheckedDowncastToActualType<const Iterator>(&other);
// We must report iterators equal if they both point beyond their
// respective ranges. That can happen in a variety of fashions,
// so we have to consult AtEnd().
return (AtEnd() && typed_other->AtEnd()) ||
($for j && [[
current$(j)_ == typed_other->current$(j)_
]]);
}
private:
Iterator(const Iterator& other)
: base_(other.base_), $for j, [[
begin$(j)_(other.begin$(j)_),
end$(j)_(other.end$(j)_),
current$(j)_(other.current$(j)_)
]] {
ComputeCurrentValue();
}
void ComputeCurrentValue() {
if (!AtEnd())
current_value_ = ParamType($for j, [[*current$(j)_]]);
}
bool AtEnd() const {
// We must report iterator past the end of the range when either of the
// component iterators has reached the end of its range.
return
$for j || [[
current$(j)_ == end$(j)_
]];
}
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator.
$for j [[
const typename ParamGenerator<T$j>::iterator begin$(j)_;
const typename ParamGenerator<T$j>::iterator end$(j)_;
typename ParamGenerator<T$j>::iterator current$(j)_;
]]
ParamType current_value_;
}; // class CartesianProductGenerator$i::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator$i& other);
$for j [[
const ParamGenerator<T$j> g$(j)_;
]]
}; // class CartesianProductGenerator$i
]]
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Helper classes providing Combine() with polymorphic features. They allow
// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
// convertible to U.
//
$range i 2..maxtuple
$for i [[
$range j 1..i
template <$for j, [[class Generator$j]]>
class CartesianProductHolder$i {
public:
CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
: $for j, [[g$(j)_(g$j)]] {}
template <$for j, [[typename T$j]]>
operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const {
return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >(
new CartesianProductGenerator$i<$for j, [[T$j]]>(
$for j,[[
static_cast<ParamGenerator<T$j> >(g$(j)_)
]]));
}
private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder$i& other);
$for j [[
const Generator$j g$(j)_;
]]
}; // class CartesianProductHolder$i
]]
# endif // GTEST_HAS_COMBINE
} // namespace internal
} // namespace testing
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_

View File

@ -1,619 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
// Type and function utilities for implementing parameterized tests.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
#include <iterator>
#include <utility>
#include <vector>
// scripts/fuse_gtest.py depends on gtest's own header being #included
// *unconditionally*. Therefore these #includes cannot be moved
// inside #if GTEST_HAS_PARAM_TEST.
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/gtest-printers.h"
#if GTEST_HAS_PARAM_TEST
namespace testing {
namespace internal {
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Outputs a message explaining invalid registration of different
// fixture class for the same test case. This may happen when
// TEST_P macro is used to define two tests with the same name
// but in different namespaces.
GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
const char* file, int line);
template <typename> class ParamGeneratorInterface;
template <typename> class ParamGenerator;
// Interface for iterating over elements provided by an implementation
// of ParamGeneratorInterface<T>.
template <typename T>
class ParamIteratorInterface {
public:
virtual ~ParamIteratorInterface() {}
// A pointer to the base generator instance.
// Used only for the purposes of iterator comparison
// to make sure that two iterators belong to the same generator.
virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
// Advances iterator to point to the next element
// provided by the generator. The caller is responsible
// for not calling Advance() on an iterator equal to
// BaseGenerator()->End().
virtual void Advance() = 0;
// Clones the iterator object. Used for implementing copy semantics
// of ParamIterator<T>.
virtual ParamIteratorInterface* Clone() const = 0;
// Dereferences the current iterator and provides (read-only) access
// to the pointed value. It is the caller's responsibility not to call
// Current() on an iterator equal to BaseGenerator()->End().
// Used for implementing ParamGenerator<T>::operator*().
virtual const T* Current() const = 0;
// Determines whether the given iterator and other point to the same
// element in the sequence generated by the generator.
// Used for implementing ParamGenerator<T>::operator==().
virtual bool Equals(const ParamIteratorInterface& other) const = 0;
};
// Class iterating over elements provided by an implementation of
// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
// and implements the const forward iterator concept.
template <typename T>
class ParamIterator {
public:
typedef T value_type;
typedef const T& reference;
typedef ptrdiff_t difference_type;
// ParamIterator assumes ownership of the impl_ pointer.
ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
ParamIterator& operator=(const ParamIterator& other) {
if (this != &other)
impl_.reset(other.impl_->Clone());
return *this;
}
const T& operator*() const { return *impl_->Current(); }
const T* operator->() const { return impl_->Current(); }
// Prefix version of operator++.
ParamIterator& operator++() {
impl_->Advance();
return *this;
}
// Postfix version of operator++.
ParamIterator operator++(int /*unused*/) {
ParamIteratorInterface<T>* clone = impl_->Clone();
impl_->Advance();
return ParamIterator(clone);
}
bool operator==(const ParamIterator& other) const {
return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
}
bool operator!=(const ParamIterator& other) const {
return !(*this == other);
}
private:
friend class ParamGenerator<T>;
explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
scoped_ptr<ParamIteratorInterface<T> > impl_;
};
// ParamGeneratorInterface<T> is the binary interface to access generators
// defined in other translation units.
template <typename T>
class ParamGeneratorInterface {
public:
typedef T ParamType;
virtual ~ParamGeneratorInterface() {}
// Generator interface definition
virtual ParamIteratorInterface<T>* Begin() const = 0;
virtual ParamIteratorInterface<T>* End() const = 0;
};
// Wraps ParamGeneratorInterface<T> and provides general generator syntax
// compatible with the STL Container concept.
// This class implements copy initialization semantics and the contained
// ParamGeneratorInterface<T> instance is shared among all copies
// of the original object. This is possible because that instance is immutable.
template<typename T>
class ParamGenerator {
public:
typedef ParamIterator<T> iterator;
explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
ParamGenerator& operator=(const ParamGenerator& other) {
impl_ = other.impl_;
return *this;
}
iterator begin() const { return iterator(impl_->Begin()); }
iterator end() const { return iterator(impl_->End()); }
private:
linked_ptr<const ParamGeneratorInterface<T> > impl_;
};
// Generates values from a range of two comparable values. Can be used to
// generate sequences of user-defined types that implement operator+() and
// operator<().
// This class is used in the Range() function.
template <typename T, typename IncrementT>
class RangeGenerator : public ParamGeneratorInterface<T> {
public:
RangeGenerator(T begin, T end, IncrementT step)
: begin_(begin), end_(end),
step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
virtual ~RangeGenerator() {}
virtual ParamIteratorInterface<T>* Begin() const {
return new Iterator(this, begin_, 0, step_);
}
virtual ParamIteratorInterface<T>* End() const {
return new Iterator(this, end_, end_index_, step_);
}
private:
class Iterator : public ParamIteratorInterface<T> {
public:
Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
IncrementT step)
: base_(base), value_(value), index_(index), step_(step) {}
virtual ~Iterator() {}
virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
return base_;
}
virtual void Advance() {
value_ = value_ + step_;
index_++;
}
virtual ParamIteratorInterface<T>* Clone() const {
return new Iterator(*this);
}
virtual const T* Current() const { return &value_; }
virtual bool Equals(const ParamIteratorInterface<T>& other) const {
// Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
<< "The program attempted to compare iterators "
<< "from different generators." << std::endl;
const int other_index =
CheckedDowncastToActualType<const Iterator>(&other)->index_;
return index_ == other_index;
}
private:
Iterator(const Iterator& other)
: ParamIteratorInterface<T>(),
base_(other.base_), value_(other.value_), index_(other.index_),
step_(other.step_) {}
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<T>* const base_;
T value_;
int index_;
const IncrementT step_;
}; // class RangeGenerator::Iterator
static int CalculateEndIndex(const T& begin,
const T& end,
const IncrementT& step) {
int end_index = 0;
for (T i = begin; i < end; i = i + step)
end_index++;
return end_index;
}
// No implementation - assignment is unsupported.
void operator=(const RangeGenerator& other);
const T begin_;
const T end_;
const IncrementT step_;
// The index for the end() iterator. All the elements in the generated
// sequence are indexed (0-based) to aid iterator comparison.
const int end_index_;
}; // class RangeGenerator
// Generates values from a pair of STL-style iterators. Used in the
// ValuesIn() function. The elements are copied from the source range
// since the source can be located on the stack, and the generator
// is likely to persist beyond that stack frame.
template <typename T>
class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
public:
template <typename ForwardIterator>
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
: container_(begin, end) {}
virtual ~ValuesInIteratorRangeGenerator() {}
virtual ParamIteratorInterface<T>* Begin() const {
return new Iterator(this, container_.begin());
}
virtual ParamIteratorInterface<T>* End() const {
return new Iterator(this, container_.end());
}
private:
typedef typename ::std::vector<T> ContainerType;
class Iterator : public ParamIteratorInterface<T> {
public:
Iterator(const ParamGeneratorInterface<T>* base,
typename ContainerType::const_iterator iterator)
: base_(base), iterator_(iterator) {}
virtual ~Iterator() {}
virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
return base_;
}
virtual void Advance() {
++iterator_;
value_.reset();
}
virtual ParamIteratorInterface<T>* Clone() const {
return new Iterator(*this);
}
// We need to use cached value referenced by iterator_ because *iterator_
// can return a temporary object (and of type other then T), so just
// having "return &*iterator_;" doesn't work.
// value_ is updated here and not in Advance() because Advance()
// can advance iterator_ beyond the end of the range, and we cannot
// detect that fact. The client code, on the other hand, is
// responsible for not calling Current() on an out-of-range iterator.
virtual const T* Current() const {
if (value_.get() == NULL)
value_.reset(new T(*iterator_));
return value_.get();
}
virtual bool Equals(const ParamIteratorInterface<T>& other) const {
// Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
<< "The program attempted to compare iterators "
<< "from different generators." << std::endl;
return iterator_ ==
CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
}
private:
Iterator(const Iterator& other)
// The explicit constructor call suppresses a false warning
// emitted by gcc when supplied with the -Wextra option.
: ParamIteratorInterface<T>(),
base_(other.base_),
iterator_(other.iterator_) {}
const ParamGeneratorInterface<T>* const base_;
typename ContainerType::const_iterator iterator_;
// A cached value of *iterator_. We keep it here to allow access by
// pointer in the wrapping iterator's operator->().
// value_ needs to be mutable to be accessed in Current().
// Use of scoped_ptr helps manage cached value's lifetime,
// which is bound by the lifespan of the iterator itself.
mutable scoped_ptr<const T> value_;
}; // class ValuesInIteratorRangeGenerator::Iterator
// No implementation - assignment is unsupported.
void operator=(const ValuesInIteratorRangeGenerator& other);
const ContainerType container_;
}; // class ValuesInIteratorRangeGenerator
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Stores a parameter value and later creates tests parameterized with that
// value.
template <class TestClass>
class ParameterizedTestFactory : public TestFactoryBase {
public:
typedef typename TestClass::ParamType ParamType;
explicit ParameterizedTestFactory(ParamType parameter) :
parameter_(parameter) {}
virtual Test* CreateTest() {
TestClass::SetParam(&parameter_);
return new TestClass();
}
private:
const ParamType parameter_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
};
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// TestMetaFactoryBase is a base class for meta-factories that create
// test factories for passing into MakeAndRegisterTestInfo function.
template <class ParamType>
class TestMetaFactoryBase {
public:
virtual ~TestMetaFactoryBase() {}
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
};
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// TestMetaFactory creates test factories for passing into
// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
// ownership of test factory pointer, same factory object cannot be passed
// into that method twice. But ParameterizedTestCaseInfo is going to call
// it for each Test/Parameter value combination. Thus it needs meta factory
// creator class.
template <class TestCase>
class TestMetaFactory
: public TestMetaFactoryBase<typename TestCase::ParamType> {
public:
typedef typename TestCase::ParamType ParamType;
TestMetaFactory() {}
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {
return new ParameterizedTestFactory<TestCase>(parameter);
}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
};
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// ParameterizedTestCaseInfoBase is a generic interface
// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase
// accumulates test information provided by TEST_P macro invocations
// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations
// and uses that information to register all resulting test instances
// in RegisterTests method. The ParameterizeTestCaseRegistry class holds
// a collection of pointers to the ParameterizedTestCaseInfo objects
// and calls RegisterTests() on each of them when asked.
class ParameterizedTestCaseInfoBase {
public:
virtual ~ParameterizedTestCaseInfoBase() {}
// Base part of test case name for display purposes.
virtual const string& GetTestCaseName() const = 0;
// Test case id to verify identity.
virtual TypeId GetTestCaseTypeId() const = 0;
// UnitTest class invokes this method to register tests in this
// test case right before running them in RUN_ALL_TESTS macro.
// This method should not be called more then once on any single
// instance of a ParameterizedTestCaseInfoBase derived class.
virtual void RegisterTests() = 0;
protected:
ParameterizedTestCaseInfoBase() {}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);
};
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P
// macro invocations for a particular test case and generators
// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that
// test case. It registers tests with all values generated by all
// generators when asked.
template <class TestCase>
class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
public:
// ParamType and GeneratorCreationFunc are private types but are required
// for declarations of public methods AddTestPattern() and
// AddTestCaseInstantiation().
typedef typename TestCase::ParamType ParamType;
// A function that returns an instance of appropriate generator type.
typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
explicit ParameterizedTestCaseInfo(const char* name)
: test_case_name_(name) {}
// Test case base name for display purposes.
virtual const string& GetTestCaseName() const { return test_case_name_; }
// Test case id to verify identity.
virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
// TEST_P macro uses AddTestPattern() to record information
// about a single test in a LocalTestInfo structure.
// test_case_name is the base name of the test case (without invocation
// prefix). test_base_name is the name of an individual test without
// parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
// test case base name and DoBar is test base name.
void AddTestPattern(const char* test_case_name,
const char* test_base_name,
TestMetaFactoryBase<ParamType>* meta_factory) {
tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
test_base_name,
meta_factory)));
}
// INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
// about a generator.
int AddTestCaseInstantiation(const string& instantiation_name,
GeneratorCreationFunc* func,
const char* /* file */,
int /* line */) {
instantiations_.push_back(::std::make_pair(instantiation_name, func));
return 0; // Return value used only to run this method in namespace scope.
}
// UnitTest class invokes this method to register tests in this test case
// test cases right before running tests in RUN_ALL_TESTS macro.
// This method should not be called more then once on any single
// instance of a ParameterizedTestCaseInfoBase derived class.
// UnitTest has a guard to prevent from calling this method more then once.
virtual void RegisterTests() {
for (typename TestInfoContainer::iterator test_it = tests_.begin();
test_it != tests_.end(); ++test_it) {
linked_ptr<TestInfo> test_info = *test_it;
for (typename InstantiationContainer::iterator gen_it =
instantiations_.begin(); gen_it != instantiations_.end();
++gen_it) {
const string& instantiation_name = gen_it->first;
ParamGenerator<ParamType> generator((*gen_it->second)());
Message test_case_name_stream;
if ( !instantiation_name.empty() )
test_case_name_stream << instantiation_name << "/";
test_case_name_stream << test_info->test_case_base_name;
int i = 0;
for (typename ParamGenerator<ParamType>::iterator param_it =
generator.begin();
param_it != generator.end(); ++param_it, ++i) {
Message test_name_stream;
test_name_stream << test_info->test_base_name << "/" << i;
MakeAndRegisterTestInfo(
test_case_name_stream.GetString().c_str(),
test_name_stream.GetString().c_str(),
NULL, // No type parameter.
PrintToString(*param_it).c_str(),
GetTestCaseTypeId(),
TestCase::SetUpTestCase,
TestCase::TearDownTestCase,
test_info->test_meta_factory->CreateTestFactory(*param_it));
} // for param_it
} // for gen_it
} // for test_it
} // RegisterTests
private:
// LocalTestInfo structure keeps information about a single test registered
// with TEST_P macro.
struct TestInfo {
TestInfo(const char* a_test_case_base_name,
const char* a_test_base_name,
TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
test_case_base_name(a_test_case_base_name),
test_base_name(a_test_base_name),
test_meta_factory(a_test_meta_factory) {}
const string test_case_base_name;
const string test_base_name;
const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
};
typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
// Keeps pairs of <Instantiation name, Sequence generator creation function>
// received from INSTANTIATE_TEST_CASE_P macros.
typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> >
InstantiationContainer;
const string test_case_name_;
TestInfoContainer tests_;
InstantiationContainer instantiations_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);
}; // class ParameterizedTestCaseInfo
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase
// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P
// macros use it to locate their corresponding ParameterizedTestCaseInfo
// descriptors.
class ParameterizedTestCaseRegistry {
public:
ParameterizedTestCaseRegistry() {}
~ParameterizedTestCaseRegistry() {
for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
it != test_case_infos_.end(); ++it) {
delete *it;
}
}
// Looks up or creates and returns a structure containing information about
// tests and instantiations of a particular test case.
template <class TestCase>
ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
const char* test_case_name,
const char* file,
int line) {
ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;
for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
it != test_case_infos_.end(); ++it) {
if ((*it)->GetTestCaseName() == test_case_name) {
if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {
// Complain about incorrect usage of Google Test facilities
// and terminate the program since we cannot guaranty correct
// test case setup and tear-down in this case.
ReportInvalidTestCaseType(test_case_name, file, line);
posix::Abort();
} else {
// At this point we are sure that the object we found is of the same
// type we are looking for, so we downcast it to that type
// without further checks.
typed_test_info = CheckedDowncastToActualType<
ParameterizedTestCaseInfo<TestCase> >(*it);
}
break;
}
}
if (typed_test_info == NULL) {
typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name);
test_case_infos_.push_back(typed_test_info);
}
return typed_test_info;
}
void RegisterTests() {
for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
it != test_case_infos_.end(); ++it) {
(*it)->RegisterTests();
}
}
private:
typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;
TestCaseInfoContainer test_case_infos_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);
};
} // namespace internal
} // namespace testing
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,350 +0,0 @@
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file declares the String class and functions used internally by
// Google Test. They are subject to change without notice. They should not used
// by code external to Google Test.
//
// This header file is #included by <gtest/internal/gtest-internal.h>.
// It should not be #included by other files.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#ifdef __BORLANDC__
// string.h is not guaranteed to provide strcpy on C++ Builder.
# include <mem.h>
#endif
#include <string.h>
#include "gtest/internal/gtest-port.h"
#include <string>
namespace testing {
namespace internal {
// String - a UTF-8 string class.
//
// For historic reasons, we don't use std::string.
//
// TODO(wan@google.com): replace this class with std::string or
// implement it in terms of the latter.
//
// Note that String can represent both NULL and the empty string,
// while std::string cannot represent NULL.
//
// NULL and the empty string are considered different. NULL is less
// than anything (including the empty string) except itself.
//
// This class only provides minimum functionality necessary for
// implementing Google Test. We do not intend to implement a full-fledged
// string class here.
//
// Since the purpose of this class is to provide a substitute for
// std::string on platforms where it cannot be used, we define a copy
// constructor and assignment operators such that we don't need
// conditional compilation in a lot of places.
//
// In order to make the representation efficient, the d'tor of String
// is not virtual. Therefore DO NOT INHERIT FROM String.
class GTEST_API_ String {
public:
// Static utility methods
// Returns the input enclosed in double quotes if it's not NULL;
// otherwise returns "(null)". For example, "\"Hello\"" is returned
// for input "Hello".
//
// This is useful for printing a C string in the syntax of a literal.
//
// Known issue: escape sequences are not handled yet.
static String ShowCStringQuoted(const char* c_str);
// Clones a 0-terminated C string, allocating memory using new. The
// caller is responsible for deleting the return value using
// delete[]. Returns the cloned string, or NULL if the input is
// NULL.
//
// This is different from strdup() in string.h, which allocates
// memory using malloc().
static const char* CloneCString(const char* c_str);
#if GTEST_OS_WINDOWS_MOBILE
// Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
// able to pass strings to Win32 APIs on CE we need to convert them
// to 'Unicode', UTF-16.
// Creates a UTF-16 wide string from the given ANSI string, allocating
// memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the wide string, or NULL if the
// input is NULL.
//
// The wide string is created using the ANSI codepage (CP_ACP) to
// match the behaviour of the ANSI versions of Win32 calls and the
// C runtime.
static LPCWSTR AnsiToUtf16(const char* c_str);
// Creates an ANSI string from the given wide string, allocating
// memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the ANSI string, or NULL if the
// input is NULL.
//
// The returned string is created using the ANSI codepage (CP_ACP) to
// match the behaviour of the ANSI versions of Win32 calls and the
// C runtime.
static const char* Utf16ToAnsi(LPCWSTR utf16_str);
#endif
// Compares two C strings. Returns true iff they have the same content.
//
// Unlike strcmp(), this function can handle NULL argument(s). A
// NULL C string is considered different to any non-NULL C string,
// including the empty string.
static bool CStringEquals(const char* lhs, const char* rhs);
// Converts a wide C string to a String using the UTF-8 encoding.
// NULL will be converted to "(null)". If an error occurred during
// the conversion, "(failed to convert from wide string)" is
// returned.
static String ShowWideCString(const wchar_t* wide_c_str);
// Similar to ShowWideCString(), except that this function encloses
// the converted string in double quotes.
static String ShowWideCStringQuoted(const wchar_t* wide_c_str);
// Compares two wide C strings. Returns true iff they have the same
// content.
//
// Unlike wcscmp(), this function can handle NULL argument(s). A
// NULL C string is considered different to any non-NULL C string,
// including the empty string.
static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
// Compares two C strings, ignoring case. Returns true iff they
// have the same content.
//
// Unlike strcasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL C string,
// including the empty string.
static bool CaseInsensitiveCStringEquals(const char* lhs,
const char* rhs);
// Compares two wide C strings, ignoring case. Returns true iff they
// have the same content.
//
// Unlike wcscasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL wide C string,
// including the empty string.
// NB: The implementations on different platforms slightly differ.
// On windows, this method uses _wcsicmp which compares according to LC_CTYPE
// environment variable. On GNU platform this method uses wcscasecmp
// which compares according to LC_CTYPE category of the current locale.
// On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
// current locale.
static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
const wchar_t* rhs);
// Formats a list of arguments to a String, using the same format
// spec string as for printf.
//
// We do not use the StringPrintf class as it is not universally
// available.
//
// The result is limited to 4096 characters (including the tailing
// 0). If 4096 characters are not enough to format the input,
// "<buffer exceeded>" is returned.
static String Format(const char* format, ...);
// C'tors
// The default c'tor constructs a NULL string.
String() : c_str_(NULL), length_(0) {}
// Constructs a String by cloning a 0-terminated C string.
String(const char* a_c_str) { // NOLINT
if (a_c_str == NULL) {
c_str_ = NULL;
length_ = 0;
} else {
ConstructNonNull(a_c_str, strlen(a_c_str));
}
}
// Constructs a String by copying a given number of chars from a
// buffer. E.g. String("hello", 3) creates the string "hel",
// String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
// and String(NULL, 1) results in access violation.
String(const char* buffer, size_t a_length) {
ConstructNonNull(buffer, a_length);
}
// The copy c'tor creates a new copy of the string. The two
// String objects do not share content.
String(const String& str) : c_str_(NULL), length_(0) { *this = str; }
// D'tor. String is intended to be a final class, so the d'tor
// doesn't need to be virtual.
~String() { delete[] c_str_; }
// Allows a String to be implicitly converted to an ::std::string or
// ::string, and vice versa. Converting a String containing a NULL
// pointer to ::std::string or ::string is undefined behavior.
// Converting a ::std::string or ::string containing an embedded NUL
// character to a String will result in the prefix up to the first
// NUL character.
String(const ::std::string& str) {
ConstructNonNull(str.c_str(), str.length());
}
operator ::std::string() const { return ::std::string(c_str(), length()); }
#if GTEST_HAS_GLOBAL_STRING
String(const ::string& str) {
ConstructNonNull(str.c_str(), str.length());
}
operator ::string() const { return ::string(c_str(), length()); }
#endif // GTEST_HAS_GLOBAL_STRING
// Returns true iff this is an empty string (i.e. "").
bool empty() const { return (c_str() != NULL) && (length() == 0); }
// Compares this with another String.
// Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
// if this is greater than rhs.
int Compare(const String& rhs) const;
// Returns true iff this String equals the given C string. A NULL
// string and a non-NULL string are considered not equal.
bool operator==(const char* a_c_str) const { return Compare(a_c_str) == 0; }
// Returns true iff this String is less than the given String. A
// NULL string is considered less than "".
bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
// Returns true iff this String doesn't equal the given C string. A NULL
// string and a non-NULL string are considered not equal.
bool operator!=(const char* a_c_str) const { return !(*this == a_c_str); }
// Returns true iff this String ends with the given suffix. *Any*
// String is considered to end with a NULL or empty suffix.
bool EndsWith(const char* suffix) const;
// Returns true iff this String ends with the given suffix, not considering
// case. Any String is considered to end with a NULL or empty suffix.
bool EndsWithCaseInsensitive(const char* suffix) const;
// Returns the length of the encapsulated string, or 0 if the
// string is NULL.
size_t length() const { return length_; }
// Gets the 0-terminated C string this String object represents.
// The String object still owns the string. Therefore the caller
// should NOT delete the return value.
const char* c_str() const { return c_str_; }
// Assigns a C string to this object. Self-assignment works.
const String& operator=(const char* a_c_str) {
return *this = String(a_c_str);
}
// Assigns a String object to this object. Self-assignment works.
const String& operator=(const String& rhs) {
if (this != &rhs) {
delete[] c_str_;
if (rhs.c_str() == NULL) {
c_str_ = NULL;
length_ = 0;
} else {
ConstructNonNull(rhs.c_str(), rhs.length());
}
}
return *this;
}
private:
// Constructs a non-NULL String from the given content. This
// function can only be called when c_str_ has not been allocated.
// ConstructNonNull(NULL, 0) results in an empty string ("").
// ConstructNonNull(NULL, non_zero) is undefined behavior.
void ConstructNonNull(const char* buffer, size_t a_length) {
char* const str = new char[a_length + 1];
memcpy(str, buffer, a_length);
str[a_length] = '\0';
c_str_ = str;
length_ = a_length;
}
const char* c_str_;
size_t length_;
}; // class String
// Streams a String to an ostream. Each '\0' character in the String
// is replaced with "\\0".
inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
if (str.c_str() == NULL) {
os << "(null)";
} else {
const char* const c_str = str.c_str();
for (size_t i = 0; i != str.length(); i++) {
if (c_str[i] == '\0') {
os << "\\0";
} else {
os << c_str[i];
}
}
}
return os;
}
// Gets the content of the stringstream's buffer as a String. Each '\0'
// character in the buffer is replaced with "\\0".
GTEST_API_ String StringStreamToString(::std::stringstream* stream);
// Converts a streamable value to a String. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
// Declared here but defined in gtest.h, so that it has access
// to the definition of the Message class, required by the ARM
// compiler.
template <typename T>
String StreamableToString(const T& streamable);
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_

View File

@ -1,968 +0,0 @@
// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
// Copyright 2009 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#include <utility> // For ::std::pair.
// The compiler used in Symbian has a bug that prevents us from declaring the
// tuple template as a friend (it complains that tuple is redefined). This
// hack bypasses the bug by declaring the members that should otherwise be
// private as public.
// Sun Studio versions < 12 also have the above bug.
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#else
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
private:
#endif
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
#define GTEST_0_TUPLE_(T) tuple<>
#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
void, void, void>
#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
void, void, void>
#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
void, void, void>
#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
void, void, void>
#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
void, void, void>
#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
void, void, void>
#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
void, void, void>
#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
T##7, void, void>
#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
T##7, T##8, void>
#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
T##7, T##8, T##9>
// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
#define GTEST_0_TYPENAMES_(T)
#define GTEST_1_TYPENAMES_(T) typename T##0
#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3
#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4
#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4, typename T##5
#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4, typename T##5, typename T##6
#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4, typename T##5, typename T##6, \
typename T##7, typename T##8
#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
typename T##3, typename T##4, typename T##5, typename T##6, \
typename T##7, typename T##8, typename T##9
// In theory, defining stuff in the ::std namespace is undefined
// behavior. We can do this as we are playing the role of a standard
// library vendor.
namespace std {
namespace tr1 {
template <typename T0 = void, typename T1 = void, typename T2 = void,
typename T3 = void, typename T4 = void, typename T5 = void,
typename T6 = void, typename T7 = void, typename T8 = void,
typename T9 = void>
class tuple;
// Anything in namespace gtest_internal is Google Test's INTERNAL
// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
namespace gtest_internal {
// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
template <typename T>
struct ByRef { typedef const T& type; }; // NOLINT
template <typename T>
struct ByRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for ByRef.
#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
// AddRef<T>::type is T if T is a reference; otherwise it's T&. This
// is the same as tr1::add_reference<T>::type.
template <typename T>
struct AddRef { typedef T& type; }; // NOLINT
template <typename T>
struct AddRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for AddRef.
#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
// A helper for implementing get<k>().
template <int k> class Get;
// A helper for implementing tuple_element<k, T>. kIndexValid is true
// iff k < the number of fields in tuple type T.
template <bool kIndexValid, int kIndex, class Tuple>
struct TupleElement;
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
template <GTEST_10_TYPENAMES_(T)>
struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
} // namespace gtest_internal
template <>
class tuple<> {
public:
tuple() {}
tuple(const tuple& /* t */) {}
tuple& operator=(const tuple& /* t */) { return *this; }
};
template <GTEST_1_TYPENAMES_(T)>
class GTEST_1_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_() {}
explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
tuple(const tuple& t) : f0_(t.f0_) {}
template <GTEST_1_TYPENAMES_(U)>
tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_1_TYPENAMES_(U)>
tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_1_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
f0_ = t.f0_;
return *this;
}
T0 f0_;
};
template <GTEST_2_TYPENAMES_(T)>
class GTEST_2_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
f1_(f1) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
template <GTEST_2_TYPENAMES_(U)>
tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
template <typename U0, typename U1>
tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_2_TYPENAMES_(U)>
tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
return CopyFrom(t);
}
template <typename U0, typename U1>
tuple& operator=(const ::std::pair<U0, U1>& p) {
f0_ = p.first;
f1_ = p.second;
return *this;
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_2_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
return *this;
}
T0 f0_;
T1 f1_;
};
template <GTEST_3_TYPENAMES_(T)>
class GTEST_3_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
template <GTEST_3_TYPENAMES_(U)>
tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_3_TYPENAMES_(U)>
tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_3_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
};
template <GTEST_4_TYPENAMES_(T)>
class GTEST_4_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
f3_(f3) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
template <GTEST_4_TYPENAMES_(U)>
tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_4_TYPENAMES_(U)>
tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_4_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
};
template <GTEST_5_TYPENAMES_(T)>
class GTEST_5_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_) {}
template <GTEST_5_TYPENAMES_(U)>
tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_5_TYPENAMES_(U)>
tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_5_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
};
template <GTEST_6_TYPENAMES_(T)>
class GTEST_6_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
f5_(f5) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_), f5_(t.f5_) {}
template <GTEST_6_TYPENAMES_(U)>
tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_6_TYPENAMES_(U)>
tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_6_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
f5_ = t.f5_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
T5 f5_;
};
template <GTEST_7_TYPENAMES_(T)>
class GTEST_7_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
template <GTEST_7_TYPENAMES_(U)>
tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_7_TYPENAMES_(U)>
tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_7_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
f5_ = t.f5_;
f6_ = t.f6_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
T5 f5_;
T6 f6_;
};
template <GTEST_8_TYPENAMES_(T)>
class GTEST_8_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
f5_(f5), f6_(f6), f7_(f7) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
template <GTEST_8_TYPENAMES_(U)>
tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_8_TYPENAMES_(U)>
tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_8_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
f5_ = t.f5_;
f6_ = t.f6_;
f7_ = t.f7_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
T5 f5_;
T6 f6_;
T7 f7_;
};
template <GTEST_9_TYPENAMES_(T)>
class GTEST_9_TUPLE_(T) {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
template <GTEST_9_TYPENAMES_(U)>
tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_9_TYPENAMES_(U)>
tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_9_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
f5_ = t.f5_;
f6_ = t.f6_;
f7_ = t.f7_;
f8_ = t.f8_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
T5 f5_;
T6 f6_;
T7 f7_;
T8 f8_;
};
template <GTEST_10_TYPENAMES_(T)>
class tuple {
public:
template <int k> friend class gtest_internal::Get;
tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
f9_() {}
explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
template <GTEST_10_TYPENAMES_(U)>
tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
f9_(t.f9_) {}
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_10_TYPENAMES_(U)>
tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
return CopyFrom(t);
}
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_10_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
f0_ = t.f0_;
f1_ = t.f1_;
f2_ = t.f2_;
f3_ = t.f3_;
f4_ = t.f4_;
f5_ = t.f5_;
f6_ = t.f6_;
f7_ = t.f7_;
f8_ = t.f8_;
f9_ = t.f9_;
return *this;
}
T0 f0_;
T1 f1_;
T2 f2_;
T3 f3_;
T4 f4_;
T5 f5_;
T6 f6_;
T7 f7_;
T8 f8_;
T9 f9_;
};
// 6.1.3.2 Tuple creation functions.
// Known limitations: we don't support passing an
// std::tr1::reference_wrapper<T> to make_tuple(). And we don't
// implement tie().
inline tuple<> make_tuple() { return tuple<>(); }
template <GTEST_1_TYPENAMES_(T)>
inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
return GTEST_1_TUPLE_(T)(f0);
}
template <GTEST_2_TYPENAMES_(T)>
inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
return GTEST_2_TUPLE_(T)(f0, f1);
}
template <GTEST_3_TYPENAMES_(T)>
inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
return GTEST_3_TUPLE_(T)(f0, f1, f2);
}
template <GTEST_4_TYPENAMES_(T)>
inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3) {
return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
}
template <GTEST_5_TYPENAMES_(T)>
inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4) {
return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
}
template <GTEST_6_TYPENAMES_(T)>
inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4, const T5& f5) {
return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
}
template <GTEST_7_TYPENAMES_(T)>
inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
}
template <GTEST_8_TYPENAMES_(T)>
inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
}
template <GTEST_9_TYPENAMES_(T)>
inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
const T8& f8) {
return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
}
template <GTEST_10_TYPENAMES_(T)>
inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
const T8& f8, const T9& f9) {
return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
}
// 6.1.3.3 Tuple helper classes.
template <typename Tuple> struct tuple_size;
template <GTEST_0_TYPENAMES_(T)>
struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
template <GTEST_1_TYPENAMES_(T)>
struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
template <GTEST_2_TYPENAMES_(T)>
struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
template <GTEST_3_TYPENAMES_(T)>
struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
template <GTEST_4_TYPENAMES_(T)>
struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
template <GTEST_5_TYPENAMES_(T)>
struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
template <GTEST_6_TYPENAMES_(T)>
struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
template <GTEST_7_TYPENAMES_(T)>
struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
template <GTEST_8_TYPENAMES_(T)>
struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
template <GTEST_9_TYPENAMES_(T)>
struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
template <GTEST_10_TYPENAMES_(T)>
struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
template <int k, class Tuple>
struct tuple_element {
typedef typename gtest_internal::TupleElement<
k < (tuple_size<Tuple>::value), k, Tuple>::type type;
};
#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
// 6.1.3.4 Element access.
namespace gtest_internal {
template <>
class Get<0> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
Field(Tuple& t) { return t.f0_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
ConstField(const Tuple& t) { return t.f0_; }
};
template <>
class Get<1> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
Field(Tuple& t) { return t.f1_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
ConstField(const Tuple& t) { return t.f1_; }
};
template <>
class Get<2> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
Field(Tuple& t) { return t.f2_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
ConstField(const Tuple& t) { return t.f2_; }
};
template <>
class Get<3> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
Field(Tuple& t) { return t.f3_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
ConstField(const Tuple& t) { return t.f3_; }
};
template <>
class Get<4> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
Field(Tuple& t) { return t.f4_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
ConstField(const Tuple& t) { return t.f4_; }
};
template <>
class Get<5> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
Field(Tuple& t) { return t.f5_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
ConstField(const Tuple& t) { return t.f5_; }
};
template <>
class Get<6> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
Field(Tuple& t) { return t.f6_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
ConstField(const Tuple& t) { return t.f6_; }
};
template <>
class Get<7> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
Field(Tuple& t) { return t.f7_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
ConstField(const Tuple& t) { return t.f7_; }
};
template <>
class Get<8> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
Field(Tuple& t) { return t.f8_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
ConstField(const Tuple& t) { return t.f8_; }
};
template <>
class Get<9> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
Field(Tuple& t) { return t.f9_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
ConstField(const Tuple& t) { return t.f9_; }
};
} // namespace gtest_internal
template <int k, GTEST_10_TYPENAMES_(T)>
GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
get(GTEST_10_TUPLE_(T)& t) {
return gtest_internal::Get<k>::Field(t);
}
template <int k, GTEST_10_TYPENAMES_(T)>
GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
get(const GTEST_10_TUPLE_(T)& t) {
return gtest_internal::Get<k>::ConstField(t);
}
// 6.1.3.5 Relational operators
// We only implement == and !=, as we don't have a need for the rest yet.
namespace gtest_internal {
// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
// first k fields of t1 equals the first k fields of t2.
// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
// k1 != k2.
template <int kSize1, int kSize2>
struct SameSizeTuplePrefixComparator;
template <>
struct SameSizeTuplePrefixComparator<0, 0> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
return true;
}
};
template <int k>
struct SameSizeTuplePrefixComparator<k, k> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& t1, const Tuple2& t2) {
return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
}
};
} // namespace gtest_internal
template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
inline bool operator==(const GTEST_10_TUPLE_(T)& t,
const GTEST_10_TUPLE_(U)& u) {
return gtest_internal::SameSizeTuplePrefixComparator<
tuple_size<GTEST_10_TUPLE_(T)>::value,
tuple_size<GTEST_10_TUPLE_(U)>::value>::Eq(t, u);
}
template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
// 6.1.4 Pairs.
// Unimplemented.
} // namespace tr1
} // namespace std
#undef GTEST_0_TUPLE_
#undef GTEST_1_TUPLE_
#undef GTEST_2_TUPLE_
#undef GTEST_3_TUPLE_
#undef GTEST_4_TUPLE_
#undef GTEST_5_TUPLE_
#undef GTEST_6_TUPLE_
#undef GTEST_7_TUPLE_
#undef GTEST_8_TUPLE_
#undef GTEST_9_TUPLE_
#undef GTEST_10_TUPLE_
#undef GTEST_0_TYPENAMES_
#undef GTEST_1_TYPENAMES_
#undef GTEST_2_TYPENAMES_
#undef GTEST_3_TYPENAMES_
#undef GTEST_4_TYPENAMES_
#undef GTEST_5_TYPENAMES_
#undef GTEST_6_TYPENAMES_
#undef GTEST_7_TYPENAMES_
#undef GTEST_8_TYPENAMES_
#undef GTEST_9_TYPENAMES_
#undef GTEST_10_TYPENAMES_
#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
#undef GTEST_BY_REF_
#undef GTEST_ADD_REF_
#undef GTEST_TUPLE_ELEMENT_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_

View File

@ -1,336 +0,0 @@
$$ -*- mode: c++; -*-
$var n = 10 $$ Maximum number of tuple fields we want to support.
$$ This meta comment fixes auto-indentation in Emacs. }}
// Copyright 2009 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#include <utility> // For ::std::pair.
// The compiler used in Symbian has a bug that prevents us from declaring the
// tuple template as a friend (it complains that tuple is redefined). This
// hack bypasses the bug by declaring the members that should otherwise be
// private as public.
// Sun Studio versions < 12 also have the above bug.
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#else
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \
private:
#endif
$range i 0..n-1
$range j 0..n
$range k 1..n
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
#define GTEST_0_TUPLE_(T) tuple<>
$for k [[
$range m 0..k-1
$range m2 k..n-1
#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>
]]
// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
$for j [[
$range m 0..j-1
#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]
]]
// In theory, defining stuff in the ::std namespace is undefined
// behavior. We can do this as we are playing the role of a standard
// library vendor.
namespace std {
namespace tr1 {
template <$for i, [[typename T$i = void]]>
class tuple;
// Anything in namespace gtest_internal is Google Test's INTERNAL
// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
namespace gtest_internal {
// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
template <typename T>
struct ByRef { typedef const T& type; }; // NOLINT
template <typename T>
struct ByRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for ByRef.
#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
// AddRef<T>::type is T if T is a reference; otherwise it's T&. This
// is the same as tr1::add_reference<T>::type.
template <typename T>
struct AddRef { typedef T& type; }; // NOLINT
template <typename T>
struct AddRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for AddRef.
#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
// A helper for implementing get<k>().
template <int k> class Get;
// A helper for implementing tuple_element<k, T>. kIndexValid is true
// iff k < the number of fields in tuple type T.
template <bool kIndexValid, int kIndex, class Tuple>
struct TupleElement;
$for i [[
template <GTEST_$(n)_TYPENAMES_(T)>
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T)> [[]]
{ typedef T$i type; };
]]
} // namespace gtest_internal
template <>
class tuple<> {
public:
tuple() {}
tuple(const tuple& /* t */) {}
tuple& operator=(const tuple& /* t */) { return *this; }
};
$for k [[
$range m 0..k-1
template <GTEST_$(k)_TYPENAMES_(T)>
class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {
public:
template <int k> friend class gtest_internal::Get;
tuple() : $for m, [[f$(m)_()]] {}
explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]
$for m, [[f$(m)_(f$m)]] {}
tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
template <GTEST_$(k)_TYPENAMES_(U)>
tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
$if k == 2 [[
template <typename U0, typename U1>
tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
]]
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_$(k)_TYPENAMES_(U)>
tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {
return CopyFrom(t);
}
$if k == 2 [[
template <typename U0, typename U1>
tuple& operator=(const ::std::pair<U0, U1>& p) {
f0_ = p.first;
f1_ = p.second;
return *this;
}
]]
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_$(k)_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {
$for m [[
f$(m)_ = t.f$(m)_;
]]
return *this;
}
$for m [[
T$m f$(m)_;
]]
};
]]
// 6.1.3.2 Tuple creation functions.
// Known limitations: we don't support passing an
// std::tr1::reference_wrapper<T> to make_tuple(). And we don't
// implement tie().
inline tuple<> make_tuple() { return tuple<>(); }
$for k [[
$range m 0..k-1
template <GTEST_$(k)_TYPENAMES_(T)>
inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {
return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);
}
]]
// 6.1.3.3 Tuple helper classes.
template <typename Tuple> struct tuple_size;
$for j [[
template <GTEST_$(j)_TYPENAMES_(T)>
struct tuple_size<GTEST_$(j)_TUPLE_(T)> { static const int value = $j; };
]]
template <int k, class Tuple>
struct tuple_element {
typedef typename gtest_internal::TupleElement<
k < (tuple_size<Tuple>::value), k, Tuple>::type type;
};
#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
// 6.1.3.4 Element access.
namespace gtest_internal {
$for i [[
template <>
class Get<$i> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
Field(Tuple& t) { return t.f$(i)_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
ConstField(const Tuple& t) { return t.f$(i)_; }
};
]]
} // namespace gtest_internal
template <int k, GTEST_$(n)_TYPENAMES_(T)>
GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
get(GTEST_$(n)_TUPLE_(T)& t) {
return gtest_internal::Get<k>::Field(t);
}
template <int k, GTEST_$(n)_TYPENAMES_(T)>
GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
get(const GTEST_$(n)_TUPLE_(T)& t) {
return gtest_internal::Get<k>::ConstField(t);
}
// 6.1.3.5 Relational operators
// We only implement == and !=, as we don't have a need for the rest yet.
namespace gtest_internal {
// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
// first k fields of t1 equals the first k fields of t2.
// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
// k1 != k2.
template <int kSize1, int kSize2>
struct SameSizeTuplePrefixComparator;
template <>
struct SameSizeTuplePrefixComparator<0, 0> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
return true;
}
};
template <int k>
struct SameSizeTuplePrefixComparator<k, k> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& t1, const Tuple2& t2) {
return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
}
};
} // namespace gtest_internal
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,
const GTEST_$(n)_TUPLE_(U)& u) {
return gtest_internal::SameSizeTuplePrefixComparator<
tuple_size<GTEST_$(n)_TUPLE_(T)>::value,
tuple_size<GTEST_$(n)_TUPLE_(U)>::value>::Eq(t, u);
}
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,
const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }
// 6.1.4 Pairs.
// Unimplemented.
} // namespace tr1
} // namespace std
$for j [[
#undef GTEST_$(j)_TUPLE_
]]
$for j [[
#undef GTEST_$(j)_TYPENAMES_
]]
#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
#undef GTEST_BY_REF_
#undef GTEST_ADD_REF_
#undef GTEST_TUPLE_ELEMENT_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,296 +0,0 @@
$$ -*- mode: c++; -*-
$var n = 50 $$ Maximum length of type lists we want to support.
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Type utilities needed for implementing typed and type-parameterized
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
//
// Currently we support at most $n types in a list, and at most $n
// type-parameterized tests in one type-parameterized test case.
// Please contact googletestframework@googlegroups.com if you need
// more.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-string.h"
// #ifdef __GNUC__ is too general here. It is possible to use gcc without using
// libstdc++ (which is where cxxabi.h comes from).
# ifdef __GLIBCXX__
# include <cxxabi.h>
# elif defined(__HP_aCC)
# include <acxx_demangle.h>
# endif // __GLIBCXX__
namespace testing {
namespace internal {
// GetTypeName<T>() returns a human-readable name of type T.
// NB: This function is also used in Google Mock, so don't move it inside of
// the typed-test-only section below.
template <typename T>
String GetTypeName() {
# if GTEST_HAS_RTTI
const char* const name = typeid(T).name();
# if defined(__GLIBCXX__) || defined(__HP_aCC)
int status = 0;
// gcc's implementation of typeid(T).name() mangles the type name,
// so we have to demangle it.
# ifdef __GLIBCXX__
using abi::__cxa_demangle;
# endif // __GLIBCXX__
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name);
free(readable_name);
return name_str;
# else
return name;
# endif // __GLIBCXX__ || __HP_aCC
# else
return "<type>";
# endif // GTEST_HAS_RTTI
}
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
// type. This can be used as a compile-time assertion to ensure that
// two types are equal.
template <typename T1, typename T2>
struct AssertTypeEq;
template <typename T>
struct AssertTypeEq<T, T> {
typedef bool type;
};
// A unique type used as the default value for the arguments of class
// template Types. This allows us to simulate variadic templates
// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
// support directly.
struct None {};
// The following family of struct and struct templates are used to
// represent type lists. In particular, TypesN<T1, T2, ..., TN>
// represents a type list with N types (T1, T2, ..., and TN) in it.
// Except for Types0, every struct in the family has two member types:
// Head for the first type in the list, and Tail for the rest of the
// list.
// The empty type list.
struct Types0 {};
// Type lists of length 1, 2, 3, and so on.
template <typename T1>
struct Types1 {
typedef T1 Head;
typedef Types0 Tail;
};
$range i 2..n
$for i [[
$range j 1..i
$range k 2..i
template <$for j, [[typename T$j]]>
struct Types$i {
typedef T1 Head;
typedef Types$(i-1)<$for k, [[T$k]]> Tail;
};
]]
} // namespace internal
// We don't want to require the users to write TypesN<...> directly,
// as that would require them to count the length. Types<...> is much
// easier to write, but generates horrible messages when there is a
// compiler error, as gcc insists on printing out each template
// argument, even if it has the default value (this means Types<int>
// will appear as Types<int, None, None, ..., None> in the compiler
// errors).
//
// Our solution is to combine the best part of the two approaches: a
// user would write Types<T1, ..., TN>, and Google Test will translate
// that to TypesN<T1, ..., TN> internally to make error messages
// readable. The translation is done by the 'type' member of the
// Types template.
$range i 1..n
template <$for i, [[typename T$i = internal::None]]>
struct Types {
typedef internal::Types$n<$for i, [[T$i]]> type;
};
template <>
struct Types<$for i, [[internal::None]]> {
typedef internal::Types0 type;
};
$range i 1..n-1
$for i [[
$range j 1..i
$range k i+1..n
template <$for j, [[typename T$j]]>
struct Types<$for j, [[T$j]]$for k[[, internal::None]]> {
typedef internal::Types$i<$for j, [[T$j]]> type;
};
]]
namespace internal {
# define GTEST_TEMPLATE_ template <typename T> class
// The template "selector" struct TemplateSel<Tmpl> is used to
// represent Tmpl, which must be a class template with one type
// parameter, as a type. TemplateSel<Tmpl>::Bind<T>::type is defined
// as the type Tmpl<T>. This allows us to actually instantiate the
// template "selected" by TemplateSel<Tmpl>.
//
// This trick is necessary for simulating typedef for class templates,
// which C++ doesn't support directly.
template <GTEST_TEMPLATE_ Tmpl>
struct TemplateSel {
template <typename T>
struct Bind {
typedef Tmpl<T> type;
};
};
# define GTEST_BIND_(TmplSel, T) \
TmplSel::template Bind<T>::type
// A unique struct template used as the default value for the
// arguments of class template Templates. This allows us to simulate
// variadic templates (e.g. Templates<int>, Templates<int, double>,
// and etc), which C++ doesn't support directly.
template <typename T>
struct NoneT {};
// The following family of struct and struct templates are used to
// represent template lists. In particular, TemplatesN<T1, T2, ...,
// TN> represents a list of N templates (T1, T2, ..., and TN). Except
// for Templates0, every struct in the family has two member types:
// Head for the selector of the first template in the list, and Tail
// for the rest of the list.
// The empty template list.
struct Templates0 {};
// Template lists of length 1, 2, 3, and so on.
template <GTEST_TEMPLATE_ T1>
struct Templates1 {
typedef TemplateSel<T1> Head;
typedef Templates0 Tail;
};
$range i 2..n
$for i [[
$range j 1..i
$range k 2..i
template <$for j, [[GTEST_TEMPLATE_ T$j]]>
struct Templates$i {
typedef TemplateSel<T1> Head;
typedef Templates$(i-1)<$for k, [[T$k]]> Tail;
};
]]
// We don't want to require the users to write TemplatesN<...> directly,
// as that would require them to count the length. Templates<...> is much
// easier to write, but generates horrible messages when there is a
// compiler error, as gcc insists on printing out each template
// argument, even if it has the default value (this means Templates<list>
// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
// errors).
//
// Our solution is to combine the best part of the two approaches: a
// user would write Templates<T1, ..., TN>, and Google Test will translate
// that to TemplatesN<T1, ..., TN> internally to make error messages
// readable. The translation is done by the 'type' member of the
// Templates template.
$range i 1..n
template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]>
struct Templates {
typedef Templates$n<$for i, [[T$i]]> type;
};
template <>
struct Templates<$for i, [[NoneT]]> {
typedef Templates0 type;
};
$range i 1..n-1
$for i [[
$range j 1..i
$range k i+1..n
template <$for j, [[GTEST_TEMPLATE_ T$j]]>
struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
typedef Templates$i<$for j, [[T$j]]> type;
};
]]
// The TypeList template makes it possible to use either a single type
// or a Types<...> list in TYPED_TEST_CASE() and
// INSTANTIATE_TYPED_TEST_CASE_P().
template <typename T>
struct TypeList { typedef Types1<T> type; };
$range i 1..n
template <$for i, [[typename T$i]]>
struct TypeList<Types<$for i, [[T$i]]> > {
typedef typename Types<$for i, [[T$i]]>::type type;
};
#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_

View File

@ -1,48 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
// Google C++ Testing Framework (Google Test)
//
// Sometimes it's desirable to build Google Test by compiling a single file.
// This file serves this purpose.
// This line ensures that gtest.h can be compiled on its own, even
// when it's fused.
#include "gtest/gtest.h"
// The following lines pull in the real gtest *.cc files.
#include "src/gtest.cc"
#include "src/gtest-death-test.cc"
#include "src/gtest-filepath.cc"
#include "src/gtest-port.cc"
#include "src/gtest-printers.cc"
#include "src/gtest-test-part.cc"
#include "src/gtest-typed-test.cc"

File diff suppressed because it is too large Load Diff

View File

@ -1,380 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-port.h"
#include <stdlib.h>
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h>
#elif GTEST_OS_WINDOWS
# include <direct.h>
# include <io.h>
#elif GTEST_OS_SYMBIAN || GTEST_OS_NACL
// Symbian OpenC and NaCl have PATH_MAX in sys/syslimits.h
# include <sys/syslimits.h>
#else
# include <limits.h>
# include <climits> // Some Linux distributions define PATH_MAX here.
#endif // GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS
# define GTEST_PATH_MAX_ _MAX_PATH
#elif defined(PATH_MAX)
# define GTEST_PATH_MAX_ PATH_MAX
#elif defined(_XOPEN_PATH_MAX)
# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
#else
# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
#endif // GTEST_OS_WINDOWS
#include "gtest/internal/gtest-string.h"
namespace testing {
namespace internal {
#if GTEST_OS_WINDOWS
// On Windows, '\\' is the standard path separator, but many tools and the
// Windows API also accept '/' as an alternate path separator. Unless otherwise
// noted, a file path can contain either kind of path separators, or a mixture
// of them.
const char kPathSeparator = '\\';
const char kAlternatePathSeparator = '/';
const char kPathSeparatorString[] = "\\";
const char kAlternatePathSeparatorString[] = "/";
# if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't have a current directory. You should not use
// the current directory in tests on Windows CE, but this at least
// provides a reasonable fallback.
const char kCurrentDirectoryString[] = "\\";
// Windows CE doesn't define INVALID_FILE_ATTRIBUTES
const DWORD kInvalidFileAttributes = 0xffffffff;
# else
const char kCurrentDirectoryString[] = ".\\";
# endif // GTEST_OS_WINDOWS_MOBILE
#else
const char kPathSeparator = '/';
const char kPathSeparatorString[] = "/";
const char kCurrentDirectoryString[] = "./";
#endif // GTEST_OS_WINDOWS
// Returns whether the given character is a valid path separator.
static bool IsPathSeparator(char c) {
#if GTEST_HAS_ALT_PATH_SEP_
return (c == kPathSeparator) || (c == kAlternatePathSeparator);
#else
return c == kPathSeparator;
#endif
}
// Returns the current working directory, or "" if unsuccessful.
FilePath FilePath::GetCurrentDir() {
#if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't have a current directory, so we just return
// something reasonable.
return FilePath(kCurrentDirectoryString);
#elif GTEST_OS_WINDOWS
char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#else
char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#endif // GTEST_OS_WINDOWS_MOBILE
}
// Returns a copy of the FilePath with the case-insensitive extension removed.
// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
// FilePath("dir/file"). If a case-insensitive extension is not
// found, returns a copy of the original FilePath.
FilePath FilePath::RemoveExtension(const char* extension) const {
String dot_extension(String::Format(".%s", extension));
if (pathname_.EndsWithCaseInsensitive(dot_extension.c_str())) {
return FilePath(String(pathname_.c_str(), pathname_.length() - 4));
}
return *this;
}
// Returns a pointer to the last occurence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
const char* FilePath::FindLastPathSeparator() const {
const char* const last_sep = strrchr(c_str(), kPathSeparator);
#if GTEST_HAS_ALT_PATH_SEP_
const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
// Comparing two pointers of which only one is NULL is undefined.
if (last_alt_sep != NULL &&
(last_sep == NULL || last_alt_sep > last_sep)) {
return last_alt_sep;
}
#endif
return last_sep;
}
// Returns a copy of the FilePath with the directory part removed.
// Example: FilePath("path/to/file").RemoveDirectoryName() returns
// FilePath("file"). If there is no directory part ("just_a_file"), it returns
// the FilePath unmodified. If there is no file part ("just_a_dir/") it
// returns an empty FilePath ("").
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath FilePath::RemoveDirectoryName() const {
const char* const last_sep = FindLastPathSeparator();
return last_sep ? FilePath(String(last_sep + 1)) : *this;
}
// RemoveFileName returns the directory path with the filename removed.
// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath FilePath::RemoveFileName() const {
const char* const last_sep = FindLastPathSeparator();
String dir;
if (last_sep) {
dir = String(c_str(), last_sep + 1 - c_str());
} else {
dir = kCurrentDirectoryString;
}
return FilePath(dir);
}
// Helper functions for naming files in a directory for xml output.
// Given directory = "dir", base_name = "test", number = 0,
// extension = "xml", returns "dir/test.xml". If number is greater
// than zero (e.g., 12), returns "dir/test_12.xml".
// On Windows platform, uses \ as the separator rather than /.
FilePath FilePath::MakeFileName(const FilePath& directory,
const FilePath& base_name,
int number,
const char* extension) {
String file;
if (number == 0) {
file = String::Format("%s.%s", base_name.c_str(), extension);
} else {
file = String::Format("%s_%d.%s", base_name.c_str(), number, extension);
}
return ConcatPaths(directory, FilePath(file));
}
// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
// On Windows, uses \ as the separator rather than /.
FilePath FilePath::ConcatPaths(const FilePath& directory,
const FilePath& relative_path) {
if (directory.IsEmpty())
return relative_path;
const FilePath dir(directory.RemoveTrailingPathSeparator());
return FilePath(String::Format("%s%c%s", dir.c_str(), kPathSeparator,
relative_path.c_str()));
}
// Returns true if pathname describes something findable in the file-system,
// either a file, directory, or whatever.
bool FilePath::FileOrDirectoryExists() const {
#if GTEST_OS_WINDOWS_MOBILE
LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
const DWORD attributes = GetFileAttributes(unicode);
delete [] unicode;
return attributes != kInvalidFileAttributes;
#else
posix::StatStruct file_stat;
return posix::Stat(pathname_.c_str(), &file_stat) == 0;
#endif // GTEST_OS_WINDOWS_MOBILE
}
// Returns true if pathname describes a directory in the file-system
// that exists.
bool FilePath::DirectoryExists() const {
bool result = false;
#if GTEST_OS_WINDOWS
// Don't strip off trailing separator if path is a root directory on
// Windows (like "C:\\").
const FilePath& path(IsRootDirectory() ? *this :
RemoveTrailingPathSeparator());
#else
const FilePath& path(*this);
#endif
#if GTEST_OS_WINDOWS_MOBILE
LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
const DWORD attributes = GetFileAttributes(unicode);
delete [] unicode;
if ((attributes != kInvalidFileAttributes) &&
(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
result = true;
}
#else
posix::StatStruct file_stat;
result = posix::Stat(path.c_str(), &file_stat) == 0 &&
posix::IsDir(file_stat);
#endif // GTEST_OS_WINDOWS_MOBILE
return result;
}
// Returns true if pathname describes a root directory. (Windows has one
// root directory per disk drive.)
bool FilePath::IsRootDirectory() const {
#if GTEST_OS_WINDOWS
// TODO(wan@google.com): on Windows a network share like
// \\server\share can be a root directory, although it cannot be the
// current directory. Handle this properly.
return pathname_.length() == 3 && IsAbsolutePath();
#else
return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);
#endif
}
// Returns true if pathname describes an absolute path.
bool FilePath::IsAbsolutePath() const {
const char* const name = pathname_.c_str();
#if GTEST_OS_WINDOWS
return pathname_.length() >= 3 &&
((name[0] >= 'a' && name[0] <= 'z') ||
(name[0] >= 'A' && name[0] <= 'Z')) &&
name[1] == ':' &&
IsPathSeparator(name[2]);
#else
return IsPathSeparator(name[0]);
#endif
}
// Returns a pathname for a file that does not currently exist. The pathname
// will be directory/base_name.extension or
// directory/base_name_<number>.extension if directory/base_name.extension
// already exists. The number will be incremented until a pathname is found
// that does not already exist.
// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
// There could be a race condition if two or more processes are calling this
// function at the same time -- they could both pick the same filename.
FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
const FilePath& base_name,
const char* extension) {
FilePath full_pathname;
int number = 0;
do {
full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
} while (full_pathname.FileOrDirectoryExists());
return full_pathname;
}
// Returns true if FilePath ends with a path separator, which indicates that
// it is intended to represent a directory. Returns false otherwise.
// This does NOT check that a directory (or file) actually exists.
bool FilePath::IsDirectory() const {
return !pathname_.empty() &&
IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);
}
// Create directories so that path exists. Returns true if successful or if
// the directories already exist; returns false if unable to create directories
// for any reason.
bool FilePath::CreateDirectoriesRecursively() const {
if (!this->IsDirectory()) {
return false;
}
if (pathname_.length() == 0 || this->DirectoryExists()) {
return true;
}
const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
return parent.CreateDirectoriesRecursively() && this->CreateFolder();
}
// Create the directory so that path exists. Returns true if successful or
// if the directory already exists; returns false if unable to create the
// directory for any reason, including if the parent directory does not
// exist. Not named "CreateDirectory" because that's a macro on Windows.
bool FilePath::CreateFolder() const {
#if GTEST_OS_WINDOWS_MOBILE
FilePath removed_sep(this->RemoveTrailingPathSeparator());
LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
int result = CreateDirectory(unicode, NULL) ? 0 : -1;
delete [] unicode;
#elif GTEST_OS_WINDOWS
int result = _mkdir(pathname_.c_str());
#else
int result = mkdir(pathname_.c_str(), 0777);
#endif // GTEST_OS_WINDOWS_MOBILE
if (result == -1) {
return this->DirectoryExists(); // An error is OK if the directory exists.
}
return true; // No error.
}
// If input name has a trailing separator character, remove it and return the
// name, otherwise return the name string unmodified.
// On Windows platform, uses \ as the separator, other platforms use /.
FilePath FilePath::RemoveTrailingPathSeparator() const {
return IsDirectory()
? FilePath(String(pathname_.c_str(), pathname_.length() - 1))
: *this;
}
// Removes any redundant separators that might be in the pathname.
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..".
// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share).
void FilePath::Normalize() {
if (pathname_.c_str() == NULL) {
pathname_ = "";
return;
}
const char* src = pathname_.c_str();
char* const dest = new char[pathname_.length() + 1];
char* dest_ptr = dest;
memset(dest_ptr, 0, pathname_.length() + 1);
while (*src != '\0') {
*dest_ptr = *src;
if (!IsPathSeparator(*src)) {
src++;
} else {
#if GTEST_HAS_ALT_PATH_SEP_
if (*dest_ptr == kAlternatePathSeparator) {
*dest_ptr = kPathSeparator;
}
#endif
while (IsPathSeparator(*src))
src++;
}
dest_ptr++;
}
*dest_ptr = '\0';
pathname_ = dest;
delete[] dest;
}
} // namespace internal
} // namespace testing

File diff suppressed because it is too large Load Diff

View File

@ -1,763 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/internal/gtest-port.h"
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> // For TerminateProcess()
#elif GTEST_OS_WINDOWS
# include <io.h>
# include <sys/stat.h>
#else
# include <dirent.h>
# include <unistd.h>
#endif // GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_MAC
# include <mach/mach_init.h>
# include <mach/task.h>
# include <mach/vm_map.h>
#endif // GTEST_OS_MAC
#include "gtest/gtest-spi.h"
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-string.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing {
namespace internal {
#if defined(_MSC_VER) || defined(__BORLANDC__)
// MSVC and C++Builder do not provide a definition of STDERR_FILENO.
const int kStdOutFileno = 1;
const int kStdErrFileno = 2;
#else
const int kStdOutFileno = STDOUT_FILENO;
const int kStdErrFileno = STDERR_FILENO;
#endif // _MSC_VER
#if GTEST_OS_MAC
// Returns the number of threads running in the process, or 0 to indicate that
// we cannot detect it.
size_t GetThreadCount() {
const task_t task = mach_task_self();
mach_msg_type_number_t thread_count;
thread_act_array_t thread_list;
const kern_return_t status = task_threads(task, &thread_list, &thread_count);
if (status == KERN_SUCCESS) {
// task_threads allocates resources in thread_list and we need to free them
// to avoid leaks.
vm_deallocate(task,
reinterpret_cast<vm_address_t>(thread_list),
sizeof(thread_t) * thread_count);
return static_cast<size_t>(thread_count);
} else {
return 0;
}
}
#elif GTEST_OS_LINUX
// Returns the number of threads running in the process, or 0 to indicate that
// we cannot detect it.
size_t GetThreadCount() {
size_t thread_count = 0;
if (DIR *dir = opendir("/proc/self/task")) {
while (dirent *entry = readdir(dir)) {
if (entry->d_name[0] != '.')
++thread_count;
}
closedir(dir);
}
return thread_count;
}
#else
size_t GetThreadCount() {
// There's no portable way to detect the number of threads, so we just
// return 0 to indicate that we cannot detect it.
return 0;
}
#endif // GTEST_OS_MAC
#if GTEST_USES_POSIX_RE
// Implements RE. Currently only needed for death tests.
RE::~RE() {
if (is_valid_) {
// regfree'ing an invalid regex might crash because the content
// of the regex is undefined. Since the regex's are essentially
// the same, one cannot be valid (or invalid) without the other
// being so too.
regfree(&partial_regex_);
regfree(&full_regex_);
}
free(const_cast<char*>(pattern_));
}
// Returns true iff regular expression re matches the entire str.
bool RE::FullMatch(const char* str, const RE& re) {
if (!re.is_valid_) return false;
regmatch_t match;
return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
}
// Returns true iff regular expression re matches a substring of str
// (including str itself).
bool RE::PartialMatch(const char* str, const RE& re) {
if (!re.is_valid_) return false;
regmatch_t match;
return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;
}
// Initializes an RE from its string representation.
void RE::Init(const char* regex) {
pattern_ = posix::StrDup(regex);
// Reserves enough bytes to hold the regular expression used for a
// full match.
const size_t full_regex_len = strlen(regex) + 10;
char* const full_pattern = new char[full_regex_len];
snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
// We want to call regcomp(&partial_regex_, ...) even if the
// previous expression returns false. Otherwise partial_regex_ may
// not be properly initialized can may cause trouble when it's
// freed.
//
// Some implementation of POSIX regex (e.g. on at least some
// versions of Cygwin) doesn't accept the empty string as a valid
// regex. We change it to an equivalent form "()" to be safe.
if (is_valid_) {
const char* const partial_regex = (*regex == '\0') ? "()" : regex;
is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
}
EXPECT_TRUE(is_valid_)
<< "Regular expression \"" << regex
<< "\" is not a valid POSIX Extended regular expression.";
delete[] full_pattern;
}
#elif GTEST_USES_SIMPLE_RE
// Returns true iff ch appears anywhere in str (excluding the
// terminating '\0' character).
bool IsInSet(char ch, const char* str) {
return ch != '\0' && strchr(str, ch) != NULL;
}
// Returns true iff ch belongs to the given classification. Unlike
// similar functions in <ctype.h>, these aren't affected by the
// current locale.
bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
bool IsAsciiPunct(char ch) {
return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~");
}
bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); }
bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); }
bool IsAsciiWordChar(char ch) {
return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
('0' <= ch && ch <= '9') || ch == '_';
}
// Returns true iff "\\c" is a supported escape sequence.
bool IsValidEscape(char c) {
return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
}
// Returns true iff the given atom (specified by escaped and pattern)
// matches ch. The result is undefined if the atom is invalid.
bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
if (escaped) { // "\\p" where p is pattern_char.
switch (pattern_char) {
case 'd': return IsAsciiDigit(ch);
case 'D': return !IsAsciiDigit(ch);
case 'f': return ch == '\f';
case 'n': return ch == '\n';
case 'r': return ch == '\r';
case 's': return IsAsciiWhiteSpace(ch);
case 'S': return !IsAsciiWhiteSpace(ch);
case 't': return ch == '\t';
case 'v': return ch == '\v';
case 'w': return IsAsciiWordChar(ch);
case 'W': return !IsAsciiWordChar(ch);
}
return IsAsciiPunct(pattern_char) && pattern_char == ch;
}
return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
}
// Helper function used by ValidateRegex() to format error messages.
String FormatRegexSyntaxError(const char* regex, int index) {
return (Message() << "Syntax error at index " << index
<< " in simple regular expression \"" << regex << "\": ").GetString();
}
// Generates non-fatal failures and returns false if regex is invalid;
// otherwise returns true.
bool ValidateRegex(const char* regex) {
if (regex == NULL) {
// TODO(wan@google.com): fix the source file location in the
// assertion failures to match where the regex is used in user
// code.
ADD_FAILURE() << "NULL is not a valid simple regular expression.";
return false;
}
bool is_valid = true;
// True iff ?, *, or + can follow the previous atom.
bool prev_repeatable = false;
for (int i = 0; regex[i]; i++) {
if (regex[i] == '\\') { // An escape sequence
i++;
if (regex[i] == '\0') {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
<< "'\\' cannot appear at the end.";
return false;
}
if (!IsValidEscape(regex[i])) {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
<< "invalid escape sequence \"\\" << regex[i] << "\".";
is_valid = false;
}
prev_repeatable = true;
} else { // Not an escape sequence.
const char ch = regex[i];
if (ch == '^' && i > 0) {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
<< "'^' can only appear at the beginning.";
is_valid = false;
} else if (ch == '$' && regex[i + 1] != '\0') {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
<< "'$' can only appear at the end.";
is_valid = false;
} else if (IsInSet(ch, "()[]{}|")) {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
<< "'" << ch << "' is unsupported.";
is_valid = false;
} else if (IsRepeat(ch) && !prev_repeatable) {
ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
<< "'" << ch << "' can only follow a repeatable token.";
is_valid = false;
}
prev_repeatable = !IsInSet(ch, "^$?*+");
}
}
return is_valid;
}
// Matches a repeated regex atom followed by a valid simple regular
// expression. The regex atom is defined as c if escaped is false,
// or \c otherwise. repeat is the repetition meta character (?, *,
// or +). The behavior is undefined if str contains too many
// characters to be indexable by size_t, in which case the test will
// probably time out anyway. We are fine with this limitation as
// std::string has it too.
bool MatchRepetitionAndRegexAtHead(
bool escaped, char c, char repeat, const char* regex,
const char* str) {
const size_t min_count = (repeat == '+') ? 1 : 0;
const size_t max_count = (repeat == '?') ? 1 :
static_cast<size_t>(-1) - 1;
// We cannot call numeric_limits::max() as it conflicts with the
// max() macro on Windows.
for (size_t i = 0; i <= max_count; ++i) {
// We know that the atom matches each of the first i characters in str.
if (i >= min_count && MatchRegexAtHead(regex, str + i)) {
// We have enough matches at the head, and the tail matches too.
// Since we only care about *whether* the pattern matches str
// (as opposed to *how* it matches), there is no need to find a
// greedy match.
return true;
}
if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i]))
return false;
}
return false;
}
// Returns true iff regex matches a prefix of str. regex must be a
// valid simple regular expression and not start with "^", or the
// result is undefined.
bool MatchRegexAtHead(const char* regex, const char* str) {
if (*regex == '\0') // An empty regex matches a prefix of anything.
return true;
// "$" only matches the end of a string. Note that regex being
// valid guarantees that there's nothing after "$" in it.
if (*regex == '$')
return *str == '\0';
// Is the first thing in regex an escape sequence?
const bool escaped = *regex == '\\';
if (escaped)
++regex;
if (IsRepeat(regex[1])) {
// MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so
// here's an indirect recursion. It terminates as the regex gets
// shorter in each recursion.
return MatchRepetitionAndRegexAtHead(
escaped, regex[0], regex[1], regex + 2, str);
} else {
// regex isn't empty, isn't "$", and doesn't start with a
// repetition. We match the first atom of regex with the first
// character of str and recurse.
return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) &&
MatchRegexAtHead(regex + 1, str + 1);
}
}
// Returns true iff regex matches any substring of str. regex must be
// a valid simple regular expression, or the result is undefined.
//
// The algorithm is recursive, but the recursion depth doesn't exceed
// the regex length, so we won't need to worry about running out of
// stack space normally. In rare cases the time complexity can be
// exponential with respect to the regex length + the string length,
// but usually it's must faster (often close to linear).
bool MatchRegexAnywhere(const char* regex, const char* str) {
if (regex == NULL || str == NULL)
return false;
if (*regex == '^')
return MatchRegexAtHead(regex + 1, str);
// A successful match can be anywhere in str.
do {
if (MatchRegexAtHead(regex, str))
return true;
} while (*str++ != '\0');
return false;
}
// Implements the RE class.
RE::~RE() {
free(const_cast<char*>(pattern_));
free(const_cast<char*>(full_pattern_));
}
// Returns true iff regular expression re matches the entire str.
bool RE::FullMatch(const char* str, const RE& re) {
return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
}
// Returns true iff regular expression re matches a substring of str
// (including str itself).
bool RE::PartialMatch(const char* str, const RE& re) {
return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
}
// Initializes an RE from its string representation.
void RE::Init(const char* regex) {
pattern_ = full_pattern_ = NULL;
if (regex != NULL) {
pattern_ = posix::StrDup(regex);
}
is_valid_ = ValidateRegex(regex);
if (!is_valid_) {
// No need to calculate the full pattern when the regex is invalid.
return;
}
const size_t len = strlen(regex);
// Reserves enough bytes to hold the regular expression used for a
// full match: we need space to prepend a '^', append a '$', and
// terminate the string with '\0'.
char* buffer = static_cast<char*>(malloc(len + 3));
full_pattern_ = buffer;
if (*regex != '^')
*buffer++ = '^'; // Makes sure full_pattern_ starts with '^'.
// We don't use snprintf or strncpy, as they trigger a warning when
// compiled with VC++ 8.0.
memcpy(buffer, regex, len);
buffer += len;
if (len == 0 || regex[len - 1] != '$')
*buffer++ = '$'; // Makes sure full_pattern_ ends with '$'.
*buffer = '\0';
}
#endif // GTEST_USES_POSIX_RE
const char kUnknownFile[] = "unknown file";
// Formats a source file path and a line number as they would appear
// in an error message from the compiler used to compile this code.
GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
const char* const file_name = file == NULL ? kUnknownFile : file;
if (line < 0) {
return String::Format("%s:", file_name).c_str();
}
#ifdef _MSC_VER
return String::Format("%s(%d):", file_name, line).c_str();
#else
return String::Format("%s:%d:", file_name, line).c_str();
#endif // _MSC_VER
}
// Formats a file location for compiler-independent XML output.
// Although this function is not platform dependent, we put it next to
// FormatFileLocation in order to contrast the two functions.
// Note that FormatCompilerIndependentFileLocation() does NOT append colon
// to the file location it produces, unlike FormatFileLocation().
GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(
const char* file, int line) {
const char* const file_name = file == NULL ? kUnknownFile : file;
if (line < 0)
return file_name;
else
return String::Format("%s:%d", file_name, line).c_str();
}
GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)
: severity_(severity) {
const char* const marker =
severity == GTEST_INFO ? "[ INFO ]" :
severity == GTEST_WARNING ? "[WARNING]" :
severity == GTEST_ERROR ? "[ ERROR ]" : "[ FATAL ]";
GetStream() << ::std::endl << marker << " "
<< FormatFileLocation(file, line).c_str() << ": ";
}
// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
GTestLog::~GTestLog() {
GetStream() << ::std::endl;
if (severity_ == GTEST_FATAL) {
fflush(stderr);
posix::Abort();
}
}
// Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close)
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4996)
#endif // _MSC_VER
#if GTEST_HAS_STREAM_REDIRECTION
// Object that captures an output stream (stdout/stderr).
class CapturedStream {
public:
// The ctor redirects the stream to a temporary file.
CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
# if GTEST_OS_WINDOWS
char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT
char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT
::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);
const UINT success = ::GetTempFileNameA(temp_dir_path,
"gtest_redir",
0, // Generate unique file name.
temp_file_path);
GTEST_CHECK_(success != 0)
<< "Unable to create a temporary file in " << temp_dir_path;
const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "
<< temp_file_path;
filename_ = temp_file_path;
# else
// There's no guarantee that a test has write access to the
// current directory, so we create the temporary file in the /tmp
// directory instead.
char name_template[] = "/tmp/captured_stream.XXXXXX";
const int captured_fd = mkstemp(name_template);
filename_ = name_template;
# endif // GTEST_OS_WINDOWS
fflush(NULL);
dup2(captured_fd, fd_);
close(captured_fd);
}
~CapturedStream() {
remove(filename_.c_str());
}
String GetCapturedString() {
if (uncaptured_fd_ != -1) {
// Restores the original stream.
fflush(NULL);
dup2(uncaptured_fd_, fd_);
close(uncaptured_fd_);
uncaptured_fd_ = -1;
}
FILE* const file = posix::FOpen(filename_.c_str(), "r");
const String content = ReadEntireFile(file);
posix::FClose(file);
return content;
}
private:
// Reads the entire content of a file as a String.
static String ReadEntireFile(FILE* file);
// Returns the size (in bytes) of a file.
static size_t GetFileSize(FILE* file);
const int fd_; // A stream to capture.
int uncaptured_fd_;
// Name of the temporary file holding the stderr output.
::std::string filename_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
};
// Returns the size (in bytes) of a file.
size_t CapturedStream::GetFileSize(FILE* file) {
fseek(file, 0, SEEK_END);
return static_cast<size_t>(ftell(file));
}
// Reads the entire content of a file as a string.
String CapturedStream::ReadEntireFile(FILE* file) {
const size_t file_size = GetFileSize(file);
char* const buffer = new char[file_size];
size_t bytes_last_read = 0; // # of bytes read in the last fread()
size_t bytes_read = 0; // # of bytes read so far
fseek(file, 0, SEEK_SET);
// Keeps reading the file until we cannot read further or the
// pre-determined file size is reached.
do {
bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
bytes_read += bytes_last_read;
} while (bytes_last_read > 0 && bytes_read < file_size);
const String content(buffer, bytes_read);
delete[] buffer;
return content;
}
# ifdef _MSC_VER
# pragma warning(pop)
# endif // _MSC_VER
static CapturedStream* g_captured_stderr = NULL;
static CapturedStream* g_captured_stdout = NULL;
// Starts capturing an output stream (stdout/stderr).
void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
if (*stream != NULL) {
GTEST_LOG_(FATAL) << "Only one " << stream_name
<< " capturer can exist at a time.";
}
*stream = new CapturedStream(fd);
}
// Stops capturing the output stream and returns the captured string.
String GetCapturedStream(CapturedStream** captured_stream) {
const String content = (*captured_stream)->GetCapturedString();
delete *captured_stream;
*captured_stream = NULL;
return content;
}
// Starts capturing stdout.
void CaptureStdout() {
CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout);
}
// Starts capturing stderr.
void CaptureStderr() {
CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr);
}
// Stops capturing stdout and returns the captured string.
String GetCapturedStdout() { return GetCapturedStream(&g_captured_stdout); }
// Stops capturing stderr and returns the captured string.
String GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); }
#endif // GTEST_HAS_STREAM_REDIRECTION
#if GTEST_HAS_DEATH_TEST
// A copy of all command line arguments. Set by InitGoogleTest().
::std::vector<String> g_argvs;
// Returns the command line as a vector of strings.
const ::std::vector<String>& GetArgvs() { return g_argvs; }
#endif // GTEST_HAS_DEATH_TEST
#if GTEST_OS_WINDOWS_MOBILE
namespace posix {
void Abort() {
DebugBreak();
TerminateProcess(GetCurrentProcess(), 1);
}
} // namespace posix
#endif // GTEST_OS_WINDOWS_MOBILE
// Returns the name of the environment variable corresponding to the
// given flag. For example, FlagToEnvVar("foo") will return
// "GTEST_FOO" in the open-source version.
static String FlagToEnvVar(const char* flag) {
const String full_flag =
(Message() << GTEST_FLAG_PREFIX_ << flag).GetString();
Message env_var;
for (size_t i = 0; i != full_flag.length(); i++) {
env_var << ToUpper(full_flag.c_str()[i]);
}
return env_var.GetString();
}
// Parses 'str' for a 32-bit signed integer. If successful, writes
// the result to *value and returns true; otherwise leaves *value
// unchanged and returns false.
bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
// Parses the environment variable as a decimal integer.
char* end = NULL;
const long long_value = strtol(str, &end, 10); // NOLINT
// Has strtol() consumed all characters in the string?
if (*end != '\0') {
// No - an invalid character was encountered.
Message msg;
msg << "WARNING: " << src_text
<< " is expected to be a 32-bit integer, but actually"
<< " has value \"" << str << "\".\n";
printf("%s", msg.GetString().c_str());
fflush(stdout);
return false;
}
// Is the parsed value in the range of an Int32?
const Int32 result = static_cast<Int32>(long_value);
if (long_value == LONG_MAX || long_value == LONG_MIN ||
// The parsed value overflows as a long. (strtol() returns
// LONG_MAX or LONG_MIN when the input overflows.)
result != long_value
// The parsed value overflows as an Int32.
) {
Message msg;
msg << "WARNING: " << src_text
<< " is expected to be a 32-bit integer, but actually"
<< " has value " << str << ", which overflows.\n";
printf("%s", msg.GetString().c_str());
fflush(stdout);
return false;
}
*value = result;
return true;
}
// Reads and returns the Boolean environment variable corresponding to
// the given flag; if it's not set, returns default_value.
//
// The value is considered true iff it's not "0".
bool BoolFromGTestEnv(const char* flag, bool default_value) {
const String env_var = FlagToEnvVar(flag);
const char* const string_value = posix::GetEnv(env_var.c_str());
return string_value == NULL ?
default_value : strcmp(string_value, "0") != 0;
}
// Reads and returns a 32-bit integer stored in the environment
// variable corresponding to the given flag; if it isn't set or
// doesn't represent a valid 32-bit integer, returns default_value.
Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
const String env_var = FlagToEnvVar(flag);
const char* const string_value = posix::GetEnv(env_var.c_str());
if (string_value == NULL) {
// The environment variable is not set.
return default_value;
}
Int32 result = default_value;
if (!ParseInt32(Message() << "Environment variable " << env_var,
string_value, &result)) {
printf("The default value %s is used.\n",
(Message() << default_value).GetString().c_str());
fflush(stdout);
return default_value;
}
return result;
}
// Reads and returns the string environment variable corresponding to
// the given flag; if it's not set, returns default_value.
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
const String env_var = FlagToEnvVar(flag);
const char* const value = posix::GetEnv(env_var.c_str());
return value == NULL ? default_value : value;
}
} // namespace internal
} // namespace testing

View File

@ -1,356 +0,0 @@
// Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Test - The Google C++ Testing Framework
//
// This file implements a universal value printer that can print a
// value of any type T:
//
// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
//
// It uses the << operator when possible, and prints the bytes in the
// object otherwise. A user can override its behavior for a class
// type Foo by defining either operator<<(::std::ostream&, const Foo&)
// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that
// defines Foo.
#include "gtest/gtest-printers.h"
#include <ctype.h>
#include <stdio.h>
#include <ostream> // NOLINT
#include <string>
#include "gtest/internal/gtest-port.h"
namespace testing {
namespace {
using ::std::ostream;
#if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s.
# define snprintf _snprintf
#elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf.
# define snprintf _snprintf_s
#elif _MSC_VER
# define snprintf _snprintf
#endif // GTEST_OS_WINDOWS_MOBILE
// Prints a segment of bytes in the given object.
void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
size_t count, ostream* os) {
char text[5] = "";
for (size_t i = 0; i != count; i++) {
const size_t j = start + i;
if (i != 0) {
// Organizes the bytes into groups of 2 for easy parsing by
// human.
if ((j % 2) == 0)
*os << ' ';
else
*os << '-';
}
snprintf(text, sizeof(text), "%02X", obj_bytes[j]);
*os << text;
}
}
// Prints the bytes in the given value to the given ostream.
void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
ostream* os) {
// Tells the user how big the object is.
*os << count << "-byte object <";
const size_t kThreshold = 132;
const size_t kChunkSize = 64;
// If the object size is bigger than kThreshold, we'll have to omit
// some details by printing only the first and the last kChunkSize
// bytes.
// TODO(wan): let the user control the threshold using a flag.
if (count < kThreshold) {
PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
} else {
PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);
*os << " ... ";
// Rounds up to 2-byte boundary.
const size_t resume_pos = (count - kChunkSize + 1)/2*2;
PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);
}
*os << ">";
}
} // namespace
namespace internal2 {
// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
// given object. The delegation simplifies the implementation, which
// uses the << operator and thus is easier done outside of the
// ::testing::internal namespace, which contains a << operator that
// sometimes conflicts with the one in STL.
void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
ostream* os) {
PrintBytesInObjectToImpl(obj_bytes, count, os);
}
} // namespace internal2
namespace internal {
// Depending on the value of a char (or wchar_t), we print it in one
// of three formats:
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
// - as a hexidecimal escape sequence (e.g. '\x7F'), or
// - as a special escape sequence (e.g. '\r', '\n').
enum CharFormat {
kAsIs,
kHexEscape,
kSpecialEscape
};
// Returns true if c is a printable ASCII character. We test the
// value of c directly instead of calling isprint(), which is buggy on
// Windows Mobile.
inline bool IsPrintableAscii(wchar_t c) {
return 0x20 <= c && c <= 0x7E;
}
// Prints a wide or narrow char c as a character literal without the
// quotes, escaping it when necessary; returns how c was formatted.
// The template argument UnsignedChar is the unsigned version of Char,
// which is the type of c.
template <typename UnsignedChar, typename Char>
static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
switch (static_cast<wchar_t>(c)) {
case L'\0':
*os << "\\0";
break;
case L'\'':
*os << "\\'";
break;
case L'\\':
*os << "\\\\";
break;
case L'\a':
*os << "\\a";
break;
case L'\b':
*os << "\\b";
break;
case L'\f':
*os << "\\f";
break;
case L'\n':
*os << "\\n";
break;
case L'\r':
*os << "\\r";
break;
case L'\t':
*os << "\\t";
break;
case L'\v':
*os << "\\v";
break;
default:
if (IsPrintableAscii(c)) {
*os << static_cast<char>(c);
return kAsIs;
} else {
*os << String::Format("\\x%X", static_cast<UnsignedChar>(c));
return kHexEscape;
}
}
return kSpecialEscape;
}
// Prints a char c as if it's part of a string literal, escaping it when
// necessary; returns how c was formatted.
static CharFormat PrintAsWideStringLiteralTo(wchar_t c, ostream* os) {
switch (c) {
case L'\'':
*os << "'";
return kAsIs;
case L'"':
*os << "\\\"";
return kSpecialEscape;
default:
return PrintAsCharLiteralTo<wchar_t>(c, os);
}
}
// Prints a char c as if it's part of a string literal, escaping it when
// necessary; returns how c was formatted.
static CharFormat PrintAsNarrowStringLiteralTo(char c, ostream* os) {
return PrintAsWideStringLiteralTo(static_cast<unsigned char>(c), os);
}
// Prints a wide or narrow character c and its code. '\0' is printed
// as "'\\0'", other unprintable characters are also properly escaped
// using the standard C++ escape sequence. The template argument
// UnsignedChar is the unsigned version of Char, which is the type of c.
template <typename UnsignedChar, typename Char>
void PrintCharAndCodeTo(Char c, ostream* os) {
// First, print c as a literal in the most readable form we can find.
*os << ((sizeof(c) > 1) ? "L'" : "'");
const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
*os << "'";
// To aid user debugging, we also print c's code in decimal, unless
// it's 0 (in which case c was printed as '\\0', making the code
// obvious).
if (c == 0)
return;
*os << " (" << String::Format("%d", c).c_str();
// For more convenience, we print c's code again in hexidecimal,
// unless c was already printed in the form '\x##' or the code is in
// [1, 9].
if (format == kHexEscape || (1 <= c && c <= 9)) {
// Do nothing.
} else {
*os << String::Format(", 0x%X",
static_cast<UnsignedChar>(c)).c_str();
}
*os << ")";
}
void PrintTo(unsigned char c, ::std::ostream* os) {
PrintCharAndCodeTo<unsigned char>(c, os);
}
void PrintTo(signed char c, ::std::ostream* os) {
PrintCharAndCodeTo<unsigned char>(c, os);
}
// Prints a wchar_t as a symbol if it is printable or as its internal
// code otherwise and also as its code. L'\0' is printed as "L'\\0'".
void PrintTo(wchar_t wc, ostream* os) {
PrintCharAndCodeTo<wchar_t>(wc, os);
}
// Prints the given array of characters to the ostream.
// The array starts at *begin, the length is len, it may include '\0' characters
// and may not be null-terminated.
static void PrintCharsAsStringTo(const char* begin, size_t len, ostream* os) {
*os << "\"";
bool is_previous_hex = false;
for (size_t index = 0; index < len; ++index) {
const char cur = begin[index];
if (is_previous_hex && IsXDigit(cur)) {
// Previous character is of '\x..' form and this character can be
// interpreted as another hexadecimal digit in its number. Break string to
// disambiguate.
*os << "\" \"";
}
is_previous_hex = PrintAsNarrowStringLiteralTo(cur, os) == kHexEscape;
}
*os << "\"";
}
// Prints a (const) char array of 'len' elements, starting at address 'begin'.
void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
PrintCharsAsStringTo(begin, len, os);
}
// Prints the given array of wide characters to the ostream.
// The array starts at *begin, the length is len, it may include L'\0'
// characters and may not be null-terminated.
static void PrintWideCharsAsStringTo(const wchar_t* begin, size_t len,
ostream* os) {
*os << "L\"";
bool is_previous_hex = false;
for (size_t index = 0; index < len; ++index) {
const wchar_t cur = begin[index];
if (is_previous_hex && isascii(cur) && IsXDigit(static_cast<char>(cur))) {
// Previous character is of '\x..' form and this character can be
// interpreted as another hexadecimal digit in its number. Break string to
// disambiguate.
*os << "\" L\"";
}
is_previous_hex = PrintAsWideStringLiteralTo(cur, os) == kHexEscape;
}
*os << "\"";
}
// Prints the given C string to the ostream.
void PrintTo(const char* s, ostream* os) {
if (s == NULL) {
*os << "NULL";
} else {
*os << ImplicitCast_<const void*>(s) << " pointing to ";
PrintCharsAsStringTo(s, strlen(s), os);
}
}
// MSVC compiler can be configured to define whar_t as a typedef
// of unsigned short. Defining an overload for const wchar_t* in that case
// would cause pointers to unsigned shorts be printed as wide strings,
// possibly accessing more memory than intended and causing invalid
// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
// wchar_t is implemented as a native type.
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
// Prints the given wide C string to the ostream.
void PrintTo(const wchar_t* s, ostream* os) {
if (s == NULL) {
*os << "NULL";
} else {
*os << ImplicitCast_<const void*>(s) << " pointing to ";
PrintWideCharsAsStringTo(s, wcslen(s), os);
}
}
#endif // wchar_t is native
// Prints a ::string object.
#if GTEST_HAS_GLOBAL_STRING
void PrintStringTo(const ::string& s, ostream* os) {
PrintCharsAsStringTo(s.data(), s.size(), os);
}
#endif // GTEST_HAS_GLOBAL_STRING
void PrintStringTo(const ::std::string& s, ostream* os) {
PrintCharsAsStringTo(s.data(), s.size(), os);
}
// Prints a ::wstring object.
#if GTEST_HAS_GLOBAL_WSTRING
void PrintWideStringTo(const ::wstring& s, ostream* os) {
PrintWideCharsAsStringTo(s.data(), s.size(), os);
}
#endif // GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_WSTRING
void PrintWideStringTo(const ::std::wstring& s, ostream* os) {
PrintWideCharsAsStringTo(s.data(), s.size(), os);
}
#endif // GTEST_HAS_STD_WSTRING
} // namespace internal
} // namespace testing

View File

@ -1,110 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
// The Google C++ Testing Framework (Google Test)
#include "gtest/gtest-test-part.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing {
using internal::GetUnitTestImpl;
// Gets the summary of the failure message by omitting the stack trace
// in it.
internal::String TestPartResult::ExtractSummary(const char* message) {
const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
return stack_trace == NULL ? internal::String(message) :
internal::String(message, stack_trace - message);
}
// Prints a TestPartResult object.
std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
return os
<< result.file_name() << ":" << result.line_number() << ": "
<< (result.type() == TestPartResult::kSuccess ? "Success" :
result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
"Non-fatal failure") << ":\n"
<< result.message() << std::endl;
}
// Appends a TestPartResult to the array.
void TestPartResultArray::Append(const TestPartResult& result) {
array_.push_back(result);
}
// Returns the TestPartResult at the given index (0-based).
const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
if (index < 0 || index >= size()) {
printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
internal::posix::Abort();
}
return array_[index];
}
// Returns the number of TestPartResult objects in the array.
int TestPartResultArray::size() const {
return static_cast<int>(array_.size());
}
namespace internal {
HasNewFatalFailureHelper::HasNewFatalFailureHelper()
: has_new_fatal_failure_(false),
original_reporter_(GetUnitTestImpl()->
GetTestPartResultReporterForCurrentThread()) {
GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);
}
HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {
GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(
original_reporter_);
}
void HasNewFatalFailureHelper::ReportTestPartResult(
const TestPartResult& result) {
if (result.fatally_failed())
has_new_fatal_failure_ = true;
original_reporter_->ReportTestPartResult(result);
}
} // namespace internal
} // namespace testing

View File

@ -1,110 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest-typed-test.h"
#include "gtest/gtest.h"
namespace testing {
namespace internal {
#if GTEST_HAS_TYPED_TEST_P
// Skips to the first non-space char in str. Returns an empty string if str
// contains only whitespace characters.
static const char* SkipSpaces(const char* str) {
while (IsSpace(*str))
str++;
return str;
}
// Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or
// aborts the program otherwise.
const char* TypedTestCasePState::VerifyRegisteredTestNames(
const char* file, int line, const char* registered_tests) {
typedef ::std::set<const char*>::const_iterator DefinedTestIter;
registered_ = true;
// Skip initial whitespace in registered_tests since some
// preprocessors prefix stringizied literals with whitespace.
registered_tests = SkipSpaces(registered_tests);
Message errors;
::std::set<String> tests;
for (const char* names = registered_tests; names != NULL;
names = SkipComma(names)) {
const String name = GetPrefixUntilComma(names);
if (tests.count(name) != 0) {
errors << "Test " << name << " is listed more than once.\n";
continue;
}
bool found = false;
for (DefinedTestIter it = defined_test_names_.begin();
it != defined_test_names_.end();
++it) {
if (name == *it) {
found = true;
break;
}
}
if (found) {
tests.insert(name);
} else {
errors << "No test named " << name
<< " can be found in this test case.\n";
}
}
for (DefinedTestIter it = defined_test_names_.begin();
it != defined_test_names_.end();
++it) {
if (tests.count(*it) == 0) {
errors << "You forgot to list test " << *it << ".\n";
}
}
const String& errors_str = errors.GetString();
if (errors_str != "") {
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
errors_str.c_str());
fflush(stderr);
posix::Abort();
}
return registered_tests;
}
#endif // GTEST_HAS_TYPED_TEST_P
} // namespace internal
} // namespace testing

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +0,0 @@
// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include "gtest/gtest.h"
GTEST_API_ int main(int argc, char **argv) {
std::cout << "Running main() from gtest_main.cc\n";
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,93 +0,0 @@
// Copyright 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests that verify interaction of exceptions and death tests.
#include "gtest/gtest-death-test.h"
#include "gtest/gtest.h"
#if GTEST_HAS_DEATH_TEST
# if GTEST_HAS_SEH
# include <windows.h> // For RaiseException().
# endif
# include "gtest/gtest-spi.h"
# if GTEST_HAS_EXCEPTIONS
# include <exception> // For std::exception.
// Tests that death tests report thrown exceptions as failures and that the
// exceptions do not escape death test macros.
TEST(CxxExceptionDeathTest, ExceptionIsFailure) {
try {
EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw 1, ""), "threw an exception");
} catch (...) { // NOLINT
FAIL() << "An exception escaped a death test macro invocation "
<< "with catch_exceptions "
<< (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
}
}
class TestException : public std::exception {
public:
virtual const char* what() const throw() { return "exceptional message"; }
};
TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
// Verifies that the exception message is quoted in the failure text.
EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
"exceptional message");
// Verifies that the location is mentioned in the failure text.
EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
"gtest-death-test_ex_test.cc");
}
# endif // GTEST_HAS_EXCEPTIONS
# if GTEST_HAS_SEH
// Tests that enabling interception of SEH exceptions with the
// catch_exceptions flag does not interfere with SEH exceptions being
// treated as death by death tests.
TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), "")
<< "with catch_exceptions "
<< (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
}
# endif
#endif // GTEST_HAS_DEATH_TEST
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
testing::GTEST_FLAG(catch_exceptions) = GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0;
return RUN_ALL_TESTS();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,696 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
// Google Test filepath utilities
//
// This file tests classes and functions used internally by
// Google Test. They are subject to change without notice.
//
// This file is #included from gtest_unittest.cc, to avoid changing
// build or make-files for some existing Google Test clients. Do not
// #include this file anywhere else!
#include "gtest/internal/gtest-filepath.h"
#include "gtest/gtest.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> // NOLINT
#elif GTEST_OS_WINDOWS
# include <direct.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MOBILE
namespace testing {
namespace internal {
namespace {
#if GTEST_OS_WINDOWS_MOBILE
// TODO(wan@google.com): Move these to the POSIX adapter section in
// gtest-port.h.
// Windows CE doesn't have the remove C function.
int remove(const char* path) {
LPCWSTR wpath = String::AnsiToUtf16(path);
int ret = DeleteFile(wpath) ? 0 : -1;
delete [] wpath;
return ret;
}
// Windows CE doesn't have the _rmdir C function.
int _rmdir(const char* path) {
FilePath filepath(path);
LPCWSTR wpath = String::AnsiToUtf16(
filepath.RemoveTrailingPathSeparator().c_str());
int ret = RemoveDirectory(wpath) ? 0 : -1;
delete [] wpath;
return ret;
}
#else
TEST(GetCurrentDirTest, ReturnsCurrentDir) {
const FilePath original_dir = FilePath::GetCurrentDir();
EXPECT_FALSE(original_dir.IsEmpty());
posix::ChDir(GTEST_PATH_SEP_);
const FilePath cwd = FilePath::GetCurrentDir();
posix::ChDir(original_dir.c_str());
# if GTEST_OS_WINDOWS
// Skips the ":".
const char* const cwd_without_drive = strchr(cwd.c_str(), ':');
ASSERT_TRUE(cwd_without_drive != NULL);
EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);
# else
EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str());
# endif
}
#endif // GTEST_OS_WINDOWS_MOBILE
TEST(IsEmptyTest, ReturnsTrueForEmptyPath) {
EXPECT_TRUE(FilePath("").IsEmpty());
EXPECT_TRUE(FilePath(NULL).IsEmpty());
}
TEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) {
EXPECT_FALSE(FilePath("a").IsEmpty());
EXPECT_FALSE(FilePath(".").IsEmpty());
EXPECT_FALSE(FilePath("a/b").IsEmpty());
EXPECT_FALSE(FilePath("a\\b\\").IsEmpty());
}
// RemoveDirectoryName "" -> ""
TEST(RemoveDirectoryNameTest, WhenEmptyName) {
EXPECT_STREQ("", FilePath("").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName "afile" -> "afile"
TEST(RemoveDirectoryNameTest, ButNoDirectory) {
EXPECT_STREQ("afile",
FilePath("afile").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName "/afile" -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) {
EXPECT_STREQ("afile",
FilePath(GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName "adir/" -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) {
EXPECT_STREQ("",
FilePath("adir" GTEST_PATH_SEP_).RemoveDirectoryName().c_str());
}
// RemoveDirectoryName "adir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileName) {
EXPECT_STREQ("afile",
FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName "adir/subdir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
EXPECT_STREQ("afile",
FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
.RemoveDirectoryName().c_str());
}
#if GTEST_HAS_ALT_PATH_SEP_
// Tests that RemoveDirectoryName() works with the alternate separator
// on Windows.
// RemoveDirectoryName("/afile") -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
FilePath("/afile").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName("adir/") -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) {
EXPECT_STREQ("",
FilePath("adir/").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName("adir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
FilePath("adir/afile").RemoveDirectoryName().c_str());
}
// RemoveDirectoryName("adir/subdir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
FilePath("adir/subdir/afile").RemoveDirectoryName().c_str());
}
#endif
// RemoveFileName "" -> "./"
TEST(RemoveFileNameTest, EmptyName) {
#if GTEST_OS_WINDOWS_MOBILE
// On Windows CE, we use the root as the current directory.
EXPECT_STREQ(GTEST_PATH_SEP_,
FilePath("").RemoveFileName().c_str());
#else
EXPECT_STREQ("." GTEST_PATH_SEP_,
FilePath("").RemoveFileName().c_str());
#endif
}
// RemoveFileName "adir/" -> "adir/"
TEST(RemoveFileNameTest, ButNoFile) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir" GTEST_PATH_SEP_).RemoveFileName().c_str());
}
// RemoveFileName "adir/afile" -> "adir/"
TEST(RemoveFileNameTest, GivesDirName) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir" GTEST_PATH_SEP_ "afile")
.RemoveFileName().c_str());
}
// RemoveFileName "adir/subdir/afile" -> "adir/subdir/"
TEST(RemoveFileNameTest, GivesDirAndSubDirName) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
.RemoveFileName().c_str());
}
// RemoveFileName "/afile" -> "/"
TEST(RemoveFileNameTest, GivesRootDir) {
EXPECT_STREQ(GTEST_PATH_SEP_,
FilePath(GTEST_PATH_SEP_ "afile").RemoveFileName().c_str());
}
#if GTEST_HAS_ALT_PATH_SEP_
// Tests that RemoveFileName() works with the alternate separator on
// Windows.
// RemoveFileName("adir/") -> "adir/"
TEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir/").RemoveFileName().c_str());
}
// RemoveFileName("adir/afile") -> "adir/"
TEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir/afile").RemoveFileName().c_str());
}
// RemoveFileName("adir/subdir/afile") -> "adir/subdir/"
TEST(RemoveFileNameTest, GivesDirAndSubDirNameForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
FilePath("adir/subdir/afile").RemoveFileName().c_str());
}
// RemoveFileName("/afile") -> "\"
TEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) {
EXPECT_STREQ(GTEST_PATH_SEP_,
FilePath("/afile").RemoveFileName().c_str());
}
#endif
TEST(MakeFileNameTest, GenerateWhenNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
0, "xml");
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
}
TEST(MakeFileNameTest, GenerateFileNameNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
12, "xml");
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
}
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 0, "xml");
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
}
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 12, "xml");
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
}
TEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) {
FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"),
0, "xml");
EXPECT_STREQ("bar.xml", actual.c_str());
}
TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {
FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"),
14, "xml");
EXPECT_STREQ("bar_14.xml", actual.c_str());
}
TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar.xml"));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
}
TEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar.xml"));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
}
TEST(ConcatPathsTest, Path1BeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath(""),
FilePath("bar.xml"));
EXPECT_STREQ("bar.xml", actual.c_str());
}
TEST(ConcatPathsTest, Path2BeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath(""));
EXPECT_STREQ("foo" GTEST_PATH_SEP_, actual.c_str());
}
TEST(ConcatPathsTest, BothPathBeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath(""),
FilePath(""));
EXPECT_STREQ("", actual.c_str());
}
TEST(ConcatPathsTest, Path1ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_ "bar"),
FilePath("foobar.xml"));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "foobar.xml",
actual.c_str());
}
TEST(ConcatPathsTest, Path2ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(
FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar" GTEST_PATH_SEP_ "bar.xml"));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "bar.xml",
actual.c_str());
}
TEST(ConcatPathsTest, Path2EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar" GTEST_PATH_SEP_));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_, actual.c_str());
}
// RemoveTrailingPathSeparator "" -> ""
TEST(RemoveTrailingPathSeparatorTest, EmptyString) {
EXPECT_STREQ("",
FilePath("").RemoveTrailingPathSeparator().c_str());
}
// RemoveTrailingPathSeparator "foo" -> "foo"
TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {
EXPECT_STREQ("foo",
FilePath("foo").RemoveTrailingPathSeparator().c_str());
}
// RemoveTrailingPathSeparator "foo/" -> "foo"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
EXPECT_STREQ(
"foo",
FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().c_str());
#if GTEST_HAS_ALT_PATH_SEP_
EXPECT_STREQ("foo",
FilePath("foo/").RemoveTrailingPathSeparator().c_str());
#endif
}
// RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_)
.RemoveTrailingPathSeparator().c_str());
}
// RemoveTrailingPathSeparator "foo/bar" -> "foo/bar"
TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" GTEST_PATH_SEP_ "bar")
.RemoveTrailingPathSeparator().c_str());
}
TEST(DirectoryTest, RootDirectoryExists) {
#if GTEST_OS_WINDOWS // We are on Windows.
char current_drive[_MAX_PATH]; // NOLINT
current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1);
current_drive[1] = ':';
current_drive[2] = '\\';
current_drive[3] = '\0';
EXPECT_TRUE(FilePath(current_drive).DirectoryExists());
#else
EXPECT_TRUE(FilePath("/").DirectoryExists());
#endif // GTEST_OS_WINDOWS
}
#if GTEST_OS_WINDOWS
TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
const int saved_drive_ = _getdrive();
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
for (char drive = 'Z'; drive >= 'A'; drive--)
if (_chdrive(drive - 'A' + 1) == -1) {
char non_drive[_MAX_PATH]; // NOLINT
non_drive[0] = drive;
non_drive[1] = ':';
non_drive[2] = '\\';
non_drive[3] = '\0';
EXPECT_FALSE(FilePath(non_drive).DirectoryExists());
break;
}
_chdrive(saved_drive_);
}
#endif // GTEST_OS_WINDOWS
#if !GTEST_OS_WINDOWS_MOBILE
// Windows CE _does_ consider an empty directory to exist.
TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
EXPECT_FALSE(FilePath("").DirectoryExists());
}
#endif // !GTEST_OS_WINDOWS_MOBILE
TEST(DirectoryTest, CurrentDirectoryExists) {
#if GTEST_OS_WINDOWS // We are on Windows.
# ifndef _WIN32_CE // Windows CE doesn't have a current directory.
EXPECT_TRUE(FilePath(".").DirectoryExists());
EXPECT_TRUE(FilePath(".\\").DirectoryExists());
# endif // _WIN32_CE
#else
EXPECT_TRUE(FilePath(".").DirectoryExists());
EXPECT_TRUE(FilePath("./").DirectoryExists());
#endif // GTEST_OS_WINDOWS
}
TEST(NormalizeTest, NullStringsEqualEmptyDirectory) {
EXPECT_STREQ("", FilePath(NULL).c_str());
EXPECT_STREQ("", FilePath(String(NULL)).c_str());
}
// "foo/bar" == foo//bar" == "foo///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_
GTEST_PATH_SEP_ "bar").c_str());
}
// "/bar" == //bar" == "///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) {
EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
}
// "foo/" == foo//" == "foo///"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" GTEST_PATH_SEP_).c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
}
#if GTEST_HAS_ALT_PATH_SEP_
// Tests that separators at the end of the string are normalized
// regardless of their combination (e.g. "foo\" =="foo/\" ==
// "foo\\/").
TEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo/").c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" GTEST_PATH_SEP_ "/").c_str());
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo//" GTEST_PATH_SEP_).c_str());
}
#endif
TEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) {
FilePath default_path;
FilePath non_default_path("path");
non_default_path = default_path;
EXPECT_STREQ("", non_default_path.c_str());
EXPECT_STREQ("", default_path.c_str()); // RHS var is unchanged.
}
TEST(AssignmentOperatorTest, NonDefaultAssignedToDefault) {
FilePath non_default_path("path");
FilePath default_path;
default_path = non_default_path;
EXPECT_STREQ("path", default_path.c_str());
EXPECT_STREQ("path", non_default_path.c_str()); // RHS var is unchanged.
}
TEST(AssignmentOperatorTest, ConstAssignedToNonConst) {
const FilePath const_default_path("const_path");
FilePath non_default_path("path");
non_default_path = const_default_path;
EXPECT_STREQ("const_path", non_default_path.c_str());
}
class DirectoryCreationTest : public Test {
protected:
virtual void SetUp() {
testdata_path_.Set(FilePath(String::Format("%s%s%s",
TempDir().c_str(), GetCurrentExecutableName().c_str(),
"_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_)));
testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator());
unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"),
0, "txt"));
unique_file1_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"),
1, "txt"));
remove(testdata_file_.c_str());
remove(unique_file0_.c_str());
remove(unique_file1_.c_str());
posix::RmDir(testdata_path_.c_str());
}
virtual void TearDown() {
remove(testdata_file_.c_str());
remove(unique_file0_.c_str());
remove(unique_file1_.c_str());
posix::RmDir(testdata_path_.c_str());
}
String TempDir() const {
#if GTEST_OS_WINDOWS_MOBILE
return String("\\temp\\");
#elif GTEST_OS_WINDOWS
const char* temp_dir = posix::GetEnv("TEMP");
if (temp_dir == NULL || temp_dir[0] == '\0')
return String("\\temp\\");
else if (String(temp_dir).EndsWith("\\"))
return String(temp_dir);
else
return String::Format("%s\\", temp_dir);
#else
return String("/tmp/");
#endif // GTEST_OS_WINDOWS_MOBILE
}
void CreateTextFile(const char* filename) {
FILE* f = posix::FOpen(filename, "w");
fprintf(f, "text\n");
fclose(f);
}
// Strings representing a directory and a file, with identical paths
// except for the trailing separator character that distinquishes
// a directory named 'test' from a file named 'test'. Example names:
FilePath testdata_path_; // "/tmp/directory_creation/test/"
FilePath testdata_file_; // "/tmp/directory_creation/test"
FilePath unique_file0_; // "/tmp/directory_creation/test/unique.txt"
FilePath unique_file1_; // "/tmp/directory_creation/test/unique_1.txt"
};
TEST_F(DirectoryCreationTest, CreateDirectoriesRecursively) {
EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str();
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
EXPECT_TRUE(testdata_path_.DirectoryExists());
}
TEST_F(DirectoryCreationTest, CreateDirectoriesForAlreadyExistingPath) {
EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str();
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
// Call 'create' again... should still succeed.
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
}
TEST_F(DirectoryCreationTest, CreateDirectoriesAndUniqueFilename) {
FilePath file_path(FilePath::GenerateUniqueFileName(testdata_path_,
FilePath("unique"), "txt"));
EXPECT_STREQ(unique_file0_.c_str(), file_path.c_str());
EXPECT_FALSE(file_path.FileOrDirectoryExists()); // file not there
testdata_path_.CreateDirectoriesRecursively();
EXPECT_FALSE(file_path.FileOrDirectoryExists()); // file still not there
CreateTextFile(file_path.c_str());
EXPECT_TRUE(file_path.FileOrDirectoryExists());
FilePath file_path2(FilePath::GenerateUniqueFileName(testdata_path_,
FilePath("unique"), "txt"));
EXPECT_STREQ(unique_file1_.c_str(), file_path2.c_str());
EXPECT_FALSE(file_path2.FileOrDirectoryExists()); // file not there
CreateTextFile(file_path2.c_str());
EXPECT_TRUE(file_path2.FileOrDirectoryExists());
}
TEST_F(DirectoryCreationTest, CreateDirectoriesFail) {
// force a failure by putting a file where we will try to create a directory.
CreateTextFile(testdata_file_.c_str());
EXPECT_TRUE(testdata_file_.FileOrDirectoryExists());
EXPECT_FALSE(testdata_file_.DirectoryExists());
EXPECT_FALSE(testdata_file_.CreateDirectoriesRecursively());
}
TEST(NoDirectoryCreationTest, CreateNoDirectoriesForDefaultXmlFile) {
const FilePath test_detail_xml("test_detail.xml");
EXPECT_FALSE(test_detail_xml.CreateDirectoriesRecursively());
}
TEST(FilePathTest, DefaultConstructor) {
FilePath fp;
EXPECT_STREQ("", fp.c_str());
}
TEST(FilePathTest, CharAndCopyConstructors) {
const FilePath fp("spicy");
EXPECT_STREQ("spicy", fp.c_str());
const FilePath fp_copy(fp);
EXPECT_STREQ("spicy", fp_copy.c_str());
}
TEST(FilePathTest, StringConstructor) {
const FilePath fp(String("cider"));
EXPECT_STREQ("cider", fp.c_str());
}
TEST(FilePathTest, Set) {
const FilePath apple("apple");
FilePath mac("mac");
mac.Set(apple); // Implement Set() since overloading operator= is forbidden.
EXPECT_STREQ("apple", mac.c_str());
EXPECT_STREQ("apple", apple.c_str());
}
TEST(FilePathTest, ToString) {
const FilePath file("drink");
String str(file.ToString());
EXPECT_STREQ("drink", str.c_str());
}
TEST(FilePathTest, RemoveExtension) {
EXPECT_STREQ("app", FilePath("app.exe").RemoveExtension("exe").c_str());
EXPECT_STREQ("APP", FilePath("APP.EXE").RemoveExtension("exe").c_str());
}
TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {
EXPECT_STREQ("app", FilePath("app").RemoveExtension("exe").c_str());
}
TEST(FilePathTest, IsDirectory) {
EXPECT_FALSE(FilePath("cola").IsDirectory());
EXPECT_TRUE(FilePath("koala" GTEST_PATH_SEP_).IsDirectory());
#if GTEST_HAS_ALT_PATH_SEP_
EXPECT_TRUE(FilePath("koala/").IsDirectory());
#endif
}
TEST(FilePathTest, IsAbsolutePath) {
EXPECT_FALSE(FilePath("is" GTEST_PATH_SEP_ "relative").IsAbsolutePath());
EXPECT_FALSE(FilePath("").IsAbsolutePath());
#if GTEST_OS_WINDOWS
EXPECT_TRUE(FilePath("c:\\" GTEST_PATH_SEP_ "is_not"
GTEST_PATH_SEP_ "relative").IsAbsolutePath());
EXPECT_FALSE(FilePath("c:foo" GTEST_PATH_SEP_ "bar").IsAbsolutePath());
EXPECT_TRUE(FilePath("c:/" GTEST_PATH_SEP_ "is_not"
GTEST_PATH_SEP_ "relative").IsAbsolutePath());
#else
EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative")
.IsAbsolutePath());
#endif // GTEST_OS_WINDOWS
}
TEST(FilePathTest, IsRootDirectory) {
#if GTEST_OS_WINDOWS
EXPECT_TRUE(FilePath("a:\\").IsRootDirectory());
EXPECT_TRUE(FilePath("Z:/").IsRootDirectory());
EXPECT_TRUE(FilePath("e://").IsRootDirectory());
EXPECT_FALSE(FilePath("").IsRootDirectory());
EXPECT_FALSE(FilePath("b:").IsRootDirectory());
EXPECT_FALSE(FilePath("b:a").IsRootDirectory());
EXPECT_FALSE(FilePath("8:/").IsRootDirectory());
EXPECT_FALSE(FilePath("c|/").IsRootDirectory());
#else
EXPECT_TRUE(FilePath("/").IsRootDirectory());
EXPECT_TRUE(FilePath("//").IsRootDirectory());
EXPECT_FALSE(FilePath("").IsRootDirectory());
EXPECT_FALSE(FilePath("\\").IsRootDirectory());
EXPECT_FALSE(FilePath("/x").IsRootDirectory());
#endif
}
} // namespace
} // namespace internal
} // namespace testing

View File

@ -1,155 +0,0 @@
// Copyright 2003, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: Dan Egnor (egnor@google.com)
// Ported to Windows: Vadim Berman (vadimb@google.com)
#include "gtest/internal/gtest-linked_ptr.h"
#include <stdlib.h>
#include "gtest/gtest.h"
namespace {
using testing::Message;
using testing::internal::linked_ptr;
int num;
Message* history = NULL;
// Class which tracks allocation/deallocation
class A {
public:
A(): mynum(num++) { *history << "A" << mynum << " ctor\n"; }
virtual ~A() { *history << "A" << mynum << " dtor\n"; }
virtual void Use() { *history << "A" << mynum << " use\n"; }
protected:
int mynum;
};
// Subclass
class B : public A {
public:
B() { *history << "B" << mynum << " ctor\n"; }
~B() { *history << "B" << mynum << " dtor\n"; }
virtual void Use() { *history << "B" << mynum << " use\n"; }
};
class LinkedPtrTest : public testing::Test {
public:
LinkedPtrTest() {
num = 0;
history = new Message;
}
virtual ~LinkedPtrTest() {
delete history;
history = NULL;
}
};
TEST_F(LinkedPtrTest, GeneralTest) {
{
linked_ptr<A> a0, a1, a2;
// Use explicit function call notation here to suppress self-assign warning.
a0.operator=(a0);
a1 = a2;
ASSERT_EQ(a0.get(), static_cast<A*>(NULL));
ASSERT_EQ(a1.get(), static_cast<A*>(NULL));
ASSERT_EQ(a2.get(), static_cast<A*>(NULL));
ASSERT_TRUE(a0 == NULL);
ASSERT_TRUE(a1 == NULL);
ASSERT_TRUE(a2 == NULL);
{
linked_ptr<A> a3(new A);
a0 = a3;
ASSERT_TRUE(a0 == a3);
ASSERT_TRUE(a0 != NULL);
ASSERT_TRUE(a0.get() == a3);
ASSERT_TRUE(a0 == a3.get());
linked_ptr<A> a4(a0);
a1 = a4;
linked_ptr<A> a5(new A);
ASSERT_TRUE(a5.get() != a3);
ASSERT_TRUE(a5 != a3.get());
a2 = a5;
linked_ptr<B> b0(new B);
linked_ptr<A> a6(b0);
ASSERT_TRUE(b0 == a6);
ASSERT_TRUE(a6 == b0);
ASSERT_TRUE(b0 != NULL);
a5 = b0;
a5 = b0;
a3->Use();
a4->Use();
a5->Use();
a6->Use();
b0->Use();
(*b0).Use();
b0.get()->Use();
}
a0->Use();
a1->Use();
a2->Use();
a1 = a2;
a2.reset(new A);
a0.reset();
linked_ptr<A> a7;
}
ASSERT_STREQ(
"A0 ctor\n"
"A1 ctor\n"
"A2 ctor\n"
"B2 ctor\n"
"A0 use\n"
"A0 use\n"
"B2 use\n"
"B2 use\n"
"B2 use\n"
"B2 use\n"
"B2 use\n"
"B2 dtor\n"
"A2 dtor\n"
"A0 use\n"
"A0 use\n"
"A1 use\n"
"A3 ctor\n"
"A0 dtor\n"
"A3 dtor\n"
"A1 dtor\n",
history->GetString().c_str()
);
}
} // Unnamed namespace

View File

@ -1,313 +0,0 @@
// Copyright 2009 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// The Google C++ Testing Framework (Google Test)
//
// This file verifies Google Test event listeners receive events at the
// right times.
#include "gtest/gtest.h"
#include <vector>
using ::testing::AddGlobalTestEnvironment;
using ::testing::Environment;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestCase;
using ::testing::TestEventListener;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::UnitTest;
using ::testing::internal::String;
// Used by tests to register their events.
std::vector<String>* g_events = NULL;
namespace testing {
namespace internal {
class EventRecordingListener : public TestEventListener {
public:
EventRecordingListener(const char* name) : name_(name) {}
protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnTestProgramStart"));
}
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
int iteration) {
Message message;
message << GetFullMethodName("OnTestIterationStart")
<< "(" << iteration << ")";
g_events->push_back(message.GetString());
}
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpStart"));
}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpEnd"));
}
virtual void OnTestCaseStart(const TestCase& /*test_case*/) {
g_events->push_back(GetFullMethodName("OnTestCaseStart"));
}
virtual void OnTestStart(const TestInfo& /*test_info*/) {
g_events->push_back(GetFullMethodName("OnTestStart"));
}
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {
g_events->push_back(GetFullMethodName("OnTestPartResult"));
}
virtual void OnTestEnd(const TestInfo& /*test_info*/) {
g_events->push_back(GetFullMethodName("OnTestEnd"));
}
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {
g_events->push_back(GetFullMethodName("OnTestCaseEnd"));
}
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownStart"));
}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownEnd"));
}
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int iteration) {
Message message;
message << GetFullMethodName("OnTestIterationEnd")
<< "(" << iteration << ")";
g_events->push_back(message.GetString());
}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {
g_events->push_back(GetFullMethodName("OnTestProgramEnd"));
}
private:
String GetFullMethodName(const char* name) {
Message message;
message << name_ << "." << name;
return message.GetString();
}
String name_;
};
class EnvironmentInvocationCatcher : public Environment {
protected:
virtual void SetUp() {
g_events->push_back(String("Environment::SetUp"));
}
virtual void TearDown() {
g_events->push_back(String("Environment::TearDown"));
}
};
class ListenerTest : public Test {
protected:
static void SetUpTestCase() {
g_events->push_back(String("ListenerTest::SetUpTestCase"));
}
static void TearDownTestCase() {
g_events->push_back(String("ListenerTest::TearDownTestCase"));
}
virtual void SetUp() {
g_events->push_back(String("ListenerTest::SetUp"));
}
virtual void TearDown() {
g_events->push_back(String("ListenerTest::TearDown"));
}
};
TEST_F(ListenerTest, DoesFoo) {
// Test execution order within a test case is not guaranteed so we are not
// recording the test name.
g_events->push_back(String("ListenerTest::* Test Body"));
SUCCEED(); // Triggers OnTestPartResult.
}
TEST_F(ListenerTest, DoesBar) {
g_events->push_back(String("ListenerTest::* Test Body"));
SUCCEED(); // Triggers OnTestPartResult.
}
} // namespace internal
} // namespace testing
using ::testing::internal::EnvironmentInvocationCatcher;
using ::testing::internal::EventRecordingListener;
void VerifyResults(const std::vector<String>& data,
const char* const* expected_data,
int expected_data_size) {
const int actual_size = data.size();
// If the following assertion fails, a new entry will be appended to
// data. Hence we save data.size() first.
EXPECT_EQ(expected_data_size, actual_size);
// Compares the common prefix.
const int shorter_size = expected_data_size <= actual_size ?
expected_data_size : actual_size;
int i = 0;
for (; i < shorter_size; ++i) {
ASSERT_STREQ(expected_data[i], data[i].c_str())
<< "at position " << i;
}
// Prints extra elements in the actual data.
for (; i < actual_size; ++i) {
printf(" Actual event #%d: %s\n", i, data[i].c_str());
}
}
int main(int argc, char **argv) {
std::vector<String> events;
g_events = &events;
InitGoogleTest(&argc, argv);
UnitTest::GetInstance()->listeners().Append(
new EventRecordingListener("1st"));
UnitTest::GetInstance()->listeners().Append(
new EventRecordingListener("2nd"));
AddGlobalTestEnvironment(new EnvironmentInvocationCatcher);
GTEST_CHECK_(events.size() == 0)
<< "AddGlobalTestEnvironment should not generate any events itself.";
::testing::GTEST_FLAG(repeat) = 2;
int ret_val = RUN_ALL_TESTS();
const char* const expected_events[] = {
"1st.OnTestProgramStart",
"2nd.OnTestProgramStart",
"1st.OnTestIterationStart(0)",
"2nd.OnTestIterationStart(0)",
"1st.OnEnvironmentsSetUpStart",
"2nd.OnEnvironmentsSetUpStart",
"Environment::SetUp",
"2nd.OnEnvironmentsSetUpEnd",
"1st.OnEnvironmentsSetUpEnd",
"1st.OnTestCaseStart",
"2nd.OnTestCaseStart",
"ListenerTest::SetUpTestCase",
"1st.OnTestStart",
"2nd.OnTestStart",
"ListenerTest::SetUp",
"ListenerTest::* Test Body",
"1st.OnTestPartResult",
"2nd.OnTestPartResult",
"ListenerTest::TearDown",
"2nd.OnTestEnd",
"1st.OnTestEnd",
"1st.OnTestStart",
"2nd.OnTestStart",
"ListenerTest::SetUp",
"ListenerTest::* Test Body",
"1st.OnTestPartResult",
"2nd.OnTestPartResult",
"ListenerTest::TearDown",
"2nd.OnTestEnd",
"1st.OnTestEnd",
"ListenerTest::TearDownTestCase",
"2nd.OnTestCaseEnd",
"1st.OnTestCaseEnd",
"1st.OnEnvironmentsTearDownStart",
"2nd.OnEnvironmentsTearDownStart",
"Environment::TearDown",
"2nd.OnEnvironmentsTearDownEnd",
"1st.OnEnvironmentsTearDownEnd",
"2nd.OnTestIterationEnd(0)",
"1st.OnTestIterationEnd(0)",
"1st.OnTestIterationStart(1)",
"2nd.OnTestIterationStart(1)",
"1st.OnEnvironmentsSetUpStart",
"2nd.OnEnvironmentsSetUpStart",
"Environment::SetUp",
"2nd.OnEnvironmentsSetUpEnd",
"1st.OnEnvironmentsSetUpEnd",
"1st.OnTestCaseStart",
"2nd.OnTestCaseStart",
"ListenerTest::SetUpTestCase",
"1st.OnTestStart",
"2nd.OnTestStart",
"ListenerTest::SetUp",
"ListenerTest::* Test Body",
"1st.OnTestPartResult",
"2nd.OnTestPartResult",
"ListenerTest::TearDown",
"2nd.OnTestEnd",
"1st.OnTestEnd",
"1st.OnTestStart",
"2nd.OnTestStart",
"ListenerTest::SetUp",
"ListenerTest::* Test Body",
"1st.OnTestPartResult",
"2nd.OnTestPartResult",
"ListenerTest::TearDown",
"2nd.OnTestEnd",
"1st.OnTestEnd",
"ListenerTest::TearDownTestCase",
"2nd.OnTestCaseEnd",
"1st.OnTestCaseEnd",
"1st.OnEnvironmentsTearDownStart",
"2nd.OnEnvironmentsTearDownStart",
"Environment::TearDown",
"2nd.OnEnvironmentsTearDownEnd",
"1st.OnEnvironmentsTearDownEnd",
"2nd.OnTestIterationEnd(1)",
"1st.OnTestIterationEnd(1)",
"2nd.OnTestProgramEnd",
"1st.OnTestProgramEnd"
};
VerifyResults(events,
expected_events,
sizeof(expected_events)/sizeof(expected_events[0]));
// We need to check manually for ad hoc test failures that happen after
// RUN_ALL_TESTS finishes.
if (UnitTest::GetInstance()->Failed())
ret_val = 1;
return ret_val;
}

View File

@ -1,166 +0,0 @@
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// Tests for the Message class.
#include "gtest/gtest-message.h"
#include "gtest/gtest.h"
namespace {
using ::testing::Message;
// A helper function that turns a Message into a C string.
const char* ToCString(const Message& msg) {
static testing::internal::String result;
result = msg.GetString();
return result.c_str();
}
// Tests the testing::Message class
// Tests the default constructor.
TEST(MessageTest, DefaultConstructor) {
const Message msg;
EXPECT_STREQ("", ToCString(msg));
}
// Tests the copy constructor.
TEST(MessageTest, CopyConstructor) {
const Message msg1("Hello");
const Message msg2(msg1);
EXPECT_STREQ("Hello", ToCString(msg2));
}
// Tests constructing a Message from a C-string.
TEST(MessageTest, ConstructsFromCString) {
Message msg("Hello");
EXPECT_STREQ("Hello", ToCString(msg));
}
// Tests streaming a float.
TEST(MessageTest, StreamsFloat) {
const char* const s = ToCString(Message() << 1.23456F << " " << 2.34567F);
// Both numbers should be printed with enough precision.
EXPECT_PRED_FORMAT2(testing::IsSubstring, "1.234560", s);
EXPECT_PRED_FORMAT2(testing::IsSubstring, " 2.345669", s);
}
// Tests streaming a double.
TEST(MessageTest, StreamsDouble) {
const char* const s = ToCString(Message() << 1260570880.4555497 << " "
<< 1260572265.1954534);
// Both numbers should be printed with enough precision.
EXPECT_PRED_FORMAT2(testing::IsSubstring, "1260570880.45", s);
EXPECT_PRED_FORMAT2(testing::IsSubstring, " 1260572265.19", s);
}
// Tests streaming a non-char pointer.
TEST(MessageTest, StreamsPointer) {
int n = 0;
int* p = &n;
EXPECT_STRNE("(null)", ToCString(Message() << p));
}
// Tests streaming a NULL non-char pointer.
TEST(MessageTest, StreamsNullPointer) {
int* p = NULL;
EXPECT_STREQ("(null)", ToCString(Message() << p));
}
// Tests streaming a C string.
TEST(MessageTest, StreamsCString) {
EXPECT_STREQ("Foo", ToCString(Message() << "Foo"));
}
// Tests streaming a NULL C string.
TEST(MessageTest, StreamsNullCString) {
char* p = NULL;
EXPECT_STREQ("(null)", ToCString(Message() << p));
}
// Tests streaming std::string.
TEST(MessageTest, StreamsString) {
const ::std::string str("Hello");
EXPECT_STREQ("Hello", ToCString(Message() << str));
}
// Tests that we can output strings containing embedded NULs.
TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
const char char_array_with_nul[] =
"Here's a NUL\0 and some more string";
const ::std::string string_with_nul(char_array_with_nul,
sizeof(char_array_with_nul) - 1);
EXPECT_STREQ("Here's a NUL\\0 and some more string",
ToCString(Message() << string_with_nul));
}
// Tests streaming a NUL char.
TEST(MessageTest, StreamsNULChar) {
EXPECT_STREQ("\\0", ToCString(Message() << '\0'));
}
// Tests streaming int.
TEST(MessageTest, StreamsInt) {
EXPECT_STREQ("123", ToCString(Message() << 123));
}
// Tests that basic IO manipulators (endl, ends, and flush) can be
// streamed to Message.
TEST(MessageTest, StreamsBasicIoManip) {
EXPECT_STREQ("Line 1.\nA NUL char \\0 in line 2.",
ToCString(Message() << "Line 1." << std::endl
<< "A NUL char " << std::ends << std::flush
<< " in line 2."));
}
// Tests Message::GetString()
TEST(MessageTest, GetString) {
Message msg;
msg << 1 << " lamb";
EXPECT_STREQ("1 lamb", msg.GetString().c_str());
}
// Tests streaming a Message object to an ostream.
TEST(MessageTest, StreamsToOStream) {
Message msg("Hello");
::std::stringstream ss;
ss << msg;
EXPECT_STREQ("Hello", testing::internal::StringStreamToString(&ss).c_str());
}
// Tests that a Message object doesn't take up too much stack space.
TEST(MessageTest, DoesNotTakeUpMuchStackSpace) {
EXPECT_LE(sizeof(Message), 16U);
}
} // namespace

View File

@ -1,212 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
// Google Test UnitTestOptions tests
//
// This file tests classes and functions used internally by
// Google Test. They are subject to change without notice.
//
// This file is #included from gtest.cc, to avoid changing build or
// make-files on Windows and other platforms. Do not #include this file
// anywhere else!
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h>
#elif GTEST_OS_WINDOWS
# include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace testing {
namespace internal {
namespace {
// Turns the given relative path into an absolute path.
FilePath GetAbsolutePathOf(const FilePath& relative_path) {
return FilePath::ConcatPaths(FilePath::GetCurrentDir(), relative_path);
}
// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.
TEST(XmlOutputTest, GetOutputFormatDefault) {
GTEST_FLAG(output) = "";
EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str());
}
TEST(XmlOutputTest, GetOutputFormat) {
GTEST_FLAG(output) = "xml:filename";
EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str());
}
TEST(XmlOutputTest, GetOutputFileDefault) {
GTEST_FLAG(output) = "";
EXPECT_STREQ(GetAbsolutePathOf(FilePath("test_detail.xml")).c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
}
TEST(XmlOutputTest, GetOutputFileSingleFile) {
GTEST_FLAG(output) = "xml:filename.abc";
EXPECT_STREQ(GetAbsolutePathOf(FilePath("filename.abc")).c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
}
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
const std::string expected_output_file =
GetAbsolutePathOf(
FilePath(std::string("path") + GTEST_PATH_SEP_ +
GetCurrentExecutableName().c_str() + ".xml")).c_str();
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());
#endif
}
TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
const std::string exe_str = GetCurrentExecutableName().c_str();
#if GTEST_OS_WINDOWS
const bool success =
_strcmpi("gtest-options_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest-options-ex_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_all_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_dll_test", exe_str.c_str()) == 0;
#else
// TODO(wan@google.com): remove the hard-coded "lt-" prefix when
// Chandler Carruth's libtool replacement is ready.
const bool success =
exe_str == "gtest-options_test" ||
exe_str == "gtest_all_test" ||
exe_str == "lt-gtest_all_test" ||
exe_str == "gtest_dll_test";
#endif // GTEST_OS_WINDOWS
if (!success)
FAIL() << "GetCurrentExecutableName() returns " << exe_str;
}
class XmlOutputChangeDirTest : public Test {
protected:
virtual void SetUp() {
original_working_dir_ = FilePath::GetCurrentDir();
posix::ChDir("..");
// This will make the test fail if run from the root directory.
EXPECT_STRNE(original_working_dir_.c_str(),
FilePath::GetCurrentDir().c_str());
}
virtual void TearDown() {
posix::ChDir(original_working_dir_.c_str());
}
FilePath original_working_dir_;
};
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {
GTEST_FLAG(output) = "";
EXPECT_STREQ(FilePath::ConcatPaths(original_working_dir_,
FilePath("test_detail.xml")).c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {
GTEST_FLAG(output) = "xml";
EXPECT_STREQ(FilePath::ConcatPaths(original_working_dir_,
FilePath("test_detail.xml")).c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
GTEST_FLAG(output) = "xml:filename.abc";
EXPECT_STREQ(FilePath::ConcatPaths(original_working_dir_,
FilePath("filename.abc")).c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
const std::string expected_output_file =
FilePath::ConcatPaths(
original_working_dir_,
FilePath(std::string("path") + GTEST_PATH_SEP_ +
GetCurrentExecutableName().c_str() + ".xml")).c_str();
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());
#endif
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
#if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc";
EXPECT_STREQ(FilePath("c:\\tmp\\filename.abc").c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
#else
GTEST_FLAG(output) ="xml:/tmp/filename.abc";
EXPECT_STREQ(FilePath("/tmp/filename.abc").c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
#endif
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#if GTEST_OS_WINDOWS
const std::string path = "c:\\tmp\\";
#else
const std::string path = "/tmp/";
#endif
GTEST_FLAG(output) = "xml:" + path;
const std::string expected_output_file =
path + GetCurrentExecutableName().c_str() + ".xml";
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());
#endif
}
} // namespace
} // namespace internal
} // namespace testing

View File

@ -1,65 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
#include "gtest/gtest.h"
#include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
using ::testing::Values;
using ::testing::internal::ParamGenerator;
// Tests that generators defined in a different translation unit
// are functional. The test using extern_gen is defined
// in gtest-param-test_test.cc.
ParamGenerator<int> extern_gen = Values(33);
// Tests that a parameterized test case can be defined in one translation unit
// and instantiated in another. The test is defined in gtest-param-test_test.cc
// and ExternalInstantiationTest fixture class is defined in
// gtest-param-test_test.h.
INSTANTIATE_TEST_CASE_P(MultiplesOf33,
ExternalInstantiationTest,
Values(33, 66));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest
// fixture is defined in gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest,
Values(42*3, 42*4, 42*5));
#endif // GTEST_HAS_PARAM_TEST

View File

@ -1,895 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. This file verifies that the parameter
// generators objects produce correct parameter sequences and that
// Google Test runtime instantiates correct tests from those sequences.
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm>
# include <iostream>
# include <list>
# include <sstream>
# include <string>
# include <vector>
// To include gtest-internal-inl.h.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# undef GTEST_IMPLEMENTATION_
# include "test/gtest-param-test_test.h"
using ::std::vector;
using ::std::sort;
using ::testing::AddGlobalTestEnvironment;
using ::testing::Bool;
using ::testing::Message;
using ::testing::Range;
using ::testing::TestWithParam;
using ::testing::Values;
using ::testing::ValuesIn;
# if GTEST_HAS_COMBINE
using ::testing::Combine;
using ::std::tr1::get;
using ::std::tr1::make_tuple;
using ::std::tr1::tuple;
# endif // GTEST_HAS_COMBINE
using ::testing::internal::ParamGenerator;
using ::testing::internal::UnitTestOptions;
// Prints a value to a string.
//
// TODO(wan@google.com): remove PrintValue() when we move matchers and
// EXPECT_THAT() from Google Mock to Google Test. At that time, we
// can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as
// EXPECT_THAT() and the matchers know how to print tuples.
template <typename T>
::std::string PrintValue(const T& value) {
::std::stringstream stream;
stream << value;
return stream.str();
}
# if GTEST_HAS_COMBINE
// These overloads allow printing tuples in our tests. We cannot
// define an operator<< for tuples, as that definition needs to be in
// the std namespace in order to be picked up by Google Test via
// Argument-Dependent Lookup, yet defining anything in the std
// namespace in non-STL code is undefined behavior.
template <typename T1, typename T2>
::std::string PrintValue(const tuple<T1, T2>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value) << ")";
return stream.str();
}
template <typename T1, typename T2, typename T3>
::std::string PrintValue(const tuple<T1, T2, T3>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value)
<< ", "<< get<2>(value) << ")";
return stream.str();
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
::std::string PrintValue(
const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value)
<< ", "<< get<2>(value) << ", " << get<3>(value)
<< ", "<< get<4>(value) << ", " << get<5>(value)
<< ", "<< get<6>(value) << ", " << get<7>(value)
<< ", "<< get<8>(value) << ", " << get<9>(value) << ")";
return stream.str();
}
# endif // GTEST_HAS_COMBINE
// Verifies that a sequence generated by the generator and accessed
// via the iterator object matches the expected one using Google Test
// assertions.
template <typename T, size_t N>
void VerifyGenerator(const ParamGenerator<T>& generator,
const T (&expected_values)[N]) {
typename ParamGenerator<T>::iterator it = generator.begin();
for (size_t i = 0; i < N; ++i) {
ASSERT_FALSE(it == generator.end())
<< "At element " << i << " when accessing via an iterator "
<< "created with the copy constructor.\n";
// We cannot use EXPECT_EQ() here as the values may be tuples,
// which don't support <<.
EXPECT_TRUE(expected_values[i] == *it)
<< "where i is " << i
<< ", expected_values[i] is " << PrintValue(expected_values[i])
<< ", *it is " << PrintValue(*it)
<< ", and 'it' is an iterator created with the copy constructor.\n";
it++;
}
EXPECT_TRUE(it == generator.end())
<< "At the presumed end of sequence when accessing via an iterator "
<< "created with the copy constructor.\n";
// Test the iterator assignment. The following lines verify that
// the sequence accessed via an iterator initialized via the
// assignment operator (as opposed to a copy constructor) matches
// just the same.
it = generator.begin();
for (size_t i = 0; i < N; ++i) {
ASSERT_FALSE(it == generator.end())
<< "At element " << i << " when accessing via an iterator "
<< "created with the assignment operator.\n";
EXPECT_TRUE(expected_values[i] == *it)
<< "where i is " << i
<< ", expected_values[i] is " << PrintValue(expected_values[i])
<< ", *it is " << PrintValue(*it)
<< ", and 'it' is an iterator created with the copy constructor.\n";
it++;
}
EXPECT_TRUE(it == generator.end())
<< "At the presumed end of sequence when accessing via an iterator "
<< "created with the assignment operator.\n";
}
template <typename T>
void VerifyGeneratorIsEmpty(const ParamGenerator<T>& generator) {
typename ParamGenerator<T>::iterator it = generator.begin();
EXPECT_TRUE(it == generator.end());
it = generator.begin();
EXPECT_TRUE(it == generator.end());
}
// Generator tests. They test that each of the provided generator functions
// generates an expected sequence of values. The general test pattern
// instantiates a generator using one of the generator functions,
// checks the sequence produced by the generator using its iterator API,
// and then resets the iterator back to the beginning of the sequence
// and checks the sequence again.
// Tests that iterators produced by generator functions conform to the
// ForwardIterator concept.
TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
const ParamGenerator<int> gen = Range(0, 10);
ParamGenerator<int>::iterator it = gen.begin();
// Verifies that iterator initialization works as expected.
ParamGenerator<int>::iterator it2 = it;
EXPECT_TRUE(*it == *it2) << "Initialized iterators must point to the "
<< "element same as its source points to";
// Verifies that iterator assignment works as expected.
it++;
EXPECT_FALSE(*it == *it2);
it2 = it;
EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the "
<< "element same as its source points to";
// Verifies that prefix operator++() returns *this.
EXPECT_EQ(&it, &(++it)) << "Result of the prefix operator++ must be "
<< "refer to the original object";
// Verifies that the result of the postfix operator++ points to the value
// pointed to by the original iterator.
int original_value = *it; // Have to compute it outside of macro call to be
// unaffected by the parameter evaluation order.
EXPECT_EQ(original_value, *(it++));
// Verifies that prefix and postfix operator++() advance an iterator
// all the same.
it2 = it;
it++;
++it2;
EXPECT_TRUE(*it == *it2);
}
// Tests that Range() generates the expected sequence.
TEST(RangeTest, IntRangeWithDefaultStep) {
const ParamGenerator<int> gen = Range(0, 3);
const int expected_values[] = {0, 1, 2};
VerifyGenerator(gen, expected_values);
}
// Edge case. Tests that Range() generates the single element sequence
// as expected when provided with range limits that are equal.
TEST(RangeTest, IntRangeSingleValue) {
const ParamGenerator<int> gen = Range(0, 1);
const int expected_values[] = {0};
VerifyGenerator(gen, expected_values);
}
// Edge case. Tests that Range() with generates empty sequence when
// supplied with an empty range.
TEST(RangeTest, IntRangeEmpty) {
const ParamGenerator<int> gen = Range(0, 0);
VerifyGeneratorIsEmpty(gen);
}
// Tests that Range() with custom step (greater then one) generates
// the expected sequence.
TEST(RangeTest, IntRangeWithCustomStep) {
const ParamGenerator<int> gen = Range(0, 9, 3);
const int expected_values[] = {0, 3, 6};
VerifyGenerator(gen, expected_values);
}
// Tests that Range() with custom step (greater then one) generates
// the expected sequence when the last element does not fall on the
// upper range limit. Sequences generated by Range() must not have
// elements beyond the range limits.
TEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {
const ParamGenerator<int> gen = Range(0, 4, 3);
const int expected_values[] = {0, 3};
VerifyGenerator(gen, expected_values);
}
// Verifies that Range works with user-defined types that define
// copy constructor, operator=(), operator+(), and operator<().
class DogAdder {
public:
explicit DogAdder(const char* a_value) : value_(a_value) {}
DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}
DogAdder operator=(const DogAdder& other) {
if (this != &other)
value_ = other.value_;
return *this;
}
DogAdder operator+(const DogAdder& other) const {
Message msg;
msg << value_.c_str() << other.value_.c_str();
return DogAdder(msg.GetString().c_str());
}
bool operator<(const DogAdder& other) const {
return value_ < other.value_;
}
const ::testing::internal::String& value() const { return value_; }
private:
::testing::internal::String value_;
};
TEST(RangeTest, WorksWithACustomType) {
const ParamGenerator<DogAdder> gen =
Range(DogAdder("cat"), DogAdder("catdogdog"), DogAdder("dog"));
ParamGenerator<DogAdder>::iterator it = gen.begin();
ASSERT_FALSE(it == gen.end());
EXPECT_STREQ("cat", it->value().c_str());
ASSERT_FALSE(++it == gen.end());
EXPECT_STREQ("catdog", it->value().c_str());
EXPECT_TRUE(++it == gen.end());
}
class IntWrapper {
public:
explicit IntWrapper(int a_value) : value_(a_value) {}
IntWrapper(const IntWrapper& other) : value_(other.value_) {}
IntWrapper operator=(const IntWrapper& other) {
value_ = other.value_;
return *this;
}
// operator+() adds a different type.
IntWrapper operator+(int other) const { return IntWrapper(value_ + other); }
bool operator<(const IntWrapper& other) const {
return value_ < other.value_;
}
int value() const { return value_; }
private:
int value_;
};
TEST(RangeTest, WorksWithACustomTypeWithDifferentIncrementType) {
const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));
ParamGenerator<IntWrapper>::iterator it = gen.begin();
ASSERT_FALSE(it == gen.end());
EXPECT_EQ(0, it->value());
ASSERT_FALSE(++it == gen.end());
EXPECT_EQ(1, it->value());
EXPECT_TRUE(++it == gen.end());
}
// Tests that ValuesIn() with an array parameter generates
// the expected sequence.
TEST(ValuesInTest, ValuesInArray) {
int array[] = {3, 5, 8};
const ParamGenerator<int> gen = ValuesIn(array);
VerifyGenerator(gen, array);
}
// Tests that ValuesIn() with a const array parameter generates
// the expected sequence.
TEST(ValuesInTest, ValuesInConstArray) {
const int array[] = {3, 5, 8};
const ParamGenerator<int> gen = ValuesIn(array);
VerifyGenerator(gen, array);
}
// Edge case. Tests that ValuesIn() with an array parameter containing a
// single element generates the single element sequence.
TEST(ValuesInTest, ValuesInSingleElementArray) {
int array[] = {42};
const ParamGenerator<int> gen = ValuesIn(array);
VerifyGenerator(gen, array);
}
// Tests that ValuesIn() generates the expected sequence for an STL
// container (vector).
TEST(ValuesInTest, ValuesInVector) {
typedef ::std::vector<int> ContainerType;
ContainerType values;
values.push_back(3);
values.push_back(5);
values.push_back(8);
const ParamGenerator<int> gen = ValuesIn(values);
const int expected_values[] = {3, 5, 8};
VerifyGenerator(gen, expected_values);
}
// Tests that ValuesIn() generates the expected sequence.
TEST(ValuesInTest, ValuesInIteratorRange) {
typedef ::std::vector<int> ContainerType;
ContainerType values;
values.push_back(3);
values.push_back(5);
values.push_back(8);
const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
const int expected_values[] = {3, 5, 8};
VerifyGenerator(gen, expected_values);
}
// Edge case. Tests that ValuesIn() provided with an iterator range specifying a
// single value generates a single-element sequence.
TEST(ValuesInTest, ValuesInSingleElementIteratorRange) {
typedef ::std::vector<int> ContainerType;
ContainerType values;
values.push_back(42);
const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
const int expected_values[] = {42};
VerifyGenerator(gen, expected_values);
}
// Edge case. Tests that ValuesIn() provided with an empty iterator range
// generates an empty sequence.
TEST(ValuesInTest, ValuesInEmptyIteratorRange) {
typedef ::std::vector<int> ContainerType;
ContainerType values;
const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
VerifyGeneratorIsEmpty(gen);
}
// Tests that the Values() generates the expected sequence.
TEST(ValuesTest, ValuesWorks) {
const ParamGenerator<int> gen = Values(3, 5, 8);
const int expected_values[] = {3, 5, 8};
VerifyGenerator(gen, expected_values);
}
// Tests that Values() generates the expected sequences from elements of
// different types convertible to ParamGenerator's parameter type.
TEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {
const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);
const double expected_values[] = {3.0, 5.0, 8.0};
VerifyGenerator(gen, expected_values);
}
TEST(ValuesTest, ValuesWorksForMaxLengthList) {
const ParamGenerator<int> gen = Values(
10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
410, 420, 430, 440, 450, 460, 470, 480, 490, 500);
const int expected_values[] = {
10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
410, 420, 430, 440, 450, 460, 470, 480, 490, 500};
VerifyGenerator(gen, expected_values);
}
// Edge case test. Tests that single-parameter Values() generates the sequence
// with the single value.
TEST(ValuesTest, ValuesWithSingleParameter) {
const ParamGenerator<int> gen = Values(42);
const int expected_values[] = {42};
VerifyGenerator(gen, expected_values);
}
// Tests that Bool() generates sequence (false, true).
TEST(BoolTest, BoolWorks) {
const ParamGenerator<bool> gen = Bool();
const bool expected_values[] = {false, true};
VerifyGenerator(gen, expected_values);
}
# if GTEST_HAS_COMBINE
// Tests that Combine() with two parameters generates the expected sequence.
TEST(CombineTest, CombineWithTwoParameters) {
const char* foo = "foo";
const char* bar = "bar";
const ParamGenerator<tuple<const char*, int> > gen =
Combine(Values(foo, bar), Values(3, 4));
tuple<const char*, int> expected_values[] = {
make_tuple(foo, 3), make_tuple(foo, 4),
make_tuple(bar, 3), make_tuple(bar, 4)};
VerifyGenerator(gen, expected_values);
}
// Tests that Combine() with three parameters generates the expected sequence.
TEST(CombineTest, CombineWithThreeParameters) {
const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),
Values(3, 4),
Values(5, 6));
tuple<int, int, int> expected_values[] = {
make_tuple(0, 3, 5), make_tuple(0, 3, 6),
make_tuple(0, 4, 5), make_tuple(0, 4, 6),
make_tuple(1, 3, 5), make_tuple(1, 3, 6),
make_tuple(1, 4, 5), make_tuple(1, 4, 6)};
VerifyGenerator(gen, expected_values);
}
// Tests that the Combine() with the first parameter generating a single value
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the second parameter.
TEST(CombineTest, CombineWithFirstParameterSingleValue) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),
Values(0, 1));
tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};
VerifyGenerator(gen, expected_values);
}
// Tests that the Combine() with the second parameter generating a single value
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the first parameter.
TEST(CombineTest, CombineWithSecondParameterSingleValue) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
Values(42));
tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};
VerifyGenerator(gen, expected_values);
}
// Tests that when the first parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST(CombineTest, CombineWithFirstParameterEmptyRange) {
const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),
Values(0, 1));
VerifyGeneratorIsEmpty(gen);
}
// Tests that when the second parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
Range(1, 1));
VerifyGeneratorIsEmpty(gen);
}
// Edge case. Tests that combine works with the maximum number
// of parameters supported by Google Test (currently 10).
TEST(CombineTest, CombineWithMaxNumberOfParameters) {
const char* foo = "foo";
const char* bar = "bar";
const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,
int, int> > gen = Combine(Values(foo, bar),
Values(1), Values(2),
Values(3), Values(4),
Values(5), Values(6),
Values(7), Values(8),
Values(9));
tuple<const char*, int, int, int, int, int, int, int, int, int>
expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
VerifyGenerator(gen, expected_values);
}
# endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
// assigned from another generator.
TEST(ParamGeneratorTest, AssignmentWorks) {
ParamGenerator<int> gen = Values(1, 2);
const ParamGenerator<int> gen2 = Values(3, 4);
gen = gen2;
const int expected_values[] = {3, 4};
VerifyGenerator(gen, expected_values);
}
// This test verifies that the tests are expanded and run as specified:
// one test per element from the sequence produced by the generator
// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's
// fixture constructor, SetUp(), and TearDown() have run and have been
// supplied with the correct parameters.
// The use of environment object allows detection of the case where no test
// case functionality is run at all. In this case TestCaseTearDown will not
// be able to detect missing tests, naturally.
template <int kExpectedCalls>
class TestGenerationEnvironment : public ::testing::Environment {
public:
static TestGenerationEnvironment* Instance() {
static TestGenerationEnvironment* instance = new TestGenerationEnvironment;
return instance;
}
void FixtureConstructorExecuted() { fixture_constructor_count_++; }
void SetUpExecuted() { set_up_count_++; }
void TearDownExecuted() { tear_down_count_++; }
void TestBodyExecuted() { test_body_count_++; }
virtual void TearDown() {
// If all MultipleTestGenerationTest tests have been de-selected
// by the filter flag, the following checks make no sense.
bool perform_check = false;
for (int i = 0; i < kExpectedCalls; ++i) {
Message msg;
msg << "TestsExpandedAndRun/" << i;
if (UnitTestOptions::FilterMatchesTest(
"TestExpansionModule/MultipleTestGenerationTest",
msg.GetString().c_str())) {
perform_check = true;
}
}
if (perform_check) {
EXPECT_EQ(kExpectedCalls, fixture_constructor_count_)
<< "Fixture constructor of ParamTestGenerationTest test case "
<< "has not been run as expected.";
EXPECT_EQ(kExpectedCalls, set_up_count_)
<< "Fixture SetUp method of ParamTestGenerationTest test case "
<< "has not been run as expected.";
EXPECT_EQ(kExpectedCalls, tear_down_count_)
<< "Fixture TearDown method of ParamTestGenerationTest test case "
<< "has not been run as expected.";
EXPECT_EQ(kExpectedCalls, test_body_count_)
<< "Test in ParamTestGenerationTest test case "
<< "has not been run as expected.";
}
}
private:
TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0),
tear_down_count_(0), test_body_count_(0) {}
int fixture_constructor_count_;
int set_up_count_;
int tear_down_count_;
int test_body_count_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment);
};
const int test_generation_params[] = {36, 42, 72};
class TestGenerationTest : public TestWithParam<int> {
public:
enum {
PARAMETER_COUNT =
sizeof(test_generation_params)/sizeof(test_generation_params[0])
};
typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;
TestGenerationTest() {
Environment::Instance()->FixtureConstructorExecuted();
current_parameter_ = GetParam();
}
virtual void SetUp() {
Environment::Instance()->SetUpExecuted();
EXPECT_EQ(current_parameter_, GetParam());
}
virtual void TearDown() {
Environment::Instance()->TearDownExecuted();
EXPECT_EQ(current_parameter_, GetParam());
}
static void SetUpTestCase() {
bool all_tests_in_test_case_selected = true;
for (int i = 0; i < PARAMETER_COUNT; ++i) {
Message test_name;
test_name << "TestsExpandedAndRun/" << i;
if ( !UnitTestOptions::FilterMatchesTest(
"TestExpansionModule/MultipleTestGenerationTest",
test_name.GetString())) {
all_tests_in_test_case_selected = false;
}
}
EXPECT_TRUE(all_tests_in_test_case_selected)
<< "When running the TestGenerationTest test case all of its tests\n"
<< "must be selected by the filter flag for the test case to pass.\n"
<< "If not all of them are enabled, we can't reliably conclude\n"
<< "that the correct number of tests have been generated.";
collected_parameters_.clear();
}
static void TearDownTestCase() {
vector<int> expected_values(test_generation_params,
test_generation_params + PARAMETER_COUNT);
// Test execution order is not guaranteed by Google Test,
// so the order of values in collected_parameters_ can be
// different and we have to sort to compare.
sort(expected_values.begin(), expected_values.end());
sort(collected_parameters_.begin(), collected_parameters_.end());
EXPECT_TRUE(collected_parameters_ == expected_values);
}
protected:
int current_parameter_;
static vector<int> collected_parameters_;
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest);
};
vector<int> TestGenerationTest::collected_parameters_;
TEST_P(TestGenerationTest, TestsExpandedAndRun) {
Environment::Instance()->TestBodyExecuted();
EXPECT_EQ(current_parameter_, GetParam());
collected_parameters_.push_back(GetParam());
}
INSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,
ValuesIn(test_generation_params));
// This test verifies that the element sequence (third parameter of
// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at
// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS(). For
// that, we declare param_value_ to be a static member of
// GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
// main(), just before invocation of InitGoogleTest(). After calling
// InitGoogleTest(), we set the value to 2. If the sequence is evaluated
// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a
// test with parameter other than 1, and the test body will fail the
// assertion.
class GeneratorEvaluationTest : public TestWithParam<int> {
public:
static int param_value() { return param_value_; }
static void set_param_value(int param_value) { param_value_ = param_value; }
private:
static int param_value_;
};
int GeneratorEvaluationTest::param_value_ = 0;
TEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
EXPECT_EQ(1, GetParam());
}
INSTANTIATE_TEST_CASE_P(GenEvalModule,
GeneratorEvaluationTest,
Values(GeneratorEvaluationTest::param_value()));
// Tests that generators defined in a different translation unit are
// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
extern ParamGenerator<int> extern_gen;
class ExternalGeneratorTest : public TestWithParam<int> {};
TEST_P(ExternalGeneratorTest, ExternalGenerator) {
// Sequence produced by extern_gen contains only a single value
// which we verify here.
EXPECT_EQ(GetParam(), 33);
}
INSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,
ExternalGeneratorTest,
extern_gen);
// Tests that a parameterized test case can be defined in one translation
// unit and instantiated in another. This test will be instantiated in
// gtest-param-test_test2.cc. ExternalInstantiationTest fixture class is
// defined in gtest-param-test_test.h.
TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
EXPECT_EQ(0, GetParam() % 33);
}
// Tests that a parameterized test case can be instantiated with multiple
// generators.
class MultipleInstantiationTest : public TestWithParam<int> {};
TEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {
}
INSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
INSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. This test will be instantiated
// here and in gtest-param-test_test2.cc.
// InstantiationInMultipleTranslationUnitsTest fixture class
// is defined in gtest-param-test_test.h.
TEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {
EXPECT_EQ(0, GetParam() % 42);
}
INSTANTIATE_TEST_CASE_P(Sequence1,
InstantiationInMultipleTranslaionUnitsTest,
Values(42, 42*2));
// Tests that each iteration of parameterized test runs in a separate test
// object.
class SeparateInstanceTest : public TestWithParam<int> {
public:
SeparateInstanceTest() : count_(0) {}
static void TearDownTestCase() {
EXPECT_GE(global_count_, 2)
<< "If some (but not all) SeparateInstanceTest tests have been "
<< "filtered out this test will fail. Make sure that all "
<< "GeneratorEvaluationTest are selected or de-selected together "
<< "by the test filter.";
}
protected:
int count_;
static int global_count_;
};
int SeparateInstanceTest::global_count_ = 0;
TEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
EXPECT_EQ(0, count_++);
global_count_++;
}
INSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
// Tests that all instantiations of a test have named appropriately. Test
// defined with TEST_P(TestCaseName, TestName) and instantiated with
// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named
// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the
// sequence element used to instantiate the test.
class NamingTest : public TestWithParam<int> {};
TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_case_name());
Message index_stream;
index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
}
INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
// Class that cannot be streamed into an ostream. It needs to be copyable
// (and, in case of MSVC, also assignable) in order to be a test parameter
// type. Its default copy constructor and assignment operator do exactly
// what we need.
class Unstreamable {
public:
explicit Unstreamable(int value) : value_(value) {}
private:
int value_;
};
class CommentTest : public TestWithParam<Unstreamable> {};
TEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
}
INSTANTIATE_TEST_CASE_P(InstantiationWithComments,
CommentTest,
Values(Unstreamable(1)));
// Verify that we can create a hierarchy of test fixtures, where the base
// class fixture is not parameterized and the derived class is. In this case
// ParameterizedDerivedTest inherits from NonParameterizedBaseTest. We
// perform simple tests on both.
class NonParameterizedBaseTest : public ::testing::Test {
public:
NonParameterizedBaseTest() : n_(17) { }
protected:
int n_;
};
class ParameterizedDerivedTest : public NonParameterizedBaseTest,
public ::testing::WithParamInterface<int> {
protected:
ParameterizedDerivedTest() : count_(0) { }
int count_;
static int global_count_;
};
int ParameterizedDerivedTest::global_count_ = 0;
TEST_F(NonParameterizedBaseTest, FixtureIsInitialized) {
EXPECT_EQ(17, n_);
}
TEST_P(ParameterizedDerivedTest, SeesSequence) {
EXPECT_EQ(17, n_);
EXPECT_EQ(0, count_++);
EXPECT_EQ(GetParam(), global_count_++);
}
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST
TEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {
#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n"
#endif
}
int main(int argc, char **argv) {
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
// Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(1);
#endif // GTEST_HAS_PARAM_TEST
::testing::InitGoogleTest(&argc, argv);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in
// GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(2);
#endif // GTEST_HAS_PARAM_TEST
return RUN_ALL_TESTS();
}

View File

@ -1,55 +0,0 @@
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: vladl@google.com (Vlad Losev)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file provides classes and functions used internally
// for testing Google Test itself.
#ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
#define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
class ExternalInstantiationTest : public ::testing::TestWithParam<int> {};
// Test fixture for testing instantiation of a test in multiple
// translation units.
class InstantiationInMultipleTranslaionUnitsTest
: public ::testing::TestWithParam<int> {};
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,208 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
#include "gtest/gtest-test-part.h"
#include "gtest/gtest.h"
using testing::Message;
using testing::Test;
using testing::TestPartResult;
using testing::TestPartResultArray;
namespace {
// Tests the TestPartResult class.
// The test fixture for testing TestPartResult.
class TestPartResultTest : public Test {
protected:
TestPartResultTest()
: r1_(TestPartResult::kSuccess, "foo/bar.cc", 10, "Success!"),
r2_(TestPartResult::kNonFatalFailure, "foo/bar.cc", -1, "Failure!"),
r3_(TestPartResult::kFatalFailure, NULL, -1, "Failure!") {}
TestPartResult r1_, r2_, r3_;
};
TEST_F(TestPartResultTest, ConstructorWorks) {
Message message;
message << "something is terribly wrong";
message << static_cast<const char*>(testing::internal::kStackTraceMarker);
message << "some unimportant stack trace";
const TestPartResult result(TestPartResult::kNonFatalFailure,
"some_file.cc",
42,
message.GetString().c_str());
EXPECT_EQ(TestPartResult::kNonFatalFailure, result.type());
EXPECT_STREQ("some_file.cc", result.file_name());
EXPECT_EQ(42, result.line_number());
EXPECT_STREQ(message.GetString().c_str(), result.message());
EXPECT_STREQ("something is terribly wrong", result.summary());
}
TEST_F(TestPartResultTest, ResultAccessorsWork) {
const TestPartResult success(TestPartResult::kSuccess,
"file.cc",
42,
"message");
EXPECT_TRUE(success.passed());
EXPECT_FALSE(success.failed());
EXPECT_FALSE(success.nonfatally_failed());
EXPECT_FALSE(success.fatally_failed());
const TestPartResult nonfatal_failure(TestPartResult::kNonFatalFailure,
"file.cc",
42,
"message");
EXPECT_FALSE(nonfatal_failure.passed());
EXPECT_TRUE(nonfatal_failure.failed());
EXPECT_TRUE(nonfatal_failure.nonfatally_failed());
EXPECT_FALSE(nonfatal_failure.fatally_failed());
const TestPartResult fatal_failure(TestPartResult::kFatalFailure,
"file.cc",
42,
"message");
EXPECT_FALSE(fatal_failure.passed());
EXPECT_TRUE(fatal_failure.failed());
EXPECT_FALSE(fatal_failure.nonfatally_failed());
EXPECT_TRUE(fatal_failure.fatally_failed());
}
// Tests TestPartResult::type().
TEST_F(TestPartResultTest, type) {
EXPECT_EQ(TestPartResult::kSuccess, r1_.type());
EXPECT_EQ(TestPartResult::kNonFatalFailure, r2_.type());
EXPECT_EQ(TestPartResult::kFatalFailure, r3_.type());
}
// Tests TestPartResult::file_name().
TEST_F(TestPartResultTest, file_name) {
EXPECT_STREQ("foo/bar.cc", r1_.file_name());
EXPECT_STREQ(NULL, r3_.file_name());
}
// Tests TestPartResult::line_number().
TEST_F(TestPartResultTest, line_number) {
EXPECT_EQ(10, r1_.line_number());
EXPECT_EQ(-1, r2_.line_number());
}
// Tests TestPartResult::message().
TEST_F(TestPartResultTest, message) {
EXPECT_STREQ("Success!", r1_.message());
}
// Tests TestPartResult::passed().
TEST_F(TestPartResultTest, Passed) {
EXPECT_TRUE(r1_.passed());
EXPECT_FALSE(r2_.passed());
EXPECT_FALSE(r3_.passed());
}
// Tests TestPartResult::failed().
TEST_F(TestPartResultTest, Failed) {
EXPECT_FALSE(r1_.failed());
EXPECT_TRUE(r2_.failed());
EXPECT_TRUE(r3_.failed());
}
// Tests TestPartResult::fatally_failed().
TEST_F(TestPartResultTest, FatallyFailed) {
EXPECT_FALSE(r1_.fatally_failed());
EXPECT_FALSE(r2_.fatally_failed());
EXPECT_TRUE(r3_.fatally_failed());
}
// Tests TestPartResult::nonfatally_failed().
TEST_F(TestPartResultTest, NonfatallyFailed) {
EXPECT_FALSE(r1_.nonfatally_failed());
EXPECT_TRUE(r2_.nonfatally_failed());
EXPECT_FALSE(r3_.nonfatally_failed());
}
// Tests the TestPartResultArray class.
class TestPartResultArrayTest : public Test {
protected:
TestPartResultArrayTest()
: r1_(TestPartResult::kNonFatalFailure, "foo/bar.cc", -1, "Failure 1"),
r2_(TestPartResult::kFatalFailure, "foo/bar.cc", -1, "Failure 2") {}
const TestPartResult r1_, r2_;
};
// Tests that TestPartResultArray initially has size 0.
TEST_F(TestPartResultArrayTest, InitialSizeIsZero) {
TestPartResultArray results;
EXPECT_EQ(0, results.size());
}
// Tests that TestPartResultArray contains the given TestPartResult
// after one Append() operation.
TEST_F(TestPartResultArrayTest, ContainsGivenResultAfterAppend) {
TestPartResultArray results;
results.Append(r1_);
EXPECT_EQ(1, results.size());
EXPECT_STREQ("Failure 1", results.GetTestPartResult(0).message());
}
// Tests that TestPartResultArray contains the given TestPartResults
// after two Append() operations.
TEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) {
TestPartResultArray results;
results.Append(r1_);
results.Append(r2_);
EXPECT_EQ(2, results.size());
EXPECT_STREQ("Failure 1", results.GetTestPartResult(0).message());
EXPECT_STREQ("Failure 2", results.GetTestPartResult(1).message());
}
typedef TestPartResultArrayTest TestPartResultArrayDeathTest;
// Tests that the program dies when GetTestPartResult() is called with
// an invalid index.
TEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {
TestPartResultArray results;
results.Append(r1_);
EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(-1), "");
EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(1), "");
}
// TODO(mheule@google.com): Add a test for the class HasNewFatalFailureHelper.
} // namespace

View File

@ -1,320 +0,0 @@
// Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/internal/gtest-tuple.h"
#include <utility>
#include "gtest/gtest.h"
namespace {
using ::std::tr1::get;
using ::std::tr1::make_tuple;
using ::std::tr1::tuple;
using ::std::tr1::tuple_element;
using ::std::tr1::tuple_size;
using ::testing::StaticAssertTypeEq;
// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.
TEST(tuple_element_Test, ReturnsElementType) {
StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();
StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();
StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();
}
// Tests that tuple_size<T>::value gives the number of fields in tuple
// type T.
TEST(tuple_size_Test, ReturnsNumberOfFields) {
EXPECT_EQ(0, +tuple_size<tuple<> >::value);
EXPECT_EQ(1, +tuple_size<tuple<void*> >::value);
EXPECT_EQ(1, +tuple_size<tuple<char> >::value);
EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value));
EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value));
EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value));
}
// Tests comparing a tuple with itself.
TEST(ComparisonTest, ComparesWithSelf) {
const tuple<int, char, bool> a(5, 'a', false);
EXPECT_TRUE(a == a);
EXPECT_FALSE(a != a);
}
// Tests comparing two tuples with the same value.
TEST(ComparisonTest, ComparesEqualTuples) {
const tuple<int, bool> a(5, true), b(5, true);
EXPECT_TRUE(a == b);
EXPECT_FALSE(a != b);
}
// Tests comparing two different tuples that have no reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {
typedef tuple<const int, char> FooTuple;
const FooTuple a(0, 'x');
const FooTuple b(1, 'a');
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
const FooTuple c(1, 'b');
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests comparing two different tuples that have reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {
typedef tuple<int&, const char&> FooTuple;
int i = 5;
const char ch = 'a';
const FooTuple a(i, ch);
int j = 6;
const FooTuple b(j, ch);
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
j = 5;
const char ch2 = 'b';
const FooTuple c(j, ch2);
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests that a tuple field with a reference type is an alias of the
// variable it's supposed to reference.
TEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {
int n = 0;
tuple<bool, int&> t(true, n);
n = 1;
EXPECT_EQ(n, get<1>(t))
<< "Changing a underlying variable should update the reference field.";
// Makes sure that the implementation doesn't do anything funny with
// the & operator for the return type of get<>().
EXPECT_EQ(&n, &(get<1>(t)))
<< "The address of a reference field should equal the address of "
<< "the underlying variable.";
get<1>(t) = 2;
EXPECT_EQ(2, n)
<< "Changing a reference field should update the underlying variable.";
}
// Tests that tuple's default constructor default initializes each field.
// This test needs to compile without generating warnings.
TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
// The TR1 report requires that tuple's default constructor default
// initializes each field, even if it's a primitive type. If the
// implementation forgets to do this, this test will catch it by
// generating warnings about using uninitialized variables (assuming
// a decent compiler).
tuple<> empty;
tuple<int> a1, b1;
b1 = a1;
EXPECT_EQ(0, get<0>(b1));
tuple<int, double> a2, b2;
b2 = a2;
EXPECT_EQ(0, get<0>(b2));
EXPECT_EQ(0.0, get<1>(b2));
tuple<double, char, bool*> a3, b3;
b3 = a3;
EXPECT_EQ(0.0, get<0>(b3));
EXPECT_EQ('\0', get<1>(b3));
EXPECT_TRUE(get<2>(b3) == NULL);
tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;
b10 = a10;
EXPECT_EQ(0, get<0>(b10));
EXPECT_EQ(0, get<1>(b10));
EXPECT_EQ(0, get<2>(b10));
EXPECT_EQ(0, get<3>(b10));
EXPECT_EQ(0, get<4>(b10));
EXPECT_EQ(0, get<5>(b10));
EXPECT_EQ(0, get<6>(b10));
EXPECT_EQ(0, get<7>(b10));
EXPECT_EQ(0, get<8>(b10));
EXPECT_EQ(0, get<9>(b10));
}
// Tests constructing a tuple from its fields.
TEST(TupleConstructorTest, ConstructsFromFields) {
int n = 1;
// Reference field.
tuple<int&> a(n);
EXPECT_EQ(&n, &(get<0>(a)));
// Non-reference fields.
tuple<int, char> b(5, 'a');
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ('a', get<1>(b));
// Const reference field.
const int m = 2;
tuple<bool, const int&> c(true, m);
EXPECT_TRUE(get<0>(c));
EXPECT_EQ(&m, &(get<1>(c)));
}
// Tests tuple's copy constructor.
TEST(TupleConstructorTest, CopyConstructor) {
tuple<double, bool> a(0.0, true);
tuple<double, bool> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_TRUE(get<1>(b));
}
// Tests constructing a tuple from another tuple that has a compatible
// but different type.
TEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {
tuple<int, int, char> a(0, 1, 'a');
tuple<double, long, int> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_EQ(1, get<1>(b));
EXPECT_EQ('a', get<2>(b));
}
// Tests constructing a 2-tuple from an std::pair.
TEST(TupleConstructorTest, ConstructsFromPair) {
::std::pair<int, char> a(1, 'a');
tuple<int, char> b(a);
tuple<int, const char&> c(a);
}
// Tests assigning a tuple to another tuple with the same type.
TEST(TupleAssignmentTest, AssignsToSameTupleType) {
const tuple<int, long> a(5, 7L);
tuple<int, long> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ(7L, get<1>(b));
}
// Tests assigning a tuple to another tuple with a different but
// compatible type.
TEST(TupleAssignmentTest, AssignsToDifferentTupleType) {
const tuple<int, long, bool> a(1, 7L, true);
tuple<long, int, bool> b;
b = a;
EXPECT_EQ(1L, get<0>(b));
EXPECT_EQ(7, get<1>(b));
EXPECT_TRUE(get<2>(b));
}
// Tests assigning an std::pair to a 2-tuple.
TEST(TupleAssignmentTest, AssignsFromPair) {
const ::std::pair<int, bool> a(5, true);
tuple<int, bool> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_TRUE(get<1>(b));
tuple<long, bool> c;
c = a;
EXPECT_EQ(5L, get<0>(c));
EXPECT_TRUE(get<1>(c));
}
// A fixture for testing big tuples.
class BigTupleTest : public testing::Test {
protected:
typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;
BigTupleTest() :
a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),
b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}
BigTuple a_, b_;
};
// Tests constructing big tuples.
TEST_F(BigTupleTest, Construction) {
BigTuple a;
BigTuple b(b_);
}
// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.
TEST_F(BigTupleTest, get) {
EXPECT_EQ(1, get<0>(a_));
EXPECT_EQ(2, get<9>(a_));
// Tests that get() works on a const tuple too.
const BigTuple a(a_);
EXPECT_EQ(1, get<0>(a));
EXPECT_EQ(2, get<9>(a));
}
// Tests comparing big tuples.
TEST_F(BigTupleTest, Comparisons) {
EXPECT_TRUE(a_ == a_);
EXPECT_FALSE(a_ != a_);
EXPECT_TRUE(a_ != b_);
EXPECT_FALSE(a_ == b_);
}
TEST(MakeTupleTest, WorksForScalarTypes) {
tuple<bool, int> a;
a = make_tuple(true, 5);
EXPECT_TRUE(get<0>(a));
EXPECT_EQ(5, get<1>(a));
tuple<char, int, long> b;
b = make_tuple('a', 'b', 5);
EXPECT_EQ('a', get<0>(b));
EXPECT_EQ('b', get<1>(b));
EXPECT_EQ(5, get<2>(b));
}
TEST(MakeTupleTest, WorksForPointers) {
int a[] = { 1, 2, 3, 4 };
const char* const str = "hi";
int* const p = a;
tuple<const char*, int*> t;
t = make_tuple(str, p);
EXPECT_EQ(str, get<0>(t));
EXPECT_EQ(p, get<1>(t));
}
} // namespace

View File

@ -1,45 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include <vector>
#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
#if GTEST_HAS_TYPED_TEST_P
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest,
testing::Types<std::vector<int> >);
#endif // GTEST_HAS_TYPED_TEST_P

View File

@ -1,360 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include <set>
#include <vector>
#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
using testing::Test;
// Used for testing that SetUpTestCase()/TearDownTestCase(), fixture
// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and
// type-parameterized test.
template <typename T>
class CommonTest : public Test {
// For some technical reason, SetUpTestCase() and TearDownTestCase()
// must be public.
public:
static void SetUpTestCase() {
shared_ = new T(5);
}
static void TearDownTestCase() {
delete shared_;
shared_ = NULL;
}
// This 'protected:' is optional. There's no harm in making all
// members of this fixture class template public.
protected:
// We used to use std::list here, but switched to std::vector since
// MSVC's <list> doesn't compile cleanly with /W4.
typedef std::vector<T> Vector;
typedef std::set<int> IntSet;
CommonTest() : value_(1) {}
virtual ~CommonTest() { EXPECT_EQ(3, value_); }
virtual void SetUp() {
EXPECT_EQ(1, value_);
value_++;
}
virtual void TearDown() {
EXPECT_EQ(2, value_);
value_++;
}
T value_;
static T* shared_;
};
template <typename T>
T* CommonTest<T>::shared_ = NULL;
// This #ifdef block tests typed tests.
#if GTEST_HAS_TYPED_TEST
using testing::Types;
// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,
// and SetUp()/TearDown() work correctly in typed tests
typedef Types<char, int> TwoTypes;
TYPED_TEST_CASE(CommonTest, TwoTypes);
TYPED_TEST(CommonTest, ValuesAreCorrect) {
// Static members of the fixture class template can be visited via
// the TestFixture:: prefix.
EXPECT_EQ(5, *TestFixture::shared_);
// Typedefs in the fixture class template can be visited via the
// "typename TestFixture::" prefix.
typename TestFixture::Vector empty;
EXPECT_EQ(0U, empty.size());
typename TestFixture::IntSet empty2;
EXPECT_EQ(0U, empty2.size());
// Non-static members of the fixture class must be visited via
// 'this', as required by C++ for class templates.
EXPECT_EQ(2, this->value_);
}
// The second test makes sure shared_ is not deleted after the first
// test.
TYPED_TEST(CommonTest, ValuesAreStillCorrect) {
// Static members of the fixture class template can also be visited
// via 'this'.
ASSERT_TRUE(this->shared_ != NULL);
EXPECT_EQ(5, *this->shared_);
// TypeParam can be used to refer to the type parameter.
EXPECT_EQ(static_cast<TypeParam>(2), this->value_);
}
// Tests that multiple TYPED_TEST_CASE's can be defined in the same
// translation unit.
template <typename T>
class TypedTest1 : public Test {
};
// Verifies that the second argument of TYPED_TEST_CASE can be a
// single type.
TYPED_TEST_CASE(TypedTest1, int);
TYPED_TEST(TypedTest1, A) {}
template <typename T>
class TypedTest2 : public Test {
};
// Verifies that the second argument of TYPED_TEST_CASE can be a
// Types<...> type list.
TYPED_TEST_CASE(TypedTest2, Types<int>);
// This also verifies that tests from different typed test cases can
// share the same name.
TYPED_TEST(TypedTest2, A) {}
// Tests that a typed test case can be defined in a namespace.
namespace library1 {
template <typename T>
class NumericTest : public Test {
};
typedef Types<int, long> NumericTypes;
TYPED_TEST_CASE(NumericTest, NumericTypes);
TYPED_TEST(NumericTest, DefaultIsZero) {
EXPECT_EQ(0, TypeParam());
}
} // namespace library1
#endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests type-parameterized tests.
#if GTEST_HAS_TYPED_TEST_P
using testing::Types;
using testing::internal::TypedTestCasePState;
// Tests TypedTestCasePState.
class TypedTestCasePStateTest : public Test {
protected:
virtual void SetUp() {
state_.AddTestName("foo.cc", 0, "FooTest", "A");
state_.AddTestName("foo.cc", 0, "FooTest", "B");
state_.AddTestName("foo.cc", 0, "FooTest", "C");
}
TypedTestCasePState state_;
};
TEST_F(TypedTestCasePStateTest, SucceedsForMatchingList) {
const char* tests = "A, B, C";
EXPECT_EQ(tests,
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
}
// Makes sure that the order of the tests and spaces around the names
// don't matter.
TEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {
const char* tests = "A,C, B";
EXPECT_EQ(tests,
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
}
typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;
TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {
EXPECT_DEATH_IF_SUPPORTED(
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, A, C"),
"foo\\.cc.1.?: Test A is listed more than once\\.");
}
TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {
EXPECT_DEATH_IF_SUPPORTED(
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C, D"),
"foo\\.cc.1.?: No test named D can be found in this test case\\.");
}
TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
EXPECT_DEATH_IF_SUPPORTED(
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, C"),
"foo\\.cc.1.?: You forgot to list test B\\.");
}
// Tests that defining a test for a parameterized test case generates
// a run-time error if the test case has been registered.
TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C");
EXPECT_DEATH_IF_SUPPORTED(
state_.AddTestName("foo.cc", 2, "FooTest", "D"),
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P"
"\\(FooTest, \\.\\.\\.\\)\\.");
}
// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,
// and SetUp()/TearDown() work correctly in type-parameterized tests.
template <typename T>
class DerivedTest : public CommonTest<T> {
};
TYPED_TEST_CASE_P(DerivedTest);
TYPED_TEST_P(DerivedTest, ValuesAreCorrect) {
// Static members of the fixture class template can be visited via
// the TestFixture:: prefix.
EXPECT_EQ(5, *TestFixture::shared_);
// Non-static members of the fixture class must be visited via
// 'this', as required by C++ for class templates.
EXPECT_EQ(2, this->value_);
}
// The second test makes sure shared_ is not deleted after the first
// test.
TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {
// Static members of the fixture class template can also be visited
// via 'this'.
ASSERT_TRUE(this->shared_ != NULL);
EXPECT_EQ(5, *this->shared_);
EXPECT_EQ(2, this->value_);
}
REGISTER_TYPED_TEST_CASE_P(DerivedTest,
ValuesAreCorrect, ValuesAreStillCorrect);
typedef Types<short, long> MyTwoTypes;
INSTANTIATE_TYPED_TEST_CASE_P(My, DerivedTest, MyTwoTypes);
// Tests that multiple TYPED_TEST_CASE_P's can be defined in the same
// translation unit.
template <typename T>
class TypedTestP1 : public Test {
};
TYPED_TEST_CASE_P(TypedTestP1);
// For testing that the code between TYPED_TEST_CASE_P() and
// TYPED_TEST_P() is not enclosed in a namespace.
typedef int IntAfterTypedTestCaseP;
TYPED_TEST_P(TypedTestP1, A) {}
TYPED_TEST_P(TypedTestP1, B) {}
// For testing that the code between TYPED_TEST_P() and
// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.
typedef int IntBeforeRegisterTypedTestCaseP;
REGISTER_TYPED_TEST_CASE_P(TypedTestP1, A, B);
template <typename T>
class TypedTestP2 : public Test {
};
TYPED_TEST_CASE_P(TypedTestP2);
// This also verifies that tests from different type-parameterized
// test cases can share the same name.
TYPED_TEST_P(TypedTestP2, A) {}
REGISTER_TYPED_TEST_CASE_P(TypedTestP2, A);
// Verifies that the code between TYPED_TEST_CASE_P() and
// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.
IntAfterTypedTestCaseP after = 0;
IntBeforeRegisterTypedTestCaseP before = 0;
// Verifies that the last argument of INSTANTIATE_TYPED_TEST_CASE_P()
// can be either a single type or a Types<...> type list.
INSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP1, int);
INSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP2, Types<int>);
// Tests that the same type-parameterized test case can be
// instantiated more than once in the same translation unit.
INSTANTIATE_TYPED_TEST_CASE_P(Double, TypedTestP2, Types<double>);
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
typedef Types<std::vector<double>, std::set<char> > MyContainers;
INSTANTIATE_TYPED_TEST_CASE_P(My, ContainerTest, MyContainers);
// Tests that a type-parameterized test case can be defined and
// instantiated in a namespace.
namespace library2 {
template <typename T>
class NumericTest : public Test {
};
TYPED_TEST_CASE_P(NumericTest);
TYPED_TEST_P(NumericTest, DefaultIsZero) {
EXPECT_EQ(0, TypeParam());
}
TYPED_TEST_P(NumericTest, ZeroIsLessThanOne) {
EXPECT_LT(TypeParam(0), TypeParam(1));
}
REGISTER_TYPED_TEST_CASE_P(NumericTest,
DefaultIsZero, ZeroIsLessThanOne);
typedef Types<int, double> NumericTypes;
INSTANTIATE_TYPED_TEST_CASE_P(My, NumericTest, NumericTypes);
} // namespace library2
#endif // GTEST_HAS_TYPED_TEST_P
#if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)
// Google Test may not support type-parameterized tests with some
// compilers. If we use conditional compilation to compile out all
// code referring to the gtest_main library, MSVC linker will not link
// that library at all and consequently complain about missing entry
// point defined in that library (fatal error LNK1561: entry point
// must be defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, TypedTestsAreNotSupportedOnThisPlatform) {}
#endif // #if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)

View File

@ -1,66 +0,0 @@
// Copyright 2008 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
#define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
#include "gtest/gtest.h"
#if GTEST_HAS_TYPED_TEST_P
using testing::Test;
// For testing that the same type-parameterized test case can be
// instantiated in different translation units linked together.
// ContainerTest will be instantiated in both gtest-typed-test_test.cc
// and gtest-typed-test2_test.cc.
template <typename T>
class ContainerTest : public Test {
};
TYPED_TEST_CASE_P(ContainerTest);
TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {
TypeParam container;
}
TYPED_TEST_P(ContainerTest, InitialSizeIsZero) {
TypeParam container;
EXPECT_EQ(0U, container.size());
}
REGISTER_TYPED_TEST_CASE_P(ContainerTest,
CanBeDefaultConstructed, InitialSizeIsZero);
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_

View File

@ -1,341 +0,0 @@
// Copyright 2009 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// The Google C++ Testing Framework (Google Test)
//
// This file contains tests verifying correctness of data provided via
// UnitTest's public methods.
#include "gtest/gtest.h"
#include <string.h> // For strcmp.
#include <algorithm>
using ::testing::InitGoogleTest;
namespace testing {
namespace internal {
template <typename T>
struct LessByName {
bool operator()(const T* a, const T* b) {
return strcmp(a->name(), b->name()) < 0;
}
};
class UnitTestHelper {
public:
// Returns the array of pointers to all test cases sorted by the test case
// name. The caller is responsible for deleting the array.
static TestCase const** const GetSortedTestCases() {
UnitTest& unit_test = *UnitTest::GetInstance();
TestCase const** const test_cases =
new const TestCase*[unit_test.total_test_case_count()];
for (int i = 0; i < unit_test.total_test_case_count(); ++i)
test_cases[i] = unit_test.GetTestCase(i);
std::sort(test_cases,
test_cases + unit_test.total_test_case_count(),
LessByName<TestCase>());
return test_cases;
}
// Returns the test case by its name. The caller doesn't own the returned
// pointer.
static const TestCase* FindTestCase(const char* name) {
UnitTest& unit_test = *UnitTest::GetInstance();
for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
const TestCase* test_case = unit_test.GetTestCase(i);
if (0 == strcmp(test_case->name(), name))
return test_case;
}
return NULL;
}
// Returns the array of pointers to all tests in a particular test case
// sorted by the test name. The caller is responsible for deleting the
// array.
static TestInfo const** const GetSortedTests(const TestCase* test_case) {
TestInfo const** const tests =
new const TestInfo*[test_case->total_test_count()];
for (int i = 0; i < test_case->total_test_count(); ++i)
tests[i] = test_case->GetTestInfo(i);
std::sort(tests, tests + test_case->total_test_count(),
LessByName<TestInfo>());
return tests;
}
};
#if GTEST_HAS_TYPED_TEST
template <typename T> class TestCaseWithCommentTest : public Test {};
TYPED_TEST_CASE(TestCaseWithCommentTest, Types<int>);
TYPED_TEST(TestCaseWithCommentTest, Dummy) {}
const int kTypedTestCases = 1;
const int kTypedTests = 1;
#else
const int kTypedTestCases = 0;
const int kTypedTests = 0;
#endif // GTEST_HAS_TYPED_TEST
// We can only test the accessors that do not change value while tests run.
// Since tests can be run in any order, the values the accessors that track
// test execution (such as failed_test_count) can not be predicted.
TEST(ApiTest, UnitTestImmutableAccessorsWork) {
UnitTest* unit_test = UnitTest::GetInstance();
ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());
EXPECT_EQ(1 + kTypedTestCases, unit_test->test_case_to_run_count());
EXPECT_EQ(2, unit_test->disabled_test_count());
EXPECT_EQ(5 + kTypedTests, unit_test->total_test_count());
EXPECT_EQ(3 + kTypedTests, unit_test->test_to_run_count());
const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();
EXPECT_STREQ("ApiTest", test_cases[0]->name());
EXPECT_STREQ("DISABLED_Test", test_cases[1]->name());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ("TestCaseWithCommentTest/0", test_cases[2]->name());
#endif // GTEST_HAS_TYPED_TEST
delete[] test_cases;
// The following lines initiate actions to verify certain methods in
// FinalSuccessChecker::TearDown.
// Records a test property to verify TestResult::GetTestProperty().
RecordProperty("key", "value");
}
AssertionResult IsNull(const char* str) {
if (str != NULL) {
return testing::AssertionFailure() << "argument is " << str;
}
return AssertionSuccess();
}
TEST(ApiTest, TestCaseImmutableAccessorsWork) {
const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest");
ASSERT_TRUE(test_case != NULL);
EXPECT_STREQ("ApiTest", test_case->name());
EXPECT_TRUE(IsNull(test_case->type_param()));
EXPECT_TRUE(test_case->should_run());
EXPECT_EQ(1, test_case->disabled_test_count());
EXPECT_EQ(3, test_case->test_to_run_count());
ASSERT_EQ(4, test_case->total_test_count());
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
EXPECT_STREQ("ApiTest", tests[0]->test_case_name());
EXPECT_TRUE(IsNull(tests[0]->value_param()));
EXPECT_TRUE(IsNull(tests[0]->type_param()));
EXPECT_FALSE(tests[0]->should_run());
EXPECT_STREQ("TestCaseDisabledAccessorsWork", tests[1]->name());
EXPECT_STREQ("ApiTest", tests[1]->test_case_name());
EXPECT_TRUE(IsNull(tests[1]->value_param()));
EXPECT_TRUE(IsNull(tests[1]->type_param()));
EXPECT_TRUE(tests[1]->should_run());
EXPECT_STREQ("TestCaseImmutableAccessorsWork", tests[2]->name());
EXPECT_STREQ("ApiTest", tests[2]->test_case_name());
EXPECT_TRUE(IsNull(tests[2]->value_param()));
EXPECT_TRUE(IsNull(tests[2]->type_param()));
EXPECT_TRUE(tests[2]->should_run());
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
EXPECT_STREQ("ApiTest", tests[3]->test_case_name());
EXPECT_TRUE(IsNull(tests[3]->value_param()));
EXPECT_TRUE(IsNull(tests[3]->type_param()));
EXPECT_TRUE(tests[3]->should_run());
delete[] tests;
tests = NULL;
#if GTEST_HAS_TYPED_TEST
test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0");
ASSERT_TRUE(test_case != NULL);
EXPECT_STREQ("TestCaseWithCommentTest/0", test_case->name());
EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param());
EXPECT_TRUE(test_case->should_run());
EXPECT_EQ(0, test_case->disabled_test_count());
EXPECT_EQ(1, test_case->test_to_run_count());
ASSERT_EQ(1, test_case->total_test_count());
tests = UnitTestHelper::GetSortedTests(test_case);
EXPECT_STREQ("Dummy", tests[0]->name());
EXPECT_STREQ("TestCaseWithCommentTest/0", tests[0]->test_case_name());
EXPECT_TRUE(IsNull(tests[0]->value_param()));
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
EXPECT_TRUE(tests[0]->should_run());
delete[] tests;
#endif // GTEST_HAS_TYPED_TEST
}
TEST(ApiTest, TestCaseDisabledAccessorsWork) {
const TestCase* test_case = UnitTestHelper::FindTestCase("DISABLED_Test");
ASSERT_TRUE(test_case != NULL);
EXPECT_STREQ("DISABLED_Test", test_case->name());
EXPECT_TRUE(IsNull(test_case->type_param()));
EXPECT_FALSE(test_case->should_run());
EXPECT_EQ(1, test_case->disabled_test_count());
EXPECT_EQ(0, test_case->test_to_run_count());
ASSERT_EQ(1, test_case->total_test_count());
const TestInfo* const test_info = test_case->GetTestInfo(0);
EXPECT_STREQ("Dummy2", test_info->name());
EXPECT_STREQ("DISABLED_Test", test_info->test_case_name());
EXPECT_TRUE(IsNull(test_info->value_param()));
EXPECT_TRUE(IsNull(test_info->type_param()));
EXPECT_FALSE(test_info->should_run());
}
// These two tests are here to provide support for testing
// test_case_to_run_count, disabled_test_count, and test_to_run_count.
TEST(ApiTest, DISABLED_Dummy1) {}
TEST(DISABLED_Test, Dummy2) {}
class FinalSuccessChecker : public Environment {
protected:
virtual void TearDown() {
UnitTest* unit_test = UnitTest::GetInstance();
EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());
EXPECT_EQ(3 + kTypedTests, unit_test->successful_test_count());
EXPECT_EQ(0, unit_test->failed_test_case_count());
EXPECT_EQ(0, unit_test->failed_test_count());
EXPECT_TRUE(unit_test->Passed());
EXPECT_FALSE(unit_test->Failed());
ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());
const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();
EXPECT_STREQ("ApiTest", test_cases[0]->name());
EXPECT_TRUE(IsNull(test_cases[0]->type_param()));
EXPECT_TRUE(test_cases[0]->should_run());
EXPECT_EQ(1, test_cases[0]->disabled_test_count());
ASSERT_EQ(4, test_cases[0]->total_test_count());
EXPECT_EQ(3, test_cases[0]->successful_test_count());
EXPECT_EQ(0, test_cases[0]->failed_test_count());
EXPECT_TRUE(test_cases[0]->Passed());
EXPECT_FALSE(test_cases[0]->Failed());
EXPECT_STREQ("DISABLED_Test", test_cases[1]->name());
EXPECT_TRUE(IsNull(test_cases[1]->type_param()));
EXPECT_FALSE(test_cases[1]->should_run());
EXPECT_EQ(1, test_cases[1]->disabled_test_count());
ASSERT_EQ(1, test_cases[1]->total_test_count());
EXPECT_EQ(0, test_cases[1]->successful_test_count());
EXPECT_EQ(0, test_cases[1]->failed_test_count());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ("TestCaseWithCommentTest/0", test_cases[2]->name());
EXPECT_STREQ(GetTypeName<int>().c_str(), test_cases[2]->type_param());
EXPECT_TRUE(test_cases[2]->should_run());
EXPECT_EQ(0, test_cases[2]->disabled_test_count());
ASSERT_EQ(1, test_cases[2]->total_test_count());
EXPECT_EQ(1, test_cases[2]->successful_test_count());
EXPECT_EQ(0, test_cases[2]->failed_test_count());
EXPECT_TRUE(test_cases[2]->Passed());
EXPECT_FALSE(test_cases[2]->Failed());
#endif // GTEST_HAS_TYPED_TEST
const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest");
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
EXPECT_STREQ("ApiTest", tests[0]->test_case_name());
EXPECT_FALSE(tests[0]->should_run());
EXPECT_STREQ("TestCaseDisabledAccessorsWork", tests[1]->name());
EXPECT_STREQ("ApiTest", tests[1]->test_case_name());
EXPECT_TRUE(IsNull(tests[1]->value_param()));
EXPECT_TRUE(IsNull(tests[1]->type_param()));
EXPECT_TRUE(tests[1]->should_run());
EXPECT_TRUE(tests[1]->result()->Passed());
EXPECT_EQ(0, tests[1]->result()->test_property_count());
EXPECT_STREQ("TestCaseImmutableAccessorsWork", tests[2]->name());
EXPECT_STREQ("ApiTest", tests[2]->test_case_name());
EXPECT_TRUE(IsNull(tests[2]->value_param()));
EXPECT_TRUE(IsNull(tests[2]->type_param()));
EXPECT_TRUE(tests[2]->should_run());
EXPECT_TRUE(tests[2]->result()->Passed());
EXPECT_EQ(0, tests[2]->result()->test_property_count());
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
EXPECT_STREQ("ApiTest", tests[3]->test_case_name());
EXPECT_TRUE(IsNull(tests[3]->value_param()));
EXPECT_TRUE(IsNull(tests[3]->type_param()));
EXPECT_TRUE(tests[3]->should_run());
EXPECT_TRUE(tests[3]->result()->Passed());
EXPECT_EQ(1, tests[3]->result()->test_property_count());
const TestProperty& property = tests[3]->result()->GetTestProperty(0);
EXPECT_STREQ("key", property.key());
EXPECT_STREQ("value", property.value());
delete[] tests;
#if GTEST_HAS_TYPED_TEST
test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0");
tests = UnitTestHelper::GetSortedTests(test_case);
EXPECT_STREQ("Dummy", tests[0]->name());
EXPECT_STREQ("TestCaseWithCommentTest/0", tests[0]->test_case_name());
EXPECT_TRUE(IsNull(tests[0]->value_param()));
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
EXPECT_TRUE(tests[0]->should_run());
EXPECT_TRUE(tests[0]->result()->Passed());
EXPECT_EQ(0, tests[0]->result()->test_property_count());
delete[] tests;
#endif // GTEST_HAS_TYPED_TEST
delete[] test_cases;
}
};
} // namespace internal
} // namespace testing
int main(int argc, char **argv) {
InitGoogleTest(&argc, argv);
AddGlobalTestEnvironment(new testing::internal::FinalSuccessChecker());
return RUN_ALL_TESTS();
}

View File

@ -1,47 +0,0 @@
// Copyright 2009, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// Tests for Google C++ Testing Framework (Google Test)
//
// Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose.
#include "test/gtest-filepath_test.cc"
#include "test/gtest-linked_ptr_test.cc"
#include "test/gtest-message_test.cc"
#include "test/gtest-options_test.cc"
#include "test/gtest-port_test.cc"
#include "test/gtest_pred_impl_unittest.cc"
#include "test/gtest_prod_test.cc"
#include "test/gtest-test-part_test.cc"
#include "test/gtest-typed-test_test.cc"
#include "test/gtest-typed-test2_test.cc"
#include "test/gtest_unittest.cc"
#include "test/production.cc"

View File

@ -1,218 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Unit test for Google Test's break-on-failure mode.
A user can ask Google Test to seg-fault when an assertion fails, using
either the GTEST_BREAK_ON_FAILURE environment variable or the
--gtest_break_on_failure flag. This script tests such functionality
by invoking gtest_break_on_failure_unittest_ (a program written with
Google Test) with different environments and command line flags.
"""
__author__ = 'wan@google.com (Zhanyong Wan)'
import gtest_test_utils
import os
import sys
# Constants.
IS_WINDOWS = os.name == 'nt'
# The environment variable for enabling/disabling the break-on-failure mode.
BREAK_ON_FAILURE_ENV_VAR = 'GTEST_BREAK_ON_FAILURE'
# The command line flag for enabling/disabling the break-on-failure mode.
BREAK_ON_FAILURE_FLAG = 'gtest_break_on_failure'
# The environment variable for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'
# The environment variable for enabling/disabling the catch-exceptions mode.
CATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS'
# Path to the gtest_break_on_failure_unittest_ program.
EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_break_on_failure_unittest_')
# Utilities.
environ = os.environ.copy()
def SetEnvVar(env_var, value):
"""Sets an environment variable to a given value; unsets it when the
given value is None.
"""
if value is not None:
environ[env_var] = value
elif env_var in environ:
del environ[env_var]
def Run(command):
"""Runs a command; returns 1 if it was killed by a signal, or 0 otherwise."""
p = gtest_test_utils.Subprocess(command, env=environ)
if p.terminated_by_signal:
return 1
else:
return 0
# The tests.
class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):
"""Tests using the GTEST_BREAK_ON_FAILURE environment variable or
the --gtest_break_on_failure flag to turn assertion failures into
segmentation faults.
"""
def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault):
"""Runs gtest_break_on_failure_unittest_ and verifies that it does
(or does not) have a seg-fault.
Args:
env_var_value: value of the GTEST_BREAK_ON_FAILURE environment
variable; None if the variable should be unset.
flag_value: value of the --gtest_break_on_failure flag;
None if the flag should not be present.
expect_seg_fault: 1 if the program is expected to generate a seg-fault;
0 otherwise.
"""
SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, env_var_value)
if env_var_value is None:
env_var_value_msg = ' is not set'
else:
env_var_value_msg = '=' + env_var_value
if flag_value is None:
flag = ''
elif flag_value == '0':
flag = '--%s=0' % BREAK_ON_FAILURE_FLAG
else:
flag = '--%s' % BREAK_ON_FAILURE_FLAG
command = [EXE_PATH]
if flag:
command.append(flag)
if expect_seg_fault:
should_or_not = 'should'
else:
should_or_not = 'should not'
has_seg_fault = Run(command)
SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, None)
msg = ('when %s%s, an assertion failure in "%s" %s cause a seg-fault.' %
(BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command),
should_or_not))
self.assert_(has_seg_fault == expect_seg_fault, msg)
def testDefaultBehavior(self):
"""Tests the behavior of the default mode."""
self.RunAndVerify(env_var_value=None,
flag_value=None,
expect_seg_fault=0)
def testEnvVar(self):
"""Tests using the GTEST_BREAK_ON_FAILURE environment variable."""
self.RunAndVerify(env_var_value='0',
flag_value=None,
expect_seg_fault=0)
self.RunAndVerify(env_var_value='1',
flag_value=None,
expect_seg_fault=1)
def testFlag(self):
"""Tests using the --gtest_break_on_failure flag."""
self.RunAndVerify(env_var_value=None,
flag_value='0',
expect_seg_fault=0)
self.RunAndVerify(env_var_value=None,
flag_value='1',
expect_seg_fault=1)
def testFlagOverridesEnvVar(self):
"""Tests that the flag overrides the environment variable."""
self.RunAndVerify(env_var_value='0',
flag_value='0',
expect_seg_fault=0)
self.RunAndVerify(env_var_value='0',
flag_value='1',
expect_seg_fault=1)
self.RunAndVerify(env_var_value='1',
flag_value='0',
expect_seg_fault=0)
self.RunAndVerify(env_var_value='1',
flag_value='1',
expect_seg_fault=1)
def testBreakOnFailureOverridesThrowOnFailure(self):
"""Tests that gtest_break_on_failure overrides gtest_throw_on_failure."""
SetEnvVar(THROW_ON_FAILURE_ENV_VAR, '1')
try:
self.RunAndVerify(env_var_value=None,
flag_value='1',
expect_seg_fault=1)
finally:
SetEnvVar(THROW_ON_FAILURE_ENV_VAR, None)
if IS_WINDOWS:
def testCatchExceptionsDoesNotInterfere(self):
"""Tests that gtest_catch_exceptions doesn't interfere."""
SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, '1')
try:
self.RunAndVerify(env_var_value='1',
flag_value='1',
expect_seg_fault=1)
finally:
SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, None)
if __name__ == '__main__':
gtest_test_utils.Main()

View File

@ -1,88 +0,0 @@
// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Unit test for Google Test's break-on-failure mode.
//
// A user can ask Google Test to seg-fault when an assertion fails, using
// either the GTEST_BREAK_ON_FAILURE environment variable or the
// --gtest_break_on_failure flag. This file is used for testing such
// functionality.
//
// This program will be invoked from a Python unit test. It is
// expected to fail. Don't run it directly.
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS
# include <windows.h>
# include <stdlib.h>
#endif
namespace {
// A test that's expected to fail.
TEST(Foo, Bar) {
EXPECT_EQ(2, 3);
}
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
// On Windows Mobile global exception handlers are not supported.
LONG WINAPI ExitWithExceptionCode(
struct _EXCEPTION_POINTERS* exception_pointers) {
exit(exception_pointers->ExceptionRecord->ExceptionCode);
}
#endif
} // namespace
int main(int argc, char **argv) {
#if GTEST_OS_WINDOWS
// Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation).
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
# if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
// The default unhandled exception filter does not always exit
// with the exception code as exit code - for example it exits with
// 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
// if the application is compiled in debug mode. Thus we use our own
// filter which always exits with the exception code for unhandled
// exceptions.
SetUnhandledExceptionFilter(ExitWithExceptionCode);
# endif
#endif
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,220 +0,0 @@
#!/usr/bin/env python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests Google Test's exception catching behavior.
This script invokes gtest_catch_exceptions_test_ and
gtest_catch_exceptions_ex_test_ (programs written with
Google Test) and verifies their output.
"""
__author__ = 'vladl@google.com (Vlad Losev)'
import os
import gtest_test_utils
# Constants.
FLAG_PREFIX = '--gtest_'
LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
NO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0'
FILTER_FLAG = FLAG_PREFIX + 'filter'
# Path to the gtest_catch_exceptions_ex_test_ binary, compiled with
# exceptions enabled.
EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_catch_exceptions_ex_test_')
# Path to the gtest_catch_exceptions_test_ binary, compiled with
# exceptions disabled.
EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_catch_exceptions_no_ex_test_')
TEST_LIST = gtest_test_utils.Subprocess([EXE_PATH, LIST_TESTS_FLAG]).output
SUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST
if SUPPORTS_SEH_EXCEPTIONS:
BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output
EX_BINARY_OUTPUT = gtest_test_utils.Subprocess([EX_EXE_PATH]).output
# The tests.
if SUPPORTS_SEH_EXCEPTIONS:
# pylint:disable-msg=C6302
class CatchSehExceptionsTest(gtest_test_utils.TestCase):
"""Tests exception-catching behavior."""
def TestSehExceptions(self, test_output):
self.assert_('SEH exception with code 0x2a thrown '
'in the test fixture\'s constructor'
in test_output)
self.assert_('SEH exception with code 0x2a thrown '
'in the test fixture\'s destructor'
in test_output)
self.assert_('SEH exception with code 0x2a thrown in SetUpTestCase()'
in test_output)
self.assert_('SEH exception with code 0x2a thrown in TearDownTestCase()'
in test_output)
self.assert_('SEH exception with code 0x2a thrown in SetUp()'
in test_output)
self.assert_('SEH exception with code 0x2a thrown in TearDown()'
in test_output)
self.assert_('SEH exception with code 0x2a thrown in the test body'
in test_output)
def testCatchesSehExceptionsWithCxxExceptionsEnabled(self):
self.TestSehExceptions(EX_BINARY_OUTPUT)
def testCatchesSehExceptionsWithCxxExceptionsDisabled(self):
self.TestSehExceptions(BINARY_OUTPUT)
class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
"""Tests C++ exception-catching behavior.
Tests in this test case verify that:
* C++ exceptions are caught and logged as C++ (not SEH) exceptions
* Exception thrown affect the remainder of the test work flow in the
expected manner.
"""
def testCatchesCxxExceptionsInFixtureConstructor(self):
self.assert_('C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture\'s constructor'
in EX_BINARY_OUTPUT)
self.assert_('unexpected' not in EX_BINARY_OUTPUT,
'This failure belongs in this test only if '
'"CxxExceptionInConstructorTest" (no quotes) '
'appears on the same line as words "called unexpectedly"')
def testCatchesCxxExceptionsInFixtureDestructor(self):
self.assert_('C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture\'s destructor'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '
'called as expected.'
in EX_BINARY_OUTPUT)
def testCatchesCxxExceptionsInSetUpTestCase(self):
self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in SetUpTestCase()'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTestCaseTest constructor '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTestCaseTest destructor '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTestCaseTest::SetUp() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTestCaseTest::TearDown() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTestCaseTest test body '
'called as expected.'
in EX_BINARY_OUTPUT)
def testCatchesCxxExceptionsInTearDownTestCase(self):
self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in TearDownTestCase()'
in EX_BINARY_OUTPUT)
def testCatchesCxxExceptionsInSetUp(self):
self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in SetUp()'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTest::TearDownTestCase() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTest destructor '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInSetUpTest::TearDown() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('unexpected' not in EX_BINARY_OUTPUT,
'This failure belongs in this test only if '
'"CxxExceptionInSetUpTest" (no quotes) '
'appears on the same line as words "called unexpectedly"')
def testCatchesCxxExceptionsInTearDown(self):
self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in TearDown()'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInTearDownTest::TearDownTestCase() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInTearDownTest destructor '
'called as expected.'
in EX_BINARY_OUTPUT)
def testCatchesCxxExceptionsInTestBody(self):
self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in the test body'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInTestBodyTest::TearDownTestCase() '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInTestBodyTest destructor '
'called as expected.'
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInTestBodyTest::TearDown() '
'called as expected.'
in EX_BINARY_OUTPUT)
def testCatchesNonStdCxxExceptions(self):
self.assert_('Unknown C++ exception thrown in the test body'
in EX_BINARY_OUTPUT)
def testUnhandledCxxExceptionsAbortTheProgram(self):
# Filters out SEH exception tests on Windows. Unhandled SEH exceptions
# cause tests to show pop-up windows there.
FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'
# By default, Google Test doesn't catch the exceptions.
uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(
[EX_EXE_PATH,
NO_CATCH_EXCEPTIONS_FLAG,
FITLER_OUT_SEH_TESTS_FLAG]).output
self.assert_('Unhandled C++ exception terminating the program'
in uncaught_exceptions_ex_binary_output)
self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output)
if __name__ == '__main__':
gtest_test_utils.Main()

View File

@ -1,308 +0,0 @@
// Copyright 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. Tests in this file throw C++ or SEH
// exceptions, and the output is verified by gtest_catch_exceptions_test.py.
#include "gtest/gtest.h"
#include <stdio.h> // NOLINT
#include <stdlib.h> // For exit().
#if GTEST_HAS_SEH
# include <windows.h>
#endif
#if GTEST_HAS_EXCEPTIONS
# include <exception> // For set_terminate().
# include <stdexcept>
#endif
using testing::Test;
#if GTEST_HAS_SEH
class SehExceptionInConstructorTest : public Test {
public:
SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInConstructorTest, ThrowsExceptionInConstructor) {}
class SehExceptionInDestructorTest : public Test {
public:
~SehExceptionInDestructorTest() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
class SehExceptionInSetUpTestCaseTest : public Test {
public:
static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}
class SehExceptionInTearDownTestCaseTest : public Test {
public:
static void TearDownTestCase() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
class SehExceptionInSetUpTest : public Test {
protected:
virtual void SetUp() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}
class SehExceptionInTearDownTest : public Test {
protected:
virtual void TearDown() { RaiseException(42, 0, 0, NULL); }
};
TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
TEST(SehExceptionTest, ThrowsSehException) {
RaiseException(42, 0, 0, NULL);
}
#endif // GTEST_HAS_SEH
#if GTEST_HAS_EXCEPTIONS
class CxxExceptionInConstructorTest : public Test {
public:
CxxExceptionInConstructorTest() {
// Without this macro VC++ complains about unreachable code at the end of
// the constructor.
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(
throw std::runtime_error("Standard C++ exception"));
}
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInConstructorTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInConstructorTest() {
ADD_FAILURE() << "CxxExceptionInConstructorTest destructor "
<< "called unexpectedly.";
}
virtual void SetUp() {
ADD_FAILURE() << "CxxExceptionInConstructorTest::SetUp() "
<< "called unexpectedly.";
}
virtual void TearDown() {
ADD_FAILURE() << "CxxExceptionInConstructorTest::TearDown() "
<< "called unexpectedly.";
}
};
TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
ADD_FAILURE() << "CxxExceptionInConstructorTest test body "
<< "called unexpectedly.";
}
class CxxExceptionInDestructorTest : public Test {
public:
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInDestructorTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInDestructorTest() {
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(
throw std::runtime_error("Standard C++ exception"));
}
};
TEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
class CxxExceptionInSetUpTestCaseTest : public Test {
public:
CxxExceptionInSetUpTestCaseTest() {
printf("%s",
"CxxExceptionInSetUpTestCaseTest constructor "
"called as expected.\n");
}
static void SetUpTestCase() {
throw std::runtime_error("Standard C++ exception");
}
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInSetUpTestCaseTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInSetUpTestCaseTest() {
printf("%s",
"CxxExceptionInSetUpTestCaseTest destructor "
"called as expected.\n");
}
virtual void SetUp() {
printf("%s",
"CxxExceptionInSetUpTestCaseTest::SetUp() "
"called as expected.\n");
}
virtual void TearDown() {
printf("%s",
"CxxExceptionInSetUpTestCaseTest::TearDown() "
"called as expected.\n");
}
};
TEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {
printf("%s",
"CxxExceptionInSetUpTestCaseTest test body "
"called as expected.\n");
}
class CxxExceptionInTearDownTestCaseTest : public Test {
public:
static void TearDownTestCase() {
throw std::runtime_error("Standard C++ exception");
}
};
TEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
class CxxExceptionInSetUpTest : public Test {
public:
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInSetUpTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInSetUpTest() {
printf("%s",
"CxxExceptionInSetUpTest destructor "
"called as expected.\n");
}
virtual void SetUp() { throw std::runtime_error("Standard C++ exception"); }
virtual void TearDown() {
printf("%s",
"CxxExceptionInSetUpTest::TearDown() "
"called as expected.\n");
}
};
TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
ADD_FAILURE() << "CxxExceptionInSetUpTest test body "
<< "called unexpectedly.";
}
class CxxExceptionInTearDownTest : public Test {
public:
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInTearDownTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInTearDownTest() {
printf("%s",
"CxxExceptionInTearDownTest destructor "
"called as expected.\n");
}
virtual void TearDown() {
throw std::runtime_error("Standard C++ exception");
}
};
TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
class CxxExceptionInTestBodyTest : public Test {
public:
static void TearDownTestCase() {
printf("%s",
"CxxExceptionInTestBodyTest::TearDownTestCase() "
"called as expected.\n");
}
protected:
~CxxExceptionInTestBodyTest() {
printf("%s",
"CxxExceptionInTestBodyTest destructor "
"called as expected.\n");
}
virtual void TearDown() {
printf("%s",
"CxxExceptionInTestBodyTest::TearDown() "
"called as expected.\n");
}
};
TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {
throw std::runtime_error("Standard C++ exception");
}
TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
throw "C-string";
}
// This terminate handler aborts the program using exit() rather than abort().
// This avoids showing pop-ups on Windows systems and core dumps on Unix-like
// ones.
void TerminateHandler() {
fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program.");
fflush(NULL);
exit(3);
}
#endif // GTEST_HAS_EXCEPTIONS
int main(int argc, char** argv) {
#if GTEST_HAS_EXCEPTIONS
std::set_terminate(&TerminateHandler);
#endif
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

Some files were not shown because too many files have changed in this diff Show More