1
1
# !/usr/bin/env r
2
2
# hey emacs, please make this use -*- tab-width: 4 -*-
3
3
#
4
- # Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
4
+ # Copyright (C) 2010 - 2018 Dirk Eddelbuettel and Romain Francois
5
5
#
6
6
# This file is part of Rcpp.
7
7
#
@@ -499,7 +499,7 @@ if (.runThisTest) {
499
499
paste(letters , collapse = " " ),
500
500
msg = " CharacterVector::iterator using std::accumulate" )
501
501
}
502
-
502
+
503
503
test.CharacterVector.iterator <- function (){
504
504
fun <- character_const_iterator1
505
505
checkEquals(fun(letters ),
@@ -655,12 +655,12 @@ if (.runThisTest) {
655
655
res <- character_vector_const_proxy( " fooo" )
656
656
checkEquals( res , " fooo" , msg = " CharacterVector const proxy. #32" )
657
657
}
658
-
658
+
659
659
test.CharacterVector.test.const.proxy <- function (){
660
660
res <- CharacterVector_test_const_proxy( letters )
661
661
checkEquals( res , letters )
662
662
}
663
-
663
+
664
664
test.sort <- function () {
665
665
num <- setNames( c(1 , - 1 , 4 , NA , 5 , NaN ), letters [1 : 5 ] )
666
666
checkIdentical( sort_numeric(num ), sort(num , na.last = TRUE ) )
@@ -671,33 +671,33 @@ if (.runThisTest) {
671
671
lgcl <- as.logical(int )
672
672
checkIdentical( sort_logical(lgcl ), sort(lgcl , na.last = TRUE ) )
673
673
}
674
-
674
+
675
675
test.sort_desc <- function () {
676
676
num <- setNames(c(1 , - 1 , 4 , NA , 5 , NaN ), letters [1 : 5 ])
677
677
checkIdentical(
678
- sort_numeric_desc(num ),
678
+ sort_numeric_desc(num ),
679
679
sort(num , decreasing = TRUE , na.last = FALSE )
680
680
)
681
-
681
+
682
682
int <- as.integer(num )
683
683
checkIdentical(
684
- sort_integer_desc(int ),
685
- sort(int , decreasing = TRUE , na.last = FALSE )
684
+ sort_integer_desc(int ),
685
+ sort(int , decreasing = TRUE , na.last = FALSE )
686
686
)
687
-
687
+
688
688
char <- setNames(sample(letters , 5 ), LETTERS [1 : 5 ])
689
689
checkIdentical(
690
- sort_character_desc(char ),
691
- sort(char , decreasing = TRUE , na.last = FALSE )
690
+ sort_character_desc(char ),
691
+ sort(char , decreasing = TRUE , na.last = FALSE )
692
692
)
693
-
693
+
694
694
lgcl <- as.logical(int )
695
695
checkIdentical(
696
- sort_logical_desc(lgcl ),
697
- sort(lgcl , decreasing = TRUE , na.last = FALSE )
696
+ sort_logical_desc(lgcl ),
697
+ sort(lgcl , decreasing = TRUE , na.last = FALSE )
698
698
)
699
699
}
700
-
700
+
701
701
test.List.assign.SEXP <- function () {
702
702
l <- list (1 , 2 , 3 )
703
703
other <- list_sexp_assign(l )
@@ -711,12 +711,12 @@ if (.runThisTest) {
711
711
test.logical.vector.from.bool.assign <- function () {
712
712
checkIdentical(logical_vector_from_bool_assign(), TRUE )
713
713
}
714
-
714
+
715
715
test.noprotect_vector <- function (){
716
716
x <- rnorm(10 )
717
717
checkIdentical( noprotect_vector(x ), 10L )
718
718
}
719
-
719
+
720
720
test.noprotect_matrix <- function (){
721
721
x <- matrix (rnorm(10 ), nrow = 2 )
722
722
checkIdentical( noprotect_matrix(x ), 2L )
@@ -755,5 +755,11 @@ if (.runThisTest) {
755
755
gctorture(FALSE )
756
756
checkEquals(x [y ], z )
757
757
}
758
+
759
+ test.CharacterVectorNoProtect <- function (){
760
+ s <- " foo"
761
+ checkEquals(CharacterVectorNoProtect(s ), 1L )
762
+ checkEquals(s , " " )
763
+ }
758
764
}
759
765
0 commit comments