@@ -300,7 +300,7 @@ func TestNode(t *testing.T) {
300300 t .Error ("nodeid is all zeros" )
301301 }
302302
303- id := []byte {1 ,2 , 3 , 4 , 5 , 6 , 7 , 8 }
303+ id := []byte {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 }
304304 SetNodeID (id )
305305 ni = NodeID ()
306306 if ! bytes .Equal (ni , id [:6 ]) {
@@ -431,6 +431,40 @@ func TestBadRand(t *testing.T) {
431431 }
432432}
433433
434+ func TestUUID_Array (t * testing.T ) {
435+ expect := Array {
436+ 0xf4 , 0x7a , 0xc1 , 0x0b ,
437+ 0x58 , 0xcc ,
438+ 0x03 , 0x72 ,
439+ 0x85 , 0x67 ,
440+ 0x0e , 0x02 , 0xb2 , 0xc3 , 0xd4 , 0x79 ,
441+ }
442+ uuid := Parse ("f47ac10b-58cc-0372-8567-0e02b2c3d479" )
443+ if uuid == nil {
444+ t .Fatal ("invalid uuid" )
445+ }
446+ if uuid .Array () != expect {
447+ t .Fatal ("invalid array" )
448+ }
449+ }
450+
451+ func TestArray_UUID (t * testing.T ) {
452+ array := Array {
453+ 0xf4 , 0x7a , 0xc1 , 0x0b ,
454+ 0x58 , 0xcc ,
455+ 0x03 , 0x72 ,
456+ 0x85 , 0x67 ,
457+ 0x0e , 0x02 , 0xb2 , 0xc3 , 0xd4 , 0x79 ,
458+ }
459+ expect := Parse ("f47ac10b-58cc-0372-8567-0e02b2c3d479" )
460+ if expect == nil {
461+ t .Fatal ("invalid uuid" )
462+ }
463+ if ! bytes .Equal (array .UUID (), expect ) {
464+ t .Fatal ("invalid uuid" )
465+ }
466+ }
467+
434468func BenchmarkParse (b * testing.B ) {
435469 for i := 0 ; i < b .N ; i ++ {
436470 uuid := Parse ("f47ac10b-58cc-0372-8567-0e02b2c3d479" )
@@ -469,3 +503,41 @@ func BenchmarkUUID_URN(b *testing.B) {
469503 }
470504 }
471505}
506+
507+ func BenchmarkUUID_Array (b * testing.B ) {
508+ expect := Array {
509+ 0xf4 , 0x7a , 0xc1 , 0x0b ,
510+ 0x58 , 0xcc ,
511+ 0x03 , 0x72 ,
512+ 0x85 , 0x67 ,
513+ 0x0e , 0x02 , 0xb2 , 0xc3 , 0xd4 , 0x79 ,
514+ }
515+ uuid := Parse ("f47ac10b-58cc-0372-8567-0e02b2c3d479" )
516+ if uuid == nil {
517+ b .Fatal ("invalid uuid" )
518+ }
519+ for i := 0 ; i < b .N ; i ++ {
520+ if uuid .Array () != expect {
521+ b .Fatal ("invalid array" )
522+ }
523+ }
524+ }
525+
526+ func BenchmarkArray_UUID (b * testing.B ) {
527+ array := Array {
528+ 0xf4 , 0x7a , 0xc1 , 0x0b ,
529+ 0x58 , 0xcc ,
530+ 0x03 , 0x72 ,
531+ 0x85 , 0x67 ,
532+ 0x0e , 0x02 , 0xb2 , 0xc3 , 0xd4 , 0x79 ,
533+ }
534+ expect := Parse ("f47ac10b-58cc-0372-8567-0e02b2c3d479" )
535+ if expect == nil {
536+ b .Fatal ("invalid uuid" )
537+ }
538+ for i := 0 ; i < b .N ; i ++ {
539+ if ! bytes .Equal (array .UUID (), expect ) {
540+ b .Fatal ("invalid uuid" )
541+ }
542+ }
543+ }
0 commit comments