From d3a61fafefcae76f09188942bfb82e190a6b958e Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Tue, 28 Nov 2023 08:08:06 -0800 Subject: [PATCH] initial commits --- readlf.go | 7 +++++-- readlf_test.go | 38 +++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/readlf.go b/readlf.go index 04cc933..43d2e03 100644 --- a/readlf.go +++ b/readlf.go @@ -2,9 +2,12 @@ package eol import ( "io" + + "sourcecode.social/reiver/go-opt" ) func ReadLF(runescanner io.RuneScanner) (size int, err error) { - const runeNumber = 1 - return readthisrune(runescanner, lf, runeNumber) + const characterNumber uint64 = 1 + var circumstance internalCircumstance = specifyCircumstance(opt.Something(LF), characterNumber) + return readthisrune(circumstance, runescanner, lf) } diff --git a/readlf_test.go b/readlf_test.go index 5fc4cdb..f021117 100644 --- a/readlf_test.go +++ b/readlf_test.go @@ -67,103 +67,103 @@ func TestReadLF_fail(t *testing.T) { }{ { Value: "", - ExpectedError: `eol: problem reading character №1 of end-of-line sequence: EOF`, + ExpectedError: `eol: problem reading character №1 of end-of-line sequence "\n": EOF`, }, { Value: "\r", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\r' (U+000D)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\r' (U+000D)`, }, { Value: "\u0085", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\u0085' (U+0085)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\u0085' (U+0085)`, }, { Value: "\u2028", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\u2028' (U+2028)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\u2028' (U+2028)`, }, { Value: "😈", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '😈' (U+1F608)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '😈' (U+1F608)`, }, { Value: "\rapple banana cherry", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\r' (U+000D)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\r' (U+000D)`, }, { Value: "\u0085apple banana cherry", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\u0085' (U+0085)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\u0085' (U+0085)`, }, { Value: "\u2028apple banana cherry", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '\u2028' (U+2028)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '\u2028' (U+2028)`, }, { Value: "😈apple banana cherry", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '😈' (U+1F608)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '😈' (U+1F608)`, }, { Value: " \n", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found ' ' (U+0020)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found ' ' (U+0020)`, }, { Value: " \r", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found ' ' (U+0020)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found ' ' (U+0020)`, }, { Value: " \u0085", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found ' ' (U+0020)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found ' ' (U+0020)`, }, { Value: " \u2028", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found ' ' (U+0020)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found ' ' (U+0020)`, }, { Value: " 😈", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found ' ' (U+0020)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found ' ' (U+0020)`, }, { Value: ".\n", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '.' (U+002E)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '.' (U+002E)`, }, { Value: ".\r", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '.' (U+002E)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '.' (U+002E)`, }, { Value: ".\u0085", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '.' (U+002E)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '.' (U+002E)`, }, { Value: ".\u2028", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '.' (U+002E)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '.' (U+002E)`, }, { Value: ".😈", - ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №1 — instead found '.' (U+002E)`, + ExpectedError: `eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence "\n" character №1 — instead found '.' (U+002E)`, }, }