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
00035
00036
00037 try
00038 {
00039 HeyParser hp(1, argv);
00040 cerr << "HeyParser accepts empty argument list?\n";
00041 retval = EXIT_FAILURE;
00042 }
00043 catch(HeyParserException &e)
00044 {
00045 #if defined(DEBUG)
00046 cerr << e << endl;
00047 #endif
00048 }
00049
00050
00051
00052
00053 try
00054 {
00055 const char *hp_argv[] = {
00056 "hey", "", "list",
00057 };
00058
00059 HeyParser hp(3, hp_argv);
00060 cerr << "HeyParser accepts empty server name?\n";
00061 retval = EXIT_FAILURE;
00062 }
00063 catch(HeyParserException &e)
00064 {
00065 #if defined(DEBUG)
00066 cerr << e << endl;
00067 #endif
00068 }
00069
00070
00071
00072
00073 try
00074 {
00075 const char *hp_argv[] = {
00076 "hey", "ior", "foo",
00077 };
00078
00079 HeyParser hp(3, hp_argv);
00080 cerr << "HeyParser accepts bogus verb?\n";
00081 retval = EXIT_FAILURE;
00082 }
00083 catch(HeyParserException &e)
00084 {
00085 #if defined(DEBUG)
00086 cerr << e << endl;
00087 #endif
00088 }
00089
00090 try
00091 {
00092 const char *hp_argv[] = {
00093 "hey", "ior", "set",
00094 };
00095
00096 HeyParser hp(3, hp_argv);
00097
00098 hp.to();
00099 cerr << "HeyParser.to works without 'to' argument?\n";
00100 retval = EXIT_FAILURE;
00101 }
00102 catch(HeyParserException &e)
00103 {
00104 #if defined(DEBUG)
00105 cerr << e << endl;
00106 #endif
00107 }
00108
00109 try
00110 {
00111 const char *hp_argv[] = {
00112 "hey", "ior", "set", "foo", "to",
00113 };
00114
00115 HeyParser hp(5, hp_argv);
00116
00117 hp.to();
00118 cerr << "HeyParser.to works without 'to' value?\n";
00119 retval = EXIT_FAILURE;
00120 }
00121 catch(HeyParserException &e)
00122 {
00123 #if defined(DEBUG)
00124 cerr << e << endl;
00125 #endif
00126 }
00127
00128 try
00129 {
00130 const char *hp_argv[] = {
00131 "hey", "ior", "create", "foo", "with",
00132 };
00133
00134 HeyParser hp(5, hp_argv);
00135
00136 hp.to();
00137 cerr << "HeyParser.with works with no arguments?\n";
00138 retval = EXIT_FAILURE;
00139 }
00140 catch(HeyParserException &e)
00141 {
00142 #if defined(DEBUG)
00143 cerr << e << endl;
00144 #endif
00145 }
00146
00147 try
00148 {
00149 const char *hp_argv[] = {
00150 "hey", "ior", "create", "foo", "with", "bar",
00151 };
00152
00153 HeyParser hp(6, hp_argv);
00154
00155 hp.to();
00156 cerr << "HeyParser.with works with odd number of arguments?\n";
00157 retval = EXIT_FAILURE;
00158 }
00159 catch(HeyParserException &e)
00160 {
00161 #if defined(DEBUG)
00162 cerr << e << endl;
00163 #endif
00164 }
00165
00166 return( retval );
00167 }