1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 "chre/pal/wwan.h"
18 #include "gtest/gtest.h"
19 
TEST(PalWwanTest,PackUnpackInvalidNrNci)20 TEST(PalWwanTest, PackUnpackInvalidNrNci) {
21   constexpr int64_t kInvalidNci = INT64_MAX;
22   struct chreWwanCellIdentityNr nrId;
23   chreWwanPackNrNci(kInvalidNci, &nrId);
24 
25   EXPECT_EQ(chreWwanUnpackNrNci(&nrId), kInvalidNci);
26 }
27 
TEST(PalWwanTest,PackUnpackValidNrNci)28 TEST(PalWwanTest, PackUnpackValidNrNci) {
29   constexpr int64_t kValidNci = 0xffeedbeef;
30   struct chreWwanCellIdentityNr nrId;
31   chreWwanPackNrNci(kValidNci, &nrId);
32 
33   EXPECT_EQ(chreWwanUnpackNrNci(&nrId), kValidNci);
34 }
35 
TEST(PalWwanTest,PackUnpackIncorrectNrNci)36 TEST(PalWwanTest, PackUnpackIncorrectNrNci) {
37   // A valid NCI is a 36-bit value.
38   constexpr int64_t kIncorrectNci = 0x900dbeefdeadbeef;
39   struct chreWwanCellIdentityNr nrId;
40   chreWwanPackNrNci(kIncorrectNci, &nrId);
41 
42   // No bit masking done in chreWwanUnpackNrNci.
43   EXPECT_EQ(chreWwanUnpackNrNci(&nrId), kIncorrectNci);
44 }
45