github.com/blong14/gache@v0.0.0-20240124023949-89416fd8bbfa/internal/arena/allocator_test.go (about) 1 package arena 2 3 import ( 4 "reflect" 5 "testing" 6 7 ga "arena" 8 ) 9 10 func Test_arena_AllocateByteSlice(t *testing.T) { 11 type fields struct { 12 malloc Arena 13 } 14 type args struct { 15 len_ int 16 cap int 17 } 18 tests := []struct { 19 name string 20 fields fields 21 args args 22 want []byte 23 }{ 24 { 25 name: "should create a byte slice", 26 fields: fields{malloc: NewArena()}, 27 args: args{len_: 3, cap: 10}, 28 want: []byte{'a', 'a', 'a'}, 29 }, 30 } 31 for _, tt := range tests { 32 t.Run(tt.name, func(t *testing.T) { 33 got := tt.fields.malloc.AllocateByteSlice(tt.args.len_, tt.args.cap) 34 for i := 0; i < tt.args.len_; i++ { 35 got[i] = byte('a') 36 } 37 if !reflect.DeepEqual(got, tt.want) { 38 t.Errorf("AllocateByteSlice() = %v, want %v", got, tt.want) 39 } 40 }) 41 } 42 } 43 44 func Test_arena_Free(t *testing.T) { 45 type fields struct { 46 malloc *ga.Arena 47 } 48 tests := []struct { 49 name string 50 fields fields 51 }{ 52 // TODO: Add test cases. 53 } 54 for _, tt := range tests { 55 t.Run(tt.name, func(t *testing.T) { 56 a := &arena{ 57 malloc: tt.fields.malloc, 58 } 59 a.Free() 60 }) 61 } 62 }