@@ -782,7 +782,7 @@ if (.runThisTest) {
782782 test.sugar.median_int <- function () {
783783 fx <- median_int
784784
785- x <- as.integer(rpos (5 , 20 ))
785+ x <- as.integer(rpois (5 , 20 ))
786786 checkEquals(fx(x ), median(x ),
787787 " median_int / odd length / no NA / na.rm = FALSE" )
788788
@@ -794,7 +794,7 @@ if (.runThisTest) {
794794 " median_int / odd length / with NA / na.rm = TRUE" )
795795
796796 # #
797- x <- as.integer(rpos (6 , 20 ))
797+ x <- as.integer(rpois (6 , 20 ))
798798 checkEquals(fx(x ), median(x ),
799799 " median_int / even length / no NA / na.rm = FALSE" )
800800
@@ -874,19 +874,28 @@ if (.runThisTest) {
874874 checkEquals(fx(x ), median(x ),
875875 " median_ch / odd length / with NA / na.rm = FALSE" )
876876
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 ))),
878884 " median_ch / odd length / with NA / na.rm = TRUE" )
879885
880886 # #
881887 x <- sample(letters , 6 )
882- checkEquals(fx(x ), suppressWarnings(median(x )),
888+ checkEquals(fx(x ),
889+ as.character(suppressWarnings(median(x ))),
883890 " median_ch / even length / no NA / na.rm = FALSE" )
884891
885892 x [4 ] <- NA
886- checkEquals(fx(x ), suppressWarnings(median(x )),
893+ checkEquals(fx(x ),
894+ as.character(suppressWarnings(median(x ))),
887895 " median_ch / even length / with NA / na.rm = FALSE" )
888896
889- checkEquals(fx(x , TRUE ), suppressWarnings(median(x , TRUE )),
897+ checkEquals(fx(x , TRUE ),
898+ as.character(suppressWarnings(median(x , TRUE ))),
890899 " median_ch / even length / with NA / na.rm = TRUE" )
891900 }
892901
0 commit comments