1,expect_* series and Assert_* series.
These two series of functions are used for assertions, that is, to determine whether the requirements are met, the full will output log.
For example, Expect_eq (3,Add (1, 3)) is here to determine if 3 and Add (1, 3) are equal and then output in the result
G:\myproject\c++\gtestdemo\gtestdemo\gtestdemo.cpp (16):
Error:value Of:add (1, 3) Actual:4 Expected:3
This will return the error, because the front is 3 so to equal words to be equal to 3, so the expectation is 3, but 1+3 actual
Returned 4, so error.
Other types are expect_true and expect_false and so on.
Next I say the difference between the two,Expect_ used to play the message, if the error will be executed down, it is said to
View.
The Assert_ is used for checking and exiting the current function (not exiting the current program) once the check fails.
Note: Only the failure of the error will be typed information, success is not hit.
Hardening: If you encounter special circumstances, such as the error in the loop, it is not known that i =? Out of the time, so
Added new elements, <<.
Example, Expect_true (FALSE) << "Mimida?" <<i;
The output is
G:\myproject\c++\gtestdemo\gtestdemo\gtestdemo.cpp (16):
Error:value Of:false Actual:false,expected:true
Mimida? 8 (I=8)//This line is the input and output stream.
2,ifstream
Enter the stream and read the contents of the file into the stream.
For example
std::ifstreaminput("./case/encoding/utf8");
This is where I read the UTF8 into input.
3,getline
Read the variable from the stream element. If it's getline,
Basic functions and syntax of C + + input and output stream