77#include " gtest/gtest.h"
88#include < cstdio>
99#include < fstream>
10+ #include < stdexcept>
1011
1112// mock
1213namespace GlobalV
@@ -120,6 +121,7 @@ TEST_F(InputTest, Selfconsistent_Read)
120121 Parameter param;
121122 // readinput.read_parameters(param, "./empty_INPUT");
122123 EXPECT_NO_THROW (readinput.read_parameters (param, " ./empty_INPUT" ));
124+ EXPECT_EQ (param.inp .device , " cpu" );
123125 readinput.write_parameters (param, " ./my_INPUT1" );
124126 readinput.clear ();
125127 // readinput.read_parameters(param, "./my_INPUT1");
@@ -152,6 +154,20 @@ TEST_F(InputTest, Selfconsistent_Read)
152154 }
153155}
154156
157+ TEST_F (InputTest, RejectAutoDevice)
158+ {
159+ std::ofstream input (" auto_device_INPUT" );
160+ input << " INPUT_PARAMETERS\n "
161+ << " device auto\n " ;
162+ input.close ();
163+
164+ ModuleIO::ReadInput readinput (0 );
165+ readinput.check_ntype_flag = false ;
166+ Parameter param;
167+ EXPECT_THROW (readinput.read_parameters (param, " ./auto_device_INPUT" ), std::runtime_error);
168+ EXPECT_TRUE (std::remove (" ./auto_device_INPUT" ) == 0 );
169+ }
170+
155171TEST_F (InputTest, Check)
156172{
157173 ModuleIO::ReadInput readinput (0 );
@@ -175,4 +191,4 @@ TEST_F(InputTest, Check)
175191 std::string output = testing::internal::GetCapturedStdout ();
176192 EXPECT_THAT (output, testing::HasSubstr (" INPUT parameters have been successfully checked!" ));
177193 EXPECT_TRUE (std::remove (" ./INPUT.ref" ) == 0 );
178- }
194+ }
0 commit comments