susumu.yata
null+****@clear*****
Mon Jul 27 11:04:40 JST 2015
susumu.yata 2015-07-27 11:04:40 +0900 (Mon, 27 Jul 2015) New Revision: 4bc62900ec041a5f1d55e65686983f3a64a60e8f https://github.com/groonga/grngo/commit/4bc62900ec041a5f1d55e65686983f3a64a60e8f Message: Add tests for table reference vector. Modified files: grngo_test.go Modified: grngo_test.go (+43 -1) =================================================================== --- grngo_test.go 2015-07-24 23:59:23 +0900 (061f294) +++ grngo_test.go 2015-07-27 11:04:40 +0900 (bd044be) @@ -1267,7 +1267,15 @@ func TestRefs(t *testing.T) { t.Fatalf("Table.InsertRow() failed: %v", err) } } - column, err := table.CreateColumn("Ref", "[]Table", nil) + column, err := table.CreateColumn("Value", "Float", nil) + for i := 0; i < 100; i++ { + id := uint32(i + 1) + value := float64(i) / 10.0 + if err := column.SetValue(id, value); err != nil { + t.Fatalf("Column.SetValue() failed: %v", err) + } + } + column, err = table.CreateColumn("Ref", "[]Table", nil) for i := 0; i < 100; i++ { id := uint32(i + 1) value := [][]byte{ @@ -1287,6 +1295,23 @@ func TestRefs(t *testing.T) { value, storedValue) } } + column, err = table.FindColumn("Ref") + for i := 0; i < 100; i++ { + id := uint32(i + 1) + value := [][]byte{ + []byte(strconv.Itoa((i + 1) % 100)), + []byte(strconv.Itoa((i + 2) % 100)), + []byte(strconv.Itoa((i + 3) % 100)), + } + storedValue, err := column.GetValue(id) + if err != nil { + t.Fatalf("Column.GetValue() failed: %v", err) + } + if !reflect.DeepEqual(value, storedValue) { + t.Fatalf("Column.GetValue() failed: value = %v, storedValue = %v", + value, storedValue) + } + } column, err = table.FindColumn("Ref._key") for i := 0; i < 100; i++ { id := uint32(i + 1) @@ -1304,6 +1329,23 @@ func TestRefs(t *testing.T) { value, storedValue) } } + column, err = table.FindColumn("Ref.Value") + for i := 0; i < 100; i++ { + id := uint32(i + 1) + value := []float64{ + float64((i + 1) % 100) / 10.0, + float64((i + 2) % 100) / 10.0, + float64((i + 3) % 100) / 10.0, + } + storedValue, err := column.GetValue(id) + if err != nil { + t.Fatalf("Column.GetValue() failed: %v", err) + } + if !reflect.DeepEqual(value, storedValue) { + t.Fatalf("Column.GetValue() failed: value = %v, storedValue = %v", + value, storedValue) + } + } } // Benchmarks. -------------- next part -------------- HTML����������������������������...Download