Clone
ixen <ixen@copyhandler.com>
committed
on 17 May 07
Updated the test project.
LoggerImprovements + 5 more
ext/.../libicpf-tests/config-test.cpp (+55)
  1 #include "config-test.h"
  2 #include "cfg.h"
  3 #include "cfg_xml.h"
  4 #include "exception.h"
  5 #include <vector>
  6
  7 void ConfigTest::Run()
  8 {
  9         const ll_t llVal=-23524;
  10         const ull_t ullVal=3445;
  11         const bool bVal=true;
  12         const tchar_t* pszVal=_t("��ka �wieci jak mo�e");
  13
  14         // generate temporary file name
  15         tchar_t* pszName=_ttmpnam(NULL);
  16         if (!pszName)
  17                 THROW(_t("Cannot generate the temporary file name"), 0, 0, 0);
  18         tstring_t strPath(_t("."));
  19         strPath+=pszName;
  20         strPath+=_t("cfg");
  21
  22         // start with testing cfg class
  23         icpf::xml_cfg cfgXml;
  24         icpf::config cfg(&cfgXml);
  25
  26         ReportS(_t("Registering properties...\n"));
  27
  28         uint_t auiID[4];
  29         auiID[0]=cfg.register_signed_num(_t("test/TestSignedNum00"), 320, -23524, 640);
  30         auiID[1]=cfg.register_unsigned_num(_t("test/moo/TestUnsignedNum01"), 0, 0, 9999999);
  31         auiID[2]=cfg.register_bool(_t("test/TestBool02"), false);
  32         auiID[3]=cfg.register_string(_t("test/TestString03"), _t("none"));
  33
  34         ReportS(_t("Setting values...\n"));
  35
  36         cfg.set_signed_num(auiID[0], llVal);
  37         cfg.set_unsigned_num(auiID[1], ullVal);
  38         cfg.set_bool(auiID[2], bVal);
  39         cfg.set_string(auiID[3], pszVal);
  40
  41         ReportS(_t("Retrieving and comparing values...\n"));
  42         if (cfg.get_signed_num(auiID[0]) != llVal)
  43                 THROW(_t("Comparing signed number values failed"), 0, 0, 0);
  44         if (cfg.get_unsigned_num(auiID[1]) != ullVal)
  45                 THROW(_t("Comparing unsigned number values failed"), 0, 0, 0);
  46         if (cfg.get_bool(auiID[2]) != bVal)
  47                 THROW(_t("Comparing bool values failed"), 0, 0, 0);
  48         if (tstring_t(cfg.get_string(auiID[3])) != tstring_t(pszVal))
  49                 THROW(_t("Comparing string values failed"), 0, 0, 0);
  50
  51         // store values in the file
  52         Report(_t("Storing properties in the file '") TSTRFMT _t("'"), strPath.c_str());
  53         cfg.write(strPath.c_str());
  54
  55 }