FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_hamilt/test/dnrm2_test.cpp at develop · pplab/abacus-develop · GitHub
pplab
/
abacus-develop
Public
forked from
deepmodeling/abacus-develop
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
abacus-develop
/
source
/
source_hamilt
/
test
/
dnrm2_test.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (37 loc) · 1.22 KB
Breadcrumbs
abacus-develop
/
source
/
source_hamilt
/
test
/
dnrm2_test.cpp
Copy path
File metadata and controls
43 lines (37 loc) · 1.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
include
"
gtest/gtest.h
"
#
include
"
gmock/gmock.h
"
#
include
"
../module_ewald/dnrm2.h
"
/*
***********************************************
* unit test of dnrm2.cpp
**********************************************
*/
/*
*
* - Tested Functions:
* - dnrm2(const int n, const double *x, const int incx):
* - compute the Euclidean length (12 norm) of std::vector x,
* with scaling of input to avoid destructive underflow and overflow
*/
class
EwaldTest
: public ::testing::Test
{
};
TEST_F
(EwaldTest,Dnrm2Test)
{
std::string output;
double
x[
3
]={
1.5
,
2.5
,
3.5
} ;
int
incx1=
1
;
int
n1=-
1
;
int
n2=
0
;
int
n3=
3
;
//
case 1
testing :: internal ::
CaptureStderr
();
EXPECT_EQ
(
dnrm2
(n1,x,incx1),
0
);
output =
testing::internal::GetCapturedStderr
();
EXPECT_THAT
(output,
testing::HasSubstr
(
"
error in dnrm2, n < 0 or incx <= 0,
"
));
testing :: internal ::
CaptureStderr
();
EXPECT_EQ
(
dnrm2
(n3,x,
0
),
0
);
output =
testing::internal::GetCapturedStderr
();
EXPECT_THAT
(output,
testing::HasSubstr
(
"
error in dnrm2, n < 0 or incx <= 0,
"
));
//
case 2
EXPECT_EQ
(
dnrm2
(n2,x,incx1),
0
);
//
case 3
EXPECT_EQ
(
dnrm2
(n3,x,incx1),
sqrt
(
1.5
*
1.5
+
2.5
*
2.5
+
3.5
*
3.5
));
}
Back
|
FazBrowse Home
|
New Git URL