some ini adjustment related to UT .

This commit is contained in:
Zero Fanker 2024-04-11 23:23:05 -04:00
parent de8426f014
commit fcd5b6b37f
4 changed files with 16 additions and 20 deletions

View file

@ -41,19 +41,6 @@ using namespace std;
const CIniFileSection CIniFile::EmptySection;
const CString CIniFileSection::EmptyValue;
bool SortDummy::operator()(const CString& x, const CString& y) const
{
// the length is more important than spelling (numbers!!!)...
if (x.GetLength() < y.GetLength()) return true;
if (x.GetLength() == y.GetLength())
{
if (x < y) return true;
}
return false;
}
typedef map<CString, CIniFileSection>::iterator CIniI;
typedef map<CString, CString, SortDummy>::iterator SI;
typedef map<CString, int, SortDummy>::iterator SII;
@ -159,14 +146,11 @@ WORD CIniFile::InsertFile(const std::string& filename, const char* Section, BOOL
CString name = cLine.substr(0, equals).c_str();
CString value = cLine.substr(equals + 1, cLine.size() - equals - 1).c_str();
int cuValueIndex = sections[cSec].Size();
if (bNoSpaces)
{
name.Trim();
value.Trim();
}
sections[cSec].SetString(name, value);
}
}

View file

@ -38,22 +38,32 @@
#include <ios>
#include "IniHelper.h"
using namespace std;
class SortDummy
{
public:
bool operator() (const CString&, const CString&) const;
bool operator()(const CString& x, const CString& y) const
{
// the length is more important than spelling (numbers!!!)...
if (x.GetLength() < y.GetLength()) {
return true;
}
if (x.GetLength() == y.GetLength()) {
if (x < y) {
return true;
}
}
return false;
}
};
class CIniFileSection
{
public:
static const CString EmptyValue;
public:
CIniFileSection();
virtual ~CIniFileSection();

View file

@ -59,6 +59,7 @@ public:
{
char buffer[0x100];
_itoa_s(origin, buffer, 10);
buffer[sizeof buffer - 1] = '\0';
return buffer;
}
};

View file

@ -19,6 +19,7 @@ AllowUnidirectionalTunnels=yes
CIniFile file;
ASSERT_EQ(file.LoadFile(std::string(testIni)), 0);
remove(testIni);
EXPECT_EQ(true, file.GetBool("Debug","AllowTunnels"));
}