| 278 | } |
| 279 | |
| 280 | func TestCoding(t *testing.T) { |
| 281 | text := "7d444840-9dc0-11d1-b245-5ffdce74fad2" |
| 282 | urn := "urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2" |
| 283 | data := UUID{ |
| 284 | 0x7d, 0x44, 0x48, 0x40, |
| 285 | 0x9d, 0xc0, |
| 286 | 0x11, 0xd1, |
| 287 | 0xb2, 0x45, |
| 288 | 0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2, |
| 289 | } |
| 290 | if v := data.String(); v != text { |
| 291 | t.Errorf("%x: encoded to %s, expected %s", data, v, text) |
| 292 | } |
| 293 | if v := data.URN(); v != urn { |
| 294 | t.Errorf("%x: urn is %s, expected %s", data, v, urn) |
| 295 | } |
| 296 | |
| 297 | uuid, err := Parse(text) |
| 298 | if err != nil { |
| 299 | t.Errorf("Parse returned unexpected error %v", err) |
| 300 | } |
| 301 | if data != uuid { |
| 302 | t.Errorf("%s: decoded to %s, expected %s", text, uuid, data) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | func TestVersion1(t *testing.T) { |
| 307 | uuid1, err := NewUUID() |