Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/simpleini.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrodie Thiesfield <brofield@gmail.com>2009-06-30 13:23:17 +0400
committerBrodie Thiesfield <brofield@gmail.com>2009-06-30 13:23:17 +0400
commit871c57f1fbe8f6684ff242bf544bfeb133c375eb (patch)
tree7bf09f7b7c12b8427aaac1829efe7da8e6174ba5
parent74aab3c0a0983462f24decead41583ce0fe86014 (diff)
test script (although really just testing in name rather than spirit)
-rw-r--r--SimpleIni.h25
-rw-r--r--package.cmd2
-rw-r--r--test.cmd16
-rw-r--r--test1-expected.ini41
4 files changed, 62 insertions, 22 deletions
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<SI_CHAR,SI_STRLESS,SI_CONVERTER>::CSimpleIniTempl(
, m_bStoreIsUtf8(a_bIsUtf8)
, m_bAllowMultiKey(a_bAllowMultiKey)
, m_bAllowMultiLine(a_bAllowMultiLine)
+ , m_bSpaces(true)
, m_nOrder(0)
{ }
@@ -2319,7 +2336,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::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=<<<SI-END-OF-MULTILINE-TEXT
+multiline-1 = <<<SI-END-OF-MULTILINE-TEXT
This is a multi-line comment. It
will continue until we have the word MULTI
@@ -61,15 +67,16 @@ SI-END-OF-MULTILINE-TEXT
; This looks like multi-line, but because the newline following the last
; line is discarded, it will be converted into a single line entry.
-another-2=This is not a multiline entry.
+another-2 = This is not a multiline entry.
; If you wanted a multiline entry with a single line, you need to add
; an extra line to it.
-another-3=<<<SI-END-OF-MULTILINE-TEXT
+another-3 = <<<SI-END-OF-MULTILINE-TEXT
This is a multiline entry.
SI-END-OF-MULTILINE-TEXT
+
[integer]
-dec=42
-hex=0x2a
+dec = 42
+hex = 0x2a