summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/tests/sanitizer_type_traits_test.cc
blob: ccefeb6869ae5e4b90ce307f656f06f83d8986a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//===-- sanitizer_type_traits_test.cc -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of ThreadSanitizer/AddressSanitizer runtime.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_type_traits.h"
#include "gtest/gtest.h"
#include "sanitizer_common/sanitizer_internal_defs.h"

using namespace __sanitizer;

TEST(SanitizerCommon, IsSame) {
  ASSERT_TRUE((is_same<unsigned, unsigned>::value));
  ASSERT_TRUE((is_same<uptr, uptr>::value));
  ASSERT_TRUE((is_same<sptr, sptr>::value));
  ASSERT_TRUE((is_same<const uptr, const uptr>::value));

  ASSERT_FALSE((is_same<unsigned, signed>::value));
  ASSERT_FALSE((is_same<uptr, sptr>::value));
  ASSERT_FALSE((is_same<uptr, const uptr>::value));
}

TEST(SanitizerCommon, Conditional) {
  ASSERT_TRUE((is_same<int, conditional<true, int, double>::type>::value));
  ASSERT_TRUE((is_same<double, conditional<false, int, double>::type>::value));
}