This commit is contained in:
2020-04-26 02:42:14 +03:00
parent 753cb7bfd6
commit 294a89ba74
59 changed files with 1840 additions and 0 deletions

27
tests/common.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
ScriptFullname=$(readlink -e "$0")
ScriptName=$(echo "$ScriptFullname" | awk -F '/' '{print $NF;}')
ScriptDir=$(dirname "$ScriptFullname")
Multini="$1"
InDir="$ScriptDir/in_ini"
InIni="$InDir/$ScriptName.ini"
OutDir="$ScriptDir/out_ini"
OutIni="$OutDir/$ScriptName.ini"
ExpectedIni="$ScriptDir/expected_ini/$ScriptName.ini"
if [[ ! -d "$OutDir" ]]; then
mkdir -p "$OutDir"
fi
rm -f "$OutIni"
function compare ()
{
if ! cmp -s "$OutIni" "$ExpectedIni" ; then
diff "$OutIni" "$ExpectedIni"
return 1
fi
rm -f "$OutIni"
return 0
}

View File

@ -0,0 +1,20 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
Key3 = 3
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,20 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
Key = 4
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,20 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]
[NewSection]

View File

@ -0,0 +1,18 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,16 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,18 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,17 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1 @@
Some Value2 And Tabs!

View File

@ -0,0 +1,3 @@
1
2
3

View File

@ -0,0 +1,7 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!

View File

@ -0,0 +1,5 @@
SimpleSection
MultipleKeySection
SectionWithIndent
SectionWithoutNewLineBefore

View File

@ -0,0 +1,17 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = onlyone
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

View File

@ -0,0 +1,19 @@
# comment
; comment again
DefKey1 = Some Value1
DefKey2 = Some Value2 And Tabs! # With Comment
DefKey3=NoSpaces!
[SimpleSection] # Comment For Section
Key1 = 1
Key2 = 2
[MultipleKeySection]
Key = 1
Key = 2
Key = 3
[SectionWithIndent]
Key=Value
[SectionWithoutNewLineBefore]

7
tests/test_add_keyval.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --add "$InIni" SimpleSection Key3 3
compare

View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --add "$InIni" MultipleKeySection Key 4
compare

7
tests/test_add_section.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --add "$InIni" NewSection
compare

7
tests/test_del_key.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --del "$InIni" SimpleSection Key1
compare

7
tests/test_del_key_multiple.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --del "$InIni" MultipleKeySection Key
compare

7
tests/test_del_keyval.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --del "$InIni" MultipleKeySection Key 2
compare

7
tests/test_del_section.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --del "$InIni" SectionWithIndent
compare

7
tests/test_get_key.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini --get "$InIni" '' DefKey2 > "$OutIni"
compare

7
tests/test_get_key_multiple.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini --get "$InIni" MultipleKeySection Key > "$OutIni"
compare

7
tests/test_get_keyval.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini --get "$InIni" MultipleKeySection Key 3 > "$OutIni"
compare

7
tests/test_get_section.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini --get "$InIni" '' > "$OutIni"
compare

7
tests/test_get_section_list.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini --get "$InIni" > "$OutIni"
compare

7
tests/test_set_keyval.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "common.sh"
$Multini -o "$OutIni" --set "$InIni" MultipleKeySection Key onlyone
compare