|
1 | 1 | #!/usr/bin/r -t
|
2 | 2 | # -*- mode: R; tab-width: 4; -*-
|
3 | 3 | #
|
4 |
| -# Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois |
| 4 | +# Copyright (C) 2010 - 2014 Dirk Eddelbuettel and Romain Francois |
5 | 5 | #
|
6 | 6 | # This file is part of Rcpp.
|
7 | 7 | #
|
|
22 | 22 |
|
23 | 23 | if (.runThisTest) {
|
24 | 24 |
|
25 |
| -.setUp <- Rcpp:::unit_test_setup( "DataFrame.cpp" ) |
| 25 | + .setUp <- Rcpp:::unitTestSetup("DataFrame.cpp") |
26 | 26 |
|
27 |
| -test.DataFrame.FromSEXP <- function() { |
28 |
| - DF <- data.frame(a=1:3, b=c("a","b","c")) |
29 |
| - checkEquals( FromSEXP(DF), DF, msg = "DataFrame pass-through") |
30 |
| -} |
| 27 | + test.DataFrame.FromSEXP <- function() { |
| 28 | + DF <- data.frame(a=1:3, b=c("a","b","c")) |
| 29 | + checkEquals( FromSEXP(DF), DF, msg = "DataFrame pass-through") |
| 30 | + } |
31 | 31 |
|
32 |
| -test.DataFrame.index.byName <- function() { |
33 |
| - DF <- data.frame(a=1:3, b=c("a","b","c")) |
34 |
| - checkEquals( index_byName(DF, "a"), DF$a, msg = "DataFrame column by name 'a'") |
35 |
| - checkEquals( index_byName(DF, "b"), DF$b, msg = "DataFrame column by name 'b'") |
36 |
| -} |
| 32 | + test.DataFrame.index.byName <- function() { |
| 33 | + DF <- data.frame(a=1:3, b=c("a","b","c")) |
| 34 | + checkEquals( index_byName(DF, "a"), DF$a, msg = "DataFrame column by name 'a'") |
| 35 | + checkEquals( index_byName(DF, "b"), DF$b, msg = "DataFrame column by name 'b'") |
| 36 | + } |
37 | 37 |
|
38 |
| -test.DataFrame.index.byPosition <- function() { |
39 |
| - DF <- data.frame(a=1:3, b=c("a","b","c")) |
40 |
| - checkEquals( index_byPosition(DF, 0), DF$a, msg = "DataFrame column by position 0") |
41 |
| - checkEquals( index_byPosition(DF, 1), DF$b, msg = "DataFrame column by position 1") |
42 |
| -} |
| 38 | + test.DataFrame.index.byPosition <- function() { |
| 39 | + DF <- data.frame(a=1:3, b=c("a","b","c")) |
| 40 | + checkEquals( index_byPosition(DF, 0), DF$a, msg = "DataFrame column by position 0") |
| 41 | + checkEquals( index_byPosition(DF, 1), DF$b, msg = "DataFrame column by position 1") |
| 42 | + } |
43 | 43 |
|
44 |
| -test.DataFrame.string.element <- function() { |
45 |
| - DF <- data.frame(a=1:3, b=c("a","b","c"), stringsAsFactors=FALSE) |
46 |
| - checkEquals( string_element(DF), DF[2,"b"], msg = "DataFrame string element") |
47 |
| -} |
| 44 | + test.DataFrame.string.element <- function() { |
| 45 | + DF <- data.frame(a=1:3, b=c("a","b","c"), stringsAsFactors=FALSE) |
| 46 | + checkEquals( string_element(DF), DF[2,"b"], msg = "DataFrame string element") |
| 47 | + } |
48 | 48 |
|
49 |
| -test.DataFrame.CreateOne <- function() { |
50 |
| - DF <- data.frame(a=1:3) |
51 |
| - checkEquals( createOne(), DF, msg = "DataFrame create1") |
52 |
| -} |
| 49 | + test.DataFrame.CreateOne <- function() { |
| 50 | + DF <- data.frame(a=1:3) |
| 51 | + checkEquals( createOne(), DF, msg = "DataFrame create1") |
| 52 | + } |
53 | 53 |
|
54 |
| -test.DataFrame.CreateTwo <- function() { |
55 |
| - DF <- data.frame(a=1:3, b=c("a","b","c")) |
56 |
| - checkEquals( createTwo(), DF, msg = "DataFrame create2") |
57 |
| -} |
| 54 | + test.DataFrame.CreateTwo <- function() { |
| 55 | + DF <- data.frame(a=1:3, b=c("a","b","c")) |
| 56 | + checkEquals( createTwo(), DF, msg = "DataFrame create2") |
| 57 | + } |
58 | 58 |
|
59 |
| -test.DataFrame.SlotProxy <- function(){ |
60 |
| - setClass("track", representation(x="data.frame", y = "function")) |
61 |
| - df <- data.frame( x = 1:10, y = 1:10 ) |
62 |
| - tr1 <- new( "track", x = df, y = rnorm ) |
63 |
| - checkTrue( identical( SlotProxy(tr1, "x"), df ), msg = "DataFrame( SlotProxy )" ) |
64 |
| - checkException( SlotProxy(tr1, "y"), msg = "DataFrame( SlotProxy ) -> exception" ) |
65 |
| -} |
| 59 | + test.DataFrame.SlotProxy <- function(){ |
| 60 | + setClass("track", representation(x="data.frame", y = "function")) |
| 61 | + df <- data.frame( x = 1:10, y = 1:10 ) |
| 62 | + tr1 <- new( "track", x = df, y = rnorm ) |
| 63 | + checkTrue( identical( SlotProxy(tr1, "x"), df ), msg = "DataFrame( SlotProxy )" ) |
| 64 | + checkException( SlotProxy(tr1, "y"), msg = "DataFrame( SlotProxy ) -> exception" ) |
| 65 | + } |
66 | 66 |
|
67 |
| -test.DataFrame.AttributeProxy <- function(){ |
68 |
| - df <- data.frame( x = 1:10, y = 1:10 ) |
69 |
| - tr1 <- structure( NULL, x = df, y = rnorm ) |
70 |
| - checkTrue( identical( AttributeProxy(tr1, "x"), df) , msg = "DataFrame( AttributeProxy )" ) |
71 |
| - checkException( AttributeProxy(tr1, "y"), msg = "DataFrame( AttributeProxy ) -> exception" ) |
72 |
| -} |
| 67 | + test.DataFrame.AttributeProxy <- function(){ |
| 68 | + df <- data.frame( x = 1:10, y = 1:10 ) |
| 69 | + tr1 <- structure( NULL, x = df, y = rnorm ) |
| 70 | + checkTrue( identical( AttributeProxy(tr1, "x"), df) , msg = "DataFrame( AttributeProxy )" ) |
| 71 | + checkException( AttributeProxy(tr1, "y"), msg = "DataFrame( AttributeProxy ) -> exception" ) |
| 72 | + } |
73 | 73 |
|
74 |
| -test.DataFrame.CreateTwo.stringsAsFactors <- function() { |
75 |
| - DF <- data.frame(a=1:3, b=c("a","b","c"), stringsAsFactors = FALSE ) |
76 |
| - checkEquals( createTwoStringsAsFactors(), DF, msg = "DataFrame create2 stringsAsFactors = false") |
77 |
| -} |
| 74 | + test.DataFrame.CreateTwo.stringsAsFactors <- function() { |
| 75 | + DF <- data.frame(a=1:3, b=c("a","b","c"), stringsAsFactors = FALSE ) |
| 76 | + checkEquals( createTwoStringsAsFactors(), DF, msg = "DataFrame create2 stringsAsFactors = false") |
| 77 | + } |
78 | 78 |
|
79 |
| -test.DataFrame.nrows <- function(){ |
80 |
| - df <- data.frame( x = 1:10, y = 1:10 ) |
81 |
| - checkEquals( DataFrame_nrows( df ), nrow(df) ) |
82 |
| -} |
| 79 | + test.DataFrame.nrows <- function(){ |
| 80 | + df <- data.frame( x = 1:10, y = 1:10 ) |
| 81 | + checkEquals( DataFrame_nrows( df ), nrow(df) ) |
| 82 | + } |
83 | 83 |
|
84 | 84 |
|
85 | 85 | }
|
0 commit comments