Skip to content

Commit f651a54

Browse files
committed
* Added table/types.Equal(lhs, rhs) helper for check equal for two types
1 parent fdea8ea commit f651a54

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
* Refactored `internal/value` package for decrease CPU and memory workload with GC
1+
* Refactored `internal/value` package for decrease CPU and memory workload with GC
2+
* Added `table/types.Equal(lhs, rhs)` helper for check equal for two types
23

34
## v3.28.3
45
* Fixed false-positive node pessimization on receiving from stream io.EOF

table/types/type.go renamed to table/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Type interface {
1313
value.Type
1414
}
1515

16+
// Equal checks for type equivalence
1617
func Equal(lhs, rhs Type) bool {
1718
return value.TypesEqual(lhs, rhs)
1819
}

table/types/types_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package types
2+
3+
import "testing"
4+
5+
func TestEqual(t *testing.T) {
6+
tests := []struct {
7+
lhs Type
8+
rhs Type
9+
equal bool
10+
}{
11+
{
12+
TypeBool,
13+
TypeBool,
14+
true,
15+
},
16+
{
17+
TypeBool,
18+
TypeUTF8,
19+
false,
20+
},
21+
{
22+
TypeUTF8,
23+
TypeUTF8,
24+
true,
25+
},
26+
{
27+
Optional(TypeBool),
28+
Optional(TypeBool),
29+
true,
30+
},
31+
{
32+
Optional(TypeBool),
33+
Optional(TypeUTF8),
34+
false,
35+
},
36+
{
37+
Optional(TypeUTF8),
38+
Optional(TypeUTF8),
39+
true,
40+
},
41+
}
42+
for _, tt := range tests {
43+
t.Run("", func(t *testing.T) {
44+
if equal := Equal(tt.lhs, tt.rhs); equal != tt.equal {
45+
t.Errorf("Equal(%s, %s) = %v, want %v", tt.lhs, tt.rhs, equal, tt.equal)
46+
}
47+
})
48+
}
49+
}

0 commit comments

Comments
 (0)