Take a QTC header that is only a series number as ten lines

An operator copying a header off the air often types the series number and
nothing else. That read as a header the program could not parse, so the box
went yellow and Close refused to log the series.

N1MM fills the count in: "If he only types the batch number without the
forward slash and count, the program will assume the count is 10."

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157i7PiZyqBkquxS9A6FTdQ
This commit is contained in:
2026-09-10 19:30:47 +00:00
co-authored by Claude Opus 5
parent 265f90ccd7
commit 9b3e10d127
2 changed files with 26 additions and 7 deletions
+13 -6
View File
@@ -214,16 +214,23 @@ public sealed class QtcTraffic
/// The header a station sends in front of a series: a series number, a /// The header a station sends in front of a series: a series number, a
/// separator and how many lines follow. Anything between the two numbers /// separator and how many lines follow. Anything between the two numbers
/// counts as the separator, because it is copied off the air. /// counts as the separator, because it is copied off the air. A series
/// number on its own means ten lines, which is what N1MM assumes: "If he
/// only types the batch number without the forward slash and count, the
/// program will assume the count is 10."
public static (int Series, int Count)? ReadHeader(string text) public static (int Series, int Count)? ReadHeader(string text)
{ {
string[] parts = text.Trim().ToUpperInvariant().Replace("QTC", "").Trim() string[] parts = text.Trim().ToUpperInvariant().Replace("QTC", "").Trim()
.Split(['/', '-', ' ', '\\'], StringSplitOptions.RemoveEmptyEntries); .Split(['/', '-', ' ', '\\'], StringSplitOptions.RemoveEmptyEntries);
return parts.Length >= 2 if (parts.Length == 0 || !int.TryParse(parts[0], out int series) || series <= 0)
&& int.TryParse(parts[0], out int series) {
&& int.TryParse(parts[1], out int count) return null;
&& series > 0 }
&& count is > 0 and <= WaeQtc.MostPerSeries if (parts.Length == 1)
{
return (series, WaeQtc.MostPerSeries);
}
return int.TryParse(parts[1], out int count) && count is > 0 and <= WaeQtc.MostPerSeries
? (series, count) ? (series, count)
: null; : null;
} }
+13 -1
View File
@@ -314,9 +314,21 @@ public class QtcTrafficTests
Assert.Equal(10, count); Assert.Equal(10, count);
} }
/// N1MM fills in the count when the operator types the series number
/// alone, because ten is the usual series.
[Theory]
[InlineData("87")]
[InlineData("QTC 87")]
public void ASeriesNumberOnItsOwnMeansTenLines(string text)
{
(int series, int count) = Assert.IsType<(int, int)>(QtcTraffic.ReadHeader(text));
Assert.Equal(87, series);
Assert.Equal(10, count);
}
[Theory] [Theory]
[InlineData("")] [InlineData("")]
[InlineData("87")]
[InlineData("87/11")] [InlineData("87/11")]
[InlineData("abc/10")] [InlineData("abc/10")]
public void AHeaderThatIsNotOneReadsAsNothing(string text) => public void AHeaderThatIsNotOneReadsAsNothing(string text) =>