~ubuntu-branches/ubuntu/wily/r-bioc-genomeinfodb/wily-proposed

« back to all changes in this revision

Viewing changes to inst/unitTests/test_utils.R

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2015-05-09 22:01:45 UTC
  • mfrom: (1.2.1) (3.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20150509220145-mqmfymcczq9n1yr8
Tags: 1.4.0-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
test_mergeNamedAtomicVectors <- function()
 
2
{
 
3
    ## The function is currently not exported.
 
4
    mergeNamedAtomicVectors <- GenomeInfoDb:::mergeNamedAtomicVectors
 
5
 
 
6
    x <- c(a=1, b=2, c=3, d=NA)
 
7
    checkIdentical(mergeNamedAtomicVectors(x, x), x)
 
8
 
 
9
    y1 <- x[FALSE]
 
10
    checkIdentical(mergeNamedAtomicVectors(x, y1), x)
 
11
    checkIdentical(mergeNamedAtomicVectors(y1, x), x)
 
12
 
 
13
    y2 <- c(c=NA_real_, d=NA_real_, b=NA_real_)
 
14
    checkIdentical(mergeNamedAtomicVectors(x, y2), x)
 
15
    checkIdentical(mergeNamedAtomicVectors(y2, x)[names(x)], x)
 
16
    checkIdentical(mergeNamedAtomicVectors(y2, x)[names(y2)], x[names(y2)])
 
17
 
 
18
    y3 <- c(c=3, e=NA, d=4, b=2)
 
19
    got <- mergeNamedAtomicVectors(x, y3)
 
20
    want <- c(a=1, b=2, c=3, d=4, e=NA)
 
21
    checkIdentical(got, want)
 
22
    got <- mergeNamedAtomicVectors(y3, x)
 
23
    want <- c(c=3, e=NA, d=4, b=2, a=1)
 
24
    checkIdentical(got, want)
 
25
 
 
26
    y4 <- c(c=0, e=NA, d=4, b=0)
 
27
    checkException(mergeNamedAtomicVectors(x, y4), silent=TRUE)
 
28
    checkException(mergeNamedAtomicVectors(y4, x), silent=TRUE)
 
29
 
 
30
    x2 <- c(a=1, b=NA, c=3, d=NA)
 
31
    y5 <- c(c=NA, e=5, d=4, b=2)
 
32
    got <- mergeNamedAtomicVectors(x2, y5)
 
33
    want <- c(a=1, b=2, c=3, d=4, e=5)
 
34
    checkIdentical(got, want)
 
35
}
 
36