Index: ext/libicpf/src/libicpf-tests/config-test.cpp =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/config-test.cpp (revision 0) +++ ext/libicpf/src/libicpf-tests/config-test.cpp (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -0,0 +1,55 @@ +#include "config-test.h" +#include "cfg.h" +#include "cfg_xml.h" +#include "exception.h" +#include + +void ConfigTest::Run() +{ + const ll_t llVal=-23524; + const ull_t ullVal=3445; + const bool bVal=true; + const tchar_t* pszVal=_t("��ka �wieci jak mo�e"); + + // generate temporary file name + tchar_t* pszName=_ttmpnam(NULL); + if (!pszName) + THROW(_t("Cannot generate the temporary file name"), 0, 0, 0); + tstring_t strPath(_t(".")); + strPath+=pszName; + strPath+=_t("cfg"); + + // start with testing cfg class + icpf::xml_cfg cfgXml; + icpf::config cfg(&cfgXml); + + ReportS(_t("Registering properties...\n")); + + uint_t auiID[4]; + auiID[0]=cfg.register_signed_num(_t("test/TestSignedNum00"), 320, -23524, 640); + auiID[1]=cfg.register_unsigned_num(_t("test/moo/TestUnsignedNum01"), 0, 0, 9999999); + auiID[2]=cfg.register_bool(_t("test/TestBool02"), false); + auiID[3]=cfg.register_string(_t("test/TestString03"), _t("none")); + + ReportS(_t("Setting values...\n")); + + cfg.set_signed_num(auiID[0], llVal); + cfg.set_unsigned_num(auiID[1], ullVal); + cfg.set_bool(auiID[2], bVal); + cfg.set_string(auiID[3], pszVal); + + ReportS(_t("Retrieving and comparing values...\n")); + if (cfg.get_signed_num(auiID[0]) != llVal) + THROW(_t("Comparing signed number values failed"), 0, 0, 0); + if (cfg.get_unsigned_num(auiID[1]) != ullVal) + THROW(_t("Comparing unsigned number values failed"), 0, 0, 0); + if (cfg.get_bool(auiID[2]) != bVal) + THROW(_t("Comparing bool values failed"), 0, 0, 0); + if (tstring_t(cfg.get_string(auiID[3])) != tstring_t(pszVal)) + THROW(_t("Comparing string values failed"), 0, 0, 0); + + // store values in the file + Report(_t("Storing properties in the file '") TSTRFMT _t("'"), strPath.c_str()); + cfg.write(strPath.c_str()); + +} Index: ext/libicpf/src/libicpf-tests/config-test.h =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/config-test.h (revision 0) +++ ext/libicpf/src/libicpf-tests/config-test.h (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -0,0 +1,14 @@ +#ifndef __CONFIGTEST_H__ +#define __CONFIGTEST_H__ + +#include "test-base.h" + +class ConfigTest : public TestBase +{ +public: + ConfigTest() : TestBase() { }; + + virtual void Run(); +}; + +#endif Index: ext/libicpf/src/libicpf-tests/libicpf-tests.cpp =================================================================== diff -u -N -r607822e0b875d4357808668f88e9a57d1c6e5d65 -r1504b5e9af0cbbc688765c3530ee3443cb04fc01 --- ext/libicpf/src/libicpf-tests/libicpf-tests.cpp (.../libicpf-tests.cpp) (revision 607822e0b875d4357808668f88e9a57d1c6e5d65) +++ ext/libicpf/src/libicpf-tests/libicpf-tests.cpp (.../libicpf-tests.cpp) (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -1,9 +1,33 @@ // libicpf-tests.cpp : Defines the entry point for the console application. // +#if defined(_WIN32) || defined(_WIN64) + #include +#endif +#include +#include "gen_types.h" +#include "config-test.h" +#include "exception.h" -int _tmain(int argc, _TCHAR* argv[]) +#if defined(_WIN32) || defined(_WIN64) +int_t _tmain(int_t argc, tchar_t* argv[]) +#else +int main(int argc, char_t* argv[]) +#endif { + ConfigTest ct; + + try + { + ct.Run(); + } + catch(icpf::exception& e) + { + tchar_t szData[4096]; + e.get_info(szData, 4096); + _tprintf(TSTRFMT, szData); + } + + _getch(); return 0; } - Index: ext/libicpf/src/libicpf-tests/libicpf-tests.vc71.vcproj =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/libicpf-tests.vc71.vcproj (revision 0) +++ ext/libicpf/src/libicpf-tests/libicpf-tests.vc71.vcproj (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ext/libicpf/src/libicpf-tests/libicpf-tests.vcproj =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/libicpf-tests.vcproj (revision 607822e0b875d4357808668f88e9a57d1c6e5d65) +++ ext/libicpf/src/libicpf-tests/libicpf-tests.vcproj (revision 0) @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: ext/libicpf/src/libicpf-tests/test-base.cpp =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/test-base.cpp (revision 0) +++ ext/libicpf/src/libicpf-tests/test-base.cpp (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -0,0 +1,35 @@ +#include "test-base.h" +#include +#include + +#define MAX_BUF 4096 + +TestBase::TestBase() +{ +} + +TestBase::~TestBase() +{ +} + +void TestBase::Run() +{ + assert(false); +} + +void TestBase::Report(const tchar_t* pszFmt, ...) +{ + va_list va; + va_start(va, pszFmt); + + tchar_t szBuf[MAX_BUF]; + _vsntprintf(szBuf, MAX_BUF, pszFmt, va); // user passed stuff + ReportS(szBuf); + + va_end(va); +} + +void TestBase::ReportS(const tchar_t* pszStr) +{ + _tprintf(TSTRFMT, pszStr); +} Index: ext/libicpf/src/libicpf-tests/test-base.h =================================================================== diff -u -N --- ext/libicpf/src/libicpf-tests/test-base.h (revision 0) +++ ext/libicpf/src/libicpf-tests/test-base.h (revision 1504b5e9af0cbbc688765c3530ee3443cb04fc01) @@ -0,0 +1,19 @@ +#ifndef __TESTBASE_H__ +#define __TESTBASE_H__ + +#include +#include "gen_types.h" + +class TestBase +{ +public: + TestBase(); + virtual ~TestBase(); + + virtual void Run(); + + void Report(const tchar_t* pszFmt, ...); + void ReportS(const tchar_t* pszFmt); +}; + +#endif