Skip to content

Commit

Permalink
Merge pull request #26 from gochore/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre authored Oct 14, 2020
2 parents acfaeee + 9be15ab commit 7cee8a4
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/generate/gen_x_seq.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,10 @@ func (s *{{.Name}}Seq) Trim(fn func(i int, v {{.Name}}) bool) error {
}
return nil
}

func (s *{{.Name}}Seq) Clone() *{{.Name}}Seq {
if s == nil {
return nil
}
return new{{.Name}}Seq(s.slice)
}
30 changes: 30 additions & 0 deletions cmd/generate/gen_x_seq_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,33 @@ func Test{{.Name}}Seq_Trim(t *testing.T) {
})
}
}

func Test{{.Name}}Seq_Clone(t *testing.T) {
data := Random{{.Name}}s(10)
Sort(data)
tests := []struct {
name string
seq *{{.Name}}Seq
want *{{.Name}}Seq
}{
{
name: "regular",
seq: New{{.Name}}Seq(data),
want: &{{.Name}}Seq{
slice: data,
},
},
{
name: "nil",
seq: nil,
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.seq.Clone(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Clone() = %v, want %v", got, tt.want)
}
})
}
}
7 changes: 7 additions & 0 deletions gen_float64_seq.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions gen_float64_seq_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions gen_int64_seq.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions gen_int64_seq_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions gen_int_seq.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions gen_int_seq_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions gen_uint64_seq.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions gen_uint64_seq_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7cee8a4

Please sign in to comment.