diff --git a/sdk/core/azure-core/test/ut/bodystream_test.cpp b/sdk/core/azure-core/test/ut/bodystream_test.cpp index 30e1a3e77..446a435ea 100644 --- a/sdk/core/azure-core/test/ut/bodystream_test.cpp +++ b/sdk/core/azure-core/test/ut/bodystream_test.cpp @@ -34,6 +34,7 @@ TEST(BodyStream, Rewind) { TestBodyStream tb; +#if GTEST_HAS_DEATH_TEST #if defined(NDEBUG) // Release build won't provide assert msg ASSERT_DEATH(tb.Rewind(), ""); @@ -41,6 +42,7 @@ TEST(BodyStream, Rewind) ASSERT_DEATH( tb.Rewind(), "The specified BodyStream doesn't support Rewind which is required to guarantee fault "); +#endif #endif std::string testDataPath(AZURE_TEST_DATA_PATH); @@ -61,6 +63,7 @@ TEST(BodyStream, Rewind) EXPECT_NO_THROW(ms.Rewind()); } +#if GTEST_HAS_DEATH_TEST TEST(BodyStream, BadInput) { TestBodyStream tb; @@ -71,14 +74,17 @@ TEST(BodyStream, BadInput) } TEST(MemoryBodyStream, BadInput) { ASSERT_DEATH(MemoryBodyStream(NULL, 1), ""); } +#endif TEST(FileBodyStream, BadInput) { +#if GTEST_HAS_DEATH_TEST #if defined(NDEBUG) // Release build won't provide assert msg ASSERT_DEATH(FileBodyStream(""), ""); #else ASSERT_DEATH(FileBodyStream(""), "The file name must not be an empty string."); +#endif #endif EXPECT_THROW(Azure::Core::IO::FileBodyStream("FileNotFound"), std::runtime_error); diff --git a/sdk/core/azure-core/test/ut/context_test.cpp b/sdk/core/azure-core/test/ut/context_test.cpp index 440a7f3db..17102d94e 100644 --- a/sdk/core/azure-core/test/ut/context_test.cpp +++ b/sdk/core/azure-core/test/ut/context_test.cpp @@ -437,7 +437,7 @@ TEST(Context, Deadline) } } -#if defined(AZ_CORE_RTTI) +#if defined(AZ_CORE_RTTI) && GTEST_HAS_DEATH_TEST TEST(Context, PreCondition) { // Get a mismatch type from the context @@ -478,6 +478,7 @@ TEST(Context, KeyTypePairPrecondition) EXPECT_FALSE(c2.TryGetValue(keyNotFound, strValue)); EXPECT_FALSE(c2.TryGetValue(keyNotFound, intValue)); +#if GTEST_HAS_DEATH_TEST // Type-safe assert requires RTTI build #if defined(AZ_CORE_RTTI) #if defined(NDEBUG) @@ -487,6 +488,7 @@ TEST(Context, KeyTypePairPrecondition) ASSERT_DEATH( c2.TryGetValue(key, strValue), "Type mismatch for Context::TryGetValue"); #endif +#endif #endif EXPECT_TRUE(strValue == "previous value"); @@ -494,6 +496,7 @@ TEST(Context, KeyTypePairPrecondition) EXPECT_TRUE(c2.TryGetValue(key, intValue)); EXPECT_TRUE(intValue == 123); +#if GTEST_HAS_DEATH_TEST // Type-safe assert requires RTTI build #if defined(AZ_CORE_RTTI) #if defined(NDEBUG) @@ -502,6 +505,7 @@ TEST(Context, KeyTypePairPrecondition) #else ASSERT_DEATH(c3.TryGetValue(key, intValue), "Type mismatch for Context::TryGetValue"); #endif +#endif #endif EXPECT_TRUE(intValue == 123); diff --git a/sdk/core/azure-core/test/ut/etag_test.cpp b/sdk/core/azure-core/test/ut/etag_test.cpp index 8f9d11120..6369b6a35 100644 --- a/sdk/core/azure-core/test/ut/etag_test.cpp +++ b/sdk/core/azure-core/test/ut/etag_test.cpp @@ -259,6 +259,7 @@ TEST(ETag, EqualsWeak) EXPECT_FALSE(ETag::Equals(weakTagtwo, weakTagTwo, ETag::ETagComparison::Weak)); } +#if GTEST_HAS_DEATH_TEST TEST(ETag, PreCondition) { ETag emptyTag; @@ -270,3 +271,4 @@ TEST(ETag, PreCondition) ASSERT_DEATH(emptyTag.ToString(), "Empty ETag"); #endif } +#endif diff --git a/sdk/core/azure-core/test/ut/md5_test.cpp b/sdk/core/azure-core/test/ut/md5_test.cpp index 1f2e3a0bc..792fa3d75 100644 --- a/sdk/core/azure-core/test/ut/md5_test.cpp +++ b/sdk/core/azure-core/test/ut/md5_test.cpp @@ -103,13 +103,16 @@ TEST(Md5Hash, ExpectThrow) const uint8_t* ptr = reinterpret_cast(data.c_str()); Md5Hash instance; +#if GTEST_HAS_DEATH_TEST ASSERT_DEATH(instance.Final(nullptr, 1), ""); ASSERT_DEATH(instance.Append(nullptr, 1), ""); +#endif EXPECT_EQ( Azure::Core::Convert::Base64Encode(instance.Final(ptr, data.length())), "1B2M2Y8AsgTpgAmY7PhCfg=="); +#if GTEST_HAS_DEATH_TEST #if defined(NDEBUG) // Release build won't provide assert msg ASSERT_DEATH(instance.Final(), ""); @@ -120,6 +123,7 @@ TEST(Md5Hash, ExpectThrow) ASSERT_DEATH(instance.Final(ptr, data.length()), "Cannot call Final"); ASSERT_DEATH(instance.Append(ptr, data.length()), "Cannot call Append after calling Final"); #endif +#endif } TEST(Md5Hash, CtorDtor) diff --git a/sdk/core/azure-core/test/ut/nullable_test.cpp b/sdk/core/azure-core/test/ut/nullable_test.cpp index ee358d2f2..6306af33e 100644 --- a/sdk/core/azure-core/test/ut/nullable_test.cpp +++ b/sdk/core/azure-core/test/ut/nullable_test.cpp @@ -174,6 +174,7 @@ TEST(Nullable, ValueOr) void Foo(int&& rValue) { (void)rValue; } +#if GTEST_HAS_DEATH_TEST TEST(Nullable, PreCondition) { Nullable emptyNullable; @@ -207,6 +208,7 @@ TEST(Nullable, PreCondition3) ASSERT_DEATH(Foo(Nullable().Value());, "Empty Nullable"); #endif } +#endif TEST(Nullable, Operator) { diff --git a/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp b/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp index 3925e5f94..dc0d1cbea 100644 --- a/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp +++ b/sdk/storage/azure-storage-common/test/ut/crypt_functions_test.cpp @@ -117,12 +117,15 @@ namespace Azure { namespace Storage { namespace Test { const uint8_t* ptr = reinterpret_cast(data.data()); Crc64Hash instance; +#if GTEST_HAS_DEATH_TEST ASSERT_DEATH(instance.Final(nullptr, 1), ""); ASSERT_DEATH(instance.Append(nullptr, 1), ""); +#endif EXPECT_EQ( Azure::Core::Convert::Base64Encode(instance.Final(ptr, data.length())), "AAAAAAAAAAA="); +#if GTEST_HAS_DEATH_TEST #if defined(NDEBUG) // Release build won't provide assert msg ASSERT_DEATH(instance.Final(), ""); @@ -132,6 +135,7 @@ namespace Azure { namespace Storage { namespace Test { ASSERT_DEATH(instance.Final(), "Cannot call Final"); ASSERT_DEATH(instance.Final(ptr, data.length()), "Cannot call Final"); ASSERT_DEATH(instance.Append(ptr, data.length()), "Cannot call Append after calling Final"); +#endif #endif }