github.com/vertgenlab/gonomics@v1.0.0/fileio/fileio_test.go (about) 1 package fileio 2 3 import ( 4 "testing" 5 ) 6 7 var testfile string = "testdata/smallTest" 8 var line1 string = "#shhhh this line is a secret" 9 var line2 string = "Hello World" 10 var line3 string = "I am a gopher" 11 12 func TestNextLine(t *testing.T) { 13 file := EasyOpen(testfile) 14 l1, done := NextLine(file.BuffReader) 15 if l1 != line1 || done { 16 t.Errorf("problem reading next line") 17 } 18 l2, done := NextLine(file.BuffReader) 19 if l2 != line2 || done { 20 t.Errorf("problem reading next line") 21 } 22 l3, done := NextLine(file.BuffReader) 23 if l3 != line3 || done { 24 t.Errorf("problem reading next line") 25 } 26 l4, done := NextLine(file.BuffReader) 27 if l4 != "" || !done { 28 t.Errorf("problem reading next line") 29 } 30 } 31 32 func TestNextRealLine(t *testing.T) { 33 file := EasyOpen(testfile) 34 l1, done := NextRealLine(file.BuffReader) 35 if l1 != line2 || done { 36 t.Errorf("problem reading next line") 37 } 38 l2, done := NextRealLine(file.BuffReader) 39 if l2 != line3 || done { 40 t.Errorf("problem reading next line") 41 } 42 l3, done := NextRealLine(file.BuffReader) 43 if l3 != "" || !done { 44 t.Errorf("problem reading next line") 45 } 46 } 47 48 func TestEqual(t *testing.T) { 49 if !AreEqual(testfile, testfile) || !AreEqualIgnoreComments(testfile, testfile) { 50 t.Errorf("problem with equal") 51 } 52 }