Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the make commands required to build and run tests.
- Loading branch information
1 parent
b045ccd
commit 1f2ad36
Showing
6 changed files
with
84 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
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,34 @@ | ||
// Copyright by Contributors | ||
#include <xgboost/data.h> | ||
#include <gtest/gtest.h> | ||
|
||
TEST(MetaInfo, GetSet) { | ||
xgboost::MetaInfo info; | ||
|
||
double double2[2] = {1.0, 2.0}; | ||
EXPECT_EQ(info.GetRoot(1), 0) | ||
<< "When no root_index is given, was expecting default value 0"; | ||
info.SetInfo("root_index", double2, xgboost::kDouble, 2); | ||
EXPECT_EQ(info.GetRoot(1), 2.0f); | ||
|
||
EXPECT_EQ(info.labels.size(), 0); | ||
info.SetInfo("label", double2, xgboost::kFloat32, 2); | ||
EXPECT_EQ(info.labels.size(), 2); | ||
|
||
float float2[2] = {1.0f, 2.0f}; | ||
EXPECT_EQ(info.GetWeight(1), 1.0f) | ||
<< "When no weights are given, was expecting default value 1"; | ||
info.SetInfo("weight", float2, xgboost::kFloat32, 2); | ||
EXPECT_EQ(info.GetWeight(1), 2.0f); | ||
|
||
uint32_t uint32_t2[2] = {1U, 2U}; | ||
EXPECT_EQ(info.base_margin.size(), 0); | ||
info.SetInfo("base_margin", uint32_t2, xgboost::kUInt32, 2); | ||
EXPECT_EQ(info.base_margin.size(), 2); | ||
|
||
uint64_t uint64_t2[2] = {1U, 2U}; | ||
EXPECT_EQ(info.group_ptr.size(), 0); | ||
info.SetInfo("group", uint64_t2, xgboost::kUInt64, 2); | ||
ASSERT_EQ(info.group_ptr.size(), 3); | ||
EXPECT_EQ(info.group_ptr[2], 3); | ||
} |
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,8 @@ | ||
// Copyright by Contributors | ||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char ** argv) { | ||
testing::InitGoogleTest(&argc, argv); | ||
testing::FLAGS_gtest_death_test_style = "threadsafe"; | ||
return RUN_ALL_TESTS(); | ||
} |
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,23 @@ | ||
UTEST_ROOT=tests/cpp | ||
UTEST_OBJ_ROOT=build_$(UTEST_ROOT) | ||
UNITTEST=$(UTEST_ROOT)/xgboost_test | ||
UNITTEST_SRC=$(wildcard $(UTEST_ROOT)/*.cc $(UTEST_ROOT)/*/*.cc) | ||
UNITTEST_OBJ=$(patsubst $(UTEST_ROOT)%.cc, $(UTEST_OBJ_ROOT)%.o, $(UNITTEST_SRC)) | ||
|
||
GTEST_LIB=$(GTEST_PATH)/lib/ | ||
GTEST_INC=$(GTEST_PATH)/include/ | ||
|
||
UNITTEST_CFLAGS=$(CFLAGS) | ||
UNITTEST_LDFLAGS=$(LDFLAGS) -L$(GTEST_LIB) -lgtest | ||
UNITTEST_DEPS=lib/libxgboost.a $(DMLC_CORE)/libdmlc.a $(RABIT)/lib/$(LIB_RABIT) | ||
|
||
$(UTEST_OBJ_ROOT)/%.o: $(UTEST_ROOT)/%.cc | ||
@mkdir -p $(@D) | ||
$(CXX) $(UNITTEST_CFLAGS) -I$(GTEST_INC) -o $@ -c $< | ||
|
||
$(UNITTEST): $(UNITTEST_OBJ) $(UNITTEST_DEPS) | ||
$(CXX) $(UNITTEST_CFLAGS) -o $@ $^ $(UNITTEST_LDFLAGS) | ||
|
||
|
||
ALL_TEST=$(UNITTEST) | ||
ALL_TEST_OBJ=$(UNITTEST_OBJ) |