Skip to content

Commit

Permalink
Tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
billschereriii committed Aug 22, 2023
1 parent f09030d commit 62d1380
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
3 changes: 0 additions & 3 deletions doc/advanced_topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,3 @@ lead to race conditions:
void delete_list(const std::string& list_name);
.. _advanced_topics_dataset_aggregation:

Multiple Database Support
=========================
2 changes: 1 addition & 1 deletion src/cpp/configoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ std::string ConfigOptions::_suffixed(const std::string& option_name)
}
std::string result(option_name);
if (_source == cs_envt && _string != "")
result = _string + + "_" + option_name;
result = option_name + + "_" + _string;
return result;
}

Expand Down
28 changes: 14 additions & 14 deletions tests/cpp/unit-tests/test_configopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,33 +111,33 @@ SCENARIO("Testing for ConfigOptions", "[CfgOpts]")
log_data(context, LLDebug, "***End ConfigOptions testing***");
}

SCENARIO("Prefix Testing for ConfigOptions", "[CfgOpts]")
SCENARIO("Suffix Testing for ConfigOptions", "[CfgOpts]")
{
std::cout << std::to_string(get_time_offset()) << ": Prefix Testing for ConfigOptions" << std::endl;
std::cout << std::to_string(get_time_offset()) << ": Suffix Testing for ConfigOptions" << std::endl;
std::string context("test_configopts");
log_data(context, LLDebug, "***Beginning ConfigOptions prefix testing***");
log_data(context, LLDebug, "***Beginning ConfigOptions suffix testing***");

GIVEN("A ConfigOptions object")
{
// Make sure keys aren't set before we start
const char* keys[] = {
"prefixtest_integer_key_that_is_not_really_present",
"prefixtest_string_key_that_is_not_really_present",
"prefixtest_integer_key",
"prefixtest_string_key"
"integer_key_that_is_not_really_present_suffixtest",
"string_key_that_is_not_really_present_suffixtest",
"integer_key_suffixtest",
"string_key_suffixtest"
};
INFO("Reserved keys must not be set before running this test.");
for (size_t i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) {
REQUIRE(std::getenv(keys[i]) == NULL);
}

// Set up keys for testing
setenv("prefixtest_integer_key", "42", true);
setenv("prefixtest_string_key", "charizard", true);
setenv("integer_key_suffixtest", "42", true);
setenv("string_key_suffixtest", "charizard", true);

auto co = ConfigOptions::create_from_environment("prefixtest");
auto co = ConfigOptions::create_from_environment("suffixtest");

THEN("Prefixed options should be configurable")
THEN("Suffixed options should be configurable")
{
// integer option tests
CHECK(co->get_integer_option("integer_key") == 42);
Expand Down Expand Up @@ -180,9 +180,9 @@ SCENARIO("Prefix Testing for ConfigOptions", "[CfgOpts]")
}

// Clean up test keys
unsetenv("prefixtest_integer_key");
unsetenv("prefixtest_string_key");
unsetenv("integer_key_suffixtest");
unsetenv("string_key_suffixtest");

log_data(context, LLDebug, "***End ConfigOptions prefix testing***");
log_data(context, LLDebug, "***End ConfigOptions suffix testing***");
}

24 changes: 12 additions & 12 deletions tests/fortran/client_test_configoptions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ program main

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Establish test keys
! non-prefixed testing keys
! non-suffixed testing keys
call setenv("test_integer_key", "42")
call setenv("test_string_key", "charizard")
! prefixed testing keys
call setenv("prefixtest_integer_key", "42")
call setenv("prefixtest_string_key", "charizard")
! suffixed testing keys
call setenv("integer_key_suffixtest", "42")
call setenv("string_key_suffixtest", "charizard")

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! non-prefixed option testing
!! non-suffixed option testing
result = co%create_configoptions_from_environment("");
if (result .ne. SRNoError) error stop

Expand Down Expand Up @@ -118,12 +118,12 @@ program main


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Prefixed testing
result = co%create_configoptions_from_environment("prefixtest");
! suffixtest testing
result = co%create_configoptions_from_environment("suffixtest");
if (result .ne. SRNoError) error stop

! integer option tests
write(*,*) "ConfigOption testing: prefixed integer option tests"
write(*,*) "ConfigOption testing: suffixed integer option tests"

result = co%get_integer_option("integer_key", iresult)
if (result .ne. SRNoError) error stop
Expand Down Expand Up @@ -155,7 +155,7 @@ program main


! string option tests
write(*,*) "ConfigOption testing: prefixed string option tests"
write(*,*) "ConfigOption testing: suffixed string option tests"

result = co%get_string_option("string_key", sresult)
if (result .ne. SRNoError) error stop
Expand Down Expand Up @@ -189,9 +189,9 @@ program main
! non-prefixed testing keys
call unsetenv("test_integer_key")
call unsetenv("test_string_key")
! prefixed testing keys
call unsetenv("prefixtest_integer_key")
call unsetenv("prefixtest_string_key")
! suffixed testing keys
call unsetenv("integer_key_suffixtest")
call unsetenv("string_key_suffixtest")

! Done
write(*,*) "ConfigOption testing: passed"
Expand Down
8 changes: 4 additions & 4 deletions tests/python/test_configoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def test_options(monkeypatch):
assert co.get_string_option(
"test_string_key_that_is_not_really_present") == "meowth"

def test_options_with_prefix(monkeypatch):
monkeypatch.setenv("prefixtest_integer_key", "42")
monkeypatch.setenv("prefixtest_string_key", "charizard")
co = ConfigOptions.create_from_environment("prefixtest")
def test_options_with_suffix(monkeypatch):
monkeypatch.setenv("integer_key_suffixtest", "42")
monkeypatch.setenv("string_key_suffixtest", "charizard")
co = ConfigOptions.create_from_environment("suffixtest")

# integer option tests
assert co.get_integer_option("integer_key") == 42
Expand Down

0 comments on commit 62d1380

Please sign in to comment.