comparison UnitTestsSources/GenericToolboxTests.cpp @ 1101:141593f1aa88

fix build on ubuntu
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 26 Oct 2019 11:35:41 +0200
parents 287ec78f63b4
children f7759637cdfb f68da12e852b
comparison
equal deleted inserted replaced
1094:dead648f8ff1 1101:141593f1aa88
3760 //const double FACTOR = 1.000000000171271211; 3760 //const double FACTOR = 1.000000000171271211;
3761 const double FACTOR = 1.71271211; 3761 const double FACTOR = 1.71271211;
3762 for (double b = DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR) 3762 for (double b = DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR)
3763 { 3763 {
3764 char txt[1024]; 3764 char txt[1024];
3765 #if defined(_MSC_VER)
3765 sprintf_s(txt, "%.17f", b); 3766 sprintf_s(txt, "%.17f", b);
3767 #else
3768 snprintf(txt, sizeof(txt) - 1, "%.17f", b);
3769 #endif
3766 double r = 0.0; 3770 double r = 0.0;
3767 bool ok = StringToDouble(r, txt); 3771 bool ok = StringToDouble(r, txt);
3768 3772
3769 #if 0 3773 #if 0
3770 if (ok) 3774 if (ok)
3800 //const double FACTOR = 1.000000000171271211; 3804 //const double FACTOR = 1.000000000171271211;
3801 const double FACTOR = 1.71271211; 3805 const double FACTOR = 1.71271211;
3802 for (double b = -1.0*DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR) 3806 for (double b = -1.0*DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR)
3803 { 3807 {
3804 char txt[1024]; 3808 char txt[1024];
3809 #if defined(_MSC_VER)
3805 sprintf_s(txt, "%.17f", b); 3810 sprintf_s(txt, "%.17f", b);
3811 #else
3812 snprintf(txt, sizeof(txt) - 1, "%.17f", b);
3813 #endif
3806 double r = 0.0; 3814 double r = 0.0;
3807 bool ok = StringToDouble(r, txt); 3815 bool ok = StringToDouble(r, txt);
3808 3816
3809 #if 0 3817 #if 0
3810 if (ok) 3818 if (ok)
3840 const double FACTOR = 1.71271211; 3848 const double FACTOR = 1.71271211;
3841 for (double b = DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR) 3849 for (double b = DBL_EPSILON; b < DBL_MAX && i < COUNT; ++i, b *= FACTOR)
3842 { 3850 {
3843 int64_t bi = static_cast<int64_t>(b); 3851 int64_t bi = static_cast<int64_t>(b);
3844 char txt[1024]; 3852 char txt[1024];
3845 #if (defined __clang__) || (defined __GNUC__) || ( (defined _MSC_VER) && (_MSC_VER > 1800) ) 3853 #if defined(_MSC_VER)
3854 # if (_MSC_VER > 1800)
3846 sprintf_s(txt, "%lld", bi); 3855 sprintf_s(txt, "%lld", bi);
3847 #elif (defined _MSC_VER) 3856 # else
3848 sprintf_s(txt, "%I64d", bi); 3857 sprintf_s(txt, "%I64d", bi);
3858 # endif
3849 #else 3859 #else
3850 #error Please adjust for your platform 3860 snprintf(txt, sizeof(txt) - 1, "%ld", bi);
3851 #endif 3861 #endif
3852 int64_t r = 0; 3862 int64_t r = 0;
3853 bool ok = StringToInteger<int64_t>(r, txt); 3863 bool ok = StringToInteger<int64_t>(r, txt);
3854 EXPECT_TRUE(ok); 3864 EXPECT_TRUE(ok);
3855 EXPECT_EQ(bi, r); 3865 EXPECT_EQ(bi, r);