Line data Source code
1 : // Copyright 2024 Accenture. 2 : 3 : #include "estd/static_assert.h" 4 : 5 : #include "estd/array.h" 6 : 7 : #include <gmock/gmock.h> 8 : 9 : // [EXAMPLE_ESTD_STATIC_ASSERT_START] 10 3 : TEST(Assert, ZeroLength) 11 : { 12 : // Compilation stops with error message ESTD_STATIC_ASSERT, if the array is created with size 0. 13 1 : ::estd::array<int32_t, 4> zeroLengthArray{}; 14 : 15 1 : ESTD_STATIC_ASSERT(zeroLengthArray.size() > 0); 16 1 : } 17 : 18 : // [EXAMPLE_ESTD_STATIC_ASSERT_END] 19 : 20 : // [EXAMPLE_ESTD_STATIC_ASSERT_MESSAGE_START] 21 3 : TEST(AssertMessage, ZeroLength) 22 : { 23 : // If the array is created with size 0, compilation stops with error message provided as 24 : // argument. 25 1 : ::estd::array<int32_t, 3> zeroLengthArray{}; 26 : 27 1 : ESTD_STATIC_ASSERT_MESSAGE(zeroLengthArray.size() > 0, "Zero sized array should be avoided"); 28 1 : } 29 : 30 : // [EXAMPLE_ESTD_STATIC_ASSERT_MESSAGE_END]