aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/hunk_spec.lua
blob: c640afb5ba3cd80f26d462d5084cdeb07b843c26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
describe("Parsing of a hunk header", function()
    local hk, header, test_header

    setup(function()
        hk = require("hunk")
        test_header = "@@ -20,8 +20,17 @@ Hunk #1, a/tests/test_ec_curves.py"
    end)

    before_each(function()
        header = hk.Header:parse(test_header)
    end)

    it("it is not nil", function()
        assert.is_not_nil(header)
    end)

    it("original line number is preserved in the attribute line", function()
        -- not relevant here, because parse() method was run without line#
        assert.is_nil(header.line)
    end)

    it("attributes are set correctly", function()
        assert.are.equal(20, header.oldFirst)
        assert.are.equal(8, header.oldCount)
        assert.are.equal(20, header.newFirst)
        assert.are.equal(17, header.newCount)
    end)

    it("remainder of the line is preserved as well", function()
        assert.are.equal("Hunk #1, a/tests/test_ec_curves.py", header.remainderLine)
    end)
end)

describe("Class functions", function()
    local hk, header, test_header

    setup(function()
        hk = require("hunk")
    end)

    it("generates correct header", function()
        local header_str = hk.createHunkHeader(12,15,25,30,"something")
        local exp_str = "@@ -12,15 +25,30 @@ something"
        assert.are.equal(exp_str, header_str)
    end)
end)