PhotonMain, done for 0.0.1

This commit is contained in:
James Turk 2005-08-08 04:55:48 +00:00
parent 0b64a143b4
commit 8bd0e0ec0a
5 changed files with 145 additions and 162 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: ConfigFile_test.cpp,v 1.2 2005/07/19 18:41:36 cozman Exp $ // $Id: ConfigFile_test.cpp,v 1.3 2005/08/08 04:55:48 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
@ -17,38 +17,32 @@ using namespace photon;
// Simple test of ConfigFile functionality // Simple test of ConfigFile functionality
// Tests reading/writing to a ConfigFile // Tests reading/writing to a ConfigFile
// Successful test will simply output a message indicating success. // Successful test will simply output a message indicating success.
class ConfigTest : public Application int PhotonMain(const StrVec& args)
{ {
public: util::ConfigFile c1("config1.ini"),c2;
c2.open("config2.ini");
int main(const StrVec& args)
{
util::ConfigFile c1("config1.ini"),c2;
c2.open("config2.ini");
// set three variables
c1.setVariable("sec","int",3);
c1.setVariable("sec","float",3.0f);
c1.setVariable("sec","string","three");
// ensure all 3 variables were written correctly
assert(c1.getVariable("sec","int",0) == 3);
assert(c1.getVariable("sec","float",0.0f) == 3.0f);
assert(c1.getVariable("sec","string",std::string()) == "three");
// check reading/default value functionality
assert(c2.getVariable("sec","var",-1) != -1);
assert(c2.getVariable("sec2","var",-1) != -1);
assert(c2.getVariable("sec2","hex",0) == 0);
c1.close(); // set three variables
c2.close(); c1.setVariable("sec","int",3);
c1.setVariable("sec","float",3.0f);
// got here, meaning success c1.setVariable("sec","string","three");
std::cerr << "ConfigFile test completed successfully!\n";
// ensure all 3 variables were written correctly
return 0; assert(c1.getVariable("sec","int",0) == 3);
} assert(c1.getVariable("sec","float",0.0f) == 3.0f);
}; assert(c1.getVariable("sec","string",std::string()) == "three");
// check reading/default value functionality
assert(c2.getVariable("sec","var",-1) != -1);
assert(c2.getVariable("sec2","var",-1) != -1);
assert(c2.getVariable("sec2","hex",0) == 0);
c1.close();
c2.close();
// got here, meaning success
std::cerr << "ConfigFile test completed successfully!\n";
return 0;
}
ENTRYPOINT(ConfigTest) // make ConfigTest the entrypoint class

View File

