@@ -813,9 +813,11 @@ static string ToStringPadded(Half value)
813
813
/// <summary>Verifies that two <see cref="double"/> values are equal, within the <paramref name="allowedVariance"/>.</summary>
814
814
/// <param name="expected">The expected value</param>
815
815
/// <param name="actual">The value to be compared against</param>
816
- /// <param name="allowedVariance">The total variance allowed between the expected and actual results.</param>
816
+ /// <param name="variance">The total variance allowed between the expected and actual results.</param>
817
+ /// <param name="banner">The banner to show; if <c>null</c>, then the standard
818
+ /// banner of "Values differ" will be used</param>
817
819
/// <exception cref="EqualException">Thrown when the values are not equal</exception>
818
- public static void Equal ( double expected , double actual , double variance )
820
+ public static void Equal ( double expected , double actual , double variance , string ? banner = null )
819
821
{
820
822
if ( double . IsNaN ( expected ) )
821
823
{
@@ -824,11 +826,11 @@ public static void Equal(double expected, double actual, double variance)
824
826
return ;
825
827
}
826
828
827
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
829
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
828
830
}
829
831
else if ( double . IsNaN ( actual ) )
830
832
{
831
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
833
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
832
834
}
833
835
834
836
if ( double . IsNegativeInfinity ( expected ) )
@@ -838,11 +840,11 @@ public static void Equal(double expected, double actual, double variance)
838
840
return ;
839
841
}
840
842
841
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
843
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
842
844
}
843
845
else if ( double . IsNegativeInfinity ( actual ) )
844
846
{
845
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
847
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
846
848
}
847
849
848
850
if ( double . IsPositiveInfinity ( expected ) )
@@ -852,11 +854,11 @@ public static void Equal(double expected, double actual, double variance)
852
854
return ;
853
855
}
854
856
855
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
857
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
856
858
}
857
859
else if ( double . IsPositiveInfinity ( actual ) )
858
860
{
859
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
861
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
860
862
}
861
863
862
864
if ( IsNegativeZero ( expected ) )
@@ -868,7 +870,7 @@ public static void Equal(double expected, double actual, double variance)
868
870
869
871
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
870
872
{
871
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
873
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
872
874
}
873
875
874
876
// When the variance is not +-0.0, then we are handling a case where
@@ -879,7 +881,7 @@ public static void Equal(double expected, double actual, double variance)
879
881
{
880
882
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
881
883
{
882
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
884
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
883
885
}
884
886
885
887
// When the variance is not +-0.0, then we are handling a case where
@@ -896,7 +898,7 @@ public static void Equal(double expected, double actual, double variance)
896
898
897
899
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
898
900
{
899
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
901
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
900
902
}
901
903
902
904
// When the variance is not +-0.0, then we are handling a case where
@@ -907,7 +909,7 @@ public static void Equal(double expected, double actual, double variance)
907
909
{
908
910
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
909
911
{
910
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
912
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
911
913
}
912
914
913
915
// When the variance is not +-0.0, then we are handling a case where
@@ -919,16 +921,18 @@ public static void Equal(double expected, double actual, double variance)
919
921
920
922
if ( delta > variance )
921
923
{
922
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
924
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
923
925
}
924
926
}
925
927
926
928
/// <summary>Verifies that two <see cref="float"/> values are equal, within the <paramref name="variance"/>.</summary>
927
929
/// <param name="expected">The expected value</param>
928
930
/// <param name="actual">The value to be compared against</param>
929
931
/// <param name="variance">The total variance allowed between the expected and actual results.</param>
932
+ /// <param name="banner">The banner to show; if <c>null</c>, then the standard
933
+ /// banner of "Values differ" will be used</param>
930
934
/// <exception cref="EqualException">Thrown when the values are not equal</exception>
931
- public static void Equal ( float expected , float actual , float variance )
935
+ public static void Equal ( float expected , float actual , float variance , string ? banner = null )
932
936
{
933
937
if ( float . IsNaN ( expected ) )
934
938
{
@@ -937,11 +941,11 @@ public static void Equal(float expected, float actual, float variance)
937
941
return ;
938
942
}
939
943
940
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
944
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
941
945
}
942
946
else if ( float . IsNaN ( actual ) )
943
947
{
944
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
948
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
945
949
}
946
950
947
951
if ( float . IsNegativeInfinity ( expected ) )
@@ -951,11 +955,11 @@ public static void Equal(float expected, float actual, float variance)
951
955
return ;
952
956
}
953
957
954
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
958
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
955
959
}
956
960
else if ( float . IsNegativeInfinity ( actual ) )
957
961
{
958
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
962
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
959
963
}
960
964
961
965
if ( float . IsPositiveInfinity ( expected ) )
@@ -965,11 +969,11 @@ public static void Equal(float expected, float actual, float variance)
965
969
return ;
966
970
}
967
971
968
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
972
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
969
973
}
970
974
else if ( float . IsPositiveInfinity ( actual ) )
971
975
{
972
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
976
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
973
977
}
974
978
975
979
if ( IsNegativeZero ( expected ) )
@@ -981,7 +985,7 @@ public static void Equal(float expected, float actual, float variance)
981
985
982
986
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
983
987
{
984
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
988
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
985
989
}
986
990
987
991
// When the variance is not +-0.0, then we are handling a case where
@@ -992,7 +996,7 @@ public static void Equal(float expected, float actual, float variance)
992
996
{
993
997
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
994
998
{
995
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
999
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
996
1000
}
997
1001
998
1002
// When the variance is not +-0.0, then we are handling a case where
@@ -1009,7 +1013,7 @@ public static void Equal(float expected, float actual, float variance)
1009
1013
1010
1014
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1011
1015
{
1012
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1016
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1013
1017
}
1014
1018
1015
1019
// When the variance is not +-0.0, then we are handling a case where
@@ -1020,7 +1024,7 @@ public static void Equal(float expected, float actual, float variance)
1020
1024
{
1021
1025
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1022
1026
{
1023
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1027
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1024
1028
}
1025
1029
1026
1030
// When the variance is not +-0.0, then we are handling a case where
@@ -1032,7 +1036,7 @@ public static void Equal(float expected, float actual, float variance)
1032
1036
1033
1037
if ( delta > variance )
1034
1038
{
1035
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1039
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1036
1040
}
1037
1041
}
1038
1042
@@ -1041,8 +1045,10 @@ public static void Equal(float expected, float actual, float variance)
1041
1045
/// <param name="expected">The expected value</param>
1042
1046
/// <param name="actual">The value to be compared against</param>
1043
1047
/// <param name="variance">The total variance allowed between the expected and actual results.</param>
1048
+ /// <param name="banner">The banner to show; if <c>null</c>, then the standard
1049
+ /// banner of "Values differ" will be used</param>
1044
1050
/// <exception cref="EqualException">Thrown when the values are not equal</exception>
1045
- public static void Equal ( Half expected , Half actual , Half variance )
1051
+ public static void Equal ( Half expected , Half actual , Half variance , string ? banner = null )
1046
1052
{
1047
1053
if ( Half . IsNaN ( expected ) )
1048
1054
{
@@ -1051,11 +1057,11 @@ public static void Equal(Half expected, Half actual, Half variance)
1051
1057
return ;
1052
1058
}
1053
1059
1054
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1060
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1055
1061
}
1056
1062
else if ( Half . IsNaN ( actual ) )
1057
1063
{
1058
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1064
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1059
1065
}
1060
1066
1061
1067
if ( Half . IsNegativeInfinity ( expected ) )
@@ -1065,11 +1071,11 @@ public static void Equal(Half expected, Half actual, Half variance)
1065
1071
return ;
1066
1072
}
1067
1073
1068
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1074
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1069
1075
}
1070
1076
else if ( Half . IsNegativeInfinity ( actual ) )
1071
1077
{
1072
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1078
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1073
1079
}
1074
1080
1075
1081
if ( Half . IsPositiveInfinity ( expected ) )
@@ -1079,11 +1085,11 @@ public static void Equal(Half expected, Half actual, Half variance)
1079
1085
return ;
1080
1086
}
1081
1087
1082
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1088
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1083
1089
}
1084
1090
else if ( Half . IsPositiveInfinity ( actual ) )
1085
1091
{
1086
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1092
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1087
1093
}
1088
1094
1089
1095
if ( IsNegativeZero ( expected ) )
@@ -1095,7 +1101,7 @@ public static void Equal(Half expected, Half actual, Half variance)
1095
1101
1096
1102
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1097
1103
{
1098
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1104
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1099
1105
}
1100
1106
1101
1107
// When the variance is not +-0.0, then we are handling a case where
@@ -1106,7 +1112,7 @@ public static void Equal(Half expected, Half actual, Half variance)
1106
1112
{
1107
1113
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1108
1114
{
1109
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1115
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1110
1116
}
1111
1117
1112
1118
// When the variance is not +-0.0, then we are handling a case where
@@ -1123,7 +1129,7 @@ public static void Equal(Half expected, Half actual, Half variance)
1123
1129
1124
1130
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1125
1131
{
1126
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1132
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1127
1133
}
1128
1134
1129
1135
// When the variance is not +-0.0, then we are handling a case where
@@ -1134,7 +1140,7 @@ public static void Equal(Half expected, Half actual, Half variance)
1134
1140
{
1135
1141
if ( IsPositiveZero ( variance ) || IsNegativeZero ( variance ) )
1136
1142
{
1137
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1143
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1138
1144
}
1139
1145
1140
1146
// When the variance is not +-0.0, then we are handling a case where
@@ -1146,7 +1152,7 @@ public static void Equal(Half expected, Half actual, Half variance)
1146
1152
1147
1153
if ( delta > variance )
1148
1154
{
1149
- throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) ) ;
1155
+ throw EqualException . ForMismatchedValues ( ToStringPadded ( expected ) , ToStringPadded ( actual ) , banner ) ;
1150
1156
}
1151
1157
}
1152
1158
#endif
0 commit comments