Skip to content

Commit 2d92ad7

Browse files
authored
Test:UT of IntArrayAlloc (#1812)
1 parent a831e95 commit 2d92ad7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

source/module_base/test/intarray_test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../intarray.h"
22
#include "gtest/gtest.h"
3+
#include "gmock/gmock.h"
34

45
/************************************************
56
* unit test of class IntArray
@@ -30,8 +31,15 @@
3031
* - ConstParentheses
3132
* - access element by using "()" through pointer
3233
* - without changing its elements
34+
* -IntArrayAlloc
35+
* - Warning of integer array allocation error
3336
*/
3437

38+
namespace ModuleBase
39+
{
40+
void IntArrayAlloc();
41+
}
42+
3543
class IntArrayTest : public testing::Test
3644
{
3745
protected:
@@ -306,3 +314,11 @@ TEST_F(IntArrayTest,ConstParentheses)
306314
EXPECT_EQ((*x6)(5,4,8,2,1,0),10);
307315
}
308316

317+
TEST_F(IntArrayTest,Alloc)
318+
{
319+
std::string output;
320+
testing::internal::CaptureStdout();
321+
EXPECT_EXIT(ModuleBase::IntArrayAlloc(), ::testing::ExitedWithCode(0),"");
322+
output = testing::internal::GetCapturedStdout();
323+
EXPECT_THAT(output,testing::HasSubstr("Allocation error for IntArray"));
324+
}

0 commit comments

Comments
 (0)