change project structure

This commit is contained in:
2020-11-03 10:47:19 +03:00
parent c76140ffe1
commit 44e955a047
59 changed files with 0 additions and 0 deletions

27
test/data/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,21 @@
# 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
test/data/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
test/data/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
test/data/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

View File

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

7
test/data/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
test/data/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
test/data/test_get_key.sh Executable file
View File

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

View File

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

7
test/data/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
test/data/test_get_section.sh Executable file
View File

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

View File

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

7
test/data/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

29
test/run_test.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
DEF='\e[0m'; BLD='\e[1m'; RED='\e[31m'; GRN='\e[32m'; WHT='\e[97m'
ScriptFullname=$(readlink -e "$0")
ScriptName=$(echo "$ScriptFullname" | awk -F '/' '{print $NF;}')
ScriptDir=$(dirname "$ScriptFullname")
TestDir="$ScriptDir/tests"
Multini=$(readlink -e "$1")
if [[ -z "$Multini" ]]; then
Multini="$ScriptDir/multini"
fi
RetCode=0
pushd "$TestDir" > /dev/null
while read Test
do
echo -ne "${BLD}${WHT}[----]${DEF} $Test"
Errors=$("$TestDir/$Test" "$Multini")
if [[ $? -ne 0 ]]; then
echo -e "\r${BLD}${WHT}[${RED}FAIL${WHT}]${DEF} $Test"
RetCode=1
echo "$Errors"
else
echo -e "\r${BLD}${WHT}[${GRN} OK ${WHT}]${DEF} $Test"
fi
done < <(find "$TestDir" -type f -name 'test_*.sh' -printf "%f\n")
popd > /dev/null
exit "$RetCode"