I always thought that assert is just an error function, in fact, it is actually a macro, and the role is not "error."After a certain understanding of its role and use of a certain understanding of the use of assert () is like a "contractual
Assert is used to determine the correctness of the program running and ensure that the program running behavior is consistent with what we understand. The call form is assert (logic expression). If the logic expression is false, abort () is called
I. OverviewThere are assert keys in both C and C + + languages, which represent assertions.In Java, there is also an ASSERT keyword, which means that the assertion, usage, and meaning are similar.Second, the grammarIn Java, the Assert keyword was
Assert () function usage Summary (recommended), assert Function
The assert macro prototype is defined inIf its condition returns an error, terminate the program execution. The prototype is defined as follows:
#include void assert( int expression
I always thought that assert is just an error function, in fact, it is actually a macro, and the role is not "error." After a certain understanding of its role and use of a certain understanding of the use of assert () is like a "contractual
Assert class in unit test and Assert class in unit test
I. Use of Assert class
1. The namespace of the Assert class is Microsoft. VisualStudio. TestTools. UnitTesting. You only need to reference Microsoft. VisualStudio. QualityTools.
The stereotype of an Assert macro is defined in , which terminates the execution of the program if its condition returns an error, and the prototype defines:#include void assert (int expression);
The function of assert is to calculate the
I. assert is a macro
Specifically: in C, ASSERT is a macro rather than a function.Assert () is a macro that is often used when debugging programs. When the program is running, it calculates the expressions in parentheses.
If the expression is FALSE (
Use of assert in C language and assert in C LanguageAssertFunctionThe key points in the program can be asserted through the assert macro. If the assertions are not true, the program stops, and a standard error is returned, a specific error message
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.