N1MM splits the telnet stream on CR, not LF, which says some nodes send CR with no LF after it. Against those the assembler was handing the whole session back as one unfinished line. Also adds "user:" to the login prompts, which N1MM matches and we did not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using Nonemm.Spotting.Telnet;
|
|
|
|
namespace Nonemm.Spotting.Tests;
|
|
|
|
public class LineAssemblerTests
|
|
{
|
|
[Fact]
|
|
public void CompleteLinesComeOutWithoutTheirEndings()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Equal(["one", "two"], assembler.Add("one\r\ntwo\r\n"));
|
|
Assert.Equal("", assembler.Pending);
|
|
}
|
|
|
|
[Fact]
|
|
public void ALineSplitOverTwoBlocksIsPutBackTogether()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Empty(assembler.Add("DX de W3"));
|
|
Assert.Equal(["DX de W3LPL"], assembler.Add("LPL\r\n"));
|
|
}
|
|
|
|
/// The login prompt has no line ending, so it only ever shows up here.
|
|
[Fact]
|
|
public void TextWithNoLineEndingWaitsInPending()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Empty(assembler.Add("login: "));
|
|
Assert.Equal("login: ", assembler.Pending);
|
|
}
|
|
|
|
/// N1MM splits on CR alone, so some nodes evidently leave the LF out.
|
|
[Fact]
|
|
public void ALineEndedWithACarriageReturnAloneIsStillALine()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Equal(["one", "two"], assembler.Add("one\rtwo\r"));
|
|
}
|
|
|
|
[Fact]
|
|
public void CarriageReturnAndLineFeedTogetherAreOneEnding()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Equal(["one"], assembler.Add("one\r\n"));
|
|
Assert.Equal("", assembler.Pending);
|
|
}
|
|
|
|
[Fact]
|
|
public void AnEndingSplitAcrossTwoBlocksIsStillOneEnding()
|
|
{
|
|
LineAssembler assembler = new();
|
|
|
|
Assert.Equal(["one"], assembler.Add("one\r"));
|
|
Assert.Empty(assembler.Add("\n"));
|
|
}
|
|
}
|