func TestIntervalSource(t *testing.T) { var a Relatable a = parsers.NewInterval("chr1", 1234, 5678, bytes.Split([]byte("chr1\t1234\t5678"), []byte("\t")), 0, nil) a.SetSource(222) if a.Source() != 222 { t.Error("expected 222, got", a.Source()) } }
// return an interval using the info from the tabix index func newgeneric(fields [][]byte, chromCol int, startCol int, endCol int, zeroBased bool) (*parsers.Interval, error) { s, err := strconv.Atoi(unsafeString(fields[startCol])) if err != nil { return nil, err } if !zeroBased { s -= 1 } e, err := strconv.Atoi(unsafeString(fields[endCol])) if err != nil { return nil, err } return parsers.NewInterval(string(fields[chromCol]), uint32(s), uint32(e), fields, uint32(0), nil), nil }
func TestInterval(t *testing.T) { a := parsers.NewInterval("chr1", 1234, 5678, bytes.Split([]byte("chr1\t1234\t5678"), []byte("\t")), 0, nil) if a.Chrom() != "chr1" { t.Error("expected \"chr1\", got", a.Chrom()) } if a.Start() != 1234 { t.Error("expected start = 1234, got", a.Start()) } if a.End() != 5678 { t.Error("expected start = 5678, got", a.End()) } s := fmt.Sprintf("%v", a) if len(s) == 0 { t.Error("bad String") } }