aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorborman <borman@yandex-team.com>2023-12-06 18:01:50 +0300
committerborman <borman@yandex-team.com>2023-12-06 20:11:17 +0300
commit129dd7a20d55f0c0cb9de5581603e8e0b9db0da4 (patch)
tree6d90179a43d746e6159d76d5ec18c8b74d60de3b /vendor/github.com
parent8888ab678beb41b8a848e59a491017a8d08fe53f (diff)
downloadydb-129dd7a20d55f0c0cb9de5581603e8e0b9db0da4.tar.gz
Update dns, uuid, websocket for import
* Disable unix domain socket tests in dns (fail under ya make)
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/google/uuid/json_test.go51
-rw-r--r--vendor/github.com/google/uuid/uuid.go26
-rw-r--r--vendor/github.com/google/uuid/uuid_test.go48
-rw-r--r--vendor/github.com/google/uuid/ya.make4
4 files changed, 123 insertions, 6 deletions
diff --git a/vendor/github.com/google/uuid/json_test.go b/vendor/github.com/google/uuid/json_test.go
index 245f91edfb..34241d5f6b 100644
--- a/vendor/github.com/google/uuid/json_test.go
+++ b/vendor/github.com/google/uuid/json_test.go
@@ -31,6 +31,57 @@ func TestJSON(t *testing.T) {
}
}
+func TestJSONUnmarshal(t *testing.T) {
+ type S struct {
+ ID1 UUID
+ ID2 UUID `json:"ID2,omitempty"`
+ }
+
+ testCases := map[string]struct {
+ data []byte
+ expectedError error
+ expectedResult UUID
+ }{
+ "success": {
+ data: []byte(`{"ID1": "f47ac10b-58cc-0372-8567-0e02b2c3d479"}`),
+ expectedError: nil,
+ expectedResult: testUUID,
+ },
+ "zero": {
+ data: []byte(`{"ID1": "00000000-0000-0000-0000-000000000000"}`),
+ expectedError: nil,
+ expectedResult: Nil,
+ },
+ "null": {
+ data: []byte(`{"ID1": null}`),
+ expectedError: nil,
+ expectedResult: Nil,
+ },
+ "empty": {
+ data: []byte(`{"ID1": ""}`),
+ expectedError: invalidLengthError{len: 0},
+ expectedResult: Nil,
+ },
+ "omitempty": {
+ data: []byte(`{"ID2": ""}`),
+ expectedError: invalidLengthError{len: 0},
+ expectedResult: Nil,
+ },
+ }
+
+ for name, tc := range testCases {
+ t.Run(name, func(t *testing.T) {
+ var s S
+ if err := json.Unmarshal(tc.data, &s); err != tc.expectedError {
+ t.Errorf("unexpected error: got %v, want %v", err, tc.expectedError)
+ }
+ if !reflect.DeepEqual(s.ID1, tc.expectedResult) {
+ t.Errorf("got %#v, want %#v", s.ID1, tc.expectedResult)
+ }
+ })
+ }
+}
+
func BenchmarkUUID_MarshalJSON(b *testing.B) {
x := &struct {
UUID UUID `json:"uuid"`
diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go
index a56138cc4b..dc75f7d990 100644
--- a/vendor/github.com/google/uuid/uuid.go
+++ b/vendor/github.com/google/uuid/uuid.go
@@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool {
return ok
}
-// Parse decodes s into a UUID or returns an error. Both the standard UUID
-// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
-// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the
-// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex
-// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
+// Parse decodes s into a UUID or returns an error if it cannot be parsed. Both
+// the standard UUID forms defined in RFC 4122
+// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
+// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are decoded. In addition,
+// Parse accepts non-standard strings such as the raw hex encoding
+// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and 38 byte "Microsoft style" encodings,
+// e.g. {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. Only the middle 36 bytes are
+// examined in the latter case. Parse should not be used to validate strings as
+// it parses non-standard encodings as indicated above.
func Parse(s string) (UUID, error) {
var uuid UUID
switch len(s) {
@@ -294,3 +298,15 @@ func DisableRandPool() {
poolMu.Lock()
poolPos = randPoolSize
}
+
+// UUIDs is a slice of UUID types.
+type UUIDs []UUID
+
+// Strings returns a string slice containing the string form of each UUID in uuids.
+func (uuids UUIDs) Strings() []string {
+ var uuidStrs = make([]string, len(uuids))
+ for i, uuid := range uuids {
+ uuidStrs[i] = uuid.String()
+ }
+ return uuidStrs
+}
diff --git a/vendor/github.com/google/uuid/uuid_test.go b/vendor/github.com/google/uuid/uuid_test.go
index e98d0fe03c..6f22e8a611 100644
--- a/vendor/github.com/google/uuid/uuid_test.go
+++ b/vendor/github.com/google/uuid/uuid_test.go
@@ -569,6 +569,39 @@ func TestIsWrongLength(t *testing.T) {
}
}
+func FuzzParse(f *testing.F) {
+ for _, tt := range tests {
+ f.Add(tt.in)
+ f.Add(strings.ToUpper(tt.in))
+ }
+ f.Fuzz(func(t *testing.T, in string) {
+ Parse(in)
+ })
+}
+
+func FuzzParseBytes(f *testing.F) {
+ for _, tt := range tests {
+ f.Add([]byte(tt.in))
+ }
+ f.Fuzz(func(t *testing.T, in []byte) {
+ ParseBytes(in)
+ })
+}
+
+func FuzzFromBytes(f *testing.F) {
+ // Copied from TestFromBytes.
+ f.Add([]byte{
+ 0x7d, 0x44, 0x48, 0x40,
+ 0x9d, 0xc0,
+ 0x11, 0xd1,
+ 0xb2, 0x45,
+ 0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2,
+ })
+ f.Fuzz(func(t *testing.T, in []byte) {
+ FromBytes(in)
+ })
+}
+
var asString = "f47ac10b-58cc-0372-8567-0e02b2c3d479"
var asBytes = []byte(asString)
@@ -700,3 +733,18 @@ func BenchmarkUUID_NewPooled(b *testing.B) {
}
})
}
+
+func BenchmarkUUIDs_Strings(b *testing.B) {
+ uuid1, err := Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if err != nil {
+ b.Fatal(err)
+ }
+ uuid2, err := Parse("7d444840-9dc0-11d1-b245-5ffdce74fad2")
+ if err != nil {
+ b.Fatal(err)
+ }
+ uuids := UUIDs{uuid1, uuid2}
+ for i := 0; i < b.N; i++ {
+ uuids.Strings()
+ }
+}
diff --git a/vendor/github.com/google/uuid/ya.make b/vendor/github.com/google/uuid/ya.make
index f67602547c..c00c7821da 100644
--- a/vendor/github.com/google/uuid/ya.make
+++ b/vendor/github.com/google/uuid/ya.make
@@ -28,4 +28,6 @@ GO_TEST_SRCS(
END()
-RECURSE(gotest)
+RECURSE(
+ gotest
+)