• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 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 "libpandabase/utils/utils.h"
17 #include "util/shifted_vector.h"
18 
19 #include "util/tests/verifier_test.h"
20 
21 #include <gtest/gtest.h>
22 
23 namespace ark::verifier::test {
24 
TEST_F(VerifierTest,shifted_vector)25 TEST_F(VerifierTest, shifted_vector)
26 {
27     ShiftedVector<2_I, int> shiftVec {5U};
28     ASSERT_EQ(shiftVec.BeginIndex(), -2_I);
29     ASSERT_EQ(shiftVec.EndIndex(), 3_I);
30     EXPECT_TRUE(shiftVec.InValidRange(-1_I));
31     EXPECT_FALSE(shiftVec.InValidRange(5_I));
32 
33     shiftVec[0] = 7_I;
34     shiftVec.At(1) = 8_I;
35     EXPECT_EQ(shiftVec.At(0), 7_I);
36     EXPECT_EQ(shiftVec[1], 8_I);
37 
38     shiftVec.ExtendToInclude(5_I);
39     ASSERT_EQ(shiftVec.BeginIndex(), -2_I);
40     ASSERT_EQ(shiftVec.EndIndex(), 6_I);
41     EXPECT_TRUE(shiftVec.InValidRange(-1_I));
42     EXPECT_TRUE(shiftVec.InValidRange(5_I));
43     EXPECT_EQ(shiftVec.At(0), 7_I);
44     EXPECT_EQ(shiftVec[1], 8_I);
45     shiftVec[4U] = 4_I;
46     EXPECT_EQ(shiftVec.At(4U), 4_I);
47 }
48 
49 }  // namespace ark::verifier::test
50