From 19a22169c0081766ff409a8e9734bcd90ced6f34 Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Tue, 16 Apr 2024 20:54:32 +0200 Subject: [PATCH] gh-685: Fix celix_properties_setVersion ei test --- libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc index 162a86fcd..e7916ea38 100644 --- a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc +++ b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc @@ -46,6 +46,7 @@ class PropertiesErrorInjectionTestSuite : public ::testing::Test { celix_ei_expect_open_memstream(nullptr, 0, nullptr); celix_ei_expect_asprintf(nullptr, 0, -1); celix_ei_expect_malloc(nullptr, 0, nullptr); + celix_ei_expect_calloc(nullptr, 0, nullptr); celix_ei_expect_celix_stringHashMap_createWithOptions(nullptr, 0, nullptr); celix_ei_expect_celix_arrayList_copy(nullptr, 0, nullptr); celix_ei_expect_celix_utils_strdup(nullptr, 0, nullptr); @@ -453,11 +454,12 @@ TEST_F(PropertiesErrorInjectionTestSuite, SetVersionFailureTest) { celix_err_resetErrors(); celix_autoptr(celix_version_t) version2 = celix_version_create(1, 2, 3, "aaaaaaaaaaaaaaaaaaaaaaaaaa"); - celix_ei_expect_asprintf((void*) celix_version_toString, 0, -1); + celix_ei_expect_calloc((void*) celix_version_create, 0, nullptr); status = celix_properties_setVersion(props, "key", version2); ASSERT_EQ(status, CELIX_ENOMEM); - ASSERT_STREQ("Cannot fill property entry", celix_err_popLastError()); - ASSERT_STREQ("Failed to allocate memory for celix_version_toString", celix_err_popLastError()); + EXPECT_EQ(2, celix_err_getErrorCount()); + ASSERT_STREQ("Failed to copy version", celix_err_popLastError()); + ASSERT_STREQ("Failed to allocate memory for celix_version_create", celix_err_popLastError()); celix_err_resetErrors(); fillOptimizationCache(props);