Fix InstWrapper not checking instance creation
authorCharles Giessen <charles@lunarg.com>
Mon, 6 Dec 2021 21:07:09 +0000 (14:07 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Sat, 11 Dec 2021 00:08:23 +0000 (17:08 -0700)
The CheckCreate function was not correctly checking that the VkResult matched what was
expected. The old code required the client to wrap the call in EXPECT_TRUE().

tests/framework/test_environment.cpp
tests/framework/test_environment.h

index d891cfd12528eae5601cc2d336bed18a235c117b..286d5ccbd3248a3eb89d85e6f344b45b5476b5e5 100644 (file)
@@ -52,12 +52,8 @@ InstWrapper& InstWrapper::operator=(InstWrapper&& other) noexcept {
     return *this;
 }
 
-testing::AssertionResult InstWrapper::CheckCreate(VkResult result_to_check) {
-    VkResult res = functions->vkCreateInstance(create_info.get(), callbacks, &inst);
-    if (res == result_to_check)
-        return testing::AssertionSuccess();
-    else
-        return testing::AssertionFailure() << " Expected VkCreateInstance to return " << result_to_check << " but got " << res;
+void InstWrapper::CheckCreate(VkResult result_to_check) {
+    ASSERT_EQ(result_to_check, functions->vkCreateInstance(create_info.get(), callbacks, &inst));
 }
 
 std::vector<VkPhysicalDevice> InstWrapper::GetPhysDevs(uint32_t phys_dev_count, VkResult result_to_check) {
index 6004b12b9418359997b9f1f464ad05f9882c9b2d..ed1d703546cf24ec7919c47513491edb37df2a2e 100644 (file)
@@ -130,7 +130,7 @@ struct InstWrapper {
     InstWrapper& operator=(InstWrapper&&) noexcept;
 
     // Construct this VkInstance using googletest to assert if it succeeded
-    testing::AssertionResult CheckCreate(VkResult result_to_check = VK_SUCCESS);
+    void CheckCreate(VkResult result_to_check = VK_SUCCESS);
 
     // Convenience
     operator VkInstance() { return inst; }