2015-09-16 16:56:28 +03:00
|
|
|
final class DiffTests: XCTestCase {
|
|
|
|
func testSESOverEmptyCollectionsIsEmpty() {
|
|
|
|
XCTAssertEqual(Diff.diff([], []), [])
|
|
|
|
}
|
2015-09-16 17:02:20 +03:00
|
|
|
|
|
|
|
func testSESOverEmptyAndNonEmptyCollectionsIsInsertions() {
|
|
|
|
XCTAssertEqual(Diff.diff([], [ a, b ]), [ Diff.Patch(.Empty, a), Diff.Patch(.Empty, b) ])
|
|
|
|
}
|
2015-09-16 17:04:30 +03:00
|
|
|
|
|
|
|
func testSESOverNonEmptyAndEmptyCollectionsIsDeletions() {
|
|
|
|
XCTAssertEqual(Diff.diff([ a, b ], []), [ Diff.Patch(a, .Empty), Diff.Patch(b, .Empty) ])
|
|
|
|
}
|
2015-09-17 22:55:30 +03:00
|
|
|
|
|
|
|
func testSESCanInsertAtHead() {
|
|
|
|
XCTAssertEqual(Diff.diff([ a, b, c ], [ d, a, b, c ]), [ Diff.Insert(d), Diff(a), Diff(b), Diff(c) ])
|
|
|
|
}
|
2015-09-17 22:56:01 +03:00
|
|
|
|
|
|
|
func testSESCanDeleteAtHead() {
|
|
|
|
XCTAssertEqual(Diff.diff([ d, a, b, c ], [ a, b, c ]), [ Diff.Delete(d), Diff(a), Diff(b), Diff(c) ])
|
|
|
|
}
|
2015-09-17 22:56:53 +03:00
|
|
|
|
|
|
|
func testSESCanInsertInMiddle() {
|
|
|
|
XCTAssertEqual(Diff.diff([ a, b, c ], [ a, d, b, c ]), [ Diff(a), Diff.Insert(d), Diff(b), Diff(c) ])
|
|
|
|
}
|
|
|
|
|
|
|
|
func testSESCanDeleteInMiddle() {
|
|
|
|
XCTAssertEqual(Diff.diff([ a, d, b, c ], [ a, b, c ]), [ Diff(a), Diff.Delete(d), Diff(b), Diff(c) ])
|
|
|
|
}
|
2015-09-16 16:56:28 +03:00
|
|
|
}
|
|
|
|
|
2015-09-18 17:12:34 +03:00
|
|
|
private let a = Term(.Literal("a"))
|
|
|
|
private let b = Term(.Literal("b"))
|
|
|
|
private let c = Term(.Literal("c"))
|
|
|
|
private let d = Term(.Literal("d"))
|
2015-09-16 17:02:20 +03:00
|
|
|
|
2015-09-16 16:56:28 +03:00
|
|
|
import Doubt
|
|
|
|
import XCTest
|