From 871c57f1fbe8f6684ff242bf544bfeb133c375eb Mon Sep 17 00:00:00 2001 From: Brodie Thiesfield Date: Tue, 30 Jun 2009 09:23:17 +0000 Subject: test script (although really just testing in name rather than spirit) --- SimpleIni.h | 25 +++++++++++++++++++++---- package.cmd | 2 +- test.cmd | 16 ++++++++++++++++ test1-expected.ini | 41 ++++++++++++++++++++++++----------------- 4 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 test.cmd diff --git a/SimpleIni.h b/SimpleIni.h index 390b9b1..b5a526a 100644 --- a/SimpleIni.h +++ b/SimpleIni.h @@ -445,8 +445,8 @@ public: @param a_bMultiLine See the method SetMultiLine() for details. */ CSimpleIniTempl( - bool a_bIsUtf8 = false, - bool a_bMultiKey = false, + bool a_bIsUtf8 = false, + bool a_bMultiKey = false, bool a_bMultiLine = false ); @@ -519,6 +519,19 @@ public: /** Query the status of multi-line data */ bool IsMultiLine() const { return m_bAllowMultiLine; } + /** Should spaces be added around the equals sign when writing key/value + pairs out. When true, the result will be "key = value". When false, + the result will be "key=value". This value may be changed at any time. + + \param a_bSpaces Add spaces around the equals sign? + */ + void SetSpaces(bool a_bSpaces = true) { + m_bSpaces = a_bSpaces; + } + + /** Query the status of spaces output */ + bool UsingSpaces() const { return m_bSpaces; } + /*-----------------------------------------------------------------------*/ /** @} @{ @name Loading INI Data */ @@ -986,7 +999,7 @@ public: SI_Error SetBoolValue( const SI_CHAR * a_pSection, const SI_CHAR * a_pKey, - bool a_nValue, + bool a_bValue, const SI_CHAR * a_pComment = NULL, bool a_bForceReplace = false ); @@ -1165,6 +1178,9 @@ private: /** Are data values permitted to span multiple lines? */ bool m_bAllowMultiLine; + /** Should spaces be written out surrounding the equals sign? */ + bool m_bSpaces; + /** Next order value, used to ensure sections and keys are output in the same order that they are loaded/added. */ @@ -1187,6 +1203,7 @@ CSimpleIniTempl::CSimpleIniTempl( , m_bStoreIsUtf8(a_bIsUtf8) , m_bAllowMultiKey(a_bAllowMultiKey) , m_bAllowMultiLine(a_bAllowMultiLine) + , m_bSpaces(true) , m_nOrder(0) { } @@ -2319,7 +2336,7 @@ CSimpleIniTempl::Save( if (!convert.ConvertToStore(iValue->pItem)) { return SI_FAIL; } - a_oOutput.Write(" = "); + a_oOutput.Write(m_bSpaces ? " = " : "="); if (m_bAllowMultiLine && IsMultiLineData(iValue->pItem)) { // multi-line data needs to be processed specially to ensure // that we use the correct newline format for the current system diff --git a/package.cmd b/package.cmd index 3a59c4d..eb72549 100644 --- a/package.cmd +++ b/package.cmd @@ -1,4 +1,4 @@ -set VERSION=4.10 +set VERSION=4.11 set SEVENZIP="C:\Program Files\7-Zip\7z.exe" diff --git a/test.cmd b/test.cmd new file mode 100644 index 0000000..2181328 --- /dev/null +++ b/test.cmd @@ -0,0 +1,16 @@ +@echo off + +Debug\testsi.exe -u -m -l test1-input.ini > test1-blah.ini +fc test1-expected.ini test1-output.ini +if errorlevel 1 goto error + +Release\testsi.exe -u -m -l test1-input.ini > test1-blah.ini +fc test1-expected.ini test1-output.ini +if errorlevel 1 goto error + +exit /b 0 + +:error +echo Failed during test run. Output file doesn't match expected file. +pause +exit /b 1 diff --git a/test1-expected.ini b/test1-expected.ini index 0964b1a..4f19e99 100644 --- a/test1-expected.ini +++ b/test1-expected.ini @@ -10,8 +10,8 @@ ; with no section. ; Key with no section -lonely-key=nosection -another=nosection either +lonely-key = nosection +another = nosection either ; This should be joined with the comment below about japanese. @@ -19,37 +19,43 @@ another=nosection either ; This is a section of keys showing the word Japanese in different syllabies. [ordered-1] -a-1=blah +a-1 = blah ; this is in kanji -japanese-2=日本語 +japanese-2 = 日本語 ; this is in hiragana -japanese-3=にほんご +japanese-3 = にほんご ; this is in katakana -japanese-4=ニホンゴ +japanese-4 = ニホンゴ ; this is in romaji -japanese-5=nihongo +japanese-5 = nihongo ; kanji as the key -日本語-6=japanese +日本語-6 = japanese [multi-2] ; value a -test=a -test=b -test=c -test=d +test = a + +; value b +test = b + +; value c +test = c + +; value d +test = d [multiline-3] ; This is obviously a multi-line entry -multiline-1=<<