mirror of
				https://github.com/fmtlib/fmt.git
				synced 2025-11-03 23:51:41 +01:00 
			
		
		
		
	* 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
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
// Formatting library for C++ - time formatting tests
 | 
						|
//
 | 
						|
// Copyright (c) 2012 - present, Victor Zverovich
 | 
						|
// All rights reserved.
 | 
						|
//
 | 
						|
// For the license information refer to format.h.
 | 
						|
 | 
						|
#ifdef WIN32
 | 
						|
#define _CRT_SECURE_NO_WARNINGS
 | 
						|
#endif
 | 
						|
 | 
						|
#include "gmock.h"
 | 
						|
#include "fmt/time.h"
 | 
						|
 | 
						|
TEST(TimeTest, Format) {
 | 
						|
  std::tm tm = std::tm();
 | 
						|
  tm.tm_year = 116;
 | 
						|
  tm.tm_mon  = 3;
 | 
						|
  tm.tm_mday = 25;
 | 
						|
  EXPECT_EQ("The date is 2016-04-25.",
 | 
						|
            fmt::format("The date is {:%Y-%m-%d}.", tm));
 | 
						|
}
 | 
						|
 | 
						|
TEST(TimeTest, GrowBuffer) {
 | 
						|
  std::string s = "{:";
 | 
						|
  for (int i = 0; i < 30; ++i)
 | 
						|
    s += "%c";
 | 
						|
  s += "}\n";
 | 
						|
  std::time_t t = std::time(nullptr);
 | 
						|
  fmt::format(s, *std::localtime(&t));
 | 
						|
}
 | 
						|
 | 
						|
TEST(TimeTest, EmptyResult) {
 | 
						|
  EXPECT_EQ("", fmt::format("{}", std::tm()));
 | 
						|
}
 | 
						|
 | 
						|
static bool EqualTime(const std::tm &lhs, const std::tm &rhs) {
 | 
						|
  return lhs.tm_sec == rhs.tm_sec &&
 | 
						|
         lhs.tm_min == rhs.tm_min &&
 | 
						|
         lhs.tm_hour == rhs.tm_hour &&
 | 
						|
         lhs.tm_mday == rhs.tm_mday &&
 | 
						|
         lhs.tm_mon == rhs.tm_mon &&
 | 
						|
         lhs.tm_year == rhs.tm_year &&
 | 
						|
         lhs.tm_wday == rhs.tm_wday &&
 | 
						|
         lhs.tm_yday == rhs.tm_yday &&
 | 
						|
         lhs.tm_isdst == rhs.tm_isdst;
 | 
						|
}
 | 
						|
 | 
						|
TEST(TimeTest, LocalTime) {
 | 
						|
  std::time_t t = std::time(nullptr);
 | 
						|
  std::tm tm = *std::localtime(&t);
 | 
						|
  EXPECT_TRUE(EqualTime(tm, fmt::localtime(t)));
 | 
						|
}
 | 
						|
 | 
						|
TEST(TimeTest, GMTime) {
 | 
						|
  std::time_t t = std::time(nullptr);
 | 
						|
  std::tm tm = *std::gmtime(&t);
 | 
						|
  EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t)));
 | 
						|
}
 |