File: cpp_main_example.cpp

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (12 lines) | stat: -rw-r--r-- 440 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
//  boost cpp_main_example program  ------------------------------------------//

#include <boost/test/cpp_main.cpp> // included rather than linked implementation

int add( int i, int j ) { return i+j; }

int cpp_main( int, char *[] )  // note the name!
{
  // two ways to detect and report the same error:
  if ( add(2,2) != 4 ) throw "Oops..."; // #1 throws on error
  return add(2,2) == 4 ? 0 : 1;         // #2 returns error directly
}