Skip to content

Commit

Permalink
[tests] Fix cpp streaming data tests (#5481)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS authored Oct 12, 2022
1 parent f5dd320 commit 0c0eb2a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/cpp_tests/test_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void test_stream_dense(
int has_init_scores = init_scores != nullptr;
int has_queries = groups != nullptr;

bool succeeded = true;
std::string exceptionText("");

try {
int result = 0;
switch (creation_type) {
Expand Down Expand Up @@ -111,13 +114,19 @@ void test_stream_dense(
init_scores,
groups);
}
catch (...) {
catch (std::exception& ex) {
succeeded = false;
exceptionText = std::string(ex.what());
}

if (dataset_handle) {
int result = LGBM_DatasetFree(dataset_handle);
EXPECT_EQ(0, result) << "LGBM_DatasetFree result code: " << result;
}

if (!succeeded) {
FAIL() << "Test Dense Stream failed with exception: " << exceptionText;
}
}

void test_stream_sparse(
Expand All @@ -142,6 +151,9 @@ void test_stream_sparse(
int has_init_scores = init_scores != nullptr;
int has_queries = groups != nullptr;

bool succeeded = true;
std::string exceptionText("");

try {
int result = 0;
switch (creation_type) {
Expand Down Expand Up @@ -220,13 +232,19 @@ void test_stream_sparse(
init_scores,
groups);
}
catch (...) {
catch (std::exception& ex) {
succeeded = false;
exceptionText = std::string(ex.what());
}

if (dataset_handle) {
int result = LGBM_DatasetFree(dataset_handle);
EXPECT_EQ(0, result) << "LGBM_DatasetFree result code: " << result;
}

if (!succeeded) {
FAIL() << "Test Sparse Stream failed with exception: " << exceptionText;
}
}

TEST(Stream, PushDenseRowsWithMetadata) {
Expand Down

0 comments on commit 0c0eb2a

Please sign in to comment.