blob: 13518f5eeb7e5f135d6c86213fc66484e47a0e75 [file] [log] [blame]
Calin Juravleda030de2014-02-20 13:40:36 +00001/*
2 * Copyright (C) 2014 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
Elliott Hughes7f850e32025-04-21 08:42:00 -070017#include <stdint.h>
18
Calin Juravleda030de2014-02-20 13:40:36 +000019#include <gtest/gtest.h>
20
Elliott Hughes7f850e32025-04-21 08:42:00 -070021#include <limits>
Calin Juravleda030de2014-02-20 13:40:36 +000022
Elliott Hughes995eee62025-04-14 07:57:27 -070023#if !defined(__WINT_UNSIGNED__)
24#error wint_t is unsigned on Android
25#endif
26
Elliott Hughes7f850e32025-04-21 08:42:00 -070027TEST(stdint, wint_sign) {
28 EXPECT_FALSE(std::numeric_limits<wint_t>::is_signed);
29}
30
31TEST(stdint, fast_type_sizes) {
32 EXPECT_EQ(1U, sizeof(int_fast8_t));
33 EXPECT_EQ(8U, sizeof(int_fast64_t));
34 EXPECT_EQ(1U, sizeof(uint_fast8_t));
35 EXPECT_EQ(8U, sizeof(uint_fast64_t));
Calin Juravleda030de2014-02-20 13:40:36 +000036#if defined(__LP64__)
Elliott Hughes7f850e32025-04-21 08:42:00 -070037 EXPECT_EQ(8U, sizeof(int_fast16_t));
38 EXPECT_EQ(8U, sizeof(int_fast32_t));
39 EXPECT_EQ(8U, sizeof(uint_fast16_t));
40 EXPECT_EQ(8U, sizeof(uint_fast32_t));
Calin Juravleda030de2014-02-20 13:40:36 +000041#else
Elliott Hughes7f850e32025-04-21 08:42:00 -070042 EXPECT_EQ(4U, sizeof(int_fast16_t));
43 EXPECT_EQ(4U, sizeof(int_fast32_t));
44 EXPECT_EQ(4U, sizeof(uint_fast16_t));
45 EXPECT_EQ(4U, sizeof(uint_fast32_t));
Calin Juravleda030de2014-02-20 13:40:36 +000046#endif
47}
Elliott Hughes7f850e32025-04-21 08:42:00 -070048
49TEST(stdint, least_type_sizes) {
50 EXPECT_EQ(1U, sizeof(int_least8_t));
51 EXPECT_EQ(1U, sizeof(uint_least8_t));
52 EXPECT_EQ(2U, sizeof(int_least16_t));
53 EXPECT_EQ(2U, sizeof(uint_least16_t));
54 EXPECT_EQ(4U, sizeof(int_least32_t));
55 EXPECT_EQ(4U, sizeof(uint_least32_t));
56 EXPECT_EQ(8U, sizeof(int_least64_t));
57 EXPECT_EQ(8U, sizeof(uint_least64_t));
58}