# Test_IniFile

Provides unit tests and examples for the IniFile module.

Summary

Test_IniFile | Provides unit tests and examples for the IniFile module.
Tests to run | The tests are run with all combinations of the following three parameters:
TEST a/c/e |
comment_ace |
sep_ace |
entry_ace |
title_ace |
record_ace |
lns_ace |
conf_ace |
lns_ace | Testing the a/c/e combination
lns_ace | Quotes can appear within bare values
TEST a/c/f |
comment_acf |
sep_acf |
entry_acf |
title_acf |
record_acf |
lns_acf |
conf_acf |
lns_acf | Testing the a/c/f combination
TEST a/d/e |
comment_ade |
sep_ade |
entry_ade |
title_ade |
record_ade |
lns_ade |
conf_ade |
lns_ade | Testing the a/d/e combination
TEST a/d/f |
comment_adf |
sep_adf |
entry_adf |
title_adf |
record_adf |
lns_adf |
conf_adf |
lns_adf | Testing the a/d/f combination
TEST b/c/e |
comment_bce |
sep_bce |
entry_bce |
title_bce |
record_bce |
lns_bce |
conf_bce |
lns_bce | Testing the b/c/e combination
TEST b/c/f |
comment_bcf |
sep_bcf |
entry_bcf |
title_bcf |
record_bcf |
lns_bcf |
conf_bcf |
lns_bcf | Testing the b/c/f combination
TEST b/d/e |
comment_bde |
sep_bde |
entry_bde |
title_bde |
record_bde |
lns_bde |
conf_bde |
lns_bde | Testing the b/d/e combination
TEST b/d/f |
comment_bdf |
sep_bdf |
entry_bdf |
title_bdf |
record_bdf |
lns_bdf |
conf_bdf |
lns_bdf | Testing the b/d/f combination
TEST multiline values |
multiline_test |
multiline_nl |
multiline_ace |
multiline_ace | Testing the a/c/e combination with a multiline entry
multiline_nl | Multiline values can begin with a single newline
lns_ace | Ticket #243
TEST list entries |
list_test |
list_ace | Testing the a/c/e combination with a list entry
list_nocomment_test |
list_nocomment_ace | Testing the a/c/e combination with a list entry without end-of-line comment
IniFile.lns_loose |
IniFile.lns_loose_multiline |

### Tests to run

The tests are run with all combinations of the following three parameters:

