Skip to content

Commit 58e2964

Browse files
committed
add unit test for clzll()
1 parent aa5dd60 commit 58e2964

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/unittest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include(CheckCXXCompilerFlag)
33
set(UNITTEST_SOURCES
44
allocatorstest.cpp
55
bigintegertest.cpp
6+
clzlltest.cpp
67
cursorstreamwrappertest.cpp
78
documenttest.cpp
89
dtoatest.cpp

test/unittest/clzlltest.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Tencent is pleased to support the open source community by making RapidJSON available.
2+
//
3+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4+
//
5+
// Licensed under the MIT License (the "License"); you may not use this file except
6+
// in compliance with the License. You may obtain a copy of the License at
7+
//
8+
// http://opensource.org/licenses/MIT
9+
//
10+
// Unless required by applicable law or agreed to in writing, software distributed
11+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
// specific language governing permissions and limitations under the License.
14+
15+
#include "unittest.h"
16+
#include "rapidjson/internal/clzll.h"
17+
18+
#ifdef __GNUC__
19+
RAPIDJSON_DIAG_PUSH
20+
#endif
21+
22+
using namespace rapidjson::internal;
23+
24+
TEST(clzll, normal) {
25+
EXPECT_EQ(clzll(1), 0U);
26+
EXPECT_EQ(clzll(2), 1U);
27+
EXPECT_EQ(clzll(12), 3U);
28+
EXPECT_EQ(clzll(0x0000000080000001UL), 31U);
29+
EXPECT_EQ(clzll(0x8000000000000001UL), 63U);
30+
}
31+
32+
#ifdef __GNUC__
33+
RAPIDJSON_DIAG_POP
34+
#endif

0 commit comments

Comments
 (0)