00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021
00022 #include <ucommon/ucommon.h>
00023
00024 #include <stdio.h>
00025
00026 using namespace UCOMMON_NAMESPACE;
00027
00028 extern "C" int main()
00029 {
00030 int test_argc;
00031 char *test_argv[6];
00032
00033 shell::bind("test");
00034
00035 test_argc = 5;
00036 test_argv[0] = (char *)"test";
00037
00038 test_argv[1] = (char *)"--lines=5";
00039 test_argv[2] = (char *)"-r";
00040 test_argv[3] = (char *)"a";
00041 test_argv[4] = (char *)"b";
00042 test_argv[5] = NULL;
00043
00044 shell::flagopt rflag('r', "--reverse", "reverse order of arguments");
00045 shell::flagopt tflag('t', "--testing", "never hit this flag");
00046 shell::numericopt lines('l', "--lines", "number of lines in output");
00047 shell args(test_argc, test_argv);
00048
00049 assert(!tflag);
00050 assert(is(rflag));
00051 assert(*lines == 5);
00052 assert(args() == 2);
00053 assert(eq(args[0], "a"));
00054
00055 string_t prefix, subdir, basedir;
00056
00057 prefix = shell::path(shell::SYSTEM_PREFIX);
00058 subdir = shell::path(shell::SYSTEM_PREFIX, "test");
00059 basedir = shell::path(shell::SYSTEM_PREFIX, "/test");
00060
00061 prefix = prefix + "/test";
00062
00063 assert(eq(basedir, "/test"));
00064 assert(eq(subdir, prefix));
00065 }