1 /*
2  * Copyright 2020 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 "common/numbers.h"
18 
19 #include <cstdint>
20 
21 #include <gtest/gtest.h>
22 
23 namespace testing {
24 
25 using bluetooth::common::IsNumberInNumericLimits;
26 
TEST(NumbersTest,test_is_number_in_numeric_limits)27 TEST(NumbersTest, test_is_number_in_numeric_limits) {
28   // INT32_MAX+1
29   int64_t n = 2147483648L;
30   ASSERT_FALSE(IsNumberInNumericLimits<int32_t>(n));
31   ASSERT_TRUE(IsNumberInNumericLimits<int64_t>(n));
32   ASSERT_FALSE(IsNumberInNumericLimits<int8_t>(int32_t(128)));
33   ASSERT_FALSE(IsNumberInNumericLimits<uint8_t>(uint32_t(256)));
34   ASSERT_FALSE(IsNumberInNumericLimits<int8_t>(int32_t(-129)));
35 }
36 
37 }  // namespace testing