aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/strings/ffsll_test.cpp
blob: bdd7a2ed30f3cb0b254e7c5656a6419bf02b3e0c (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
33
34
35
36
37
38
39
40
//===-- Unittests for ffsll -----------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/strings/ffsll.h"

#include "src/__support/macros/config.h"
#include "test/UnitTest/Test.h"

namespace LIBC_NAMESPACE_DECL {

TEST(LlvmLibcFfsllTest, SimpleFfsll) {
  ASSERT_EQ(ffsll(0x0000000000000000LL), 0);
  ASSERT_EQ(ffsll(0x0000000000000001LL), 1);
  ASSERT_EQ(ffsll(0x0000000000000020LL), 6);
  ASSERT_EQ(ffsll(0x0000000000000400LL), 11);
  ASSERT_EQ(ffsll(0x0000000000008000LL), 16);
  ASSERT_EQ(ffsll(0x0000000000010000LL), 17);
  ASSERT_EQ(ffsll(0x0000000000200000LL), 22);
  ASSERT_EQ(ffsll(0x0000000004000000LL), 27);
  ASSERT_EQ(ffsll(0x0000000080000000LL), 32);
  ASSERT_EQ(ffsll(0x0000000100000000LL), 33);
  ASSERT_EQ(ffsll(0x0000002000000000LL), 38);
  ASSERT_EQ(ffsll(0x0000040000000000LL), 43);
  ASSERT_EQ(ffsll(0x0000800000000000LL), 48);
  ASSERT_EQ(ffsll(0x0001000000000000LL), 49);
  ASSERT_EQ(ffsll(0x0020000000000000LL), 54);
  ASSERT_EQ(ffsll(0x0400000000000000LL), 59);
  ASSERT_EQ(ffsll(0x8000000000000000LL), 64);
  ASSERT_EQ(ffsll(0xfbe71LL), 1);
  ASSERT_EQ(ffsll(0xfbe70LL), 5);
  ASSERT_EQ(ffsll(0x10LL), 5);
  ASSERT_EQ(ffsll(0x100LL), 9);
}

} // namespace LIBC_NAMESPACE_DECL