Skip to content

Commit

Permalink
Merge branch 'develop' into disable_clang_format
Browse files Browse the repository at this point in the history
  • Loading branch information
mkstoyanov authored Nov 20, 2024
2 parents 396897e + 938a61d commit 0130fa5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/asgard_program_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ void prog_opts::process_file(std::string_view const &exec_name)
while (std::isspace(static_cast<unsigned char>(s[be])))
be++;
std::string::size_type en = s.size() - 1;
std::string::size_type sharp = s.find('#');
if (sharp < s.size())
en = sharp - 1;
while (en > be and std::isspace(static_cast<unsigned char>(s[en])))
en--;
return s.substr(be, en - be + 1);
Expand Down
5 changes: 5 additions & 0 deletions src/asgard_program_options_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ TEST_CASE("input file processing", "[file i/o]")
static_assert(std::is_same_v<decltype(name), std::optional<std::string>>);
REQUIRE(!!name);
REQUIRE(name.value() == "some-name test");

auto nu = prog.file_value<int>("var nu");
static_assert(std::is_same_v<decltype(nu), std::optional<int>>);
REQUIRE(!!nu);
REQUIRE(nu.value() == 314);
}

SECTION("test_input1.txt -- direct ")
Expand Down
2 changes: 2 additions & 0 deletions testing/test_input2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ v_thermal : 0.5
half percent : 5.E-3
extra name : some-name test

# line above has white spaces # #
var nu : 314 # inlined comment

0 comments on commit 0130fa5

Please sign in to comment.