mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
avoid infinite loop in next uuid generation
This commit is contained in:
parent
242624de96
commit
ca71c0300f
@ -47,6 +47,7 @@ func (this *UUID) Next() *UUID {
|
|||||||
if !newid.Equals(this) {
|
if !newid.Equals(this) {
|
||||||
return newid
|
return newid
|
||||||
}
|
}
|
||||||
|
md5hash.Write([]byte("533eff8a-4113-4b10-b5ce-0f5d76b98cd2"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,3 +50,12 @@ func TestRandom(t *testing.T) {
|
|||||||
assert.StringLiteral(uuid.String()).NotEquals(uuid2.String())
|
assert.StringLiteral(uuid.String()).NotEquals(uuid2.String())
|
||||||
assert.Bytes(uuid.Bytes()).NotEquals(uuid2.Bytes())
|
assert.Bytes(uuid.Bytes()).NotEquals(uuid2.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEquals(t *testing.T) {
|
||||||
|
v2testing.Current(t)
|
||||||
|
|
||||||
|
var uuid *UUID = nil
|
||||||
|
var uuid2 *UUID = nil
|
||||||
|
assert.Bool(uuid.Equals(uuid2)).IsTrue()
|
||||||
|
assert.Bool(uuid.Equals(New())).IsFalse()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user