Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangel-dev committed Jul 11, 2024
1 parent a863fd1 commit 3167492
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Tests/AutomergeTests/TestChanges.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ class ChangeSetTests: XCTestCase {
func testRelationBetweenChangeHashAndRaw() throws {
let doc = Document()
let textId = try! doc.putObject(obj: ObjId.ROOT, key: "text", ty: .Text)
let doc1 = doc.fork()
try doc.spliceText(obj: textId, start: 0, delete: 0, value: "Hello")
try doc.spliceText(obj: textId, start: 5, delete: 0, value: " World!")
try doc1.spliceText(obj: textId, start: 0, delete: 0, value: " World!")
try doc.merge(other: doc1)

let heads = doc.heads()
let restored = doc.heads(raw: heads.raw())
Expand All @@ -100,13 +102,16 @@ class ChangeSetTests: XCTestCase {
func testChangeHash_WhenRawIsManipulated_DocumentDoesNotAccept() throws {
let doc = Document()
let textId = try! doc.putObject(obj: ObjId.ROOT, key: "text", ty: .Text)
let doc1 = doc.fork()
try doc.spliceText(obj: textId, start: 0, delete: 0, value: "Hello")
try doc.spliceText(obj: textId, start: 5, delete: 0, value: " World!")
try doc1.spliceText(obj: textId, start: 0, delete: 0, value: " World!")
try doc.merge(other: doc1)

let headsRaw = doc.heads().raw().map { raw in
var raw = raw
raw[0] = 0
raw[7] = 0
raw[14] = 0
return raw
}
let restored = doc.heads(raw: headsRaw)
Expand Down

0 comments on commit 3167492

Please sign in to comment.