@@ -782,7 +782,7 @@ if (.runThisTest) {
782
782
test.sugar.median_int <- function () {
783
783
fx <- median_int
784
784
785
- x <- as.integer(rpos (5 , 20 ))
785
+ x <- as.integer(rpois (5 , 20 ))
786
786
checkEquals(fx(x ), median(x ),
787
787
" median_int / odd length / no NA / na.rm = FALSE" )
788
788
@@ -794,7 +794,7 @@ if (.runThisTest) {
794
794
" median_int / odd length / with NA / na.rm = TRUE" )
795
795
796
796
# #
797
- x <- as.integer(rpos (6 , 20 ))
797
+ x <- as.integer(rpois (6 , 20 ))
798
798
checkEquals(fx(x ), median(x ),
799
799
" median_int / even length / no NA / na.rm = FALSE" )
800
800
@@ -874,19 +874,28 @@ if (.runThisTest) {
874
874
checkEquals(fx(x ), median(x ),
875
875
" median_ch / odd length / with NA / na.rm = FALSE" )
876
876
877
- checkEquals(fx(x , TRUE ), median(x , TRUE ),
877
+ # # median(x, TRUE) returns NA_real_ for character vector input
878
+ # # which results in a warning; i.e. if the vector it passes to
879
+ # # `mean.default(sort(x, partial = half + 0L:1L)[half + 0L:1L])`
880
+ # # has ((length(x) %% 2) == 0)
881
+
882
+ checkEquals(fx(x , TRUE ),
883
+ as.character(suppressWarnings(median(x , TRUE ))),
878
884
" median_ch / odd length / with NA / na.rm = TRUE" )
879
885
880
886
# #
881
887
x <- sample(letters , 6 )
882
- checkEquals(fx(x ), suppressWarnings(median(x )),
888
+ checkEquals(fx(x ),
889
+ as.character(suppressWarnings(median(x ))),
883
890
" median_ch / even length / no NA / na.rm = FALSE" )
884
891
885
892
x [4 ] <- NA
886
- checkEquals(fx(x ), suppressWarnings(median(x )),
893
+ checkEquals(fx(x ),
894
+ as.character(suppressWarnings(median(x ))),
887
895
" median_ch / even length / with NA / na.rm = FALSE" )
888
896
889
- checkEquals(fx(x , TRUE ), suppressWarnings(median(x , TRUE )),
897
+ checkEquals(fx(x , TRUE ),
898
+ as.character(suppressWarnings(median(x , TRUE ))),
890
899
" median_ch / even length / with NA / na.rm = TRUE" )
891
900
}
892
901
0 commit comments