| 1 | // Copyright 2017 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package editscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/ |
| 6 | |
| 7 | import "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 8 | |
| 9 | func TestEditscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/TestEdit().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 10 | b := NewBufferscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/NewBuffer().([]byte("0123456789")) |
| 11 | b.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Insert().(8, ",7½,") |
| 12 | b.Replacescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Replace().(9, 10, "the-end") |
| 13 | b.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Insert().(10, "!") |
| 14 | b.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Insert().(4, "3.14,") |
| 15 | b.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Insert().(4, "π,") |
| 16 | b.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Insert().(4, "3.15,") |
| 17 | b.Replacescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Replace().(3, 4, "three,") |
| 18 | want := "012three,3.14,π,3.15,4567,7½,8the-end!" |
| 19 | |
| 20 | s := b.Stringscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#String().() |
| 21 | if s != want { |
| 22 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("b.String() = %q, want %q", s, want) |
| 23 | } |
| 24 | sb := b.Bytesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/edit`/Buffer#Bytes().() |
| 25 | if string(sb) != want { |
| 26 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("b.Bytes() = %q, want %q", sb, want) |
| 27 | } |
| 28 | } |