@@ -222,6 +222,10 @@ func TestEqual(t *testing.T) {
222
222
if Equal (mockT , myType ("1" ), myType ("2" )) {
223
223
t .Error ("Equal should return false" )
224
224
}
225
+ // A case that might be confusing, especially with numeric literals
226
+ if Equal (mockT , 10 , uint (10 )) {
227
+ t .Error ("Equal should return false" )
228
+ }
225
229
}
226
230
227
231
func ptr (i int ) * int {
@@ -544,6 +548,70 @@ func TestNotEqual(t *testing.T) {
544
548
if NotEqual (mockT , & struct {}{}, & struct {}{}) {
545
549
t .Error ("NotEqual should return false" )
546
550
}
551
+
552
+ // A case that might be confusing, especially with numeric literals
553
+ if ! NotEqual (mockT , 10 , uint (10 )) {
554
+ t .Error ("NotEqual should return false" )
555
+ }
556
+ }
557
+
558
+ func TestNotEqualValues (t * testing.T ) {
559
+
560
+ mockT := new (testing.T )
561
+
562
+ // Same tests as NotEqual since they behave the same when types are irrelevant
563
+ if ! NotEqualValues (mockT , "Hello World" , "Hello World!" ) {
564
+ t .Error ("NotEqualValues should return true" )
565
+ }
566
+ if ! NotEqualValues (mockT , 123 , 1234 ) {
567
+ t .Error ("NotEqualValues should return true" )
568
+ }
569
+ if ! NotEqualValues (mockT , 123.5 , 123.55 ) {
570
+ t .Error ("NotEqualValues should return true" )
571
+ }
572
+ if ! NotEqualValues (mockT , []byte ("Hello World" ), []byte ("Hello World!" )) {
573
+ t .Error ("NotEqualValues should return true" )
574
+ }
575
+ if ! NotEqualValues (mockT , nil , new (AssertionTesterConformingObject )) {
576
+ t .Error ("NotEqualValues should return true" )
577
+ }
578
+ if NotEqualValues (mockT , nil , nil ) {
579
+ t .Error ("NotEqualValues should return false" )
580
+ }
581
+ if NotEqualValues (mockT , "Hello World" , "Hello World" ) {
582
+ t .Error ("NotEqualValues should return false" )
583
+ }
584
+ if NotEqualValues (mockT , 123 , 123 ) {
585
+ t .Error ("NotEqualValues should return false" )
586
+ }
587
+ if NotEqualValues (mockT , 123.5 , 123.5 ) {
588
+ t .Error ("NotEqualValues should return false" )
589
+ }
590
+ if NotEqualValues (mockT , []byte ("Hello World" ), []byte ("Hello World" )) {
591
+ t .Error ("NotEqualValues should return false" )
592
+ }
593
+ if NotEqualValues (mockT , new (AssertionTesterConformingObject ), new (AssertionTesterConformingObject )) {
594
+ t .Error ("NotEqualValues should return false" )
595
+ }
596
+ if NotEqualValues (mockT , & struct {}{}, & struct {}{}) {
597
+ t .Error ("NotEqualValues should return false" )
598
+ }
599
+
600
+ // Special cases where NotEqualValues behaves differently
601
+ funcA := func () int { return 23 }
602
+ funcB := func () int { return 42 }
603
+ if ! NotEqualValues (mockT , funcA , funcB ) {
604
+ t .Error ("NotEqualValues should return true" )
605
+ }
606
+ if ! NotEqualValues (mockT , int (10 ), int (11 )) {
607
+ t .Error ("NotEqualValues should return true" )
608
+ }
609
+ if NotEqualValues (mockT , int (10 ), uint (10 )) {
610
+ t .Error ("NotEqualValues should return false" )
611
+ }
612
+ if NotEqualValues (mockT , struct {}{}, struct {}{}) {
613
+ t .Error ("NotEqualValues should return false" )
614
+ }
547
615
}
548
616
549
617
type A struct {
@@ -2139,6 +2207,7 @@ func TestComparisonAssertionFunc(t *testing.T) {
2139
2207
{"isType" , (* testing .T )(nil ), t , IsType },
2140
2208
{"equal" , t , t , Equal },
2141
2209
{"equalValues" , t , t , EqualValues },
2210
+ {"notEqualValues" , t , nil , NotEqualValues },
2142
2211
{"exactly" , t , t , Exactly },
2143
2212
{"notEqual" , t , nil , NotEqual },
2144
2213
{"notContains" , []int {1 , 2 , 3 }, 4 , NotContains },
0 commit comments