func TestMainOutput(t *testing.T) { rw, e := dsv.New(fMainTestDsv, nil) if e != nil { t.Fatal(e) } for { n, e := dsv.Read(&rw.Reader) if e == io.EOF { _, e = rw.Write(&rw.Reader) break } if n > 0 { _, e = rw.Write(&rw.Reader) if e != nil { t.Fatal(e) } } } e = rw.Writer.Flush() if e != nil { t.Fatal(e) } assertFile(t, rw.GetInput(), rw.GetOutput(), true) }
/* doInit create read-write object. */ func doInit(t *testing.T, fcfg string) (rw *dsv.ReadWriter, e error) { // Initialize dsv rw, e = dsv.New(fcfg, nil) if nil != e { t.Fatal(e) } return }
/* TestWriterWithSkip test reading and writing DSV with some column in input being skipped. */ func TestWriterWithSkip(t *testing.T) { rw, e := dsv.New("testdata/config_skip.dsv", nil) if e != nil { t.Fatal(e) } doReadWrite(t, &rw.Reader, &rw.Writer, expSkip, true) e = rw.Close() if e != nil { t.Fatal(e) } assertFile(t, rw.GetOutput(), "testdata/expected_skip.dat", true) }
/* TestWriterWithColumns test reading and writing DSV with where each row is saved in DatasetMode = 'columns'. */ func TestWriterWithColumns(t *testing.T) { rw, e := dsv.New("testdata/config_skip.dsv", nil) if e != nil { t.Fatal(e) } rw.SetDatasetMode(dsv.DatasetModeCOLUMNS) doReadWrite(t, &rw.Reader, &rw.Writer, expSkipColumns, true) e = rw.Close() if e != nil { t.Fatal(e) } assertFile(t, "testdata/expected_skip.dat", rw.GetOutput(), true) }