Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynab committed Apr 13, 2023
1 parent 99238a2 commit 5d5be62
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 18 deletions.
13 changes: 11 additions & 2 deletions lib/YANLib/YANBool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ namespace YANLib;

public static partial class YANBool
{
/// <summary>
/// Generates a random boolean value. Returns <see langword="true"/> or <see langword="false"/> with equal probability.
/// </summary>
/// <returns>A random boolean value.</returns>
public static bool GenerateRandomBool() => GenerateRandomByte(0, 2) == 1;

/// <summary>
/// Generates an <see cref="IEnumerable{bool}"/> containing random boolean values. The number of boolean values generated is determined by the value of <paramref name="size"/>.
/// </summary>
/// <typeparam name="T">The type of <paramref name="size"/>. Must be a value type.</typeparam>
/// <param name="size">The number of boolean values to generate.</param>
/// <returns>An <see cref="IEnumerable{bool}"/> containing random boolean values.</returns>
public static IEnumerable<bool> GenerateRandomBools<T>(T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomBool();
}
Expand Down
12 changes: 4 additions & 8 deletions lib/YANLib/YANDateTime.Nullable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public static IEnumerable<DateTime> ToDateTime(IReadOnlySet<string> strs, string
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <paramref name="min"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime? min, DateTime max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(min, max);
}
Expand All @@ -153,8 +152,7 @@ public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime? min, Da
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <paramref name="min"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime min, DateTime? max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(min, max);
}
Expand All @@ -181,8 +179,7 @@ public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime min, Dat
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <paramref name="min"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime? min, DateTime? max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(min, max);
}
Expand All @@ -206,8 +203,7 @@ public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime? min, Da
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <see cref="DateTime.MinValue"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime? max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(max);
}
Expand Down
9 changes: 3 additions & 6 deletions lib/YANLib/YANDateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ public static IEnumerable<DateTime> ToDateTime(IReadOnlySet<string> strs, string
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <paramref name="min"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime min, DateTime max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(min, max);
}
Expand All @@ -360,8 +359,7 @@ public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime min, Dat
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <see cref="DateTime.MinValue"/> and <see cref="DateTime.MaxValue"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime();
}
Expand All @@ -385,8 +383,7 @@ public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(T size) where T :
/// <returns>An <see cref="IEnumerable{DateTime}"/> containing random DateTime values between <see cref="DateTime.MinValue"/> and <paramref name="max"/>.</returns>
public static IEnumerable<DateTime> GenerateRandomDateTimes<T>(DateTime max, T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
for (var i = 0ul; i < size.ToUlong(); i++)
{
yield return GenerateRandomDateTime(max);
}
Expand Down
Loading

0 comments on commit 5d5be62

Please sign in to comment.