-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add unit-testing building rules for trpc/util/algorithm (#120)
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// | ||
// Tencent is pleased to support the open source community by making tRPC available. | ||
// | ||
// Copyright (C) 2023 THL A29 Limited, a Tencent company. | ||
// All rights reserved. | ||
// | ||
// If you have downloaded a copy of the tRPC source code from Tencent, | ||
// please note that tRPC source code is licensed under the Apache 2.0 License, | ||
// A copy of the Apache 2.0 License is included in this file. | ||
// | ||
// | ||
|
||
#include "trpc/util/algorithm/hash.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace trpc::testing { | ||
|
||
TEST(GetHashIndex, All) { | ||
std::uint64_t key = 10; | ||
std::uint64_t mod = 8; | ||
std::size_t ret = GetHashIndex(key, mod); | ||
ASSERT_LE(ret, mod); | ||
// Test case: mod is 0. | ||
mod = 0; | ||
ASSERT_DEATH(GetHashIndex(key, mod), ""); | ||
} | ||
|
||
} // namespace trpc::testing |