Parameterize Formatter on character type and rename it to BasicFormatter.
This commit is contained in:
+7
-14
@@ -25,12 +25,6 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Disable useless MSVC warnings.
|
||||
#undef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#undef _SCL_SECURE_NO_WARNINGS
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <cctype>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
@@ -980,7 +974,7 @@ struct CountCalls {
|
||||
TEST(TempFormatterTest, Action) {
|
||||
int num_calls = 0;
|
||||
{
|
||||
fmt::TempFormatter<CountCalls> af("test", CountCalls(num_calls));
|
||||
fmt::TempFormatter<char, CountCalls> af("test", CountCalls(num_calls));
|
||||
EXPECT_EQ(0, num_calls);
|
||||
}
|
||||
EXPECT_EQ(1, num_calls);
|
||||
@@ -989,9 +983,8 @@ TEST(TempFormatterTest, Action) {
|
||||
TEST(TempFormatterTest, ActionNotCalledOnError) {
|
||||
int num_calls = 0;
|
||||
{
|
||||
EXPECT_THROW(
|
||||
fmt::TempFormatter<CountCalls> af("{0", CountCalls(num_calls)),
|
||||
FormatError);
|
||||
typedef fmt::TempFormatter<char, CountCalls> TestFormatter;
|
||||
EXPECT_THROW(TestFormatter af("{0", CountCalls(num_calls)), FormatError);
|
||||
}
|
||||
EXPECT_EQ(0, num_calls);
|
||||
}
|
||||
@@ -1003,8 +996,8 @@ TEST(TempFormatterTest, ActionNotCalledOnError) {
|
||||
TEST(TempFormatterTest, ArgLifetime) {
|
||||
// The following code is for testing purposes only. It is a definite abuse
|
||||
// of the API and shouldn't be used in real applications.
|
||||
const fmt::TempFormatter<> &af = fmt::Format("{0}");
|
||||
const_cast<fmt::TempFormatter<>&>(af) << std::string("test");
|
||||
const fmt::TempFormatter<char> &af = fmt::Format("{0}");
|
||||
const_cast<fmt::TempFormatter<char>&>(af) << std::string("test");
|
||||
// String object passed as an argument to TempFormatter has
|
||||
// been destroyed, but ArgInserter dtor hasn't been called yet.
|
||||
// But that's OK since the Arg's dtor takes care of this and
|
||||
@@ -1023,8 +1016,8 @@ struct PrintError {
|
||||
}
|
||||
};
|
||||
|
||||
fmt::TempFormatter<PrintError> ReportError(const char *format) {
|
||||
return fmt::TempFormatter<PrintError>(format);
|
||||
fmt::TempFormatter<char, PrintError> ReportError(const char *format) {
|
||||
return fmt::TempFormatter<char, PrintError>(format);
|
||||
}
|
||||
|
||||
TEST(TempFormatterTest, Examples) {
|
||||
|
||||
Reference in New Issue
Block a user