Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More extensive tests of config behavior #435

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/config/assets/config_setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ EMP_BUILD_CONFIG( MyConfig,
VALUE(TEST_STRING, std::string, "default", "This is a string!"),
CONST(TEST_CONST, int, 91, "This is an unchanging const!"),
VALUE(TEST_STRING_SPACE, std::string, "abc def ghi", "This is a string with spaces."),
VALUE(TEST_STRING_WHITESPACE, std::string, "What about...\n\t...whitespace in values?", "This is a string with newlines and tabs."),
//VALUE(MUTATION_RATE, float, 0.025, "This is my mutation rate.", MUT_RATE),
VALUE(MUTATION_RATE, float, 0.025, "This is my mutation rate."),
)
19 changes: 18 additions & 1 deletion tests/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@ TEST_CASE("Test config", "[config]"){

// test config class template
{

MyConfig config;

// make sure printing/parsing do not alter config
std::stringstream ss1, ss2;
config.Write(ss1);
config.Read(ss1);
config.Write(ss2);
std::string l1, l2;
while ( ss1 && ss2 ) {
std::getline(ss1, l1);
std::getline(ss2, l2);
// Check every line is the same between the "files"
REQUIRE(l1 == l2);
}


config.Read("assets/test.cfg");

std::cout << "Random seed = " << config.RANDOM_SEED() << std::endl;
Expand All @@ -35,6 +50,8 @@ TEST_CASE("Test config", "[config]"){

REQUIRE(config.RANDOM_SEED() == 123);

REQUIRE(config.TEST_STRING_WHITESPACE() == "What about...\n\t...whitespace in values?");

}

}