@ -5,48 +5,41 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Log_test.cpp,v 1.2 2005/07/19 20:37:04 cozman Exp $ // $Id: Log_test.cpp,v 1.3 2005/08/08 04:55:48 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
// extremely simple log test application // extremely simple log test application
class LogTest : public Application int PhotonMain(const StrVec& args)
{ {
public: // create the log and add three sinks
int main(const StrVec& args) Log log;
{ LogSinkPtr a( new ConsoleSink("console") ); // standard error output
// create the log and add three sinks LogSinkPtr b( new TextSink("textlog") ); // plaintext log
Log log; LogSinkPtr c( new HTMLSink("htmllog") ); // html formatted log
LogSinkPtr a( new ConsoleSink("console") ); // standard error output
LogSinkPtr b( new TextSink("textlog") ); // plaintext log // logged before sinks are added, so not shown
LogSinkPtr c( new HTMLSink("htmllog") ); // html formatted log log.note() << "this isn't seen";
// logged before sinks are added, so not shown // add the three sinks
log.note() << "this isn't seen"; log.addSink(a);
log.addSink(b);
// add the three sinks log.addSink(c);
log.addSink(a);
log.addSink(b); // demo of the 5 log levels
log.addSink(c); log.note() << "notice?";
log.verbose() << "(insert verbosity here)";
// demo of the 5 log levels log.warning() << "consider yourself warned.";
log.note() << "notice?"; log.error() << "erroneous!";
log.verbose() << "(insert verbosity here)"; log.critical() << "Al the critic?";
log.warning() << "consider yourself warned.";
log.error() << "erroneous!"; log.removeSink(b); // remove b and log a message to a and c
log.critical() << "Al the critic?"; log.note() << "only seen by a and c" ;
log.removeSink(b); // remove b and log a message to a and c // remove all sinks and log a message that is not shown
log.note() << "only seen by a and c" ; log.removeSinks();
log.note() << "not seen at all!";
// remove all sinks and log a message that is not shown
log.removeSinks(); return 0;
log.note() << "not seen at all!"; }
return 0;
}
};
ENTRYPOINT(LogTest)

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: RandGen_test.cpp,v 1.2 2005/07/19 21:02:04 cozman Exp $ // $Id: RandGen_test.cpp,v 1.3 2005/08/08 04:55:48 cozman Exp $
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -14,7 +14,7 @@ using namespace photon::util;
using namespace std; using namespace std;
// simple demo of RandGen // simple demo of RandGen
int main() int PhotonMain(const photon::StrVec& args)
{ {
RandGen g1; RandGen g1;
RandGen g2(0); // seed randgen 2 and 3 with same number so they are in sync RandGen g2(0); // seed randgen 2 and 3 with same number so they are in sync
@ -72,4 +72,6 @@ int main()
// the values will fall within a small deviation from the "expected" and // the values will fall within a small deviation from the "expected" and
// they are there for reference when ensuring that the bounds are set // they are there for reference when ensuring that the bounds are set
// properly on the generators. // properly on the generators.
return 0;
} }

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: filesys_test.cpp,v 1.3 2005/07/20 01:43:57 cozman Exp $ // $Id: filesys_test.cpp,v 1.4 2005/08/08 04:55:48 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
#include <iostream> #include <iostream>
@ -16,92 +16,85 @@ using namespace photon::util;
// Basic test of util::filesys functionality, simply outputs essentially // Basic test of util::filesys functionality, simply outputs essentially
// all information available via util::filesys. // all information available via util::filesys.
class FilesysTest : public Application int PhotonMain(const StrVec& args)
{ {
public: StrVec list;
int main(const StrVec& args) //System Directories
list = filesys::getCDDirs();
cout << "CD directories: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{ {
StrVec list; cout << *i << " ";
//System Directories
list = filesys::getCDDirs();
cout << "CD directories: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
cout << "Base Directory: " << filesys::getBaseDir() << endl;
cout << "User Directory: " << filesys::getUserDir() << endl;
//Search Path
cout << "adding base directory to search & write path" << endl;
filesys::addToSearchPath( filesys::getBaseDir(), false );
filesys::setWriteDir( filesys::getBaseDir() );
list = filesys::getSearchPath();
cout << "Search path: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
// Searching & Manipulation
list = filesys::listDir("/");
cout << "base dir contents: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
cout << "filesys_test.cpp"
<< (filesys::exists("filesys_test.cpp") ? " exists" : " not found")
<< endl;
cout << "wokka "
<< (filesys::exists("wokka") ? " exists" : " not found") << endl;
cout << "making directory 'bam'" << endl;
filesys::mkdir("bam");
cout << "bam " << (filesys::isDir("bam") ? " is dir" : " not dir")
<< endl;
cout << "filesys_test.cpp"
<< (filesys::isDir("filesys_test.cpp") ? " is dir" : " not dir")
<< endl;
filesys::remove("bam");
cout << "removing directory 'bam'" << endl;
//other
cout << "Dir separator: " << filesys::getDirSeparator() << endl;
cout << "Mod time of filesys_test.cpp" ": "
<< filesys::getModTime("filesys_test.cpp") << endl;
// search path redux
cout << "removing base directory from search/write path" << endl;
filesys::removeFromSearchPath( filesys::getBaseDir() );
filesys::setWriteDir( std::string() );
list = filesys::getSearchPath();
cout << "Search path: ";
for(vector<string>::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
return 0;
} }
}; cout << endl;
ENTRYPOINT(FilesysTest) cout << "Base Directory: " << filesys::getBaseDir() << endl;
cout << "User Directory: " << filesys::getUserDir() << endl;
//Search Path
cout << "adding base directory to search & write path" << endl;
filesys::addToSearchPath( filesys::getBaseDir(), false );
filesys::setWriteDir( filesys::getBaseDir() );
list = filesys::getSearchPath();
cout << "Search path: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
// Searching & Manipulation
list = filesys::listDir("/");
cout << "base dir contents: ";
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
cout << "filesys_test.cpp"
<< (filesys::exists("filesys_test.cpp") ? " exists" : " not found")
<< endl;
cout << "wokka "
<< (filesys::exists("wokka") ? " exists" : " not found") << endl;
cout << "making directory 'bam'" << endl;
filesys::mkdir("bam");
cout << "bam " << (filesys::isDir("bam") ? " is dir" : " not dir")
<< endl;
cout << "filesys_test.cpp"
<< (filesys::isDir("filesys_test.cpp") ? " is dir" : " not dir")
<< endl;
filesys::remove("bam");
cout << "removing directory 'bam'" << endl;
//other
cout << "Dir separator: " << filesys::getDirSeparator() << endl;
cout << "Mod time of filesys_test.cpp" ": "
<< filesys::getModTime("filesys_test.cpp") << endl;
// search path redux
cout << "removing base directory from search/write path" << endl;
filesys::removeFromSearchPath( filesys::getBaseDir() );
filesys::setWriteDir( std::string() );
list = filesys::getSearchPath();
cout << "Search path: ";
for(vector<string>::iterator i=list.begin(); i != list.end(); ++i)
{
cout << *i << " ";
}
cout << endl;
return 0;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: math_test.cpp,v 1.4 2005/07/20 01:47:15 cozman Exp $ // $Id: math_test.cpp,v 1.5 2005/08/08 04:55:48 cozman Exp $
// Tests almost everything within photon::math (example run at bottom of file) // Tests almost everything within photon::math (example run at bottom of file)
// Doesn't test: // Doesn't test:
@ -161,12 +161,13 @@ void testVector2()
cout << endl; cout << endl;
} }
int main() int PhotonMain(const StrVec& args)
{ {
testGeneral(); testGeneral();
testCircle(); testCircle();
testRect(); testRect();
testVector2(); testVector2();
return 0;
} }
// Example run (values may vary slightly): // Example run (values may vary slightly):