Skip to content

Commit 14f87be

Browse files
committed
feat: shortcat arrylist in arrayx
1 parent 65f2a98 commit 14f87be

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

arrayx/list.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2022, OpeningO
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package arrayx
19+
20+
import "github.com/openingo/godkits/gox/containerx/listx"
21+
22+
// List shortcut from listx.ArrayList
23+
type List struct {
24+
listx.Arraylist
25+
}

arrayx/list_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2022, OpeningO
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package arrayx
19+
20+
import "testing"
21+
22+
func Test(t *testing.T) {
23+
lst := List{}
24+
lst.Add("hello", "world")
25+
26+
tests := []struct {
27+
name string
28+
lst List
29+
want int
30+
}{
31+
{
32+
lst: lst,
33+
want: 2,
34+
},
35+
}
36+
for _, test := range tests {
37+
t.Run(test.name, func(t *testing.T) {
38+
lst := &List{}
39+
lst.Add("hello", "world")
40+
if got := lst.Size(); got != test.want {
41+
t.Errorf("Size() = %v, want %v", got, test.want)
42+
}
43+
})
44+
}
45+
}

0 commit comments

Comments
 (0)