PhotonMain, done for 0.0.1
This commit is contained in:
parent
0b64a143b4
commit
8bd0e0ec0a
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// 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"
|
||||
|
||||
@ -17,38 +17,32 @@ using namespace photon;
|
||||
// Simple test of ConfigFile functionality
|
||||
// Tests reading/writing to a ConfigFile
|
||||
// Successful test will simply output a message indicating success.
|
||||
class ConfigTest : public Application
|
||||
int PhotonMain(const StrVec& args)
|
||||
{
|
||||
public:
|
||||
|
||||
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);
|
||||
util::ConfigFile c1("config1.ini"),c2;
|
||||
c2.open("config2.ini");
|
||||
|
||||
c1.close();
|
||||
c2.close();
|
||||
|
||||
// got here, meaning success
|
||||
std::cerr << "ConfigFile test completed successfully!\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
// 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();
|
||||
c2.close();
|
||||
|
||||
// got here, meaning success
|
||||
std::cerr << "ConfigFile test completed successfully!\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ENTRYPOINT(ConfigTest) // make ConfigTest the entrypoint class
|
||||
|
@ -5,48 +5,41 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// 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"
|
||||
using namespace photon;
|
||||
|
||||
// extremely simple log test application
|
||||
class LogTest : public Application
|
||||
int PhotonMain(const StrVec& args)
|
||||
{
|
||||
public:
|
||||
int main(const StrVec& args)
|
||||
{
|
||||
// create the log and add three sinks
|
||||
Log log;
|
||||
LogSinkPtr a( new ConsoleSink("console") ); // standard error output
|
||||
LogSinkPtr b( new TextSink("textlog") ); // plaintext log
|
||||
LogSinkPtr c( new HTMLSink("htmllog") ); // html formatted log
|
||||
|
||||
// logged before sinks are added, so not shown
|
||||
log.note() << "this isn't seen";
|
||||
|
||||
// add the three sinks
|
||||
log.addSink(a);
|
||||
log.addSink(b);
|
||||
log.addSink(c);
|
||||
|
||||
// demo of the 5 log levels
|
||||
log.note() << "notice?";
|
||||
log.verbose() << "(insert verbosity here)";
|
||||
log.warning() << "consider yourself warned.";
|
||||
log.error() << "erroneous!";
|
||||
log.critical() << "Al the critic?";
|
||||
|
||||
log.removeSink(b); // remove b and log a message to a and c
|
||||
log.note() << "only seen by a and c" ;
|
||||
|
||||
// remove all sinks and log a message that is not shown
|
||||
log.removeSinks();
|
||||
log.note() << "not seen at all!";
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
ENTRYPOINT(LogTest)
|
||||
|
||||
// create the log and add three sinks
|
||||
Log log;
|
||||
LogSinkPtr a( new ConsoleSink("console") ); // standard error output
|
||||
LogSinkPtr b( new TextSink("textlog") ); // plaintext log
|
||||
LogSinkPtr c( new HTMLSink("htmllog") ); // html formatted log
|
||||
|
||||
// logged before sinks are added, so not shown
|
||||
log.note() << "this isn't seen";
|
||||
|
||||
// add the three sinks
|
||||
log.addSink(a);
|
||||
log.addSink(b);
|
||||
log.addSink(c);
|
||||
|
||||
// demo of the 5 log levels
|
||||
log.note() << "notice?";
|
||||
log.verbose() << "(insert verbosity here)";
|
||||
log.warning() << "consider yourself warned.";
|
||||
log.error() << "erroneous!";
|
||||
log.critical() << "Al the critic?";
|
||||
|
||||
log.removeSink(b); // remove b and log a message to a and c
|
||||
log.note() << "only seen by a and c" ;
|
||||
|
||||
// remove all sinks and log a message that is not shown
|
||||
log.removeSinks();
|
||||
log.note() << "not seen at all!";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// 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 <iomanip>
|
||||
@ -14,7 +14,7 @@ using namespace photon::util;
|
||||
using namespace std;
|
||||
|
||||
// simple demo of RandGen
|
||||
int main()
|
||||
int PhotonMain(const photon::StrVec& args)
|
||||
{
|
||||
RandGen g1;
|
||||
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
|
||||
// they are there for reference when ensuring that the bounds are set
|
||||
// properly on the generators.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// 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 <iostream>
|
||||
@ -16,92 +16,85 @@ using namespace photon::util;
|
||||
|
||||
// Basic test of util::filesys functionality, simply outputs essentially
|
||||
// all information available via util::filesys.
|
||||
class FilesysTest : public Application
|
||||
int PhotonMain(const StrVec& args)
|
||||
{
|
||||
public:
|
||||
|
||||
int main(const StrVec& args)
|
||||
StrVec list;
|
||||
|
||||
//System Directories
|
||||
|
||||
list = filesys::getCDDirs();
|
||||
cout << "CD directories: ";
|
||||
for(StrVec::iterator i=list.begin(); i != list.end(); ++i)
|
||||
{
|
||||
StrVec list;
|
||||
|
||||
//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 << *i << " ";
|
||||
}
|
||||
};
|
||||
|
||||
ENTRYPOINT(FilesysTest)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// 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)
|
||||
// Doesn't test:
|
||||
@ -161,12 +161,13 @@ void testVector2()
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
int PhotonMain(const StrVec& args)
|
||||
{
|
||||
testGeneral();
|
||||
testCircle();
|
||||
testRect();
|
||||
testVector2();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Example run (values may vary slightly):
|
||||
|
Loading…
Reference in New Issue
Block a user