From f33b4d716ca8fbebbd0bb083fc82d9a2377556e8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 6 Aug 2024 15:02:13 +0100 Subject: [PATCH] Updates to constexpr char traits tests --- test/test_char_traits.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/test_char_traits.cpp b/test/test_char_traits.cpp index 6f5fadd1c..bb6fb453e 100644 --- a/test/test_char_traits.cpp +++ b/test/test_char_traits.cpp @@ -55,16 +55,32 @@ namespace //************************************************************************* TEST(test_strlen) { - char data1[etl::strlen("qwerty")]; - char data2[etl::strlen(L"qwerty")]; - char data3[etl::strlen(u"qwerty")]; - char data4[etl::strlen(U"qwerty")]; + CHECK_EQUAL(6U, etl::strlen("qwerty")); + CHECK_EQUAL(6U, etl::strlen(L"qwerty")); + CHECK_EQUAL(6U, etl::strlen(u"qwerty")); + CHECK_EQUAL(6U, etl::strlen(U"qwerty")); + } + +#if ETL_USING_CPP14 && !defined(ETL_FORCE_NO_ADVANCED_CPP) + //************************************************************************* + TEST(test_strlen_constexpr) + { + constexpr size_t Size1 = etl::strlen("qwerty"); + constexpr size_t Size2 = etl::strlen(L"qwerty"); + constexpr size_t Size3 = etl::strlen(u"qwerty"); + constexpr size_t Size4 = etl::strlen(U"qwerty"); + + char data1[Size1]; + char data2[Size2]; + char data3[Size3]; + char data4[Size4]; CHECK_EQUAL(6U, sizeof(data1)); CHECK_EQUAL(6U, sizeof(data2)); CHECK_EQUAL(6U, sizeof(data3)); CHECK_EQUAL(6U, sizeof(data4)); } +#endif //************************************************************************* TEST(test_strcmp_char)