Skip to content

Commit b038602

Browse files
author
root
committed
fix ut
1 parent d07a116 commit b038602

File tree

11 files changed

+35
-15
lines changed

11 files changed

+35
-15
lines changed

source/module_base/test/global_function_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ TEST_F(GlobalFunctionTest,BlockHere)
696696
std::string block_in="111";
697697
GlobalV::MY_RANK=1;
698698
testing::internal::CaptureStdout();
699-
EXPECT_EXIT(ModuleBase::GlobalFunc::BLOCK_HERE(block_in), ::testing::ExitedWithCode(1),"");
699+
EXPECT_EXIT(ModuleBase::GlobalFunc::BLOCK_HERE(block_in), ::testing::ExitedWithCode(0),"");
700700
output2 = testing::internal::GetCapturedStdout();
701701
EXPECT_THAT(output2,testing::HasSubstr("\n********************************************"
702702
"\n Here is a Block, 1: go on 0: quit"
@@ -731,7 +731,7 @@ TEST_F(GlobalFunctionTest,BlockHere3)
731731
std::string fake_input = "0";
732732
std::istringstream iss{fake_input};
733733
std::cin.rdbuf(iss.rdbuf());
734-
EXPECT_EXIT(ModuleBase::GlobalFunc::BLOCK_HERE(block_in), ::testing::ExitedWithCode(1),"");
734+
EXPECT_EXIT(ModuleBase::GlobalFunc::BLOCK_HERE(block_in), ::testing::ExitedWithCode(0),"");
735735
output2 = testing::internal::GetCapturedStdout();
736736
EXPECT_THAT(output2,testing::HasSubstr("\n********************************************"
737737
"\n Here is a Block, 1: go on 0: quit"

source/module_base/test/intarray_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ TEST_F(IntArrayTest,Alloc)
318318
{
319319
std::string output;
320320
testing::internal::CaptureStdout();
321-
EXPECT_EXIT(ModuleBase::IntArrayAlloc(), ::testing::ExitedWithCode(1),"");
321+
EXPECT_EXIT(ModuleBase::IntArrayAlloc(), ::testing::ExitedWithCode(0),"");
322322
output = testing::internal::GetCapturedStdout();
323323
EXPECT_THAT(output,testing::HasSubstr("Allocation error for IntArray"));
324324
}

source/module_base/test/math_polyint_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TEST_F(bessell0,PolynomialInterpolationThreeDimension)
9292
EXPECT_NEAR(y4,sinc(3.005),doublethreshold);
9393
EXPECT_NEAR(y5,sinc(3.505),doublethreshold);
9494
testing::internal::CaptureStdout();
95-
EXPECT_EXIT( double y6 = ModuleBase::PolyInt::Polynomial_Interpolation(table3,0,0,TableLength,interval,3.9997); ,::testing::ExitedWithCode(1), "");
95+
EXPECT_EXIT( double y6 = ModuleBase::PolyInt::Polynomial_Interpolation(table3,0,0,TableLength,interval,3.9997); ,::testing::ExitedWithCode(0), "");
9696
std::string output = testing::internal::GetCapturedStdout();
9797
EXPECT_THAT(output,testing::HasSubstr("Not enough space allocated for radial FFT"));
9898
}

source/module_base/test/realarray_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ TEST_F(realArrayTest,Alloc)
197197
{
198198
std::string output;
199199
testing::internal::CaptureStdout();
200-
EXPECT_EXIT(ModuleBase::realArrayAlloc(), ::testing::ExitedWithCode(1),"");
200+
EXPECT_EXIT(ModuleBase::realArrayAlloc(), ::testing::ExitedWithCode(0),"");
201201
output = testing::internal::GetCapturedStdout();
202202
EXPECT_THAT(output,testing::HasSubstr("Allocation error for realArray"));
203203
}

source/module_base/test/tool_quit_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ TEST_F(ToolQuitTest,warning)
5959
TEST_F(ToolQuitTest,quit)
6060
{
6161
testing::internal::CaptureStdout();
62-
EXPECT_EXIT(ModuleBase::QUIT(), ::testing::ExitedWithCode(1), "");
62+
EXPECT_EXIT(ModuleBase::QUIT(), ::testing::ExitedWithCode(0), "");
6363
output = testing::internal::GetCapturedStdout();
6464
// test output on screen
6565
EXPECT_THAT(output,testing::HasSubstr("TIME STATISTICS"));

source/module_hamilt_general/module_vdw/test/vdw_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ TEST_F(vdwd2Test, D2Default)
191191
TEST_F(vdwd2Test, WrongVdwType)
192192
{
193193
input.vdw_method = "d2d3";
194-
EXPECT_EQ(vdw::make_vdw(ucell, input),nullptr);
194+
testing::internal::CaptureStdout();
195+
EXPECT_EXIT( vdw::make_vdw(ucell, input); ,::testing::ExitedWithCode(1), "");
196+
std::string output = testing::internal::GetCapturedStdout();
195197
}
196198

197199
TEST_F(vdwd2Test, OneAtomWarning)

source/module_hamilt_lcao/module_hcontainer/output_hcontainer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,21 @@ void Output_HContainer<T>::write(int rx_in, int ry_in, int rz_in)
4040
int find_R = 0;
4141
for (int iR = 0; iR < size_for_loop_R; iR++)
4242
{
43+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
44+
4345
this->_hcontainer->loop_R(iR, rx, ry, rz);
4446
if (rx == rx_in && ry == ry_in && rz == rz_in)
4547
{
48+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
49+
4650
find_R += 1;
4751
this->write_single_R(rx, ry, rz);
52+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
53+
4854
break;
4955
}
56+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
57+
5058
}
5159
if (find_R == 0)
5260
{
@@ -57,10 +65,18 @@ void Output_HContainer<T>::write(int rx_in, int ry_in, int rz_in)
5765
template <typename T>
5866
void Output_HContainer<T>::write_single_R(int rx, int ry, int rz)
5967
{
68+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
69+
6070
this->_hcontainer->fix_R(rx, ry, rz);
71+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
72+
6173
ModuleIO::SparseMatrix<T> sparse_matrix
6274
= ModuleIO::SparseMatrix<T>(_hcontainer->get_nbasis(), _hcontainer->get_nbasis());
75+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
76+
6377
sparse_matrix.setSparseThreshold(this->_sparse_threshold);
78+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
79+
6480
for (int iap = 0; iap < this->_hcontainer->size_atom_pairs(); ++iap)
6581
{
6682
auto atom_pair = this->_hcontainer->get_atom_pair(iap);
@@ -77,6 +93,8 @@ void Output_HContainer<T>::write_single_R(int rx, int ry, int rz)
7793
}
7894
}
7995
}
96+
std::cout << __FILE__ << " " << __LINE__ << std::endl;
97+
8098
if (sparse_matrix.getNNZ() != 0)
8199
{
82100
_ofs << rx << " " << ry << " " << rz << " " << sparse_matrix.getNNZ() << std::endl;

source/module_io/test/binstream_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TEST_F(BinstreamTest, variable)
3838
wfc >> a1;
3939
wfc >> a2;
4040
testing::internal::CaptureStdout();
41-
EXPECT_EXIT(wfc >> a3, ::testing::ExitedWithCode(1), "");
41+
EXPECT_EXIT(wfc >> a3, ::testing::ExitedWithCode(0), "");
4242
std::string output = testing::internal::GetCapturedStdout();
4343
EXPECT_THAT(output,testing::HasSubstr("Binstream"));
4444
EXPECT_EQ(bool(wfc), true);
@@ -50,7 +50,7 @@ TEST_F(BinstreamTest, variable)
5050

5151
wfc.open("wfc","w");
5252
testing::internal::CaptureStdout();
53-
EXPECT_EXIT(wfc >> a3, ::testing::ExitedWithCode(1), "");
53+
EXPECT_EXIT(wfc >> a3, ::testing::ExitedWithCode(0), "");
5454
output = testing::internal::GetCapturedStdout();
5555
EXPECT_THAT(output,testing::HasSubstr("Binstream"));
5656
remove("wfc");
@@ -73,7 +73,7 @@ TEST_F(BinstreamTest, array)
7373

7474
Binstream rwfc("wfc","r");
7575
testing::internal::CaptureStdout();
76-
EXPECT_EXIT(rwfc.read(b,11);, ::testing::ExitedWithCode(1), "");
76+
EXPECT_EXIT(rwfc.read(b,11);, ::testing::ExitedWithCode(0), "");
7777
std::string output = testing::internal::GetCapturedStdout();
7878
EXPECT_THAT(output,testing::HasSubstr("Binstream"));
7979
rwfc.close();

source/module_io/test/parse_args_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST(ParseArgsTest, OutVersionTest)
2929
char* argv1[] = {arg0, arg1};
3030
argc = 2;
3131
testing::internal::CaptureStdout();
32-
EXPECT_EXIT(ModuleIO::parse_args(argc, argv1), ::testing::ExitedWithCode(1), "");
32+
EXPECT_EXIT(ModuleIO::parse_args(argc, argv1), ::testing::ExitedWithCode(0), "");
3333
output = testing::internal::GetCapturedStdout();
3434
EXPECT_EQ(output_ref, output);
3535

@@ -38,7 +38,7 @@ TEST(ParseArgsTest, OutVersionTest)
3838
char* argv2[] = {arg0, arg2};
3939
argc = 2;
4040
testing::internal::CaptureStdout();
41-
EXPECT_EXIT(ModuleIO::parse_args(argc, argv2), ::testing::ExitedWithCode(1), "");
41+
EXPECT_EXIT(ModuleIO::parse_args(argc, argv2), ::testing::ExitedWithCode(0), "");
4242
output = testing::internal::GetCapturedStdout();
4343
EXPECT_EQ(output_ref, output);
4444

@@ -47,7 +47,7 @@ TEST(ParseArgsTest, OutVersionTest)
4747
char* argv3[] = {arg0, arg3};
4848
argc = 2;
4949
testing::internal::CaptureStdout();
50-
EXPECT_EXIT(ModuleIO::parse_args(argc, argv3), ::testing::ExitedWithCode(1), "");
50+
EXPECT_EXIT(ModuleIO::parse_args(argc, argv3), ::testing::ExitedWithCode(0), "");
5151
output = testing::internal::GetCapturedStdout();
5252
EXPECT_EQ(output_ref, output);
5353
}

source/module_io/test/read_input_ptest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ TEST_F(InputParaTest, Check)
444444
ModuleIO::ReadInput readinput(GlobalV::MY_RANK);
445445
Parameter param;
446446
testing::internal::CaptureStdout();
447-
EXPECT_EXIT(readinput.read_parameters(param, "./empty_INPUT"), ::testing::ExitedWithCode(1), "");
447+
EXPECT_EXIT(readinput.read_parameters(param, "./empty_INPUT"), ::testing::ExitedWithCode(0), "");
448448
std::string output = testing::internal::GetCapturedStdout();
449449
EXPECT_THAT(output, testing::HasSubstr("INPUT parameters have been successfully checked!"));
450450
if (GlobalV::MY_RANK == 0)

0 commit comments

Comments
 (0)