Upgrade clang-tidy on CI. (#5469)

* Correct all clang-tidy errors.
* Upgrade clang-tidy to 10 on CI.

Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
Jiaming Yuan
2020-04-05 04:42:29 +08:00
committed by GitHub
parent 30e94ddd04
commit 0012f2ef93
107 changed files with 932 additions and 903 deletions

View File

@@ -27,7 +27,7 @@ TEST(BitField, StorageSize) {
ASSERT_EQ(2, size);
}
TEST(BitField, GPU_Set) {
TEST(BitField, GPUSet) {
dh::device_vector<LBitField64::value_type> storage;
uint32_t constexpr kBits = 128;
storage.resize(128);
@@ -49,7 +49,7 @@ __global__ void TestOrKernel(LBitField64 lhs, LBitField64 rhs) {
lhs |= rhs;
}
TEST(BitField, GPU_And) {
TEST(BitField, GPUAnd) {
uint32_t constexpr kBits = 128;
dh::device_vector<LBitField64::value_type> lhs_storage(kBits);
dh::device_vector<LBitField64::value_type> rhs_storage(kBits);

View File

@@ -22,19 +22,19 @@ TEST(DenseColumn, Test) {
for (auto i = 0ull; i < dmat->Info().num_row_; i++) {
for (auto j = 0ull; j < dmat->Info().num_col_; j++) {
switch (column_matrix.GetTypeSize()) {
case UINT8_BINS_TYPE_SIZE: {
case kUint8BinsTypeSize: {
auto col = column_matrix.GetColumn<uint8_t>(j);
ASSERT_EQ(gmat.index[i * dmat->Info().num_col_ + j],
(*col.get()).GetGlobalBinIdx(i));
}
break;
case UINT16_BINS_TYPE_SIZE: {
case kUint16BinsTypeSize: {
auto col = column_matrix.GetColumn<uint16_t>(j);
ASSERT_EQ(gmat.index[i * dmat->Info().num_col_ + j],
(*col.get()).GetGlobalBinIdx(i));
}
break;
case UINT32_BINS_TYPE_SIZE: {
case kUint32BinsTypeSize: {
auto col = column_matrix.GetColumn<uint32_t>(j);
ASSERT_EQ(gmat.index[i * dmat->Info().num_col_ + j],
(*col.get()).GetGlobalBinIdx(i));
@@ -49,7 +49,7 @@ TEST(DenseColumn, Test) {
template<typename BinIdxType>
inline void CheckSparseColumn(const Column<BinIdxType>& col_input, const GHistIndexMatrix& gmat) {
const SparseColumn<BinIdxType>& col = static_cast<const SparseColumn<BinIdxType>& >(col_input);
ASSERT_EQ(col.Size(), gmat.index.size());
ASSERT_EQ(col.Size(), gmat.index.Size());
for (auto i = 0ull; i < col.Size(); i++) {
ASSERT_EQ(gmat.index[gmat.row_ptr[col.GetRowIdx(i)]],
col.GetGlobalBinIdx(i));
@@ -67,17 +67,17 @@ TEST(SparseColumn, Test) {
ColumnMatrix column_matrix;
column_matrix.Init(gmat, 0.5);
switch (column_matrix.GetTypeSize()) {
case UINT8_BINS_TYPE_SIZE: {
case kUint8BinsTypeSize: {
auto col = column_matrix.GetColumn<uint8_t>(0);
CheckSparseColumn(*col.get(), gmat);
}
break;
case UINT16_BINS_TYPE_SIZE: {
case kUint16BinsTypeSize: {
auto col = column_matrix.GetColumn<uint16_t>(0);
CheckSparseColumn(*col.get(), gmat);
}
break;
case UINT32_BINS_TYPE_SIZE: {
case kUint32BinsTypeSize: {
auto col = column_matrix.GetColumn<uint32_t>(0);
CheckSparseColumn(*col.get(), gmat);
}
@@ -108,17 +108,17 @@ TEST(DenseColumnWithMissing, Test) {
ColumnMatrix column_matrix;
column_matrix.Init(gmat, 0.2);
switch (column_matrix.GetTypeSize()) {
case UINT8_BINS_TYPE_SIZE: {
case kUint8BinsTypeSize: {
auto col = column_matrix.GetColumn<uint8_t>(0);
CheckColumWithMissingValue(*col.get(), gmat);
}
break;
case UINT16_BINS_TYPE_SIZE: {
case kUint16BinsTypeSize: {
auto col = column_matrix.GetColumn<uint16_t>(0);
CheckColumWithMissingValue(*col.get(), gmat);
}
break;
case UINT32_BINS_TYPE_SIZE: {
case kUint32BinsTypeSize: {
auto col = column_matrix.GetColumn<uint32_t>(0);
CheckColumWithMissingValue(*col.get(), gmat);
}

View File

@@ -55,14 +55,14 @@ void TestLbs() {
}
}
TEST(cub_lbs, Test) {
TEST(CubLBS, Test) {
TestLbs();
}
TEST(sumReduce, Test) {
TEST(SumReduce, Test) {
thrust::device_vector<float> data(100, 1.0f);
dh::CubMemory temp;
auto sum = dh::SumReduction(temp, dh::Raw(data), data.size());
auto sum = dh::SumReduction(&temp, dh::Raw(data), data.size());
ASSERT_NEAR(sum, 100.0f, 1e-5);
}
@@ -81,7 +81,7 @@ void TestAllocator() {
}
// Define the test in a function so we can use device lambda
TEST(bulkAllocator, Test) {
TEST(BulkAllocator, Test) {
TestAllocator();
}

View File

@@ -8,7 +8,7 @@
namespace xgboost {
namespace common {
TEST(group_data, ParallelGroupBuilder) {
TEST(GroupData, ParallelGroupBuilder) {
std::vector<size_t> offsets;
std::vector<Entry> data;
ParallelGroupBuilder<Entry, size_t> builder(&offsets, &data);

View File

@@ -218,7 +218,7 @@ TEST(SparseCuts, MultiThreadedBuild) {
omp_set_num_threads(ori_nthreads);
}
TEST(hist_util, DenseCutsCategorical) {
TEST(HistUtil, DenseCutsCategorical) {
int categorical_sizes[] = {2, 6, 8, 12};
int num_bins = 256;
int sizes[] = {25, 100, 1000};
@@ -240,7 +240,7 @@ TEST(hist_util, DenseCutsCategorical) {
}
}
TEST(hist_util, DenseCutsAccuracyTest) {
TEST(HistUtil, DenseCutsAccuracyTest) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -256,7 +256,7 @@ TEST(hist_util, DenseCutsAccuracyTest) {
}
}
TEST(hist_util, DenseCutsAccuracyTestWeights) {
TEST(HistUtil, DenseCutsAccuracyTestWeights) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -274,7 +274,7 @@ TEST(hist_util, DenseCutsAccuracyTestWeights) {
}
}
TEST(hist_util, DenseCutsExternalMemory) {
TEST(HistUtil, DenseCutsExternalMemory) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -292,7 +292,7 @@ TEST(hist_util, DenseCutsExternalMemory) {
}
}
TEST(hist_util, SparseCutsAccuracyTest) {
TEST(HistUtil, SparseCutsAccuracyTest) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -308,7 +308,7 @@ TEST(hist_util, SparseCutsAccuracyTest) {
}
}
TEST(hist_util, SparseCutsCategorical) {
TEST(HistUtil, SparseCutsCategorical) {
int categorical_sizes[] = {2, 6, 8, 12};
int num_bins = 256;
int sizes[] = {25, 100, 1000};
@@ -330,7 +330,7 @@ TEST(hist_util, SparseCutsCategorical) {
}
}
TEST(hist_util, SparseCutsExternalMemory) {
TEST(HistUtil, SparseCutsExternalMemory) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -348,13 +348,13 @@ TEST(hist_util, SparseCutsExternalMemory) {
}
}
TEST(hist_util, IndexBinBound) {
TEST(HistUtil, IndexBinBound) {
uint64_t bin_sizes[] = { static_cast<uint64_t>(std::numeric_limits<uint8_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 2 };
BinTypeSize expected_bin_type_sizes[] = {UINT8_BINS_TYPE_SIZE,
UINT16_BINS_TYPE_SIZE,
UINT32_BINS_TYPE_SIZE};
BinTypeSize expected_bin_type_sizes[] = {kUint8BinsTypeSize,
kUint16BinsTypeSize,
kUint32BinsTypeSize};
size_t constexpr kRows = 100;
size_t constexpr kCols = 10;
@@ -364,18 +364,18 @@ TEST(hist_util, IndexBinBound) {
common::GHistIndexMatrix hmat;
hmat.Init(p_fmat.get(), max_bin);
EXPECT_EQ(hmat.index.size(), kRows*kCols);
EXPECT_EQ(expected_bin_type_sizes[bin_id++], hmat.index.getBinTypeSize());
EXPECT_EQ(hmat.index.Size(), kRows*kCols);
EXPECT_EQ(expected_bin_type_sizes[bin_id++], hmat.index.GetBinTypeSize());
}
}
TEST(hist_util, SparseIndexBinBound) {
TEST(HistUtil, SparseIndexBinBound) {
uint64_t bin_sizes[] = { static_cast<uint64_t>(std::numeric_limits<uint8_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 2 };
BinTypeSize expected_bin_type_sizes[] = { UINT32_BINS_TYPE_SIZE,
UINT32_BINS_TYPE_SIZE,
UINT32_BINS_TYPE_SIZE };
BinTypeSize expected_bin_type_sizes[] = { kUint32BinsTypeSize,
kUint32BinsTypeSize,
kUint32BinsTypeSize };
size_t constexpr kRows = 100;
size_t constexpr kCols = 10;
@@ -384,19 +384,19 @@ TEST(hist_util, SparseIndexBinBound) {
auto p_fmat = RandomDataGenerator(kRows, kCols, 0.2).GenerateDMatix();
common::GHistIndexMatrix hmat;
hmat.Init(p_fmat.get(), max_bin);
EXPECT_EQ(expected_bin_type_sizes[bin_id++], hmat.index.getBinTypeSize());
EXPECT_EQ(expected_bin_type_sizes[bin_id++], hmat.index.GetBinTypeSize());
}
}
template <typename T>
void CheckIndexData(T* data_ptr, uint32_t* offsets,
const common::GHistIndexMatrix& hmat, size_t n_cols) {
for (size_t i = 0; i < hmat.index.size(); ++i) {
for (size_t i = 0; i < hmat.index.Size(); ++i) {
EXPECT_EQ(data_ptr[i] + offsets[i % n_cols], hmat.index[i]);
}
}
TEST(hist_util, IndexBinData) {
TEST(HistUtil, IndexBinData) {
uint64_t constexpr kBinSizes[] = { static_cast<uint64_t>(std::numeric_limits<uint8_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 2 };
@@ -407,8 +407,8 @@ TEST(hist_util, IndexBinData) {
auto p_fmat = RandomDataGenerator(kRows, kCols, 0).GenerateDMatix();
common::GHistIndexMatrix hmat;
hmat.Init(p_fmat.get(), max_bin);
uint32_t* offsets = hmat.index.offset();
EXPECT_EQ(hmat.index.size(), kRows*kCols);
uint32_t* offsets = hmat.index.Offset();
EXPECT_EQ(hmat.index.Size(), kRows*kCols);
switch (max_bin) {
case kBinSizes[0]:
CheckIndexData(hmat.index.data<uint8_t>(),
@@ -426,7 +426,7 @@ TEST(hist_util, IndexBinData) {
}
}
TEST(hist_util, SparseIndexBinData) {
TEST(HistUtil, SparseIndexBinData) {
uint64_t bin_sizes[] = { static_cast<uint64_t>(std::numeric_limits<uint8_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1,
static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 2 };
@@ -437,10 +437,10 @@ TEST(hist_util, SparseIndexBinData) {
auto p_fmat = RandomDataGenerator(kRows, kCols, 0.2).GenerateDMatix();
common::GHistIndexMatrix hmat;
hmat.Init(p_fmat.get(), max_bin);
EXPECT_EQ(hmat.index.offset(), nullptr);
EXPECT_EQ(hmat.index.Offset(), nullptr);
uint32_t* data_ptr = hmat.index.data<uint32_t>();
for (size_t i = 0; i < hmat.index.size(); ++i) {
for (size_t i = 0; i < hmat.index.Size(); ++i) {
EXPECT_EQ(data_ptr[i], hmat.index[i]);
}
}

View File

@@ -32,7 +32,7 @@ HistogramCuts GetHostCuts(AdapterT *adapter, int num_bins, float missing) {
builder.Build(&dmat, num_bins);
return cuts;
}
TEST(hist_util, DeviceSketch) {
TEST(HistUtil, DeviceSketch) {
int num_rows = 5;
int num_columns = 1;
int num_bins = 4;
@@ -61,7 +61,7 @@ size_t RequiredSampleCutsTest(int max_bins, size_t num_rows) {
return std::min(num_cuts, num_rows);
}
TEST(hist_util, DeviceSketchMemory) {
TEST(HistUtil, DeviceSketchMemory) {
int num_columns = 100;
int num_rows = 1000;
int num_bins = 256;
@@ -81,7 +81,7 @@ TEST(hist_util, DeviceSketchMemory) {
bytes_num_elements + bytes_cuts + bytes_constant);
}
TEST(hist_util, DeviceSketchMemoryWeights) {
TEST(HistUtil, DeviceSketchMemoryWeights) {
int num_columns = 100;
int num_rows = 1000;
int num_bins = 256;
@@ -102,7 +102,7 @@ TEST(hist_util, DeviceSketchMemoryWeights) {
size_t((bytes_num_elements + bytes_cuts) * 1.05));
}
TEST(hist_util, DeviceSketchDeterminism) {
TEST(HistUtil, DeviceSketchDeterminism) {
int num_rows = 500;
int num_columns = 5;
int num_bins = 256;
@@ -117,7 +117,7 @@ TEST(hist_util, DeviceSketchDeterminism) {
}
}
TEST(hist_util, DeviceSketchCategorical) {
TEST(HistUtil, DeviceSketchCategorical) {
int categorical_sizes[] = {2, 6, 8, 12};
int num_bins = 256;
int sizes[] = {25, 100, 1000};
@@ -131,7 +131,7 @@ TEST(hist_util, DeviceSketchDeterminism) {
}
}
TEST(hist_util, DeviceSketchMultipleColumns) {
TEST(HistUtil, DeviceSketchMultipleColumns) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -146,7 +146,7 @@ TEST(hist_util, DeviceSketchMultipleColumns) {
}
TEST(hist_util, DeviceSketchMultipleColumnsWeights) {
TEST(HistUtil, DeviceSketchMultipleColumnsWeights) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -161,7 +161,7 @@ TEST(hist_util, DeviceSketchMultipleColumnsWeights) {
}
}
TEST(hist_util, DeviceSketchBatches) {
TEST(HistUtil, DeviceSketchBatches) {
int num_bins = 256;
int num_rows = 5000;
int batch_sizes[] = {0, 100, 1500, 6000};
@@ -174,7 +174,7 @@ TEST(hist_util, DeviceSketchBatches) {
}
}
TEST(hist_util, DeviceSketchMultipleColumnsExternal) {
TEST(HistUtil, DeviceSketchMultipleColumnsExternal) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns =5;
@@ -190,7 +190,7 @@ TEST(hist_util, DeviceSketchMultipleColumnsExternal) {
}
}
TEST(hist_util, AdapterDeviceSketch)
TEST(HistUtil, AdapterDeviceSketch)
{
int rows = 5;
int cols = 1;
@@ -212,7 +212,7 @@ TEST(hist_util, AdapterDeviceSketch)
EXPECT_EQ(device_cuts.MinValues(), host_cuts.MinValues());
}
TEST(hist_util, AdapterDeviceSketchMemory) {
TEST(HistUtil, AdapterDeviceSketchMemory) {
int num_columns = 100;
int num_rows = 1000;
int num_bins = 256;
@@ -235,7 +235,7 @@ TEST(hist_util, AdapterDeviceSketchMemory) {
bytes_num_elements + bytes_cuts + bytes_num_columns + bytes_constant);
}
TEST(hist_util, AdapterDeviceSketchCategorical) {
TEST(HistUtil, AdapterDeviceSketchCategorical) {
int categorical_sizes[] = {2, 6, 8, 12};
int num_bins = 256;
int sizes[] = {25, 100, 1000};
@@ -252,7 +252,7 @@ TEST(hist_util, AdapterDeviceSketchMemory) {
}
}
TEST(hist_util, AdapterDeviceSketchMultipleColumns) {
TEST(HistUtil, AdapterDeviceSketchMultipleColumns) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;
@@ -268,7 +268,7 @@ TEST(hist_util, AdapterDeviceSketchMultipleColumns) {
}
}
}
TEST(hist_util, AdapterDeviceSketchBatches) {
TEST(HistUtil, AdapterDeviceSketchBatches) {
int num_bins = 256;
int num_rows = 5000;
int batch_sizes[] = {0, 100, 1500, 6000};
@@ -287,7 +287,7 @@ TEST(hist_util, AdapterDeviceSketchBatches) {
// Check sketching from adapter or DMatrix results in the same answer
// Consistency here is useful for testing and user experience
TEST(hist_util, SketchingEquivalent) {
TEST(HistUtil, SketchingEquivalent) {
int bin_sizes[] = {2, 16, 256, 512};
int sizes[] = {100, 1000, 1500};
int num_columns = 5;

View File

@@ -176,7 +176,7 @@ TEST(HostDeviceVector, Span) {
ASSERT_TRUE(vec.HostCanWrite());
}
TEST(HostDeviceVector, MGPU_Basic) {
TEST(HostDeviceVector, MGPU_Basic) { // NOLINT
if (AllVisibleGPUs() < 2) {
LOG(WARNING) << "Not testing in multi-gpu environment.";
return;

View File

@@ -262,7 +262,7 @@ TEST(Json, Indexing) {
Json j {Json::Load(&reader)};
auto& value_1 = j["model_parameter"];
auto& value = value_1["base_score"];
std::string result = Cast<JsonString>(&value.GetValue())->getString();
std::string result = Cast<JsonString>(&value.GetValue())->GetString();
ASSERT_EQ(result, "0.5");
}
@@ -406,7 +406,7 @@ TEST(Json, WrongCasts) {
}
}
TEST(Json, Int_vs_Float) {
TEST(Json, IntVSFloat) {
// If integer is parsed as float, calling `get<Integer>()' will throw.
{
std::string str = R"json(

View File

@@ -5,7 +5,7 @@
namespace xgboost {
namespace common {
TEST(Transform, MGPU_SpecifiedGpuId) {
TEST(Transform, MGPU_SpecifiedGpuId) { // NOLINT
if (AllVisibleGPUs() < 2) {
LOG(WARNING) << "Not testing in multi-gpu environment.";
return;