2025-12-01 06:49:26 -06:00
|
|
|
package file_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"slices"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestReadLines(t *testing.T) {
|
|
|
|
|
expectedLines := []string{
|
|
|
|
|
"hello",
|
|
|
|
|
"world",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := file.ReadLines("test.txt")
|
|
|
|
|
|
|
|
|
|
if slices.Equal(result, expectedLines) == false {
|
|
|
|
|
t.Errorf("got %s but expected %s", result, expectedLines)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-03 10:24:16 -06:00
|
|
|
|
|
|
|
|
func TestReadAllText(t *testing.T) {
|
|
|
|
|
expectedText := "hello\r\nworld\r\n"
|
|
|
|
|
|
|
|
|
|
result := file.ReadAllText("test.txt")
|
|
|
|
|
|
|
|
|
|
if result != expectedText {
|
|
|
|
|
t.Errorf("got %q but expected %q", result, expectedText)
|
|
|
|
|
}
|
|
|
|
|
}
|