00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "config.h"
00021
00022 #if !defined(DEBUG)
00023 #define DEBUG
00024 #endif
00025
00026 #include <iostream>
00027
00028 #include "HeyParser.hh"
00029
00030 int main(int argc, const char *argv[])
00031 {
00032 int retval = EXIT_SUCCESS;
00033
00034 try
00035 {
00036 HeyParser hp(1, argv);
00037 cerr << "HeyParser accepts empty argument list?\n";
00038 retval = EXIT_FAILURE;
00039 }
00040 catch(HeyParserException &e)
00041 {
00042 #if defined(DEBUG)
00043 cerr << e << endl;
00044 #endif
00045 }
00046
00047 try
00048 {
00049 const char *hp_argv[] = {
00050 "hey", "", "list",
00051 };
00052
00053 HeyParser hp(3, hp_argv);
00054 cerr << "HeyParser accepts empty server name?\n";
00055 retval = EXIT_FAILURE;
00056 }
00057 catch(HeyParserException &e)
00058 {
00059 #if defined(DEBUG)
00060 cerr << e << endl;
00061 #endif
00062 }
00063
00064 try
00065 {
00066 const char *hp_argv[] = {
00067 "hey", "ior", "foo",
00068 };
00069
00070 HeyParser hp(3, hp_argv);
00071 cerr << "HeyParser accepts bogus verb?\n";
00072 retval = EXIT_FAILURE;
00073 }
00074 catch(HeyParserException &e)
00075 {
00076 #if defined(DEBUG)
00077 cerr << e << endl;
00078 #endif
00079 }
00080
00081 try
00082 {
00083 const char *hp_argv[] = {
00084 "hey", "ior", "set",
00085 };
00086
00087 HeyParser hp(3, hp_argv);
00088
00089 hp.to();
00090 cerr << "HeyParser.to works without 'to' argument?\n";
00091 retval = EXIT_FAILURE;
00092 }
00093 catch(HeyParserException &e)
00094 {
00095 #if defined(DEBUG)
00096 cerr << e << endl;
00097 #endif
00098 }
00099
00100 try
00101 {
00102 const char *hp_argv[] = {
00103 "hey", "ior", "set", "foo", "to",
00104 };
00105
00106 HeyParser hp(5, hp_argv);
00107
00108 hp.to();
00109 cerr << "HeyParser.to works without 'to' value?\n";
00110 retval = EXIT_FAILURE;
00111 }
00112 catch(HeyParserException &e)
00113 {
00114 #if defined(DEBUG)
00115 cerr << e << endl;
00116 #endif
00117 }
00118
00119 try
00120 {
00121 const char *hp_argv[] = {
00122 "hey", "ior", "create", "foo", "with",
00123 };
00124
00125 HeyParser hp(5, hp_argv);
00126
00127 hp.to();
00128 cerr << "HeyParser.with works with no arguments?\n";
00129 retval = EXIT_FAILURE;
00130 }
00131 catch(HeyParserException &e)
00132 {
00133 #if defined(DEBUG)
00134 cerr << e << endl;
00135 #endif
00136 }
00137
00138 try
00139 {
00140 const char *hp_argv[] = {
00141 "hey", "ior", "create", "foo", "with", "bar",
00142 };
00143
00144 HeyParser hp(6, hp_argv);
00145
00146 hp.to();
00147 cerr << "HeyParser.with works with odd number of arguments?\n";
00148 retval = EXIT_FAILURE;
00149 }
00150 catch(HeyParserException &e)
00151 {
00152 #if defined(DEBUG)
00153 cerr << e << endl;
00154 #endif
00155 }
00156
00157 return( retval );
00158 }