| 1 | // Copyright 2021 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package runesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/ |
| 16 | |
| 17 | import ( |
| 18 | "testingscip-go gomod github.com/golang/go/src go1.23.0 testing/" |
| 19 | "unicode/utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/" |
| 20 | ) |
| 21 | |
| 22 | func TestNewBuffer_ASCIIscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/TestNewBuffer_ASCII().(t *testingscip-go gomod github.com/golang/go/src go1.23.0 testing/.Tscip-go gomod github.com/golang/go/src go1.23.0 testing/T#) { |
| 23 | data := "hello world!" |
| 24 | rb := NewBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/NewBuffer().(data) |
| 25 | if got, want := rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.(), utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/RuneCountInString().(data); got != want { |
| 26 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("length mismatch: got %d, want %d", got, want) |
| 27 | } |
| 28 | if got, want := rb.Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Slice.(0, rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.()), data; got != want { |
| 29 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("slice mismatch: got %q, want %q", got, want) |
| 30 | } |
| 31 | if got, want := rb.Getscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Get.(8), rune('r'); got != want { |
| 32 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("rune mismatch: got %U, want %U", got, want) |
| 33 | } |
| 34 | if _, ok := rb.(*asciiBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/asciiBuffer#); !ok { |
| 35 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("type mismatch: got %T, want %T", rb, &asciiBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/asciiBuffer#{}) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func TestNewBuffer_Basicscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/TestNewBuffer_Basic().(t *testingscip-go gomod github.com/golang/go/src go1.23.0 testing/.Tscip-go gomod github.com/golang/go/src go1.23.0 testing/T#) { |
| 40 | data := "hello w\u04E7rld!" |
| 41 | rb := NewBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/NewBuffer().(data) |
| 42 | if got, want := rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.(), utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/RuneCountInString().(data); got != want { |
| 43 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("length mismatch: got %d, want %d", got, want) |
| 44 | } |
| 45 | if got, want := rb.Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Slice.(0, rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.()), data; got != want { |
| 46 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("slice mismatch: got %q, want %q", got, want) |
| 47 | } |
| 48 | if got, want := rb.Getscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Get.(8), rune('r'); got != want { |
| 49 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("rune mismatch: got %U, want %U", got, want) |
| 50 | } |
| 51 | if _, ok := rb.(*basicBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/basicBuffer#); !ok { |
| 52 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("type mismatch: got %T, want %T", rb, &basicBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/basicBuffer#{}) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestNewBuffer_Supplementalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/TestNewBuffer_Supplemental().(t *testingscip-go gomod github.com/golang/go/src go1.23.0 testing/.Tscip-go gomod github.com/golang/go/src go1.23.0 testing/T#) { |
| 57 | data := "hello w\U0001F642rld!" |
| 58 | rb := NewBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/NewBuffer().(data) |
| 59 | if got, want := rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.(), utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/RuneCountInString().(data); got != want { |
| 60 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("length mismatch: got %d, want %d", got, want) |
| 61 | } |
| 62 | if got, want := rb.Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Slice.(0, rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.()), data; got != want { |
| 63 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("slice mismatch: got %q, want %q", got, want) |
| 64 | } |
| 65 | if got, want := rb.Getscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Get.(8), rune('r'); got != want { |
| 66 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("rune mismatch: got %U, want %U", got, want) |
| 67 | } |
| 68 | if _, ok := rb.(*supplementalBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/supplementalBuffer#); !ok { |
| 69 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("type mismatch: got %T, want %T", rb, &supplementalBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/supplementalBuffer#{}) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestNewBuffer_Allscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/TestNewBuffer_All().(t *testingscip-go gomod github.com/golang/go/src go1.23.0 testing/.Tscip-go gomod github.com/golang/go/src go1.23.0 testing/T#) { |
| 74 | data := "hell\u04E7 w\U0001F642rld!" |
| 75 | rb := NewBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/NewBuffer().(data) |
| 76 | if got, want := rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.(), utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/RuneCountInString().(data); got != want { |
| 77 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("length mismatch: got %d, want %d", got, want) |
| 78 | } |
| 79 | if got, want := rb.Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Slice.(0, rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.()), data; got != want { |
| 80 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("slice mismatch: got %q, want %q", got, want) |
| 81 | } |
| 82 | if got, want := rb.Getscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Get.(8), rune('r'); got != want { |
| 83 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("rune mismatch: got %U, want %U", got, want) |
| 84 | } |
| 85 | if _, ok := rb.(*supplementalBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/supplementalBuffer#); !ok { |
| 86 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("type mismatch: got %T, want %T", rb, &supplementalBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/supplementalBuffer#{}) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TestNewBuffer_Emptyscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/TestNewBuffer_Empty().(t *testingscip-go gomod github.com/golang/go/src go1.23.0 testing/.Tscip-go gomod github.com/golang/go/src go1.23.0 testing/T#) { |
| 91 | data := "" |
| 92 | rb := NewBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/NewBuffer().(data) |
| 93 | if got, want := rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.(), utf8scip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/.RuneCountInStringscip-go gomod github.com/golang/go/src go1.23.0 `unicode/utf8`/RuneCountInString().(data); got != want { |
| 94 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("length mismatch: got %d, want %d", got, want) |
| 95 | } |
| 96 | if got, want := rb.Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Slice.(0, rb.Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/Buffer#Len.()), data; got != want { |
| 97 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("slice mismatch: got %q, want %q", got, want) |
| 98 | } |
| 99 | if _, ok := rb.(*emptyBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/emptyBuffer#); !ok { |
| 100 | t.Errorfscip-go gomod github.com/golang/go/src go1.23.0 testing/common#Errorf().("type mismatch: got %T, want %T", rb, &emptyBufferscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/runes`/emptyBuffer#{}) |
| 101 | } |
| 102 | } |