Skip to content

Commit

Permalink
UCS/CONFIG: fixed crash on incorrect value set
Browse files Browse the repository at this point in the history
- minor refactoring
  • Loading branch information
Sergey Oblomov committed Dec 8, 2020
1 parent 56fd6a9 commit 529eaeb
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/gtest/ucs/test_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ static std::vector<std::string> config_err_exp_str;
class test_config : public ucs::test {
public:
test_config() {
m_errors = 0;
m_num_errors = 0;
}

protected:
static int m_errors;
static int m_num_errors;

static ucs_log_func_rc_t
config_error_handler(const char *file, unsigned line, const char *function,
Expand Down Expand Up @@ -261,10 +261,9 @@ class test_config : public ucs::test {
{
// Ignore errors that invalid input parameters as it is expected
if (level == UCS_LOG_LEVEL_ERROR) {
m_errors++;
wrap_errors_logger(file, line, function, level, comp_conf,
message, ap);
return UCS_LOG_FUNC_RC_STOP;
m_num_errors++;
return wrap_errors_logger(file, line, function, level, comp_conf,
message, ap);
}

return UCS_LOG_FUNC_RC_CONTINUE;
Expand Down Expand Up @@ -401,7 +400,7 @@ class test_config : public ucs::test {
}
};

int test_config::m_errors;
int test_config::m_num_errors;

UCS_TEST_F(test_config, parse_default) {
car_opts opts(UCS_DEFAULT_ENV_PREFIX, "TEST");
Expand Down Expand Up @@ -493,7 +492,7 @@ UCS_TEST_F(test_config, set_get) {
EXPECT_EQ(COLOR_WHITE, opts->color);
EXPECT_EQ(std::string(color_names[COLOR_WHITE]),
std::string(opts.get("COLOR")));
EXPECT_EQ(1, m_errors);
EXPECT_EQ(1, m_num_errors);
}

UCS_TEST_F(test_config, set_get_with_table_prefix) {
Expand Down

0 comments on commit 529eaeb

Please sign in to comment.