mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Unconditionally provide <chrono> StringMakers
This commit is contained in:
parent
34bc56340d
commit
bce5b364d3
@ -206,7 +206,6 @@ By default, Catch does not stringify some types from the standard library. This
|
|||||||
|
|
||||||
CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER // Provide StringMaker specialization for std::pair
|
CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER // Provide StringMaker specialization for std::pair
|
||||||
CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER // Provide StringMaker specialization for std::tuple
|
CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER // Provide StringMaker specialization for std::tuple
|
||||||
CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER // Provide StringMaker specialization for std::chrono::duration, std::chrono::timepoint
|
|
||||||
CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER // Provide StringMaker specialization for std::variant, std::monostate (on C++17)
|
CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER // Provide StringMaker specialization for std::variant, std::monostate (on C++17)
|
||||||
CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER // Provide StringMaker specialization for std::optional (on C++17)
|
CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER // Provide StringMaker specialization for std::optional (on C++17)
|
||||||
CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS // Defines all of the above
|
CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS // Defines all of the above
|
||||||
|
@ -59,7 +59,8 @@
|
|||||||
### Other changes
|
### Other changes
|
||||||
* `CATCH_CONFIG_DISABLE_MATCHERS` no longer exists.
|
* `CATCH_CONFIG_DISABLE_MATCHERS` no longer exists.
|
||||||
* If you do not want to use Matchers in a TU, do not include their header.
|
* If you do not want to use Matchers in a TU, do not include their header.
|
||||||
|
* `CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER` no longer exists.
|
||||||
|
* `StringMaker` specializations for <chrono> are always provided
|
||||||
|
|
||||||
## 2.10.2
|
## 2.10.2
|
||||||
|
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
# pragma clang diagnostic ignored "-Wglobal-constructors"
|
# pragma clang diagnostic ignored "-Wglobal-constructors"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable specific decls locally
|
|
||||||
#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
|
|
||||||
#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <catch2/catch_tostring.h>
|
#include <catch2/catch_tostring.h>
|
||||||
#include <catch2/catch_interfaces_config.h>
|
#include <catch2/catch_interfaces_config.h>
|
||||||
@ -250,13 +246,6 @@ std::string StringMaker<double>::convert(double value) {
|
|||||||
return fpToString(value, precision);
|
return fpToString(value, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ratio_string<std::atto>::symbol() { return "a"; }
|
|
||||||
std::string ratio_string<std::femto>::symbol() { return "f"; }
|
|
||||||
std::string ratio_string<std::pico>::symbol() { return "p"; }
|
|
||||||
std::string ratio_string<std::nano>::symbol() { return "n"; }
|
|
||||||
std::string ratio_string<std::micro>::symbol() { return "u"; }
|
|
||||||
std::string ratio_string<std::milli>::symbol() { return "m"; }
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -351,13 +351,12 @@ namespace Catch {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Separate std-lib types stringification, so it can be selectively enabled
|
// Separate std-lib types stringification, so it can be selectively enabled
|
||||||
// This means that we do not bring in
|
// This means that we do not bring in their headers
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
|
#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
|
||||||
# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
||||||
# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||||
# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||||
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
|
||||||
# define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
|
# define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -532,7 +531,6 @@ namespace Catch {
|
|||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
// Separate std::chrono::duration specialization
|
// Separate std::chrono::duration specialization
|
||||||
#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -552,29 +550,31 @@ std::string ratio_string<Ratio>::symbol() {
|
|||||||
<< Ratio::den << ']';
|
<< Ratio::den << ']';
|
||||||
return rss.str();
|
return rss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::atto> {
|
struct ratio_string<std::atto> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "a"; }
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::femto> {
|
struct ratio_string<std::femto> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "f"; }
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::pico> {
|
struct ratio_string<std::pico> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "p"; }
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::nano> {
|
struct ratio_string<std::nano> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "n"; }
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::micro> {
|
struct ratio_string<std::micro> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "u"; }
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct ratio_string<std::milli> {
|
struct ratio_string<std::milli> {
|
||||||
static std::string symbol();
|
static std::string symbol() { return "m"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
@ -647,7 +647,6 @@ struct ratio_string<std::milli> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
|
||||||
|
|
||||||
#include <catch2/catch_interfaces_registry_hub.h>
|
#include <catch2/catch_interfaces_registry_hub.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
Loading…
Reference in New Issue
Block a user