Skip to content

Commit 376ced9

Browse files
rootroot
authored andcommitted
modify global_function & its UT
1 parent 7ddd3d1 commit 376ced9

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

source/module_base/global_function.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace GlobalFunc
2323

2424
void NOTE(const std::string &words)
2525
{
26+
return;
2627
if (GlobalV::ofs_running)
2728
{
2829
// GlobalV::ofs_running << " *********************************************************************************"
@@ -33,7 +34,6 @@ void NOTE(const std::string &words)
3334
GlobalV::ofs_running << " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
3435
<< std::endl;
3536
}
36-
return;
3737
}
3838

3939
void NEW_PART(const std::string &words)
@@ -115,8 +115,7 @@ void DONE(std::ofstream &ofs, const std::string &description, const bool only_ra
115115
void TEST_LEVEL(const std::string &name)
116116
{
117117
bool disable = true;
118-
if (disable)
119-
return;
118+
if (disable) return;
120119

121120
if (name == "none")
122121
{
@@ -253,8 +252,7 @@ size_t MemAvailable()
253252
mem_sum += std::stol(size);
254253
++i;
255254
}
256-
if (i == 3)
257-
return mem_sum;
255+
if (i == 3) return mem_sum;
258256
}
259257
throw std::runtime_error("read /proc/meminfo error in " + TO_STRING(__FILE__) + " line " + TO_STRING(__LINE__));
260258
}

source/module_base/test/global_function_test.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
/**
1515
* - Tested Function
16-
* - Note
17-
* - print out warning info in running.log file
1816
* - NewPart
1917
* - note the start of new calculation part
2018
* - OutV1
@@ -45,6 +43,8 @@
4543
* - copy vector
4644
* - VectorToPointer
4745
* - get the first pointer of (const) vector or valarray
46+
* - Note
47+
* - print out warning info in running.log file
4848
*/
4949

5050
inline void EXPECT_COMPLEX_EQ(const std::complex<double>& a, const std::complex<double>& b)
@@ -76,18 +76,6 @@ class GlobalFunctionTest : public testing::Test
7676
}
7777
};
7878

79-
TEST_F(GlobalFunctionTest, Note)
80-
{
81-
ModuleBase::GlobalFunc::NOTE("Wrong Settings!");
82-
GlobalV::ofs_running.close();
83-
ifs.open("running.log");
84-
getline(ifs, output);
85-
getline(ifs, output);
86-
// output in runnint.log file
87-
EXPECT_THAT(output, testing::HasSubstr("Wrong Settings!"));
88-
ifs.close();
89-
}
90-
9179
TEST_F(GlobalFunctionTest, NewPart)
9280
{
9381
ModuleBase::GlobalFunc::NEW_PART("New Part Starts ...");
@@ -296,3 +284,17 @@ TEST_F(GlobalFunctionTest, VectorToPointer)
296284
const std::valarray<double> dd(1.0, size);
297285
EXPECT_EQ(ModuleBase::GlobalFunc::VECTOR_TO_PTR(dd), &dd[0]);
298286
}
287+
288+
/*
289+
TEST_F(GlobalFunctionTest, Note)
290+
{
291+
ModuleBase::GlobalFunc::NOTE("Wrong Settings!");
292+
GlobalV::ofs_running.close();
293+
ifs.open("running.log");
294+
getline(ifs, output);
295+
getline(ifs, output);
296+
// output in runnint.log file
297+
EXPECT_THAT(output, testing::HasSubstr("Wrong Settings!"));
298+
ifs.close();
299+
}
300+
*/

0 commit comments

Comments
 (0)