xref: /aosp_15_r20/external/federated-compute/fcp/secagg/testing/test_matchers.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2019 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FCP_SECAGG_TESTING_TEST_MATCHERS_H_
18 #define FCP_SECAGG_TESTING_TEST_MATCHERS_H_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include "gmock/gmock.h"
25 #include "absl/container/node_hash_map.h"
26 #include "fcp/secagg/shared/secagg_vector.h"
27 
28 namespace fcp {
29 namespace secagg {
30 namespace testing {
31 
32 using SecAggVectorData = std::pair<int, std::vector<uint64_t> >;
33 using SecAggVectorDataMap = absl::node_hash_map<std::string, SecAggVectorData>;
34 
35 class SecAggVectorMapMatcher {
36  public:
SecAggVectorMapMatcher(SecAggVectorDataMap expected)37   explicit SecAggVectorMapMatcher(SecAggVectorDataMap expected)
38       : expected_(expected) {}
39   // Intentionally allowed to be implicit.
40   operator ::testing::Matcher<const SecAggVectorMap&>() const;  // NOLINT
41 
42  private:
43   SecAggVectorDataMap expected_;
44 };
45 
46 SecAggVectorMapMatcher MatchesSecAggVectorMap(const SecAggVectorMap& expected);
47 SecAggVectorMapMatcher MatchesSecAggVector(const std::string& name,
48                                            const SecAggVector& vector);
49 
50 }  // namespace testing
51 }  // namespace secagg
52 }  // namespace fcp
53 
54 #endif  // FCP_SECAGG_TESTING_TEST_MATCHERS_H_
55