Skip to content

Commit

Permalink
diffstore2: add a 2nd any-leaf example
Browse files Browse the repository at this point in the history
  • Loading branch information
mcluseau committed Jan 17, 2022
1 parent c5b9997 commit 17a39e3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions client/diffstore2/any-leaf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,35 @@ func ExampleAnyLeafStore() {
// -----
// D a
}

func ExampleAnyLeafStoreFileLike() {
store := NewAnyStore[int](func(a, b string) bool { return a == b })

// File 1
// line1
// line2

store.Get(1).Set("line1")
store.Get(2).Set("line2")
store.Done()
store.printDiff()

store.Reset()

// File 2
// line2.1
// line2.2

store.Get(1).Set("line2.1")
store.Get(2).Set("line2.2")
store.Done()
store.printDiff()

// Output:
// -----
// C 1 => "{line1}"
// C 2 => "{line2}"
// -----
// U 1 => "{line2.1}"
// U 2 => "{line2.2}"
}

0 comments on commit 17a39e3

Please sign in to comment.