Skip to content

Commit

Permalink
Remove overload of JsonSubValuesMatch
Browse files Browse the repository at this point in the history
The overload is unused, but also inherently ambiguous.
Equivalent tests can be composed via AllOf(JsonSubValueMatches(x, y), ...).

PiperOrigin-RevId: 602969618
Change-Id: Idba33825e8bc4f4c4ad98e363d34fe3e33996298
  • Loading branch information
laramiel authored and copybara-github committed Jan 31, 2024
1 parent b56fcb4 commit e4323d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
1 change: 0 additions & 1 deletion tensorstore/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ tensorstore_cc_library(
":json_pointer",
"//tensorstore/internal/json:same",
"//tensorstore/util:quote_string",
"//tensorstore/util:status_testutil",
"@com_github_nlohmann_json//:nlohmann_json",
"@com_google_googletest//:gtest",
],
Expand Down
15 changes: 4 additions & 11 deletions tensorstore/internal/json_gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

#include "tensorstore/internal/json_gtest.h"

#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include "tensorstore/internal/json/same.h"
#include "tensorstore/internal/json_pointer.h"
#include "tensorstore/util/quote_string.h"
Expand Down Expand Up @@ -127,19 +130,9 @@ ::testing::Matcher<::nlohmann::json> JsonSubValueMatches(
return JsonSubValueMatches(std::move(json_pointer),
MatchesJson(std::move(value_matcher)));
}
::testing::Matcher<::nlohmann::json> JsonSubValuesMatch(
std::vector<std::pair<std::string, ::nlohmann::json>> matchers) {
std::vector<::testing::Matcher<::nlohmann::json>> all;
all.reserve(matchers.size());
for (const auto& p : matchers) {
all.push_back(JsonSubValueMatches(p.first, p.second));
}
return ::testing::AllOfArray(all);
}

::testing::Matcher<::nlohmann::json> JsonSubValuesMatch(
std::vector<std::pair<std::string, ::testing::Matcher<::nlohmann::json>>>
matchers) {
std::vector<std::pair<std::string, ::nlohmann::json>> matchers) {
std::vector<::testing::Matcher<::nlohmann::json>> all;
all.reserve(matchers.size());
for (const auto& p : matchers) {
Expand Down
6 changes: 2 additions & 4 deletions tensorstore/internal/json_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
#define TENSORSTORE_INTERNAL_JSON_GTEST_H_

#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include <gmock/gmock.h>
#include <nlohmann/json.hpp>
#include "tensorstore/util/status_testutil.h"

namespace nlohmann {
//
Expand Down Expand Up @@ -74,9 +75,6 @@ ::testing::Matcher<::nlohmann::json> JsonSubValueMatches(
/// EXPECT_THAT(obj, JsonSubValuesMatch({{"/a", 123}, {"/b/c", "xyz"}}));
::testing::Matcher<::nlohmann::json> JsonSubValuesMatch(
std::vector<std::pair<std::string, ::nlohmann::json>> matchers);
::testing::Matcher<::nlohmann::json> JsonSubValuesMatch(
std::vector<std::pair<std::string, ::testing::Matcher<::nlohmann::json>>>
matchers);

} // namespace tensorstore

Expand Down

0 comments on commit e4323d2

Please sign in to comment.