• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Unittests for ffs -------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/strings/ffs.h"
10 
11 #include "src/__support/macros/config.h"
12 #include "test/UnitTest/Test.h"
13 
14 namespace LIBC_NAMESPACE_DECL {
15 
TEST(LlvmLibcFfsTest,SimpleFfs)16 TEST(LlvmLibcFfsTest, SimpleFfs) {
17   ASSERT_EQ(ffs(0x00000000), 0);
18   ASSERT_EQ(ffs(0x00000001), 1);
19   ASSERT_EQ(ffs(0x00000020), 6);
20   ASSERT_EQ(ffs(0x00000400), 11);
21   ASSERT_EQ(ffs(0x00008000), 16);
22   ASSERT_EQ(ffs(0x00010000), 17);
23   ASSERT_EQ(ffs(0x00200000), 22);
24   ASSERT_EQ(ffs(0x04000000), 27);
25   ASSERT_EQ(ffs(0x80000000), 32);
26   ASSERT_EQ(ffs(0xfbe71), 1);
27   ASSERT_EQ(ffs(0xfbe70), 5);
28   ASSERT_EQ(ffs(0x10), 5);
29   ASSERT_EQ(ffs(0x100), 9);
30 }
31 
32 } // namespace LIBC_NAMESPACE_DECL
33