mirror of
https://github.com/anchore/syft.git
synced 2026-11-04 00:16:38 +01:00
* migrate location structs to file package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * replace source.Location refs with file package call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for file based catalogers Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for all-regular-files testing Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate file resolver implementations to separate package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * [wip] migrate resolvers to internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate resolvers to syft/internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: <>
36 lines
956 B
Go
36 lines
956 B
Go
package secrets
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLineCounter_ReadRune(t *testing.T) {
|
|
counter := &newlineCounter{RuneReader: bufio.NewReader(strings.NewReader("hi\nwhat's the weather like today?\ndunno...\n"))}
|
|
var err error
|
|
for err == nil {
|
|
_, _, err = counter.ReadRune()
|
|
}
|
|
if err != io.EOF {
|
|
t.Fatalf("should have gotten an eof, got %+v", err)
|
|
}
|
|
assert.Equal(t, 3, len(counter.newLines), "bad line count")
|
|
assert.Equal(t, []int64{3, 34, 43}, counter.newLines, "bad line positions")
|
|
}
|
|
|
|
func TestLineCounter_newlinesBefore(t *testing.T) {
|
|
counter := &newlineCounter{RuneReader: bufio.NewReader(strings.NewReader("hi\nwhat's the weather like today?\ndunno...\n"))}
|
|
var err error
|
|
for err == nil {
|
|
_, _, err = counter.ReadRune()
|
|
}
|
|
if err != io.EOF {
|
|
t.Fatalf("should have gotten an eof, got %+v", err)
|
|
}
|
|
assert.Equal(t, 1, counter.newlinesBefore(10), "bad line count")
|
|
}
|