-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exec: add unit test for AND operator
This commit adds a unit test for AND operator. It also extends our testing infrastructure to be able to specify the types schema (this was needed because nil values are treated as Int64 by default which is incorrect for tests of AND operator). Release note: None
- Loading branch information
1 parent
10193ad
commit 37b76c1
Showing
6 changed files
with
155 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package exec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/col/coltypes" | ||
) | ||
|
||
func TestAndOp(t *testing.T) { | ||
tcs := []struct { | ||
tuples []tuple | ||
expected []tuple | ||
}{ | ||
// All variations of pairs separately first. | ||
{ | ||
tuples: tuples{{false, true}}, | ||
expected: tuples{{false}}, | ||
}, | ||
{ | ||
tuples: tuples{{false, nil}}, | ||
expected: tuples{{false}}, | ||
}, | ||
{ | ||
tuples: tuples{{false, false}}, | ||
expected: tuples{{false}}, | ||
}, | ||
{ | ||
tuples: tuples{{true, true}}, | ||
expected: tuples{{true}}, | ||
}, | ||
{ | ||
tuples: tuples{{true, false}}, | ||
expected: tuples{{false}}, | ||
}, | ||
{ | ||
tuples: tuples{{true, nil}}, | ||
expected: tuples{{nil}}, | ||
}, | ||
{ | ||
tuples: tuples{{nil, true}}, | ||
expected: tuples{{nil}}, | ||
}, | ||
{ | ||
tuples: tuples{{nil, false}}, | ||
expected: tuples{{false}}, | ||
}, | ||
{ | ||
tuples: tuples{{nil, nil}}, | ||
expected: tuples{{nil}}, | ||
}, | ||
// Now all variations of pairs combined together to make sure that nothing | ||
// funky going on with multiple tuples. | ||
{ | ||
tuples: tuples{ | ||
{false, true}, {false, nil}, {false, false}, | ||
{true, true}, {true, false}, {true, nil}, | ||
{nil, true}, {nil, false}, {nil, nil}, | ||
}, | ||
expected: tuples{ | ||
{false}, {false}, {false}, | ||
{true}, {false}, {nil}, | ||
{nil}, {false}, {nil}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
runTestsWithTyps( | ||
t, | ||
[]tuples{tc.tuples}, | ||
[]coltypes.T{coltypes.Bool, coltypes.Bool}, | ||
tc.expected, | ||
orderedVerifier, | ||
[]int{2}, | ||
func(input []Operator) (Operator, error) { | ||
return NewAndOp( | ||
input[0], | ||
0, /* leftIdx */ | ||
1, /* rightIdx */ | ||
2, /* outputIdx */ | ||
), nil | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters