cpp_photon/test/ConfigFile_test.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

2005-05-15 02:50:07 +00:00
//This file is part of Photon (http://photon.sourceforge.net)
//Copyright (C) 2004-2005 James Turk
//
// Author:
// James Turk (jpt2433@rit.edu)
//
// Version:
2005-08-08 04:55:48 +00:00
// $Id: ConfigFile_test.cpp,v 1.3 2005/08/08 04:55:48 cozman Exp $
2005-05-15 02:50:07 +00:00
#include "photon.hpp"
#include <iostream>
#include <cassert>
using namespace photon;
2005-07-19 18:41:36 +00:00
// Simple test of ConfigFile functionality
// Tests reading/writing to a ConfigFile
// Successful test will simply output a message indicating success.
2005-08-08 04:55:48 +00:00
int PhotonMain(const StrVec& args)
2005-05-15 02:50:07 +00:00
{
2005-08-08 04:55:48 +00:00
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);
2005-05-15 02:50:07 +00:00
2005-08-08 04:55:48 +00:00
c1.close();
c2.close();
// got here, meaning success
std::cerr << "ConfigFile test completed successfully!\n";
2005-05-15 02:50:07 +00:00
2005-08-08 04:55:48 +00:00
return 0;
}
2005-05-15 02:50:07 +00:00