mirror of
https://github.com/nasa/trick.git
synced 2025-01-29 15:43:57 +00:00
* Added tests for MonteCarlo varfile eof line problem * Remove redundant variables in MonteCarlo varfile test * Fixed MonteCarlo varfile eof line problem. #459
This commit is contained in:
parent
da7a79e897
commit
c8619dbea7
@ -45,8 +45,12 @@ std::string Trick::MonteVarFile::get_next_value() {
|
||||
std::getline(*input_file_stream, line);
|
||||
|
||||
if(input_file_stream->eof()) {
|
||||
input_file_stream->close();
|
||||
return "EOF";
|
||||
if (line.empty()) {
|
||||
input_file_stream->close();
|
||||
return "EOF";
|
||||
} else {
|
||||
input_file_stream->seekg(0, input_file_stream->end);
|
||||
}
|
||||
}
|
||||
}
|
||||
while(line[0] == '#' || line[0] == '\0');
|
||||
|
@ -0,0 +1 @@
|
||||
0 1.0000 1.5000
|
@ -0,0 +1 @@
|
||||
0 1.0000 1.5000
|
@ -319,8 +319,6 @@ TEST_F(MonteCarloTest, TestSlaves) {
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFile) {
|
||||
std::string buffer;
|
||||
std::string buffer2;
|
||||
//req.add_requirement("3932595803");
|
||||
|
||||
// Test MonteVarFile
|
||||
@ -331,6 +329,24 @@ TEST_F(MonteCarloTest, MonteVarFile) {
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFileWithEOFLine) {
|
||||
Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_eof_line", 2) ;
|
||||
EXPECT_EQ(exec.variables.size(), 0) ;
|
||||
exec.add_variable(&var0) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ;
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "EOF") ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFileWithLineEndedEOF) {
|
||||
Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_line_ended_eof", 2) ;
|
||||
EXPECT_EQ(exec.variables.size(), 0) ;
|
||||
exec.add_variable(&var0) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ;
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "EOF") ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarRandom_Gaussian) {
|
||||
std::string str;
|
||||
double value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user