diff options
Diffstat (limited to 'mountain_pass/extract_test.go')
| -rw-r--r-- | mountain_pass/extract_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mountain_pass/extract_test.go b/mountain_pass/extract_test.go index 636372c..7eae33b 100644 --- a/mountain_pass/extract_test.go +++ b/mountain_pass/extract_test.go @@ -1,10 +1,13 @@ package mountain_pass import ( + "io" + "strings" "testing" "github.com/paulmach/osm" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestIsMountainPass(t *testing.T) { @@ -47,3 +50,21 @@ func TestParseElevation(t *testing.T) { assert.Equal(t, c.ok, ok) } } + +func TestCountingReaderTracksBytes(t *testing.T) { + const content = "0123456789abcdef" + reader := &countingReader{r: strings.NewReader(content)} + + buf := make([]byte, 4) + var total int64 + for { + n, err := reader.Read(buf) + total += int64(n) + require.Equal(t, total, reader.n) + if err == io.EOF { + break + } + require.NoError(t, err) + } + assert.Equal(t, int64(len(content)), reader.n) +} |
