diff --git a/pkg/document/crdt/array.go b/pkg/document/crdt/array.go index 44805e052..df5be3e4e 100644 --- a/pkg/document/crdt/array.go +++ b/pkg/document/crdt/array.go @@ -88,10 +88,10 @@ func (a *Array) Marshal() string { return a.elements.Marshal() } -// AnnotatedString returns a String containing the metadata of the elements +// StructureAsString returns a String containing the metadata of the elements // for debugging purpose. -func (a *Array) AnnotatedString() string { - return a.elements.AnnotatedString() +func (a *Array) StructureAsString() string { + return a.elements.StructureAsString() } // DeepCopy copies itself deeply. diff --git a/pkg/document/crdt/rga_tree_list.go b/pkg/document/crdt/rga_tree_list.go index 6270f9e59..b3a88ad9c 100644 --- a/pkg/document/crdt/rga_tree_list.go +++ b/pkg/document/crdt/rga_tree_list.go @@ -224,10 +224,10 @@ func (a *RGATreeList) Len() int { return a.size } -// AnnotatedString returns a String containing the metadata of the node id +// StructureAsString returns a String containing the metadata of the node id // for debugging purpose. -func (a *RGATreeList) AnnotatedString() string { - return a.nodeMapByIndex.AnnotatedString() +func (a *RGATreeList) StructureAsString() string { + return a.nodeMapByIndex.StructureAsString() } // Delete deletes the node of the given index. diff --git a/pkg/document/crdt/rga_tree_split.go b/pkg/document/crdt/rga_tree_split.go index 7c245b6a5..4474c1b1a 100644 --- a/pkg/document/crdt/rga_tree_split.go +++ b/pkg/document/crdt/rga_tree_split.go @@ -21,7 +21,7 @@ type RGATreeSplitValue interface { DeepCopy() RGATreeSplitValue String() string Marshal() string - AnnotatedString() string + structureAsString() string } // RGATreeSplitNodeID is an ID of RGATreeSplitNode. @@ -84,10 +84,10 @@ func (id *RGATreeSplitNodeID) Split(offset int) *RGATreeSplitNodeID { return NewRGATreeSplitNodeID(id.createdAt, id.offset+offset) } -// AnnotatedString returns a String containing the metadata of the node id +// StructureAsString returns a String containing the metadata of the node id // for debugging purpose. -func (id *RGATreeSplitNodeID) AnnotatedString() string { - return fmt.Sprintf("%s:%d", id.createdAt.AnnotatedString(), id.offset) +func (id *RGATreeSplitNodeID) StructureAsString() string { + return fmt.Sprintf("%s:%d", id.createdAt.StructureAsString(), id.offset) } func (id *RGATreeSplitNodeID) hasSameCreatedAt(other *RGATreeSplitNodeID) bool { @@ -119,10 +119,10 @@ func (pos *RGATreeSplitNodePos) getAbsoluteID() *RGATreeSplitNodeID { return NewRGATreeSplitNodeID(pos.id.createdAt, pos.id.offset+pos.relativeOffset) } -// AnnotatedString returns a String containing the metadata of the position +// StructureAsString returns a String containing the metadata of the position // for debugging purpose. -func (pos *RGATreeSplitNodePos) AnnotatedString() string { - return fmt.Sprintf("%s:%d", pos.id.AnnotatedString(), pos.relativeOffset) +func (pos *RGATreeSplitNodePos) StructureAsString() string { + return fmt.Sprintf("%s:%d", pos.id.StructureAsString(), pos.relativeOffset) } // ID returns the ID of this RGATreeSplitNodePos. @@ -259,10 +259,10 @@ func (s *RGATreeSplitNode[V]) createdAt() *time.Ticket { return s.id.createdAt } -// annotatedString returns a String containing the metadata of the node +// structureAsString returns a String containing the metadata of the node // for debugging purpose. -func (s *RGATreeSplitNode[V]) annotatedString() string { - return fmt.Sprintf("%s %s", s.id.AnnotatedString(), s.value.AnnotatedString()) +func (s *RGATreeSplitNode[V]) structureAsString() string { + return fmt.Sprintf("%s %s", s.id.StructureAsString(), s.value.structureAsString()) } // Remove removes this node if it created before the time of deletion are @@ -348,7 +348,7 @@ func (s *RGATreeSplit[V]) findNodeWithSplit( func (s *RGATreeSplit[V]) findFloorNodePreferToLeft(id *RGATreeSplitNodeID) *RGATreeSplitNode[V] { node := s.findFloorNode(id) if node == nil { - panic("the node of the given id should be found: " + s.AnnotatedString()) + panic("the node of the given id should be found: " + s.StructureAsString()) } if id.offset > 0 && node.id.offset == id.offset { @@ -364,7 +364,7 @@ func (s *RGATreeSplit[V]) findFloorNodePreferToLeft(id *RGATreeSplitNodeID) *RGA func (s *RGATreeSplit[V]) splitNode(node *RGATreeSplitNode[V], offset int) *RGATreeSplitNode[V] { if offset > node.contentLen() { - panic("offset should be less than or equal to length: " + s.AnnotatedString()) + panic("offset should be less than or equal to length: " + s.StructureAsString()) } if offset == 0 { @@ -598,17 +598,17 @@ func (s *RGATreeSplit[V]) nodes() []*RGATreeSplitNode[V] { return nodes } -// AnnotatedString returns a String containing the metadata of the nodes +// StructureAsString returns a String containing the metadata of the nodes // for debugging purpose. -func (s *RGATreeSplit[V]) AnnotatedString() string { +func (s *RGATreeSplit[V]) StructureAsString() string { builder := strings.Builder{} node := s.initialHead for node != nil { if node.removedAt != nil { - builder.WriteString(fmt.Sprintf("{%s}", node.annotatedString())) + builder.WriteString(fmt.Sprintf("{%s}", node.structureAsString())) } else { - builder.WriteString(fmt.Sprintf("[%s]", node.annotatedString())) + builder.WriteString(fmt.Sprintf("[%s]", node.structureAsString())) } node = node.next } diff --git a/pkg/document/crdt/rich_text.go b/pkg/document/crdt/rich_text.go index 7877255aa..8928b023b 100644 --- a/pkg/document/crdt/rich_text.go +++ b/pkg/document/crdt/rich_text.go @@ -70,9 +70,9 @@ func (t *RichTextValue) Marshal() string { ) } -// AnnotatedString returns a String containing the metadata of this value +// structureAsString returns a String containing the metadata of this value // for debugging purpose. -func (t *RichTextValue) AnnotatedString() string { +func (t *RichTextValue) structureAsString() string { return fmt.Sprintf( `%s "%s"`, t.attrs.Marshal(), @@ -270,10 +270,10 @@ func (t *RichText) Nodes() []*RGATreeSplitNode[*RichTextValue] { return t.rgaTreeSplit.nodes() } -// AnnotatedString returns a String containing the metadata of the text +// StructureAsString returns a String containing the metadata of the text // for debugging purpose. -func (t *RichText) AnnotatedString() string { - return t.rgaTreeSplit.AnnotatedString() +func (t *RichText) StructureAsString() string { + return t.rgaTreeSplit.StructureAsString() } // removedNodesLen returns length of removed nodes diff --git a/pkg/document/crdt/text.go b/pkg/document/crdt/text.go index 51ddf7eea..7f4461011 100644 --- a/pkg/document/crdt/text.go +++ b/pkg/document/crdt/text.go @@ -52,9 +52,9 @@ func (t *TextValue) Marshal() string { return EscapeString(t.value) } -// AnnotatedString returns a String containing the metadata of this value +// structureAsString returns a String containing the metadata of this value // for debugging purpose. -func (t *TextValue) AnnotatedString() string { +func (t *TextValue) structureAsString() string { return EscapeString(t.value) } @@ -210,10 +210,10 @@ func (t *Text) Nodes() []*RGATreeSplitNode[*TextValue] { return t.rgaTreeSplit.nodes() } -// AnnotatedString returns a String containing the metadata of the text +// StructureAsString returns a String containing the metadata of the text // for debugging purpose. -func (t *Text) AnnotatedString() string { - return t.rgaTreeSplit.AnnotatedString() +func (t *Text) StructureAsString() string { + return t.rgaTreeSplit.StructureAsString() } // CheckWeight returns false when there is an incorrect weight node. diff --git a/pkg/document/document_test.go b/pkg/document/document_test.go index 64d0432c3..0a6cbf252 100644 --- a/pkg/document/document_test.go +++ b/pkg/document/document_test.go @@ -129,22 +129,22 @@ func TestDocument(t *testing.T) { root.SetNewArray("k1").AddInteger(1).AddInteger(2).AddInteger(3) assert.Equal(t, 3, root.GetArray("k1").Len()) assert.Equal(t, `{"k1":[1,2,3]}`, root.Marshal()) - assert.Equal(t, "[0,0]0[1,1]1[2,1]2[3,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(t, "[0,0]0[1,1]1[2,1]2[3,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").Delete(1) assert.Equal(t, `{"k1":[1,3]}`, root.Marshal()) assert.Equal(t, 2, root.GetArray("k1").Len()) - assert.Equal(t, "[0,0]0[1,1]1[2,0]2[1,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(t, "[0,0]0[1,1]1[2,0]2[1,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").InsertIntegerAfter(0, 2) assert.Equal(t, `{"k1":[1,2,3]}`, root.Marshal()) assert.Equal(t, 3, root.GetArray("k1").Len()) - assert.Equal(t, "[0,0]0[1,1]1[3,1]2[1,0]2[1,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(t, "[0,0]0[1,1]1[3,1]2[1,0]2[1,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").InsertIntegerAfter(2, 4) assert.Equal(t, `{"k1":[1,2,3,4]}`, root.Marshal()) assert.Equal(t, 4, root.GetArray("k1").Len()) - assert.Equal(t, "[0,0]0[1,1]1[2,1]2[2,0]2[3,1]3[4,1]4", root.GetArray("k1").AnnotatedString()) + assert.Equal(t, "[0,0]0[1,1]1[2,1]2[2,0]2[3,1]3[4,1]4", root.GetArray("k1").StructureAsString()) for i := 0; i < root.GetArray("k1").Len(); i++ { assert.Equal( @@ -180,23 +180,23 @@ func TestDocument(t *testing.T) { text := root.GetText("k1") assert.Equal(t, "[0:0:00:0 ][1:2:00:0 A][1:3:00:0 12]{1:2:00:1 BC}[1:2:00:3 D]", - text.AnnotatedString(), + text.StructureAsString(), ) from, _ := text.CreateRange(0, 0) - assert.Equal(t, "0:0:00:0:0", from.AnnotatedString()) + assert.Equal(t, "0:0:00:0:0", from.StructureAsString()) from, _ = text.CreateRange(1, 1) - assert.Equal(t, "1:2:00:0:1", from.AnnotatedString()) + assert.Equal(t, "1:2:00:0:1", from.StructureAsString()) from, _ = text.CreateRange(2, 2) - assert.Equal(t, "1:3:00:0:1", from.AnnotatedString()) + assert.Equal(t, "1:3:00:0:1", from.StructureAsString()) from, _ = text.CreateRange(3, 3) - assert.Equal(t, "1:3:00:0:2", from.AnnotatedString()) + assert.Equal(t, "1:3:00:0:2", from.StructureAsString()) from, _ = text.CreateRange(4, 4) - assert.Equal(t, "1:2:00:3:1", from.AnnotatedString()) + assert.Equal(t, "1:2:00:3:1", from.StructureAsString()) return nil }) assert.NoError(t, err) @@ -229,7 +229,7 @@ func TestDocument(t *testing.T) { assert.Equal( t, `[0:0:00:0 {} ""][1:2:00:0 {} "Hello world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -241,7 +241,7 @@ func TestDocument(t *testing.T) { text.SetStyle(0, 5, map[string]string{"b": "1"}) assert.Equal(t, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hello"][1:2:00:5 {} " world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -258,7 +258,7 @@ func TestDocument(t *testing.T) { assert.Equal( t, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hello"][1:2:00:5 {} " world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) text.SetStyle(3, 5, map[string]string{"i": "1"}) @@ -266,7 +266,7 @@ func TestDocument(t *testing.T) { t, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"][1:2:00:5 {} " world"]`+ `[1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -284,7 +284,7 @@ func TestDocument(t *testing.T) { t, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"]`+ `[4:1:00:0 {} " Yorkie"]{1:2:00:5 {} " world"}[1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -302,7 +302,7 @@ func TestDocument(t *testing.T) { t, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"]`+ `[5:1:00:0 {"list":"true"} "\n"][4:1:00:0 {} " Yorkie"]{1:2:00:5 {} " world"}[1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -465,7 +465,7 @@ func TestDocument(t *testing.T) { assert.Equal( t, `[0:0:00:0 ][1:3:00:0 12]{1:2:00:0 AB}[1:2:00:2 CD]`, - doc.Root().GetText("text").AnnotatedString(), + doc.Root().GetText("text").StructureAsString(), ) assert.Equal(t, 1, doc.GarbageLen()) @@ -474,7 +474,7 @@ func TestDocument(t *testing.T) { assert.Equal( t, `[0:0:00:0 ][1:3:00:0 12][1:2:00:2 CD]`, - doc.Root().GetText("text").AnnotatedString(), + doc.Root().GetText("text").StructureAsString(), ) err = doc.Update(func(root *json.Object) error { @@ -485,7 +485,7 @@ func TestDocument(t *testing.T) { assert.Equal( t, `[0:0:00:0 ][1:3:00:0 12]{1:2:00:2 CD}`, - doc.Root().GetText("text").AnnotatedString(), + doc.Root().GetText("text").StructureAsString(), ) }) diff --git a/pkg/document/time/ticket.go b/pkg/document/time/ticket.go index b6938b2bd..69a989f11 100644 --- a/pkg/document/time/ticket.go +++ b/pkg/document/time/ticket.go @@ -70,9 +70,9 @@ func NewTicket( } } -// AnnotatedString returns a string containing the metadata of the ticket +// StructureAsString returns a string containing the metadata of the ticket // for debugging purpose. -func (t *Ticket) AnnotatedString() string { +func (t *Ticket) StructureAsString() string { return fmt.Sprintf( "%d:%d:%s", t.lamport, t.delimiter, t.actorID.String()[22:24], ) diff --git a/pkg/document/time/ticket_test.go b/pkg/document/time/ticket_test.go index 00f0e8c8b..500d5f796 100644 --- a/pkg/document/time/ticket_test.go +++ b/pkg/document/time/ticket_test.go @@ -31,7 +31,7 @@ func TestTicket(t *testing.T) { assert.Equal(t, "0:1:"+ticket.ActorIDHex(), ticket.Key()) assert.Equal(t, "0:1:"+ticket.ActorIDHex()[22:24], - ticket.AnnotatedString()) + ticket.StructureAsString()) }) t.Run("ticket comparing test", func(t *testing.T) { diff --git a/pkg/splay/splay.go b/pkg/splay/splay.go index dbe55fdcf..ff8db874a 100644 --- a/pkg/splay/splay.go +++ b/pkg/splay/splay.go @@ -220,9 +220,9 @@ func (t *Tree[V]) String() string { return builder.String() } -// AnnotatedString returns a string containing the metadata of the Node +// StructureAsString returns a string containing the metadata of the Node // for debugging purpose. -func (t *Tree[V]) AnnotatedString() string { +func (t *Tree[V]) StructureAsString() string { var builder strings.Builder traverseInOrder(t.root, func(node *Node[V]) { @@ -286,8 +286,8 @@ func (t *Tree[V]) Delete(node *Node[V]) { } if leftTree.root != nil { - maxNode := leftTree.maximum() - leftTree.Splay(maxNode) + rightmost := leftTree.rightmost() + leftTree.Splay(rightmost) leftTree.root.right = rightTree.root if rightTree.root != nil { rightTree.root.parent = leftTree.root @@ -379,7 +379,7 @@ func (t *Tree[V]) rotateRight(pivot *Node[V]) { t.UpdateWeight(pivot) } -func (t *Tree[V]) maximum() *Node[V] { +func (t *Tree[V]) rightmost() *Node[V] { node := t.root for node.right != nil { node = node.right diff --git a/pkg/splay/splay_test.go b/pkg/splay/splay_test.go index 7f6e69b6f..4e665df85 100644 --- a/pkg/splay/splay_test.go +++ b/pkg/splay/splay_test.go @@ -55,16 +55,16 @@ func TestSplayTree(t *testing.T) { assert.Equal(t, 0, idx) nodeA := tree.Insert(newSplayNode("A2")) - assert.Equal(t, "[2,2]A2", tree.AnnotatedString()) + assert.Equal(t, "[2,2]A2", tree.StructureAsString()) nodeB := tree.Insert(newSplayNode("B23")) - assert.Equal(t, "[2,2]A2[5,3]B23", tree.AnnotatedString()) + assert.Equal(t, "[2,2]A2[5,3]B23", tree.StructureAsString()) nodeC := tree.Insert(newSplayNode("C234")) - assert.Equal(t, "[2,2]A2[5,3]B23[9,4]C234", tree.AnnotatedString()) + assert.Equal(t, "[2,2]A2[5,3]B23[9,4]C234", tree.StructureAsString()) nodeD := tree.Insert(newSplayNode("D2345")) - assert.Equal(t, "[2,2]A2[5,3]B23[9,4]C234[14,5]D2345", tree.AnnotatedString()) + assert.Equal(t, "[2,2]A2[5,3]B23[9,4]C234[14,5]D2345", tree.StructureAsString()) tree.Splay(nodeB) - assert.Equal(t, "[2,2]A2[14,3]B23[9,4]C234[5,5]D2345", tree.AnnotatedString()) + assert.Equal(t, "[2,2]A2[14,3]B23[9,4]C234[5,5]D2345", tree.StructureAsString()) assert.Equal(t, 0, tree.IndexOf(nodeA)) assert.Equal(t, 2, tree.IndexOf(nodeB)) @@ -88,16 +88,16 @@ func TestSplayTree(t *testing.T) { tree := splay.NewTree[*stringValue](nil) nodeH := tree.Insert(newSplayNode("H")) - assert.Equal(t, "[1,1]H", tree.AnnotatedString()) + assert.Equal(t, "[1,1]H", tree.StructureAsString()) nodeE := tree.Insert(newSplayNode("E")) - assert.Equal(t, "[1,1]H[2,1]E", tree.AnnotatedString()) + assert.Equal(t, "[1,1]H[2,1]E", tree.StructureAsString()) nodeL := tree.Insert(newSplayNode("LL")) - assert.Equal(t, "[1,1]H[2,1]E[4,2]LL", tree.AnnotatedString()) + assert.Equal(t, "[1,1]H[2,1]E[4,2]LL", tree.StructureAsString()) nodeO := tree.Insert(newSplayNode("O")) - assert.Equal(t, "[1,1]H[2,1]E[4,2]LL[5,1]O", tree.AnnotatedString()) + assert.Equal(t, "[1,1]H[2,1]E[4,2]LL[5,1]O", tree.StructureAsString()) tree.Delete(nodeE) - assert.Equal(t, "[4,1]H[3,2]LL[1,1]O", tree.AnnotatedString()) + assert.Equal(t, "[4,1]H[3,2]LL[1,1]O", tree.StructureAsString()) assert.Equal(t, tree.IndexOf(nodeH), 0) assert.Equal(t, tree.IndexOf(nodeE), -1) @@ -113,7 +113,7 @@ func TestSplayTree(t *testing.T) { assert.Equal( t, "[1,1]A[3,2]BB[6,3]CCC[10,4]DDDD[15,5]EEEEE[19,4]FFFF[22,3]GGG[0,0]HH[0,0]I", - tree.AnnotatedString(), + tree.StructureAsString(), ) tree, nodes = makeSampleTree() @@ -123,7 +123,7 @@ func TestSplayTree(t *testing.T) { assert.Equal( t, "[1,1]A[3,2]BB[6,3]CCC[0,0]DDDD[0,0]EEEEE[0,0]FFFF[0,0]GGG[9,2]HH[1,1]I", - tree.AnnotatedString(), + tree.StructureAsString(), ) tree, nodes = makeSampleTree() @@ -135,7 +135,7 @@ func TestSplayTree(t *testing.T) { assert.Equal( t, "[1,1]A[3,2]BB[6,3]CCC[0,0]DDDD[0,0]EEEEE[0,0]FFFF[0,0]GGG[0,0]HH[7,1]I", - tree.AnnotatedString(), + tree.StructureAsString(), ) }) } diff --git a/test/bench/document_bench_test.go b/test/bench/document_bench_test.go index 0570b2092..4f56784a9 100644 --- a/test/bench/document_bench_test.go +++ b/test/bench/document_bench_test.go @@ -140,22 +140,22 @@ func BenchmarkDocument(b *testing.B) { root.SetNewArray("k1").AddInteger(1).AddInteger(2).AddInteger(3) assert.Equal(b, 3, root.GetArray("k1").Len()) assert.Equal(b, `{"k1":[1,2,3]}`, root.Marshal()) - assert.Equal(b, "[0,0]0[1,1]1[2,1]2[3,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(b, "[0,0]0[1,1]1[2,1]2[3,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").Delete(1) assert.Equal(b, `{"k1":[1,3]}`, root.Marshal()) assert.Equal(b, 2, root.GetArray("k1").Len()) - assert.Equal(b, "[0,0]0[1,1]1[2,0]2[1,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(b, "[0,0]0[1,1]1[2,0]2[1,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").InsertIntegerAfter(0, 2) assert.Equal(b, `{"k1":[1,2,3]}`, root.Marshal()) assert.Equal(b, 3, root.GetArray("k1").Len()) - assert.Equal(b, "[0,0]0[1,1]1[3,1]2[1,0]2[1,1]3", root.GetArray("k1").AnnotatedString()) + assert.Equal(b, "[0,0]0[1,1]1[3,1]2[1,0]2[1,1]3", root.GetArray("k1").StructureAsString()) root.GetArray("k1").InsertIntegerAfter(2, 4) assert.Equal(b, `{"k1":[1,2,3,4]}`, root.Marshal()) assert.Equal(b, 4, root.GetArray("k1").Len()) - assert.Equal(b, "[0,0]0[1,1]1[2,1]2[2,0]2[3,1]3[4,1]4", root.GetArray("k1").AnnotatedString()) + assert.Equal(b, "[0,0]0[1,1]1[2,1]2[2,0]2[3,1]3[4,1]4", root.GetArray("k1").StructureAsString()) for i := 0; i < root.GetArray("k1").Len(); i++ { assert.Equal( @@ -193,23 +193,23 @@ func BenchmarkDocument(b *testing.B) { text := root.GetText("k1") assert.Equal(b, "[0:0:00:0 ][1:2:00:0 A][1:3:00:0 12]{1:2:00:1 BC}[1:2:00:3 D]", - text.AnnotatedString(), + text.StructureAsString(), ) from, _ := text.CreateRange(0, 0) - assert.Equal(b, "0:0:00:0:0", from.AnnotatedString()) + assert.Equal(b, "0:0:00:0:0", from.StructureAsString()) from, _ = text.CreateRange(1, 1) - assert.Equal(b, "1:2:00:0:1", from.AnnotatedString()) + assert.Equal(b, "1:2:00:0:1", from.StructureAsString()) from, _ = text.CreateRange(2, 2) - assert.Equal(b, "1:3:00:0:1", from.AnnotatedString()) + assert.Equal(b, "1:3:00:0:1", from.StructureAsString()) from, _ = text.CreateRange(3, 3) - assert.Equal(b, "1:3:00:0:2", from.AnnotatedString()) + assert.Equal(b, "1:3:00:0:2", from.StructureAsString()) from, _ = text.CreateRange(4, 4) - assert.Equal(b, "1:2:00:3:1", from.AnnotatedString()) + assert.Equal(b, "1:2:00:3:1", from.StructureAsString()) return nil }) assert.NoError(b, err) @@ -246,7 +246,7 @@ func BenchmarkDocument(b *testing.B) { assert.Equal( b, `[0:0:00:0 {} ""][1:2:00:0 {} "Hello world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -258,7 +258,7 @@ func BenchmarkDocument(b *testing.B) { text.SetStyle(0, 5, map[string]string{"b": "1"}) assert.Equal(b, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hello"][1:2:00:5 {} " world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -275,14 +275,14 @@ func BenchmarkDocument(b *testing.B) { assert.Equal( b, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hello"][1:2:00:5 {} " world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) text.SetStyle(3, 5, map[string]string{"i": "1"}) assert.Equal( b, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"][1:2:00:5 {} " world"][1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -300,7 +300,7 @@ func BenchmarkDocument(b *testing.B) { b, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"]`+ `[4:1:00:0 {} " Yorkie"]{1:2:00:5 {} " world"}[1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil }) @@ -317,7 +317,7 @@ func BenchmarkDocument(b *testing.B) { assert.Equal( b, `[0:0:00:0 {} ""][1:2:00:0 {"b":"1"} "Hel"][1:2:00:3 {"b":"1","i":"1"} "lo"][5:1:00:0 {"list":"true"} "\n"][4:1:00:0 {} " Yorkie"]{1:2:00:5 {} " world"}[1:1:00:0 {} "\n"]`, - text.AnnotatedString(), + text.StructureAsString(), ) return nil })