Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a getter for all defined Sections in parsecfg #15450

Merged
merged 5 commits into from
Mar 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions tests/stdlib/tparsecfg.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ dict1.writeConfig(ss)

## Reading a configuration file.
var dict2 = loadConfig(newStringStream(ss.data))
timotheecour marked this conversation as resolved.
Show resolved Hide resolved
var charset = dict2.getSectionValue("", "charset")
var threads = dict2.getSectionValue("Package", "--threads")
var pname = dict2.getSectionValue("Package", "name")
var name = dict2.getSectionValue("Author", "name")
var qq = dict2.getSectionValue("Author", "qq")
var email = dict2.getSectionValue("Author", "email")
doAssert charset == "utf-8"
doAssert threads == "on"
doAssert pname == "hello"
doAssert name == "lihf8515"
doAssert qq == "10214028"
doAssert email == "lihaifeng@wxm.com"
doAssert dict2.getSectionValue("", "charset") == "utf-8"
doAssert dict2.getSectionValue("Package", "--threads") == "on"
doAssert dict2.getSectionValue("Package", "name") == "hello"
doAssert dict2.getSectionValue("Author", "name") == "lihf8515"
doAssert dict2.getSectionValue("Author", "qq") == "10214028"
doAssert dict2.getSectionValue("Author", "email") == "lihaifeng@wxm.com"
doAssert toSeq(dict2.sections) == @["", "Package", "Author"]

## Modifying a configuration file.
Expand Down