1 /*
2 * Copyright 2018 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 #include "fcp/secagg/shared/input_vector_specification.h"
18
19 #include <string>
20
21 #include "gmock/gmock.h"
22 #include "gtest/gtest.h"
23 #include "fcp/secagg/shared/secagg_vector.h"
24
25 namespace fcp {
26 namespace secagg {
27 namespace {
28
29 using ::testing::Eq;
30
TEST(InputVectorSpecificationTest,GettersReturnAppropriateValues)31 TEST(InputVectorSpecificationTest, GettersReturnAppropriateValues) {
32 std::string name = "test";
33 int length = 2;
34 uint64_t modulus = 256;
35
36 InputVectorSpecification vec_spec(name, length, modulus);
37 EXPECT_THAT(vec_spec.modulus(), Eq(modulus));
38 EXPECT_THAT(vec_spec.length(), Eq(length));
39 EXPECT_THAT(vec_spec.name(), Eq(name));
40 }
41
TEST(InputVectorSpecificationTest,ConstructorDiesOnSmallModulus)42 TEST(InputVectorSpecificationTest, ConstructorDiesOnSmallModulus) {
43 EXPECT_DEATH(InputVectorSpecification vec_spec("test", 5, 1),
44 "The specified modulus is not valid");
45 }
46
TEST(InputVectorSpecificationTest,ConstructorDiesOnModulusGreatorThanMax)47 TEST(InputVectorSpecificationTest, ConstructorDiesOnModulusGreatorThanMax) {
48 EXPECT_DEATH(InputVectorSpecification vec_spec("test", 5,
49 SecAggVector::kMaxModulus + 1),
50 "The specified modulus is not valid");
51 }
52
TEST(InputVectorSpecificationTest,ConstructorDiesOnNegativeLength)53 TEST(InputVectorSpecificationTest, ConstructorDiesOnNegativeLength) {
54 EXPECT_DEATH(InputVectorSpecification vec_spec("test", -1, 256),
55 "Length must be >= 0");
56 }
57
58 } // namespace
59 } // namespace secagg
60 } // namespace fcp
61