@@ -367,6 +367,30 @@ func SNil[S ~[]T, T any](s S, a ...any) {
367
367
}
368
368
}
369
369
370
+ // CNil asserts that the channel is nil. If it is not it panics/errors
371
+ // (default Asserter) the auto-generated (args appended) message.
372
+ //
373
+ // Note that when [Plain] asserter is used ([SetDefault]), optional arguments
374
+ // are used to override the auto-generated assert violation message.
375
+ func CNil [C ~ chan T , T any ](c C , a ... any ) {
376
+ if c != nil {
377
+ defMsg := assertionMsg + ": channel shouldn't be nil"
378
+ current ().reportAssertionFault (defMsg , a )
379
+ }
380
+ }
381
+
382
+ // MNil asserts that the map is nil. If it is not it panics/errors (default
383
+ // Asserter) the auto-generated (args appended) message.
384
+ //
385
+ // Note that when [Plain] asserter is used ([SetDefault]), optional arguments
386
+ // are used to override the auto-generated assert violation message.
387
+ func MNil [M ~ map [T ]U , T comparable , U any ](m M , a ... any ) {
388
+ if m != nil {
389
+ defMsg := assertionMsg + ": map should be nil"
390
+ current ().reportAssertionFault (defMsg , a )
391
+ }
392
+ }
393
+
370
394
// SNotNil asserts that the slice is not nil. If it is it panics/errors (default
371
395
// Asserter) the auto-generated (args appended) message.
372
396
//
@@ -735,6 +759,24 @@ func Empty(obj string, a ...any) {
735
759
}
736
760
}
737
761
762
+ // SEmpty asserts that the slice is empty. If it is NOT, it panics/errors
763
+ // (according the current Asserter) with the auto-generated message. You can
764
+ // append the generated got-want message by using optional message arguments.
765
+ //
766
+ // Note that when [Plain] asserter is used ([SetDefault]), optional arguments
767
+ // are used to override the auto-generated assert violation message.
768
+ //
769
+ // Note! This is reasonably fast but not as fast as [That] because of lacking
770
+ // inlining for the current implementation of Go's type parametric functions.
771
+ func SEmpty [S ~ []T , T any ](obj S , a ... any ) {
772
+ l := len (obj )
773
+
774
+ if l != 0 {
775
+ defMsg := assertionMsg + ": slice should be empty"
776
+ current ().reportAssertionFault (defMsg , a )
777
+ }
778
+ }
779
+
738
780
// SNotEmpty asserts that the slice is not empty. If it is, it panics/errors
739
781
// (according the current Asserter) with the auto-generated message. You can
740
782
// append the generated got-want message by using optional message arguments.
@@ -753,6 +795,26 @@ func SNotEmpty[S ~[]T, T any](obj S, a ...any) {
753
795
}
754
796
}
755
797
798
+ // MEmpty asserts that the map is empty. If it is NOT, it panics/errors
799
+ // (according the current Asserter) with the auto-generated message. You can
800
+ // append the generated got-want message by using optional message arguments.
801
+ // You can append the generated got-want message by using optional message
802
+ // arguments.
803
+ //
804
+ // Note that when [Plain] asserter is used ([SetDefault]), optional arguments
805
+ // are used to override the auto-generated assert violation message.
806
+ //
807
+ // Note! This is reasonably fast but not as fast as [That] because of lacking
808
+ // inlining for the current implementation of Go's type parametric functions.
809
+ func MEmpty [M ~ map [T ]U , T comparable , U any ](obj M , a ... any ) {
810
+ l := len (obj )
811
+
812
+ if l != 0 {
813
+ defMsg := assertionMsg + ": map should be empty"
814
+ current ().reportAssertionFault (defMsg , a )
815
+ }
816
+ }
817
+
756
818
// MNotEmpty asserts that the map is not empty. If it is, it panics/errors
757
819
// (according the current Asserter) with the auto-generated message. You can
758
820
// append the generated got-want message by using optional message arguments.
0 commit comments