00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "expand.h"
00020 #include <string>
00021
00022 void TestExpandFunction()
00023 {
00024 std::string line;
00025
00026 line = "foo";
00027 cout << "input: '" << line << "'" << endl;
00028 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00029 line = "'foo'";
00030 cout << "input: '" << line << "'" << endl;
00031 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00032 line = "'$USER'";
00033 cout << "input: '" << line << "'" << endl;
00034 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00035 line = "$USER";
00036 cout << "input: '" << line << "'" << endl;
00037 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00038 line = "\"$USER\"";
00039 cout << "input: '" << line << "'" << endl;
00040 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00041 line = "`ls -l`";
00042 cout << "input: '" << line << "'" << endl;
00043 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00044 line = "~";
00045 cout << "input: '" << line << "'" << endl;
00046 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00047 line = "~cary";
00048 cout << "input: '" << line << "'" << endl;
00049 cout << "output: '" << Expand::Expand(line) << "'" << endl;
00050 }
00051
00052 void TestExpandClass()
00053 {
00054 std::string line;
00055
00056 line = "foo";
00057 Expand::Expander ex(line);
00058 cout << "input: '" << line << "'" << endl;
00059 cout << "output: '" << ex() << "'" << endl;
00060 line = "'foo'";
00061 cout << "input: '" << line << "'" << endl;
00062 cout << "output: '" << ex(line) << "'" << endl;
00063 line = "'$USER'";
00064 cout << "input: '" << line << "'" << endl;
00065 cout << "output: '" << ex(line) << "'" << endl;
00066 line = "$USER";
00067 cout << "input: '" << line << "'" << endl;
00068 cout << "output: '" << ex(line) << "'" << endl;
00069 line = "\"$USER\"";
00070 cout << "input: '" << line << "'" << endl;
00071 cout << "output: '" << ex(line) << "'" << endl;
00072 line = "`ls -l`";
00073 cout << "input: '" << line << "'" << endl;
00074 cout << "output: '" << ex(line) << "'" << endl;
00075 line = "~";
00076 cout << "input: '" << line << "'" << endl;
00077 cout << "output: '" << ex(line) << "'" << endl;
00078 line = "~cary";
00079 cout << "input: '" << line << "'" << endl;
00080 cout << "output: '" << ex(line) << "'" << endl;
00081 }
00082
00083 main()
00084 {
00085 cout << endl << "Testing shell expansion (function version):" << endl;
00086 TestExpandFunction();
00087 cout << endl << "Testing shell expansion (class version):" << endl;
00088 TestExpandClass();
00089 }