From f85d32c6003bc38e4c5979304d5b99473731fe14 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 20 Aug 2014 17:09:12 -0600 Subject: [PATCH] Make GapRead a function --- src/netarch/gapstr.go | 10 +++++++--- src/netarch/gapstr_test.go | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/netarch/gapstr.go b/src/netarch/gapstr.go index f992dcf..6174bb7 100644 --- a/src/netarch/gapstr.go +++ b/src/netarch/gapstr.go @@ -147,7 +147,7 @@ func (g *Gapstr) Slice(beg, end int) *Gapstr { type GapstrReader struct { g *Gapstr pos int - GapRead bool + gapread bool } func NewGapstrReader(g *Gapstr) (*GapstrReader) { @@ -157,11 +157,15 @@ func NewGapstrReader(g *Gapstr) (*GapstrReader) { func (gr *GapstrReader) Read(p []byte) (n int, err error) { gs := gr.g.Slice(gr.pos, gr.pos + len(p)) if gs.HasGaps() { - gr.GapRead = true + gr.gapread = true } s := []byte(gs.String()) nread := copy(p, s) gr.pos += nread return nread, nil -} \ No newline at end of file +} + +func (gr *GapstrReader) GapRead() bool { + return gr.gapread +} diff --git a/src/netarch/gapstr_test.go b/src/netarch/gapstr_test.go index c7eed50..56a08c9 100644 --- a/src/netarch/gapstr_test.go +++ b/src/netarch/gapstr_test.go @@ -53,7 +53,7 @@ func TestGapstr(t *testing.T) { func TestGapstrReader(t *testing.T) { g := new(Gapstr) - g = g.AppendString("\xff\xff") + g = g.AppendString("\xff\xffaoeu") g = g.AppendGap(8) g = g.AppendString("\xff\xff\xff") @@ -68,6 +68,7 @@ func TestGapstrReader(t *testing.T) { truth := gs[beg:end] nread, err := gr.Read(b) + DUMP(gr.GapRead()) AssertEqual(t, nread, len(truth)) AssertEqual(t, err, nil) AssertEqual(t, string(b[:nread]), truth)