• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "util/shifted_vector.h"
17 
18 #include "util/tests/verifier_test.h"
19 
20 #include <gtest/gtest.h>
21 
22 namespace panda::verifier::test {
23 
TEST_F(VerifierTest,shifted_vector)24 TEST_F(VerifierTest, shifted_vector)
25 {
26     ShiftedVector<2, int> shift_vec {5};
27     ASSERT_EQ(shift_vec.begin_index(), -2);
28     ASSERT_EQ(shift_vec.end_index(), 3);
29     EXPECT_TRUE(shift_vec.InValidRange(-1));
30     EXPECT_FALSE(shift_vec.InValidRange(5));
31 
32     shift_vec[0] = 7;
33     shift_vec.at(1) = 8;
34     EXPECT_EQ(shift_vec.at(0), 7);
35     EXPECT_EQ(shift_vec[1], 8);
36 
37     shift_vec.ExtendToInclude(5);
38     ASSERT_EQ(shift_vec.begin_index(), -2);
39     ASSERT_EQ(shift_vec.end_index(), 6);
40     EXPECT_TRUE(shift_vec.InValidRange(-1));
41     EXPECT_TRUE(shift_vec.InValidRange(5));
42     EXPECT_EQ(shift_vec.at(0), 7);
43     EXPECT_EQ(shift_vec[1], 8);
44     shift_vec[4] = 4;
45     EXPECT_EQ(shift_vec.at(4), 4);
46 }
47 
48 }  // namespace panda::verifier::test