Skip to content

Commit

Permalink
test: ini parser spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Mar 27, 2022
1 parent 52ae436 commit ce694b0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/fixtures/ini/all.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[section1]
one = 1
nothing =

[section2]
right=true

[section3]
nope=
3 changes: 3 additions & 0 deletions spec/fixtures/ini/booleans.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[section]
good = true
bad = false
4 changes: 4 additions & 0 deletions spec/fixtures/ini/comments.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; There is only a single comment in this file
;
; [section]
; key=value
3 changes: 3 additions & 0 deletions spec/fixtures/ini/numbers.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[section]
one = 1
two = 2
40 changes: 40 additions & 0 deletions spec/unit/parser_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local ini = require "telescope._extensions.bookmarks.parser.ini"

describe("ini parser", function()
it("should ignore comments", function()
assert.are.same(ini.load "spec/fixtures/ini/comments.ini", {})
end)

it("should parse numbers", function()
assert.are.same(ini.load "spec/fixtures/ini/numbers.ini", {
section = {
one = 1,
two = 2,
},
})
end)

it("should parse booleans", function()
assert.are.same(ini.load "spec/fixtures/ini/booleans.ini", {
section = {
good = true,
bad = false,
},
})
end)

it("should parse multiple sections and empty values", function()
assert.are.same(ini.load "spec/fixtures/ini/all.ini", {
section1 = {
one = 1,
nothing = "",
},
section2 = {
right = true,
},
section3 = {
nope = "",
},
})
end)
end)

0 comments on commit ce694b0

Please sign in to comment.