1bf215546Sopenharmony_ci// Copyright 2007, Google Inc. 2bf215546Sopenharmony_ci// All rights reserved. 3bf215546Sopenharmony_ci// 4bf215546Sopenharmony_ci// Redistribution and use in source and binary forms, with or without 5bf215546Sopenharmony_ci// modification, are permitted provided that the following conditions are 6bf215546Sopenharmony_ci// met: 7bf215546Sopenharmony_ci// 8bf215546Sopenharmony_ci// * Redistributions of source code must retain the above copyright 9bf215546Sopenharmony_ci// notice, this list of conditions and the following disclaimer. 10bf215546Sopenharmony_ci// * Redistributions in binary form must reproduce the above 11bf215546Sopenharmony_ci// copyright notice, this list of conditions and the following disclaimer 12bf215546Sopenharmony_ci// in the documentation and/or other materials provided with the 13bf215546Sopenharmony_ci// distribution. 14bf215546Sopenharmony_ci// * Neither the name of Google Inc. nor the names of its 15bf215546Sopenharmony_ci// contributors may be used to endorse or promote products derived from 16bf215546Sopenharmony_ci// this software without specific prior written permission. 17bf215546Sopenharmony_ci// 18bf215546Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19bf215546Sopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20bf215546Sopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21bf215546Sopenharmony_ci// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22bf215546Sopenharmony_ci// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23bf215546Sopenharmony_ci// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24bf215546Sopenharmony_ci// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25bf215546Sopenharmony_ci// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26bf215546Sopenharmony_ci// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27bf215546Sopenharmony_ci// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28bf215546Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci// The Google C++ Testing and Mocking Framework (Google Test) 31bf215546Sopenharmony_ci// 32bf215546Sopenharmony_ci// This file implements just enough of the matcher interface to allow 33bf215546Sopenharmony_ci// EXPECT_DEATH and friends to accept a matcher argument. 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "gtest/internal/gtest-internal.h" 36bf215546Sopenharmony_ci#include "gtest/internal/gtest-port.h" 37bf215546Sopenharmony_ci#include "gtest/gtest-matchers.h" 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci#include <string> 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_cinamespace testing { 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci// Constructs a matcher that matches a const std::string& whose value is 44bf215546Sopenharmony_ci// equal to s. 45bf215546Sopenharmony_ciMatcher<const std::string&>::Matcher(const std::string& s) { *this = Eq(s); } 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci// Constructs a matcher that matches a const std::string& whose value is 48bf215546Sopenharmony_ci// equal to s. 49bf215546Sopenharmony_ciMatcher<const std::string&>::Matcher(const char* s) { 50bf215546Sopenharmony_ci *this = Eq(std::string(s)); 51bf215546Sopenharmony_ci} 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci// Constructs a matcher that matches a std::string whose value is equal to 54bf215546Sopenharmony_ci// s. 55bf215546Sopenharmony_ciMatcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); } 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci// Constructs a matcher that matches a std::string whose value is equal to 58bf215546Sopenharmony_ci// s. 59bf215546Sopenharmony_ciMatcher<std::string>::Matcher(const char* s) { *this = Eq(std::string(s)); } 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci#if GTEST_HAS_ABSL 62bf215546Sopenharmony_ci// Constructs a matcher that matches a const absl::string_view& whose value is 63bf215546Sopenharmony_ci// equal to s. 64bf215546Sopenharmony_ciMatcher<const absl::string_view&>::Matcher(const std::string& s) { 65bf215546Sopenharmony_ci *this = Eq(s); 66bf215546Sopenharmony_ci} 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci// Constructs a matcher that matches a const absl::string_view& whose value is 69bf215546Sopenharmony_ci// equal to s. 70bf215546Sopenharmony_ciMatcher<const absl::string_view&>::Matcher(const char* s) { 71bf215546Sopenharmony_ci *this = Eq(std::string(s)); 72bf215546Sopenharmony_ci} 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci// Constructs a matcher that matches a const absl::string_view& whose value is 75bf215546Sopenharmony_ci// equal to s. 76bf215546Sopenharmony_ciMatcher<const absl::string_view&>::Matcher(absl::string_view s) { 77bf215546Sopenharmony_ci *this = Eq(std::string(s)); 78bf215546Sopenharmony_ci} 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci// Constructs a matcher that matches a absl::string_view whose value is equal to 81bf215546Sopenharmony_ci// s. 82bf215546Sopenharmony_ciMatcher<absl::string_view>::Matcher(const std::string& s) { *this = Eq(s); } 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci// Constructs a matcher that matches a absl::string_view whose value is equal to 85bf215546Sopenharmony_ci// s. 86bf215546Sopenharmony_ciMatcher<absl::string_view>::Matcher(const char* s) { 87bf215546Sopenharmony_ci *this = Eq(std::string(s)); 88bf215546Sopenharmony_ci} 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci// Constructs a matcher that matches a absl::string_view whose value is equal to 91bf215546Sopenharmony_ci// s. 92bf215546Sopenharmony_ciMatcher<absl::string_view>::Matcher(absl::string_view s) { 93bf215546Sopenharmony_ci *this = Eq(std::string(s)); 94bf215546Sopenharmony_ci} 95bf215546Sopenharmony_ci#endif // GTEST_HAS_ABSL 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci} // namespace testing 98