| 1 | // Copyright (C) 2013-2018 by Maxim Bublis <[email protected]> |
| 2 | // |
| 3 | // Permission is hereby granted, free of charge, to any person obtaining |
| 4 | // a copy of this software and associated documentation files (the |
| 5 | // "Software"), to deal in the Software without restriction, including |
| 6 | // without limitation the rights to use, copy, modify, merge, publish, |
| 7 | // distribute, sublicense, and/or sell copies of the Software, and to |
| 8 | // permit persons to whom the Software is furnished to do so, subject to |
| 9 | // the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be |
| 12 | // included in all copies or substantial portions of the Software. |
| 13 | // |
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 15 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 18 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 19 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 20 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | package uuidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/ |
| 23 | |
| 24 | import ( |
| 25 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/" |
| 26 | "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 27 | "testingscip-go gomod github.com/golang/go/src go1.25 testing/" |
| 28 | ) |
| 29 | |
| 30 | func TestSQLscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestSQL().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 31 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Value", testSQLValuescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLValue().) |
| 32 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Scan", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 33 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Binary", testSQLScanBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanBinary().) |
| 34 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("String", testSQLScanStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanString().) |
| 35 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Text", testSQLScanTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanText().) |
| 36 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Unsupported", testSQLScanUnsupportedscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanUnsupported().) |
| 37 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Nil", testSQLScanNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanNil().) |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | func testSQLValuescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLValue().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 42 | v, err := codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..Valuescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Value().() |
| 43 | if err != nil { |
| 44 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 45 | } |
| 46 | got, ok := v.(string) |
| 47 | if !ok { |
| 48 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("Value() returned %T, want string", v) |
| 49 | } |
| 50 | if want := codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID..Stringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#String().(); got != want { |
| 51 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Value() == %q, want %q", got, want) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func testSQLScanBinaryscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanBinary().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 56 | got := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{} |
| 57 | err := got.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Scan().(codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData.) |
| 58 | if err != nil { |
| 59 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 60 | } |
| 61 | if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 62 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Scan(%x): got %v, want %v", codecTestDatascip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestData., got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func testSQLScanStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanString().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 67 | s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" |
| 68 | got := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{} |
| 69 | err := got.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Scan().(s) |
| 70 | if err != nil { |
| 71 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 72 | } |
| 73 | if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 74 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Scan(%q): got %v, want %v", s, got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func testSQLScanTextscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanText().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 79 | text := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") |
| 80 | got := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{} |
| 81 | err := got.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Scan().(text) |
| 82 | if err != nil { |
| 83 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 84 | } |
| 85 | if got != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 86 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Scan(%q): got %v, want %v", text, got, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func testSQLScanUnsupportedscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanUnsupported().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 91 | unsupported := []any{ |
| 92 | true, |
| 93 | 42, |
| 94 | } |
| 95 | for _, v := range unsupported { |
| 96 | got := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{} |
| 97 | err := got.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Scan().(v) |
| 98 | if err == nil { |
| 99 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Scan(%T) succeeded, got %v", v, got) |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func testSQLScanNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testSQLScanNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 105 | got := UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#{} |
| 106 | err := got.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/UUID#Scan().(nil) |
| 107 | if err == nil { |
| 108 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Scan(nil) succeeded, got %v", got) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestNullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/TestNullUUID().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 113 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Value", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 114 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Nil", testNullUUIDValueNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDValueNil().) |
| 115 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", testNullUUIDValueValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDValueValid().) |
| 116 | }) |
| 117 | |
| 118 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Scan", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 119 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Nil", testNullUUIDScanNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanNil().) |
| 120 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", testNullUUIDScanValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanValid().) |
| 121 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("UUID", testNullUUIDScanUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanUUID().) |
| 122 | }) |
| 123 | |
| 124 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("MarshalJSON", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 125 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Nil", testNullUUIDMarshalJSONNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONNil().) |
| 126 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Null", testNullUUIDMarshalJSONNullscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONNull().) |
| 127 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", testNullUUIDMarshalJSONValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONValid().) |
| 128 | }) |
| 129 | |
| 130 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("UnmarshalJSON", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 131 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Nil", testNullUUIDUnmarshalJSONNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONNil().) |
| 132 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Null", testNullUUIDUnmarshalJSONNullscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONNull().) |
| 133 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Valid", testNullUUIDUnmarshalJSONValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONValid().) |
| 134 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("Malformed", testNullUUIDUnmarshalJSONMalformedscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONMalformed().) |
| 135 | }) |
| 136 | } |
| 137 | |
| 138 | func testNullUUIDValueNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDValueNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 139 | nu := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{} |
| 140 | got, err := nu.Valuescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Value().() |
| 141 | if got != nil { |
| 142 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("null NullUUID.Value returned non-nil driver.Value") |
| 143 | } |
| 144 | if err != nil { |
| 145 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("null NullUUID.Value returned non-nil error") |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func testNullUUIDValueValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDValueValid().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 150 | nu := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{ |
| 151 | Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid.: true, |
| 152 | UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID.: codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., |
| 153 | } |
| 154 | got, err := nu.Valuescip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Value().() |
| 155 | if err != nil { |
| 156 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 157 | } |
| 158 | s, ok := got.(string) |
| 159 | if !ok { |
| 160 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Value() returned %T, want string", got) |
| 161 | } |
| 162 | want := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" |
| 163 | if s != want { |
| 164 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("%v.Value() == %s, want %s", nu, s, want) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | func testNullUUIDScanNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 169 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{} |
| 170 | err := u.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Scan().(nil) |
| 171 | if err != nil { |
| 172 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 173 | } |
| 174 | if u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 175 | t.Errorscip-go gomod github.com/golang/go/src go1.25 testing/common#Error().("NullUUID is valid after Scan(nil)") |
| 176 | } |
| 177 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. { |
| 178 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("NullUUID.UUID is %v after Scan(nil) want Nil", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID.) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | func testNullUUIDScanValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanValid().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 183 | s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" |
| 184 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{} |
| 185 | err := u.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Scan().(s) |
| 186 | if err != nil { |
| 187 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 188 | } |
| 189 | if !u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 190 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Valid == false after Scan(%q)", s) |
| 191 | } |
| 192 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 193 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("UUID == %v after Scan(%q), want %v", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID., s, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | func testNullUUIDScanUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDScanUUID().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 198 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{} |
| 199 | err := u.Scanscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Scan().(codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 200 | if err != nil { |
| 201 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 202 | } |
| 203 | if !u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 204 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("Valid == false after scan(%v)", codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 205 | } |
| 206 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 207 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("UUID == %v after Scan(%v), want %v", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID., codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | func testNullUUIDMarshalJSONNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 212 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid.: true} |
| 213 | |
| 214 | data, err := u.MarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#MarshalJSON().() |
| 215 | if err != nil { |
| 216 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON err want: <nil>, got: %v", u, err) |
| 217 | } |
| 218 | |
| 219 | dataStr := string(data) |
| 220 | |
| 221 | if dataStr != fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%q", Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil.) { |
| 222 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON value want: %s, got: %s", u, Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil., dataStr) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func testNullUUIDMarshalJSONValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONValid().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 227 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{ |
| 228 | Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid.: true, |
| 229 | UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID.: codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., |
| 230 | } |
| 231 | |
| 232 | data, err := u.MarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#MarshalJSON().() |
| 233 | if err != nil { |
| 234 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON err want: <nil>, got: %v", u, err) |
| 235 | } |
| 236 | |
| 237 | dataStr := string(data) |
| 238 | |
| 239 | if dataStr != fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%q", codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID.) { |
| 240 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON value want: %s, got: %s", u, codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID., dataStr) |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | func testNullUUIDMarshalJSONNullscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDMarshalJSONNull().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 245 | u := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{} |
| 246 | |
| 247 | data, err := u.MarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#MarshalJSON().() |
| 248 | if err != nil { |
| 249 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON err want: <nil>, got: %v", u, err) |
| 250 | } |
| 251 | |
| 252 | dataStr := string(data) |
| 253 | |
| 254 | if dataStr != "null" { |
| 255 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("(%#v).MarshalJSON value want: %s, got: %s", u, "null", dataStr) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | func testNullUUIDUnmarshalJSONNilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONNil().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 260 | var u NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 261 | |
| 262 | data := []byte(`"00000000-0000-0000-0000-000000000000"`) |
| 263 | |
| 264 | if err := jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/Unmarshal().(data, &u); err != nil { |
| 265 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("json.Unmarshal err = %v, want <nil>", err) |
| 266 | } |
| 267 | |
| 268 | if !u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 269 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.Valid = false, want true") |
| 270 | } |
| 271 | |
| 272 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. { |
| 273 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.UUID = %v, want %v", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID., Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil.) |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | func testNullUUIDUnmarshalJSONNullscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONNull().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 278 | var u NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 279 | |
| 280 | data := []byte(`null`) |
| 281 | |
| 282 | if err := jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/Unmarshal().(data, &u); err != nil { |
| 283 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("json.Unmarshal err = %v, want <nil>", err) |
| 284 | } |
| 285 | |
| 286 | if u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 287 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.Valid = true, want false") |
| 288 | } |
| 289 | |
| 290 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil. { |
| 291 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.UUID = %v, want %v", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID., Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil.) |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | func testNullUUIDUnmarshalJSONValidscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONValid().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 296 | var u NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 297 | |
| 298 | data := []byte(`"6ba7b810-9dad-11d1-80b4-00c04fd430c8"`) |
| 299 | |
| 300 | if err := jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/Unmarshal().(data, &u); err != nil { |
| 301 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("json.Unmarshal err = %v, want <nil>", err) |
| 302 | } |
| 303 | |
| 304 | if !u.Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid. { |
| 305 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.Valid = false, want true") |
| 306 | } |
| 307 | |
| 308 | if u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID. != codecTestUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/codecTestUUID. { |
| 309 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("u.UUID = %v, want %v", u.UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID., Nilscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/Nil.) |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | func testNullUUIDUnmarshalJSONMalformedscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/testNullUUIDUnmarshalJSONMalformed().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 314 | var u NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 315 | |
| 316 | data := []byte(`257`) |
| 317 | |
| 318 | if err := jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/Unmarshal().(data, &u); err == nil { |
| 319 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("json.Unmarshal err = <nil>, want error") |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | func BenchmarkNullMarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkNullMarshalJSON().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 324 | b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("Valid", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 325 | u, err := FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("6ba7b810-9dad-11d1-80b4-00c04fd430c8") |
| 326 | if err != nil { |
| 327 | b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 328 | } |
| 329 | n := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{UUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UUID.: u, Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid.: true} |
| 330 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N.; i++ { |
| 331 | _, _ = n.MarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#MarshalJSON().() |
| 332 | } |
| 333 | }) |
| 334 | b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("Invalid", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 335 | n := NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#{Validscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#Valid.: false} |
| 336 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N.; i++ { |
| 337 | _, _ = n.MarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#MarshalJSON().() |
| 338 | } |
| 339 | }) |
| 340 | } |
| 341 | |
| 342 | func BenchmarkNullUnmarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/BenchmarkNullUnmarshalJSON().(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 343 | baseUUID, err := FromStringscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/FromString().("6ba7b810-9dad-11d1-80b4-00c04fd430c8") |
| 344 | if err != nil { |
| 345 | b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 346 | } |
| 347 | data, err := jsonscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.25 `encoding/json`/Marshal().(&baseUUID) |
| 348 | if err != nil { |
| 349 | b.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err) |
| 350 | } |
| 351 | |
| 352 | b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("Valid", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 353 | var u NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 354 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N.; i++ { |
| 355 | _ = u.UnmarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UnmarshalJSON().(data) |
| 356 | } |
| 357 | }) |
| 358 | b.Runscip-go gomod github.com/golang/go/src go1.25 testing/B#Run().("Invalid", func(b *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Bscip-go gomod github.com/golang/go/src go1.25 testing/B#) { |
| 359 | invalid := []byte("null") |
| 360 | var n NullUUIDscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID# |
| 361 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25 testing/B#N.; i++ { |
| 362 | _ = n.UnmarshalJSONscip-go gomod github.com/gofrs/uuid/v5 . `github.com/gofrs/uuid/v5`/NullUUID#UnmarshalJSON().(invalid) |
| 363 | } |
| 364 | }) |
| 365 | } |