Difference between revisions of "CPP/Debugging/Assert"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) m (moved CPP/Assert to CPP/Debugging/Assert) |
FirstPerson (Talk | contribs) (→Assert.cpp) |
||
| Line 3: | Line 3: | ||
<source lang="cpp"> | <source lang="cpp"> | ||
#include <iostream> | #include <iostream> | ||
| − | #include < | + | #include <cassert> |
| + | #include <string> | ||
| − | + | using namespace std; | |
| − | { | + | |
| − | + | void didPass(const string& password){ | |
| − | + | assert(password == "drama"); | |
| − | + | } | |
| + | int main(){ | ||
| + | |||
| + | didPass("drama"); | ||
| + | cout << "Test 1 passed\n"; | ||
| + | |||
| + | assert("DRunk"); | ||
| + | |||
return 0; | return 0; | ||
} | } | ||
</source> | </source> | ||
Revision as of 00:00, 29 June 2010
Assert.cpp
#include <iostream> #include <cassert> #include <string> using namespace std; void didPass(const string& password){ assert(password == "drama"); } int main(){ didPass("drama"); cout << "Test 1 passed\n"; assert("DRunk"); return 0; }