FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/tests/integrate/check_file.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
/
tests
/
integrate
/
check_file.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (81 loc) · 2.13 KB
Breadcrumbs
abacus-develop
/
tests
/
integrate
/
check_file.cpp
Copy path
File metadata and controls
97 lines (81 loc) · 2.13 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
include
<
string
>
#
include
<
iostream
>
#
include
<
sstream
>
#
include
<
fstream
>
#
include
<
iomanip
>
#
include
<
cmath
>
using
namespace
std
;
int
main
(
int
argc,
char
**argv)
{
string ref_file = argv[
1
];
string cal_file = argv[
2
];
string temp = argv[
3
];
istringstream
string_temp
(temp);
double
threshold;
string_temp >> threshold;
ifstream
ref
(ref_file.
c_str
(), ios::in);
ifstream
cal
(cal_file.
c_str
(), ios::in);
if
(!ref)
{
cout <<
"
\e[1;31m [ FAILED ] \e[0m
"
;
cout <<
"
Can't find
"
<< ref_file <<
"
!
"
<< endl;
return
0
;
}
if
(!cal)
{
cout <<
"
\e[1;31m [ FAILED ] \e[0m
"
;
cout <<
"
Can't find
"
<< cal_file <<
"
!
"
<< endl;
return
0
;
}
int
num_ref=
0
, num_cal=
0
;
string word_ref, word_cal;
while
(ref.
good
())
{
ref >> word_ref;
num_ref++;
}
while
(cal.
good
())
{
cal >> word_cal;
num_cal++;
}
if
(num_ref != num_cal)
{
cout <<
"
\e[1;31m [ FAILED ] \e[0m
"
;
cout <<
"
The num of data is different !
"
<< endl;
return
0
;
}
ref.
clear
();
ref.
seekg
(
0
);
ref.
rdstate
();
cal.
clear
();
cal.
seekg
(
0
);
cal.
rdstate
();
double
data_ref, data_cal;
for
(
int
index=
0
; index<num_ref; ++index)
{
ref >> word_ref;
cal >> word_cal;
if
(word_cal != word_ref)
{
istringstream
string_cal
(word_cal);
istringstream
string_ref
(word_ref);
string_cal >> data_cal;
string_ref >> data_ref;
if
(data_ref==
0
|| data_cal==
0
)
{
cout <<
"
\e[1;31m [ FAILED ] \e[0m
"
;
cout <<
"
Data No.
"
<< index+
1
<<
"
cal=
"
<< word_cal
<<
"
ref=
"
<< word_ref << endl;
}
else
if
(
fabs
(data_ref-data_cal) > threshold)
{
cout <<
"
\e[1;31m [ FAILED ] \e[0m
"
;
cout <<
"
Data No.
"
<< index+
1
<<
"
cal=
"
<< data_cal
<<
"
ref=
"
<< data_ref <<
"
deviation=
"
<<
fabs
(data_ref-data_cal) << endl;
return
0
;
}
}
}
return
1
;
}
Back
|
FazBrowse Home
|
New Git URL