From 8b38df8f67374553c754e3d6059d26386c937aa2 Mon Sep 17 00:00:00 2001 From: Travis Lane Date: Wed, 8 Nov 2023 13:47:04 -0800 Subject: [PATCH] Explicitly cast strings to std::string_view GoogleTest when built with GTEST_HAS_ABSL fails to convert these strings to a `std::string_view`. Lets instead explicitly convert them to a `std::string_view`. --- .../SNTEndpointSecurityClientTest.mm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm b/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm index 153458d38..33a93fdb4 100644 --- a/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm +++ b/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm @@ -322,11 +322,14 @@ - (void)testMuteTargetPaths { // Ensure all paths are attempted to be muted even if some fail. // Ensure if any paths fail the overall result is false. - EXPECT_CALL(*mockESApi, MuteTargetPath(testing::_, "a", WatchItemPathType::kLiteral)) + EXPECT_CALL(*mockESApi, + MuteTargetPath(testing::_, std::string_view("a"), WatchItemPathType::kLiteral)) .WillOnce(testing::Return(true)); - EXPECT_CALL(*mockESApi, MuteTargetPath(testing::_, "b", WatchItemPathType::kLiteral)) + EXPECT_CALL(*mockESApi, + MuteTargetPath(testing::_, std::string_view("b"), WatchItemPathType::kLiteral)) .WillOnce(testing::Return(false)); - EXPECT_CALL(*mockESApi, MuteTargetPath(testing::_, "c", WatchItemPathType::kPrefix)) + EXPECT_CALL(*mockESApi, + MuteTargetPath(testing::_, std::string_view("c"), WatchItemPathType::kPrefix)) .WillOnce(testing::Return(true)); std::vector> paths = { @@ -349,11 +352,14 @@ - (void)testUnmuteTargetPaths { // Ensure all paths are attempted to be unmuted even if some fail. // Ensure if any paths fail the overall result is false. - EXPECT_CALL(*mockESApi, UnmuteTargetPath(testing::_, "a", WatchItemPathType::kLiteral)) + EXPECT_CALL(*mockESApi, + UnmuteTargetPath(testing::_, std::string_view("a"), WatchItemPathType::kLiteral)) .WillOnce(testing::Return(true)); - EXPECT_CALL(*mockESApi, UnmuteTargetPath(testing::_, "b", WatchItemPathType::kLiteral)) + EXPECT_CALL(*mockESApi, + UnmuteTargetPath(testing::_, std::string_view("b"), WatchItemPathType::kLiteral)) .WillOnce(testing::Return(false)); - EXPECT_CALL(*mockESApi, UnmuteTargetPath(testing::_, "c", WatchItemPathType::kPrefix)) + EXPECT_CALL(*mockESApi, + UnmuteTargetPath(testing::_, std::string_view("c"), WatchItemPathType::kPrefix)) .WillOnce(testing::Return(true)); std::vector> paths = {