Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dconfig/test_expand.cxx

Go to the documentation of this file.
00001 // Filename: test_expand.cxx
00002 // Created by:  cary (31Aug98)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 }

Generated on Thu May 1 22:12:58 2003 for DTool by doxygen1.3