github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/store/val/triple_test.go (about) 1 // Copyright 2021 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package val 16 17 import ( 18 "testing" 19 20 "github.com/stretchr/testify/assert" 21 ) 22 23 func TestNewTriple(t *testing.T) { 24 t.Run("test tuple round trip", func(t *testing.T) { 25 roundTripTripleFields(t) 26 }) 27 } 28 29 func roundTripTripleFields(t *testing.T) { 30 for n := 0; n < 100; n++ { 31 f1 := randomByteFields(t) 32 f2 := randomByteFields(t) 33 f3 := randomByteFields(t) 34 35 t1 := NewTuple(testPool, f1...) 36 t2 := NewTuple(testPool, f2...) 37 t3 := NewTuple(testPool, f3...) 38 39 tri := NewTriple(testPool, t1, t2, t3) 40 41 a, b, c := tri.First(), tri.Second(), tri.Third() 42 assert.Equal(t, t1, a) 43 assert.Equal(t, t2, b) 44 assert.Equal(t, t3, c) 45 46 for i, field := range f1 { 47 assert.Equal(t, field, a.GetField(i)) 48 } 49 for i, field := range f2 { 50 assert.Equal(t, field, b.GetField(i)) 51 } 52 for i, field := range f3 { 53 assert.Equal(t, field, c.GetField(i)) 54 } 55 } 56 }