Skip to content

Commit 193afc3

Browse files
committed
Write Contains, IndexOf & LastIndexOf predicate tests for LazyBuilder and ChainBuilder
1 parent 73a8fa1 commit 193afc3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

chain_builder_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ func TestChainContains(t *testing.T) {
440440
In: []string{"foo", "bar"},
441441
Contains: "bar",
442442
},
443+
{
444+
In: []string{"foo", "bar"},
445+
Contains: func (value string) bool {
446+
return value == "bar"
447+
},
448+
},
443449
{
444450
In: results,
445451
Contains: f,
@@ -468,6 +474,12 @@ func TestChainContains(t *testing.T) {
468474
In: map[int]*Foo{1: f, 3: c},
469475
Contains: 2,
470476
},
477+
{
478+
In: map[int]*Foo{1: f, 3: c},
479+
Contains: func (key int, foo *Foo) bool {
480+
return key == 3 && foo.FirstName == "Harald"
481+
},
482+
},
471483
}
472484

473485
for idx, tc := range testCases {
@@ -759,6 +771,12 @@ func TestChainIndexOf(t *testing.T) {
759771
In: []string{"foo", "bar"},
760772
Item: "bar",
761773
},
774+
{
775+
In: []string{"foo", "bar"},
776+
Item: func (value string) bool {
777+
return value == "bar"
778+
},
779+
},
762780
{
763781
In: results,
764782
Item: f,
@@ -837,6 +855,12 @@ func TestChainLastIndexOf(t *testing.T) {
837855
In: []string{"foo", "bar", "bar"},
838856
Item: "bar",
839857
},
858+
{
859+
In: []string{"foo", "bar", "bar"},
860+
Item: func (value string) bool {
861+
return value == "bar"
862+
},
863+
},
840864
{
841865
In: []int{1, 2, 2, 3},
842866
Item: 2,

lazy_builder_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ func TestLazyContains(t *testing.T) {
440440
In: []string{"foo", "bar"},
441441
Contains: "bar",
442442
},
443+
{
444+
In: []string{"foo", "bar"},
445+
Contains: func (value string) bool {
446+
return value == "bar"
447+
},
448+
},
443449
{
444450
In: results,
445451
Contains: f,
@@ -468,6 +474,12 @@ func TestLazyContains(t *testing.T) {
468474
In: map[int]*Foo{1: f, 3: c},
469475
Contains: 2,
470476
},
477+
{
478+
In: map[int]*Foo{1: f, 3: c},
479+
Contains: func (key int, foo *Foo) bool {
480+
return key == 3 && foo.FirstName == "Harald"
481+
},
482+
},
471483
}
472484

473485
for idx, tc := range testCases {
@@ -759,6 +771,12 @@ func TestLazyIndexOf(t *testing.T) {
759771
In: []string{"foo", "bar"},
760772
Item: "bar",
761773
},
774+
{
775+
In: []string{"foo", "bar"},
776+
Item: func (value string) bool {
777+
return value == "bar"
778+
},
779+
},
762780
{
763781
In: results,
764782
Item: f,
@@ -837,6 +855,12 @@ func TestLazyLastIndexOf(t *testing.T) {
837855
In: []string{"foo", "bar", "bar"},
838856
Item: "bar",
839857
},
858+
{
859+
In: []string{"foo", "bar", "bar"},
860+
Item: func (value string) bool {
861+
return value == "bar"
862+
},
863+
},
840864
{
841865
In: []int{1, 2, 2, 3},
842866
Item: 2,

0 commit comments

Comments
 (0)