fix(cli): guard min-time overflow + normalize 0 exec-timeout to null + stale comment (#54 review)
This commit is contained in:
@@ -117,4 +117,34 @@ public class TemplateScriptTimingTests
|
||||
Assert.Null(d);
|
||||
Assert.NotNull(err);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An absurdly large value (16-digit millisecond count) would overflow long/TimeSpan
|
||||
/// without the overflow guard. The parser must return false cleanly — not throw.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData("9999999999999999ms")] // 16-digit ms: far exceeds TimeSpan.MaxValue (~922337203685477ms)
|
||||
[InlineData("9999999999999999s")] // 16-digit seconds: even larger when scaled
|
||||
[InlineData("9999999999999999min")] // 16-digit minutes
|
||||
public void MinTime_AbsurdlyLarge_ReturnsFalseWithoutThrowing(string value)
|
||||
{
|
||||
// Must not throw — TryParse contract: never throws, always returns bool.
|
||||
var threw = false;
|
||||
bool result = false;
|
||||
TimeSpan? duration = null;
|
||||
string? error = null;
|
||||
try
|
||||
{
|
||||
result = TemplateCommands.TryParseMinTimeBetweenRuns(value, out duration, out error);
|
||||
}
|
||||
catch
|
||||
{
|
||||
threw = true;
|
||||
}
|
||||
|
||||
Assert.False(threw, "TryParseMinTimeBetweenRuns must not throw on large input");
|
||||
Assert.False(result);
|
||||
Assert.Null(duration);
|
||||
Assert.NotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user