krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Tests/OrgDocumentTests/DiffTests.swift

c1295824f55c7bba681fca8338bf08167e110105
orgstar/Tests/OrgDocumentTests/DiffTests.swift history · blame · raw

19 lines · 906 bytes

 1import Testing
 2@testable import OrgDocument
 3
 4struct DiffTests {
 5    @Test func diffsLines() {
 6        let diff = lineDiff(old: "a\nb\nc\n", new: "a\nB\nc\nd\n")
 7        #expect(diff == [
 8            DiffLine(kind: .same, text: "a\n"), DiffLine(kind: .removed, text: "b\n"), DiffLine(kind: .added, text: "B\n"),
 9            DiffLine(kind: .same, text: "c\n"), DiffLine(kind: .added, text: "d\n"),
10        ])
11    }
12
13    @Test func mergesWithMarkers() {
14        let merged = mergeWithMarkers(base: "a\nb\nc\nd\n", ours: "a\nB1\nc\nd\nmine\n", theirs: "x\na\nB2\nc\nd\n", oursLabel: "mine", theirsLabel: "disk")
15        #expect(merged == "x\na\n<<<<<<< mine\nB1\n=======\nB2\n>>>>>>> disk\nc\nd\nmine\n")
16        let twoWay = mergeWithMarkers(base: nil, ours: "a\nb\n", theirs: "a\nc", oursLabel: "file", theirsLabel: "copy")
17        #expect(twoWay == "a\n<<<<<<< file\nb\n=======\nc\n>>>>>>> copy\n")
18    }
19}