From 62361d8965c79dc89ed032d808661560c1db49ea Mon Sep 17 00:00:00 2001
From: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
Date: Sun, 16 Jul 2023 02:58:37 +0200
Subject: [PATCH] CombinatorialRangeAttribute: Add uint support
---
.../CombinatorialRangeAttribute.cs | 65 +++++++++++++++++++
.../CombinatorialRangeAttributeTests.cs | 57 ++++++++++++++++
2 files changed, 122 insertions(+)
diff --git a/src/Xunit.Combinatorial/CombinatorialRangeAttribute.cs b/src/Xunit.Combinatorial/CombinatorialRangeAttribute.cs
index 2ec749e..b21295f 100644
--- a/src/Xunit.Combinatorial/CombinatorialRangeAttribute.cs
+++ b/src/Xunit.Combinatorial/CombinatorialRangeAttribute.cs
@@ -78,6 +78,71 @@ public CombinatorialRangeAttribute(int from, int to, int step)
this.Values = values;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The value at the beginning of the range.
+ ///
+ /// The quantity of consecutive integer values to include.
+ /// Cannot be less than 1, which would conceptually result in zero test cases.
+ ///
+ public CombinatorialRangeAttribute(uint from, uint count)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentOutOfRangeException(nameof(count));
+ }
+
+ object[] values = new object[count];
+ for (uint i = 0; i < count; i++)
+ {
+ values[i] = from + i;
+ }
+
+ this.Values = values;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The value at the beginning of the range.
+ ///
+ /// The value at the end of the range.
+ /// Cannot be less than "from" parameter.
+ /// When "to" and "from" are equal, CombinatorialValues is more appropriate.
+ ///
+ ///
+ /// The number of unsigned integers to step for each value in result.
+ /// Cannot be less than one. Stepping zero is not useful.
+ /// Stepping over "to" does not add another value to the range.
+ ///
+ public CombinatorialRangeAttribute(uint from, uint to, uint step)
+ {
+ if (step == 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(step));
+ }
+
+ var values = new List();
+
+ if (from < to)
+ {
+ for (uint i = from; i <= to; i += step)
+ {
+ values.Add(i);
+ }
+ }
+ else
+ {
+ for (uint i = from; i >= to && i <= from; i -= step)
+ {
+ values.Add(i);
+ }
+ }
+
+ this.Values = values.Cast