From d604d40648c9cadd5631bd76d111df49d71d2999 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 25 Apr 2025 18:07:43 +0100 Subject: [PATCH] Added etl::chrono::hh_mm_ss --- include/etl/chrono.h | 18 ++ include/etl/private/chrono/duration.h | 29 ++- include/etl/private/chrono/hh_mm_ss.h | 186 +++++++++++++++ include/etl/private/chrono/month_day.h | 10 +- include/etl/private/chrono/weekday.h | 2 +- test/CMakeLists.txt | 5 + test/test_chrono_hh_mm_ss.cpp | 289 ++++++++++++++++++++++++ test/test_chrono_month.cpp | 3 - test/test_chrono_month_day.cpp | 4 +- test/test_chrono_month_weekday.cpp | 2 - test/test_chrono_month_weekday_last.cpp | 4 +- test/test_chrono_weekday.cpp | 2 + test/test_chrono_year.cpp | 1 + test/vs2022/etl.vcxproj | 13 +- test/vs2022/etl.vcxproj.filters | 12 +- 15 files changed, 554 insertions(+), 26 deletions(-) create mode 100644 include/etl/private/chrono/hh_mm_ss.h create mode 100644 test/test_chrono_hh_mm_ss.cpp diff --git a/include/etl/chrono.h b/include/etl/chrono.h index 0c35a887..84674ea5 100644 --- a/include/etl/chrono.h +++ b/include/etl/chrono.h @@ -34,6 +34,7 @@ SOFTWARE. #define ETL_IN_CHRONO_H #include "platform.h" +#include "type_traits.h" #if ETL_NOT_USING_CPP11 #error NOT SUPPORTED FOR C++03 OR BELOW @@ -42,6 +43,22 @@ SOFTWARE. #include +namespace etl +{ + namespace chrono + { + template + struct treat_as_floating_point : etl::is_floating_point + { + }; + +#if ETL_USING_CPP17 + template + constexpr bool treat_as_floating_point_v = treat_as_floating_point::value; +#endif + } +} + #include "private/chrono/last_spec.h" #include "private/chrono/duration.h" #include "private/chrono/day.h" @@ -50,6 +67,7 @@ SOFTWARE. #include "private/chrono/month_day.h" #include "private/chrono/month_weekday.h" #include "private/chrono/year.h" +#include "private/chrono/hh_mm_ss.h" #include "private/chrono/operators.h" #endif diff --git a/include/etl/private/chrono/duration.h b/include/etl/private/chrono/duration.h index df6ee983..1b929709 100644 --- a/include/etl/private/chrono/duration.h +++ b/include/etl/private/chrono/duration.h @@ -130,20 +130,23 @@ namespace etl ETL_CONSTEXPR duration(const etl::chrono::duration& other) ETL_NOEXCEPT : value(etl::chrono::duration_cast >(other).count()) { - - bool b = etl::ratio_divide::den == 1; - ETL_STATIC_ASSERT(!(etl::is_integral::value && etl::is_floating_point::value), "Cannot convert duration from floating point to integral"); } + //*********************************************************************** + ETL_CONSTEXPR14 + etl::chrono::duration operator =(const etl::chrono::duration& other) ETL_NOEXCEPT + { + value = other.count(); + + return *this; + } + //*********************************************************************** template ETL_CONSTEXPR14 - typename etl::enable_if::den == 1, etl::chrono::duration&>::type - operator =(const etl::chrono::duration& other) ETL_NOEXCEPT + etl::chrono::duration operator =(const etl::chrono::duration& other) ETL_NOEXCEPT { - bool b = etl::ratio_divide::den == 1; - value = etl::chrono::duration_cast >(other).count(); return *this; @@ -185,6 +188,12 @@ namespace etl return etl::chrono::duration(etl::chrono::duration_values::max()); } + //*********************************************************************** + ETL_CONSTEXPR etl::chrono::duration absolute() const ETL_NOEXCEPT + { + return etl::chrono::duration(value < 0 ? -value : value); + } + //*********************************************************************** ETL_CONSTEXPR duration& operator ++() { @@ -350,6 +359,12 @@ namespace etl return TToDuration(static_cast((ct_count * ct_num) / ct_den)); } } + + template + struct is_duration : etl::false_type {}; + + template + struct is_duration> : etl::true_type {}; } //************************************************************************* diff --git a/include/etl/private/chrono/hh_mm_ss.h b/include/etl/private/chrono/hh_mm_ss.h new file mode 100644 index 00000000..b987c96d --- /dev/null +++ b/include/etl/private/chrono/hh_mm_ss.h @@ -0,0 +1,186 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2025 John Wellbelove + +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. +******************************************************************************/ + +#ifndef ETL_IN_CHRONO_H + #error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H +#endif + +#include "../../absolute.h" +#include "../../power.h" + +namespace etl +{ + //*********************************************************************** + /// absolute + /// Enabled for etl::chrono::duration + //*********************************************************************** + template + ETL_NODISCARD + ETL_CONSTEXPR + typename etl::enable_if::value, TDuration>::type + absolute(TDuration dur) ETL_NOEXCEPT + { + return TDuration((dur.count() < 0) ? -dur.count() : dur.count()); + } + + namespace chrono + { + //*********************************************************************** + /// hh_mm_ss + //*********************************************************************** + template + class hh_mm_ss + { + public: + + //*********************************************************************** + // Fractional width for the duration's subseconds + //*********************************************************************** + static constexpr int fractional_width = []() constexpr + { + if (TDuration::period::den == 1) + { + return 0; + } + + int width = 0; + + for (auto den = TDuration::period::den; den > 1; den /= 10) + { + ++width; + } + + return width; + }(); + + //*********************************************************************** + /// The return type for to_duration. + //*********************************************************************** + using precision = etl::chrono::duration, + ratio<1, etl::power<10, fractional_width>::value>>; + + //*********************************************************************** + /// Default constructor. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + hh_mm_ss() ETL_NOEXCEPT + : d(TDuration::zero()) + { + } + + //*********************************************************************** + /// Construct from duration. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + explicit hh_mm_ss(TDuration d_) ETL_NOEXCEPT + : d(d_) + { + } + + //*********************************************************************** + /// Checks for negative duration. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + bool is_negative() const ETL_NOEXCEPT + { + return d < TDuration::zero(); + } + + //*********************************************************************** + /// Returns the hours. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + etl::chrono::hours hours() const ETL_NOEXCEPT + { + auto dur = etl::absolute(d); + + return etl::chrono::duration_cast(dur); + } + + //*********************************************************************** + /// Returns the minutes. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR etl::chrono::minutes minutes() const ETL_NOEXCEPT + { + auto dur = etl::absolute(d) - hours(); + + return etl::chrono::duration_cast(dur); + } + + //*********************************************************************** + /// Returns the seconds. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + etl::chrono::seconds seconds() const ETL_NOEXCEPT + { + auto dur = etl::absolute(d) - hours() - minutes(); + + return etl::chrono::duration_cast(dur); + } + + //*********************************************************************** + /// Returns the subseconds. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR precision subseconds() const ETL_NOEXCEPT + { + return etl::absolute(d) - etl::chrono::duration_cast(etl::absolute(d)); + } + + //*********************************************************************** + /// Returns the duration. + //*********************************************************************** + ETL_CONSTEXPR explicit operator precision() const ETL_NOEXCEPT + { + return to_duration(); + } + + //*********************************************************************** + /// Returns the duration. + //*********************************************************************** + ETL_NODISCARD + ETL_CONSTEXPR + precision to_duration() const ETL_NOEXCEPT + { + return d; + } + + private: + + TDuration d; + }; + } +} diff --git a/include/etl/private/chrono/month_day.h b/include/etl/private/chrono/month_day.h index e58f62f0..171480b4 100644 --- a/include/etl/private/chrono/month_day.h +++ b/include/etl/private/chrono/month_day.h @@ -116,7 +116,7 @@ namespace etl //************************************************************************* /// Less-than operator. //************************************************************************* - friend ETL_NODISCARD ETL_CONSTEXPR + ETL_NODISCARD friend ETL_CONSTEXPR bool operator <(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) ETL_NOEXCEPT { @@ -137,7 +137,7 @@ namespace etl //************************************************************************* /// Less-than-equal operator. //************************************************************************* - friend ETL_NODISCARD ETL_CONSTEXPR + ETL_NODISCARD friend ETL_CONSTEXPR bool operator <=(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) ETL_NOEXCEPT { @@ -147,7 +147,7 @@ namespace etl //************************************************************************* /// Greater-than operator. //************************************************************************* - friend ETL_NODISCARD ETL_CONSTEXPR + ETL_NODISCARD friend ETL_CONSTEXPR bool operator >(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) ETL_NOEXCEPT { @@ -157,7 +157,7 @@ namespace etl //************************************************************************* /// Greater-than-equal operator. //************************************************************************* - friend ETL_NODISCARD ETL_CONSTEXPR + ETL_NODISCARD friend ETL_CONSTEXPR bool operator >=(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) ETL_NOEXCEPT { @@ -168,7 +168,7 @@ namespace etl /// Spaceship operator //*********************************************************************** #if ETL_USING_CPP20 - friend [[nodiscard]] constexpr auto operator <=>(const etl::chrono::month_day& lhs, + [[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) noexcept { auto cmp = lhs.month() <=> rhs.month(); diff --git a/include/etl/private/chrono/weekday.h b/include/etl/private/chrono/weekday.h index e434ef56..f5e763ef 100644 --- a/include/etl/private/chrono/weekday.h +++ b/include/etl/private/chrono/weekday.h @@ -468,7 +468,7 @@ namespace etl //*********************************************************************** /// Index operator from etl::chrono::last_spec //*********************************************************************** - ETL_CONSTEXPR etl::chrono::weekday_last etl::chrono::weekday::operator[](etl::chrono::last_spec last) const ETL_NOEXCEPT + ETL_CONSTEXPR etl::chrono::weekday_last etl::chrono::weekday::operator[](etl::chrono::last_spec) const ETL_NOEXCEPT { return etl::chrono::weekday_last(*this); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bac99736..d5781a44 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -60,7 +60,12 @@ add_executable(etl_tests # test_checksum.cpp test_chrono_day.cpp test_chrono_duration.cpp + test_chrono_hh_mm_ss.cpp test_chrono_month.cpp + test_chrono_month_day.cpp + test_chrono_month_day_last.cpp + test_chrono_month_weekday.cpp + test_chrono_month_weekday_last.cpp test_chrono_weekday.cpp test_chrono_weekday_indexed.cpp test_chrono_weekday_last.cpp diff --git a/test/test_chrono_hh_mm_ss.cpp b/test/test_chrono_hh_mm_ss.cpp new file mode 100644 index 00000000..887bb42f --- /dev/null +++ b/test/test_chrono_hh_mm_ss.cpp @@ -0,0 +1,289 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Documentation: + +Copyright(c) 2025 John Wellbelove + +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. +******************************************************************************/ + +#include "etl/platform.h" + +#include "unit_test_framework.h" + +#include "etl/chrono.h" + +// Set to 0 to reference against std::chrono +#define ETL_USING_ETL_CHRONO 1 + +#if ETL_USING_ETL_CHRONO + #define Chrono etl::chrono + #define Ratio etl::ratio +#else + #if ETL_USING_CPP20 + #include + #define Chrono std::chrono + #define Ratio std::ratio + #else + #error std::chrono not supported + #endif +#endif + +namespace +{ + SUITE(test_chrono_hh_mm_ss) + { + //************************************************************************* + TEST(test_default_constructor) + { + using duration_type = Chrono::seconds; + + // Create a duration of 0 hour, 0 minutes, 0 seconds + Chrono::hh_mm_ss time; + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(Chrono::hours(0).count(), h.count()); + CHECK_EQUAL(Chrono::minutes(0).count(), m.count()); + CHECK_EQUAL(Chrono::seconds(0).count(), s.count()); + CHECK_EQUAL(duration_type(0).count(), sub.count()); + CHECK_EQUAL(0, dur.count()); + CHECK_FALSE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_seconds) + { + using duration_type = Chrono::seconds; + + // Create a duration of 1 hour, 2 minutes, 3 seconds + duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(Chrono::hours(1).count(), h.count()); + CHECK_EQUAL(Chrono::minutes(2).count(), m.count()); + CHECK_EQUAL(Chrono::seconds(3).count(), s.count()); + CHECK_EQUAL(duration_type(0).count(), sub.count()); + CHECK_EQUAL(3723, dur.count()); + CHECK_FALSE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_negative_seconds) + { + using duration_type = Chrono::seconds; + + // Create a duration of minus 1 hour, 2 minutes, 3 seconds + duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3)); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(Chrono::hours(1).count(), h.count()); + CHECK_EQUAL(Chrono::minutes(2).count(), m.count()); + CHECK_EQUAL(Chrono::seconds(3).count(), s.count()); + CHECK_EQUAL(duration_type(0).count(), sub.count()); + CHECK_EQUAL(-3723, dur.count()); + CHECK_TRUE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_milliseconds) + { + using duration_type = Chrono::milliseconds; + + // Create a duration of 1 hour, 2 minutes, 3 seconds, 456 milliseconds + duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3) + duration_type(456); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(Chrono::hours(1).count(), h.count()); + CHECK_EQUAL(Chrono::minutes(2).count(), m.count()); + CHECK_EQUAL(Chrono::seconds(3).count(), s.count()); + CHECK_EQUAL(duration_type(456).count(), sub.count()); + CHECK_EQUAL(3723456, dur.count()); + CHECK_FALSE(time.is_negative()); + CHECK_EQUAL(3, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_negative_milliseconds) + { + using duration_type = Chrono::milliseconds; + + // Create a duration of minus 1 hour, 2 minutes, 3 seconds, 456 milliseconds + duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3) + duration_type(456)); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(Chrono::hours(1).count(), h.count()); + CHECK_EQUAL(Chrono::minutes(2).count(), m.count()); + CHECK_EQUAL(Chrono::seconds(3).count(), s.count()); + CHECK_EQUAL(duration_type(456).count(), sub.count()); + CHECK_EQUAL(-3723456, dur.count()); + CHECK_TRUE(time.is_negative()); + CHECK_EQUAL(3, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_float_seconds) + { + using duration_type = Chrono::duration>; + + // Create a duration of 1 hour, 2 minutes, 3.456 seconds + duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(1, h.count()); + CHECK_EQUAL(2, m.count()); + CHECK_EQUAL(3, s.count()); + CHECK_CLOSE(0.456f, sub.count(), 0.0001f); + CHECK_CLOSE(3723.456f, dur.count(), 0.0001f); + CHECK_FALSE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_negative_float_seconds) + { + using duration_type = Chrono::duration>; + + // Create a duration of 1 hour, 2 minutes, 3.456 seconds + duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456)); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(1, h.count()); + CHECK_EQUAL(2, m.count()); + CHECK_EQUAL(3, s.count()); + CHECK_CLOSE(0.456f, sub.count(), 0.0001f); + CHECK_CLOSE(-3723.456f, dur.count(), 0.0001f); + CHECK_TRUE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_double_seconds) + { + using duration_type = Chrono::duration>; + + // Create a duration of 1 hour, 2 minutes, 3.456 seconds + duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(1, h.count()); + CHECK_EQUAL(2, m.count()); + CHECK_EQUAL(3, s.count()); + CHECK_CLOSE(0.456, sub.count(), 0.0001); + CHECK_CLOSE(3723.456, dur.count(), 0.0001); + CHECK_FALSE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + + //************************************************************************* + TEST(test_construction_with_negative_double_seconds) + { + using duration_type = Chrono::duration>; + + // Create a duration of 1 hour, 2 minutes, 3.456 seconds + duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456)); + + Chrono::hh_mm_ss time(duration); + + auto h = time.hours(); + auto m = time.minutes(); + auto s = time.seconds(); + auto sub = time.subseconds(); + auto dur = time.to_duration(); + + CHECK_EQUAL(1, h.count()); + CHECK_EQUAL(2, m.count()); + CHECK_EQUAL(3, s.count()); + CHECK_CLOSE(0.456, sub.count(), 0.0001); + CHECK_CLOSE(-3723.456, dur.count(), 0.0001); + CHECK_TRUE(time.is_negative()); + CHECK_EQUAL(0, time.fractional_width); + CHECK_TRUE((std::is_same::precision>::value)); + } + }; +} diff --git a/test/test_chrono_month.cpp b/test/test_chrono_month.cpp index 058f260a..2a5f2531 100644 --- a/test/test_chrono_month.cpp +++ b/test/test_chrono_month.cpp @@ -258,9 +258,6 @@ namespace Chrono::months months12 = month1 - month2; Chrono::months months21 = month2 - month1; - int m12 = months12.count(); - int m21 = months21.count(); - int difference12 = expected_month(m1) - expected_month(m2); int difference21 = expected_month(m2) - expected_month(m1); diff --git a/test/test_chrono_month_day.cpp b/test/test_chrono_month_day.cpp index af5d00fc..edd32e0e 100644 --- a/test/test_chrono_month_day.cpp +++ b/test/test_chrono_month_day.cpp @@ -126,7 +126,7 @@ namespace CHECK_TRUE(md1 == md1); // January == January CHECK_FALSE(md1 == md2); // January != February - CHECK_FALSE(md1 == md2); // 20th != 15th in the same month + CHECK_FALSE(md1 == md3); // 20th != 15th in the same month } //************************************************************************* @@ -138,7 +138,7 @@ namespace CHECK_FALSE(md1 != md1); // January == January CHECK_TRUE(md1 != md2); // January != February - CHECK_TRUE(md1 != md2); // 20th != 15th in the same month + CHECK_TRUE(md1 != md3); // 20th != 15th in the same month } //************************************************************************* diff --git a/test/test_chrono_month_weekday.cpp b/test/test_chrono_month_weekday.cpp index 2b21a88c..29b532ab 100644 --- a/test/test_chrono_month_weekday.cpp +++ b/test/test_chrono_month_weekday.cpp @@ -87,7 +87,6 @@ namespace { Chrono::month_weekday mwd1{Chrono::January, Chrono::weekday_indexed(Chrono::Friday, 2)}; Chrono::month_weekday mwd2{Chrono::February, Chrono::weekday_indexed(Chrono::Friday, 2)}; - Chrono::month_weekday mwd3{Chrono::January, Chrono::weekday_indexed(Chrono::Saturday, 2)}; CHECK_TRUE(mwd1 == mwd1); // January == January CHECK_FALSE(mwd1 == mwd2); // January != February @@ -99,7 +98,6 @@ namespace { Chrono::month_weekday mwd1{Chrono::January, Chrono::weekday_indexed(Chrono::Friday, 2)}; Chrono::month_weekday mwd2{Chrono::February, Chrono::weekday_indexed(Chrono::Friday, 2)}; - Chrono::month_weekday mwd3{Chrono::January, Chrono::weekday_indexed(Chrono::Saturday, 2)}; CHECK_FALSE(mwd1 != mwd1); // January == January CHECK_TRUE(mwd1 != mwd2); // January != February diff --git a/test/test_chrono_month_weekday_last.cpp b/test/test_chrono_month_weekday_last.cpp index 1a95d917..a79fe0e1 100644 --- a/test/test_chrono_month_weekday_last.cpp +++ b/test/test_chrono_month_weekday_last.cpp @@ -90,7 +90,7 @@ namespace CHECK_TRUE(mwd1 == mwd1); // January == January CHECK_FALSE(mwd1 == mwd2); // January != February - CHECK_FALSE(mwd1 == mwd2); // Friday != Saturday + CHECK_FALSE(mwd1 == mwd3); // Friday != Saturday } //************************************************************************* @@ -102,7 +102,7 @@ namespace CHECK_FALSE(mwd1 != mwd1); // January == January CHECK_TRUE(mwd1 != mwd2); // January != February - CHECK_TRUE(mwd1 != mwd2); // Friday != Saturday + CHECK_TRUE(mwd1 != mwd3); // Friday != Saturday } #if ETL_USING_ETL_CHRONO diff --git a/test/test_chrono_weekday.cpp b/test/test_chrono_weekday.cpp index ec6cedc8..d6a4a3e8 100644 --- a/test/test_chrono_weekday.cpp +++ b/test/test_chrono_weekday.cpp @@ -367,6 +367,8 @@ namespace CHECK_TRUE(weekday1 == weekday1); CHECK_FALSE(weekday1 != weekday1); + CHECK_FALSE(weekday1 == weekday2); + CHECK_TRUE(weekday1 != weekday2); } //************************************************************************* diff --git a/test/test_chrono_year.cpp b/test/test_chrono_year.cpp index 47de4f70..70c17c8a 100644 --- a/test/test_chrono_year.cpp +++ b/test/test_chrono_year.cpp @@ -34,6 +34,7 @@ SOFTWARE. #include "etl/chrono.h" +#include #include // Set to 0 to reference against std::chrono diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index 8a7a4374..90fa9853 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -1419,7 +1419,7 @@ /Zc:__cplusplus %(AdditionalOptions) true EnableFastChecks - true + false Console @@ -1444,6 +1444,7 @@ ProgramDatabase /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -1470,6 +1471,7 @@ /Zc:__cplusplus %(AdditionalOptions) true Default + false Console @@ -1494,6 +1496,7 @@ ProgramDatabase /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -1518,6 +1521,7 @@ ProgramDatabase /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -1542,6 +1546,7 @@ ProgramDatabase /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -1566,6 +1571,7 @@ EditAndContinue /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -1591,6 +1597,7 @@ /Zc:__cplusplus %(AdditionalOptions) true Default + false Console @@ -1616,6 +1623,7 @@ /Zc:__cplusplus %(AdditionalOptions) true Default + false Console @@ -1825,6 +1833,7 @@ ProgramDatabase /Zc:__cplusplus %(AdditionalOptions) true + false Console @@ -3180,6 +3189,7 @@ + @@ -8455,6 +8465,7 @@ + diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters index f868361e..4f5baf9e 100644 --- a/test/vs2022/etl.vcxproj.filters +++ b/test/vs2022/etl.vcxproj.filters @@ -1491,6 +1491,9 @@ ETL\Private\chrono + + ETL\Private\chrono + @@ -3512,9 +3515,6 @@ Tests\Containers - - Tests - Tests\Chrono @@ -3539,6 +3539,12 @@ Tests\Chrono + + Tests\Chrono + + + Tests\Syntax Checks\Source +