Skip to content

Commit

Permalink
Merge pull request #257 from JeffersonLab/AyanRoy16_issue_256_duplica…
Browse files Browse the repository at this point in the history
…tion_of_vector_default_parameters

Removing duplicate copying into input vector in SetDefaultParameter
  • Loading branch information
nathanwbrei authored Oct 20, 2023
2 parents 1dc9158 + 571dc36 commit 4fa5ec2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libraries/JANA/Services/JParameterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ template<typename T>
inline void JParameterManager::Parse(const std::string& value, std::vector<T> &val) {
std::stringstream ss(value);
std::string s;
val.clear(); // clearing the input vector to ensure no dulication which can be caused due to val.push_back(t);
while (getline(ss, s, ',')) {
T t;
Parse(s, t);
Expand Down
1 change: 1 addition & 0 deletions src/programs/tests/JParameterManagerTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ TEST_CASE("JParameterManager_VectorParams") {
std::vector<std::string> outputs;
auto param = jpm.GetParameter("test", outputs);
REQUIRE(param->GetValue() == "first,second one, third one ");
REQUIRE(inputs.size()==3); // an additional test to see that the size of the input vector remains the same: Issue #256
}
SECTION("Reading a vector of ints") {
jpm.SetParameter("test", "1,2, 3 ");
Expand Down

0 comments on commit 4fa5ec2

Please sign in to comment.