Tests/OrgDocumentTests/DiffTests.swift

44019206b2343f9f00af44ffb9964c36b4c7fb4c
orgstar/Tests/OrgDocumentTests/DiffTests.swift

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}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form