Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
348 changes: 221 additions & 127 deletions Source/Testably.Expectations/That/Numbers/ThatNumberShould.Be.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static AndOrResult<float, IThat<float>> BeFinite(
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<float>(
float.PositiveInfinity,
"be finite",
_ => "be finite",
(a, _) => !float.IsInfinity(a) && !float.IsNaN(a),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(BeFinite)),
Expand All @@ -31,7 +31,7 @@ public static AndOrResult<double, IThat<double>> BeFinite(
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<double>(
double.PositiveInfinity,
"be finite",
_ => "be finite",
(a, _) => !double.IsInfinity(a) && !double.IsNaN(a),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(BeFinite)),
Expand All @@ -44,9 +44,9 @@ public static AndOrResult<double, IThat<double>> BeFinite(
public static AndOrResult<float, IThat<float?>> BeFinite(
this IThat<float?> source)
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<float?>(
.AddConstraint(new NullableGenericConstraint<float>(
float.PositiveInfinity,
"be finite",
_ => "be finite",
(a, _) => a != null && !float.IsInfinity(a.Value) && !float.IsNaN(a.Value),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(BeFinite)),
Expand All @@ -59,9 +59,9 @@ public static AndOrResult<double, IThat<double>> BeFinite(
public static AndOrResult<double, IThat<double?>> BeFinite(
this IThat<double?> source)
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<double?>(
.AddConstraint(new NullableGenericConstraint<double>(
double.PositiveInfinity,
"be finite",
_ => "be finite",
(a, _) => a != null && !double.IsInfinity(a.Value) && !double.IsNaN(a.Value),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(BeFinite)),
Expand All @@ -76,7 +76,7 @@ public static AndOrResult<float, IThat<float>> NotBeFinite(
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<float>(
float.PositiveInfinity,
"not be finite",
_ => "not be finite",
(a, _) => float.IsInfinity(a) || float.IsNaN(a),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(NotBeFinite)),
Expand All @@ -91,7 +91,7 @@ public static AndOrResult<double, IThat<double>> NotBeFinite(
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<double>(
double.PositiveInfinity,
"not be finite",
_ => "not be finite",
(a, _) => double.IsInfinity(a) || double.IsNaN(a),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(NotBeFinite)),
Expand All @@ -104,9 +104,9 @@ public static AndOrResult<double, IThat<double>> NotBeFinite(
public static AndOrResult<float?, IThat<float?>> NotBeFinite(
this IThat<float?> source)
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<float?>(
.AddConstraint(new NullableGenericConstraint<float>(
float.PositiveInfinity,
"not be finite",
_ => "not be finite",
(a, _) => a == null || float.IsInfinity(a.Value) || float.IsNaN(a.Value),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(NotBeFinite)),
Expand All @@ -119,9 +119,9 @@ public static AndOrResult<double, IThat<double>> NotBeFinite(
public static AndOrResult<double?, IThat<double?>> NotBeFinite(
this IThat<double?> source)
=> new(source.ExpectationBuilder
.AddConstraint(new GenericConstraint<double?>(
.AddConstraint(new NullableGenericConstraint<double>(
double.PositiveInfinity,
"not be finite",
_ => "not be finite",
(a, _) => a == null || double.IsInfinity(a.Value) || double.IsNaN(a.Value),
(a, _) => $"found {Formatter.Format(a)}"))
.AppendMethodStatement(nameof(NotBeFinite)),
Expand Down
Loading
Loading