>     separator   :  (a) default (/[:=]/ "=") ;   (b) "=" "="
>     comment     :  (c) default (/[;#]/ ";") ;   (d) ";" ";"
>     empty lines :  (e) default              ;   (f) noempty

### TEST a/c/e

### comment_ace

> let comment_ace = IniFile.comment IniFile.comment_re IniFile.comment_default

### sep_ace

> let sep_ace = IniFile.sep IniFile.sep_re IniFile.sep_default

### entry_ace

> let entry_ace = IniFile.entry IniFile.entry_re sep_ace comment_ace

### title_ace

> let title_ace = IniFile.title IniFile.record_re

### record_ace

> let record_ace = IniFile.record title_ace entry_ace

### lns_ace

> let lns_ace = IniFile.lns record_ace comment_ace

### conf_ace

> let conf_ace = "# comment with sharp [section1] test_ace = value # end of line comment test_ace = test_ace = \"value with spaces\" ; comment with colon "

### lns_ace

> test lns_ace get conf_ace = { "#comment" = "comment with sharp" } {} { "section1" { "test_ace" = "value" { "#comment" = "end of line comment" } } { "test_ace" } { "test_ace" = "value with spaces" } { "#comment" = "comment with colon" } {} }

Testing the a/c/e combination

### lns_ace

> test lns_ace get "[section]\ntest_ace = value \"with quotes\" inside\n" = { "section" { "test_ace" = "value \"with quotes\" inside" } }

Quotes can appear within bare values

### TEST a/c/f

### comment_acf

> let comment_acf = IniFile.comment IniFile.comment_re IniFile.comment_default

### sep_acf

> let sep_acf = IniFile.sep IniFile.sep_re IniFile.sep_default

### entry_acf

> let entry_acf = IniFile.entry IniFile.entry_re sep_acf comment_acf

### title_acf

> let title_acf = IniFile.title IniFile.record_re

### record_acf

> let record_acf = IniFile.record_noempty title_acf entry_acf

### lns_acf

> let lns_acf = IniFile.lns_noempty record_acf comment_acf

### conf_acf

> let conf_acf = "# comment with sharp [section1] test_acf = value test_acf = test_acf : value2 # end of line comment ; comment with colon "

### lns_acf

> test lns_acf get conf_acf = { "#comment" = "comment with sharp" } { "section1" { "test_acf" = "value" } { "test_acf" } { "test_acf" = "value2" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } }

Testing the a/c/f combination

### TEST a/d/e

### comment_ade

> let comment_ade = IniFile.comment ";" ";"

### sep_ade

> let sep_ade = IniFile.sep IniFile.sep_re IniFile.sep_default

### entry_ade

> let entry_ade = IniFile.entry IniFile.entry_re sep_ade comment_ade

### title_ade

> let title_ade = IniFile.title IniFile.record_re

### record_ade

> let record_ade = IniFile.record title_ade entry_ade

### lns_ade

> let lns_ade = IniFile.lns record_ade comment_ade

### conf_ade

> let conf_ade = "; a first comment with colon [section1] test_ade = value test_ade : value2 ; end of line comment ; comment with colon test_ade = "

### lns_ade

> test lns_ade get conf_ade = { "#comment" = "a first comment with colon" } { "section1" { "test_ade" = "value" } { "test_ade" = "value2" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } {} { "test_ade" } }

Testing the a/d/e combination

### TEST a/d/f

### comment_adf

> let comment_adf = IniFile.comment ";" ";"

### sep_adf

> let sep_adf = IniFile.sep IniFile.sep_re IniFile.sep_default

### entry_adf

> let entry_adf = IniFile.entry IniFile.entry_re sep_adf comment_adf

### title_adf

> let title_adf = IniFile.title IniFile.record_re

### record_adf

> let record_adf = IniFile.record_noempty title_adf entry_adf

### lns_adf

> let lns_adf = IniFile.lns_noempty record_adf comment_adf

### conf_adf

> let conf_adf = "; a first comment with colon [section1] test_adf = value test_adf : value2 ; end of line comment ; comment with colon test_adf = "

### lns_adf

> test lns_adf get conf_adf = { "#comment" = "a first comment with colon" } { "section1" { "test_adf" = "value" } { "test_adf" = "value2" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } { "test_adf" } }

Testing the a/d/f combination

### TEST b/c/e

### comment_bce

> let comment_bce = IniFile.comment IniFile.comment_re IniFile.comment_default

### sep_bce

> let sep_bce = IniFile.sep "=" "="

### entry_bce

> let entry_bce = IniFile.entry IniFile.entry_re sep_bce comment_bce

### title_bce

> let title_bce = IniFile.title IniFile.record_re

### record_bce

> let record_bce = IniFile.record title_bce entry_bce

### lns_bce

> let lns_bce = IniFile.lns record_bce comment_bce

### conf_bce

> let conf_bce = "# comment with sharp [section1] test_bce = value # end of line comment ; comment with colon test_bce = "

### lns_bce

> test lns_bce get conf_bce = { "#comment" = "comment with sharp" } {} { "section1" { "test_bce" = "value" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } {} { "test_bce" } }

Testing the b/c/e combination

### TEST b/c/f

### comment_bcf

> let comment_bcf = IniFile.comment IniFile.comment_re IniFile.comment_default

### sep_bcf

> let sep_bcf = IniFile.sep "=" "="

### entry_bcf

> let entry_bcf = IniFile.entry IniFile.entry_re sep_bcf comment_bcf

### title_bcf

> let title_bcf = IniFile.title IniFile.record_re

### record_bcf

> let record_bcf = IniFile.record_noempty title_bce entry_bcf

### lns_bcf

> let lns_bcf = IniFile.lns_noempty record_bce comment_bcf

### conf_bcf

> let conf_bcf = "# conf with sharp [section1] test_bcf = value # end of line comment ; comment with colon test_bcf = "

### lns_bcf

> test lns_bcf get conf_bcf = { "#comment" = "conf with sharp" } { "section1" { "test_bcf" = "value" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } { "test_bcf" } }

Testing the b/c/f combination

### TEST b/d/e

### comment_bde

> let comment_bde = IniFile.comment ";" ";"

### sep_bde

> let sep_bde = IniFile.sep "=" "="

### entry_bde

> let entry_bde = IniFile.entry IniFile.entry_re sep_bde comment_bde

### title_bde

> let title_bde = IniFile.title IniFile.record_re

### record_bde

> let record_bde = IniFile.record title_bde entry_bde

### lns_bde

> let lns_bde = IniFile.lns record_bde comment_bde

### conf_bde

> let conf_bde = "; first comment with colon [section1] test_bde = value ; end of line comment ; comment with colon test_bde = "

### lns_bde

> test lns_bde get conf_bde = { "#comment" = "first comment with colon" } {} { "section1" { "test_bde" = "value" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } {} { "test_bde" } }

Testing the b/d/e combination

### TEST b/d/f

### comment_bdf

> let comment_bdf = IniFile.comment ";" ";"

### sep_bdf

> let sep_bdf = IniFile.sep "=" "="

### entry_bdf

> let entry_bdf = IniFile.entry IniFile.entry_re sep_bdf comment_bdf

### title_bdf

> let title_bdf = IniFile.title IniFile.record_re

### record_bdf

> let record_bdf = IniFile.record_noempty title_bdf entry_bdf

### lns_bdf

> let lns_bdf = IniFile.lns_noempty record_bdf comment_bdf

### conf_bdf

> let conf_bdf = "; first comment with colon [section1] test_bdf = value ; end of line comment ; comment with colon test_bdf = "

### lns_bdf

> test lns_bdf get conf_bdf = { "#comment" = "first comment with colon" } { "section1" { "test_bdf" = "value" { "#comment" = "end of line comment" } } { "#comment" = "comment with colon" } { "test_bdf" } }

Testing the b/d/f combination

### TEST multiline values

### multiline_test

> let multiline_test = "test_ace = val1\n val2\n val3\n"

### multiline_nl

> let multiline_nl = "test_ace =\n val2\n val3\n"

### multiline_ace

> let multiline_ace = IniFile.entry_multiline IniFile.entry_re sep_ace comment_ace

### multiline_ace

> test multiline_ace get multiline_test = { "test_ace" = "val1\n val2\n val3" }

Testing the a/c/e combination with a multiline entry

### multiline_nl

> test multiline_ace get multiline_nl = { "test_ace" = "\n val2\n val3" }

Multiline values can begin with a single newline

### lns_ace

> test lns_ace get "[section1] ticket_243 = \"value1;value2#value3\" # end of line comment " = { "section1" { "ticket_243" = "value1;value2#value3" { "#comment" = "end of line comment" } } }

Ticket #243

### TEST list entries

### list_test

> let list_test = "test_ace = val1,val2,val3 # a comment\n"

### list_ace

> test list_ace get list_test = { "test_ace" { "1" = "val1" } { "2" = "val2" } { "3" = "val3" } { "#comment" = "a comment" } }

Testing the a/c/e combination with a list entry

### list_nocomment_test

> let list_nocomment_test = "test_ace = val1,val2,val3 \n"

### list_nocomment_ace

> test list_nocomment_ace get list_nocomment_test = { "test_ace" { "1" = "val1" } { "2" = "val2" } { "3" = "val3" } }

Testing the a/c/e combination with a list entry without end-of-line comment

### IniFile.lns_loose

> test IniFile.lns_loose get conf_ace = { "section" = ".anon" { "#comment" = "comment with sharp" } { } } { "section" = "section1" { "test_ace" = "value" { "#comment" = "end of line comment" } } { "test_ace" } { "test_ace" = "value with spaces" } { "#comment" = "comment with colon" } { } }

### IniFile.lns_loose_multiline

> test IniFile.lns_loose_multiline get conf_ace = { "section" = ".anon" { "#comment" = "comment with sharp" } { } } { "section" = "section1" { "test_ace" = "value" { "#comment" = "end of line comment" } } { "test_ace" } { "test_ace" = "value with spaces" } { "#comment" = "comment with colon" } { } }

Generic module to create INI files lenses

> let comment_ace = IniFile.comment IniFile.comment_re IniFile.comment_default

> let sep_ace = IniFile.sep IniFile.sep_re IniFile.sep_default

> let entry_ace = IniFile.entry IniFile.entry_re sep_ace comment_ace

> let title_ace = IniFile.title IniFile.record_re

> let record_ace = IniFile.record title_ace entry_ace

> let lns_ace = IniFile.lns record_ace comment_ace

> let conf_ace = "# comment with sharp [section1] test_ace = value # end of line comment test_ace = test_ace = \"value with spaces\" ; comment with colon "

> let comment_acf = IniFile.comment IniFile.comment_re IniFile.comment_default

> let sep_acf = IniFile.sep IniFile.sep_re IniFile.sep_default

> let entry_acf = IniFile.entry IniFile.entry_re sep_acf comment_acf

> let title_acf = IniFile.title IniFile.record_re

> let record_acf = IniFile.record_noempty title_acf entry_acf

> let lns_acf = IniFile.lns_noempty record_acf comment_acf

> let conf_acf = "# comment with sharp [section1] test_acf = value test_acf = test_acf : value2 # end of line comment ; comment with colon "

> let comment_ade = IniFile.comment ";" ";"

> let sep_ade = IniFile.sep IniFile.sep_re IniFile.sep_default

> let entry_ade = IniFile.entry IniFile.entry_re sep_ade comment_ade

> let title_ade = IniFile.title IniFile.record_re

> let record_ade = IniFile.record title_ade entry_ade

> let lns_ade = IniFile.lns record_ade comment_ade

> let conf_ade = "; a first comment with colon [section1] test_ade = value test_ade : value2 ; end of line comment ; comment with colon test_ade = "

> let comment_adf = IniFile.comment ";" ";"

> let sep_adf = IniFile.sep IniFile.sep_re IniFile.sep_default

> let entry_adf = IniFile.entry IniFile.entry_re sep_adf comment_adf

> let title_adf = IniFile.title IniFile.record_re

> let record_adf = IniFile.record_noempty title_adf entry_adf

> let lns_adf = IniFile.lns_noempty record_adf comment_adf

> let conf_adf = "; a first comment with colon [section1] test_adf = value test_adf : value2 ; end of line comment ; comment with colon test_adf = "

> let comment_bce = IniFile.comment IniFile.comment_re IniFile.comment_default

> let sep_bce = IniFile.sep "=" "="

> let entry_bce = IniFile.entry IniFile.entry_re sep_bce comment_bce

> let title_bce = IniFile.title IniFile.record_re

> let record_bce = IniFile.record title_bce entry_bce

> let lns_bce = IniFile.lns record_bce comment_bce

> let conf_bce = "# comment with sharp [section1] test_bce = value # end of line comment ; comment with colon test_bce = "

> let comment_bcf = IniFile.comment IniFile.comment_re IniFile.comment_default

> let sep_bcf = IniFile.sep "=" "="

> let entry_bcf = IniFile.entry IniFile.entry_re sep_bcf comment_bcf

> let title_bcf = IniFile.title IniFile.record_re

> let record_bcf = IniFile.record_noempty title_bce entry_bcf

> let lns_bcf = IniFile.lns_noempty record_bce comment_bcf

> let conf_bcf = "# conf with sharp [section1] test_bcf = value # end of line comment ; comment with colon test_bcf = "

> let comment_bde = IniFile.comment ";" ";"

> let sep_bde = IniFile.sep "=" "="

> let entry_bde = IniFile.entry IniFile.entry_re sep_bde comment_bde

> let title_bde = IniFile.title IniFile.record_re

> let record_bde = IniFile.record title_bde entry_bde

> let lns_bde = IniFile.lns record_bde comment_bde

> let conf_bde = "; first comment with colon [section1] test_bde = value ; end of line comment ; comment with colon test_bde = "

> let comment_bdf = IniFile.comment ";" ";"

> let sep_bdf = IniFile.sep "=" "="

> let entry_bdf = IniFile.entry IniFile.entry_re sep_bdf comment_bdf

> let title_bdf = IniFile.title IniFile.record_re

> let record_bdf = IniFile.record_noempty title_bdf entry_bdf

> let lns_bdf = IniFile.lns_noempty record_bdf comment_bdf

> let conf_bdf = "; first comment with colon [section1] test_bdf = value ; end of line comment ; comment with colon test_bdf = "

> let multiline_test = "test_ace = val1\n val2\n val3\n"

> let multiline_nl = "test_ace =\n val2\n val3\n"

> let multiline_ace = IniFile.entry_multiline IniFile.entry_re sep_ace comment_ace

> let list_test = "test_ace = val1,val2,val3 # a comment\n"

> test list_ace get list_test = { "test_ace" { "1" = "val1" } { "2" = "val2" } { "3" = "val3" } { "#comment" = "a comment" } }

Testing the a/c/e combination with a list entry

> let list_nocomment_test = "test_ace = val1,val2,val3 \n"

> test list_nocomment_ace get list_nocomment_test = { "test_ace" { "1" = "val1" } { "2" = "val2" } { "3" = "val3" } }

Testing the a/c/e combination with a list entry without end-of-line comment

> test IniFile.lns_loose get conf_ace = { "section" = ".anon" { "#comment" = "comment with sharp" } { } } { "section" = "section1" { "test_ace" = "value" { "#comment" = "end of line comment" } } { "test_ace" } { "test_ace" = "value with spaces" } { "#comment" = "comment with colon" } { } }

> test IniFile.lns_loose_multiline get conf_ace = { "section" = ".anon" { "#comment" = "comment with sharp" } { } } { "section" = "section1" { "test_ace" = "value" { "#comment" = "end of line comment" } } { "test_ace" } { "test_ace" = "value with spaces" } { "#comment" = "comment with colon" } { } }

Close