Menu

[r2]: / trunk / test / test_cclap.cpp  Maximize  Restore  History

Download this file

54 lines (42 with data), 1.4 kB

 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
/** @file
* Test of the CCLAP routines.
*/
#include <iostream>
#include "cclap.h"
int main ( int argc, char *argv[] )
{
bool append = false;
bool verbose;
int time = 5;
std::string filename = "";
bool test_wrap;
cclap::set_version ( "0.1 beta" );
cclap::add_switch ( 'a', "append", "append rather than overwrite the file",
&append );
cclap::add_switch ( 'v', "verbose", "print verbose messages",
&verbose );
cclap::add_value ( 't', "time", "time to run the simulation", &time, false );
cclap::add_argument ( "filename", "name of the file", &filename, true );
cclap::add_switch ( 'w', "test-wrap", "test the word wrapping routine",
&test_wrap );
if ( cclap::arguments_valid ( argc, argv ) )
{
std::cout << "success" << std::endl;
std::cout << "- append = " << append << std::endl;
std::cout << "- verbose = " << verbose << std::endl;
std::cout << "- time = " << time << std::endl;
std::cout << "- filename = " << filename << std::endl;
}
if ( test_wrap )
{
std::cout << "\nTesting the line wrap routine:" << std::endl;
std::string test_string = "really long string that needs to be wrapped"
" a few times to be able to fit into the given"
" space"
" andhereisacompositewordthatwillnotfit into the"
" allocated line length";
std::cout << " "
<< cclap::wrap_string ( test_string, 30, 5 )
<< std::endl;
}
}