Compile fixes
[ACE_TAO.git] / ACE / tests / Arg_Shifter_Test.cpp
blob407cbdf80b2c65bb4d552b768727ae47f0dd8736
1 // ============================================================================
2 //
3 // = LIBRARY
4 // tests
5 //
6 // = DESCRIPTION
7 // This program exercises the ACE_Arg_Shifter class.
8 //
9 // = AUTHOR
10 // Steve Huston <shuston@riverace.com>
12 // ============================================================================
14 #include "ace/Arg_Shifter.h"
15 #include "test_config.h"
18 int
19 run_main (int, ACE_TCHAR *[])
21 ACE_START_TEST (ACE_TEXT ("Arg_Shifter_Test"));
22 const int test_argc_size1 = 5;
23 int argl (test_argc_size1);
24 const ACE_TCHAR *args1[test_argc_size1] = {
25 ACE_TEXT ("-known"),
26 ACE_TEXT ("-huh"),
27 ACE_TEXT ("-arg"),
28 ACE_TEXT ("-what"),
29 ACE_TEXT ("arg")
32 ACE_Arg_Shifter shifter1 (argl, args1);
34 if (!shifter1.is_anything_left ())
35 ACE_ERROR ((LM_ERROR, "is_anything_left() returned 0 at start.\n"));
37 const int test_argc_size2 = 4;
38 int arg2 = test_argc_size2;
39 const ACE_TCHAR *args2[test_argc_size2] = {
40 ACE_TEXT ("-ORBDebugLevel"),
41 ACE_TEXT ("-0"),
42 ACE_TEXT ("-o"),
43 ACE_TEXT ("server.ior")
45 bool found_ORBDebug = false;
47 ACE_Arg_Shifter arg_shifter2 (arg2, args2);
48 while (arg_shifter2.is_anything_left ())
50 if (0 == arg_shifter2.cur_arg_strncasecmp (ACE_TEXT ("-ORBDebug")))
52 found_ORBDebug = true;
53 arg_shifter2.consume_arg ();
55 else if (0 == arg_shifter2.cur_arg_strncasecmp (ACE_TEXT ("-ORBDaemon")))
57 arg_shifter2.consume_arg ();
59 else
61 arg_shifter2.ignore_arg ();
65 if (found_ORBDebug)
67 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("argshifter 2 test failed\n")), -1);
70 #ifdef ACE_USES_WCHAR
71 const char *args3[] = {
72 "-ORBDebugLevel 0",
73 "-o",
74 "server.ior",
76 int argc3 = sizeof args3 / sizeof args3[0];
77 ACE_Arg_Shifter_T<char> arg_shifter_char (argc3, args3);
78 if (15 != arg_shifter_char.cur_arg_strncasecmp ("-ORBDebugLevel"))
80 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("argshifter<char> failed\n")), -1);
82 #endif
84 ACE_END_TEST;
85 return 0;