|
| 1 | +context("test get xlim for gsplot object") |
| 2 | +test_that("xlim for single axis", { |
| 3 | + |
| 4 | + usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>% |
| 5 | + points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') |
| 6 | + |
| 7 | + expect_equal(xlim(usrDef)[[1]], c(1,1)) |
| 8 | + |
| 9 | + usrDef <- points(usrDef,x=3:10,y=4:11, side=c(3,2)) |
| 10 | + |
| 11 | + expect_equal(xlim(usrDef)[[1]], c(1,10)) |
| 12 | + |
| 13 | +}) |
| 14 | + |
| 15 | +test_that("xlim for dual axis", { |
| 16 | + |
| 17 | + usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>% |
| 18 | + points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') %>% |
| 19 | + points(x=3:10,y=4:11, side=c(1,2)) |
| 20 | + |
| 21 | + expect_equal(xlim(usrDef)[[1]], c(1,1)) |
| 22 | + expect_equal(xlim(usrDef)[[2]], c(3,10)) |
| 23 | + |
| 24 | +}) |
| 25 | + |
| 26 | +test_that("xlim for string input", { |
| 27 | + |
| 28 | + usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>% |
| 29 | + points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') %>% |
| 30 | + points(x=3:10,y=4:11, side=c(1,2)) |
| 31 | + |
| 32 | + expect_equal(xlim(usrDef)[['side.3']], c(1,1)) |
| 33 | + expect_equal(xlim(usrDef, side = 3)[[1]], c(1,1)) |
| 34 | + expect_equal(xlim(usrDef, side = 1)[[1]], c(3,10)) |
| 35 | + |
| 36 | +}) |
| 37 | + |
| 38 | +context("test get par for gsplot object") |
| 39 | + |
| 40 | +test_that("par for simple object",{ |
| 41 | + expect_equal(par(gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r'))$xaxs,'r') |
| 42 | + expect_is(par(gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r')), 'list') |
| 43 | +}) |
| 44 | + |
| 45 | +context("test get logged for gsplot object") |
| 46 | + |
| 47 | +test_that("logged for simple object",{ |
| 48 | + usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>% |
| 49 | + points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat') %>% |
| 50 | + points(x=3:10,y=4:11, side=c(1,2)) |
| 51 | + expect_equal(logged(usrDef)[[1]],"") |
| 52 | + expect_equal(logged(usrDef)[[2]],"") |
| 53 | + |
| 54 | + usrDef <- lines(usrDef,1:2,4:5, log='xy') |
| 55 | + expect_equal(logged(usrDef)[[1]],"") |
| 56 | + expect_equal(logged(usrDef)[[2]],"xy") |
| 57 | + |
| 58 | +}) |
| 59 | + |
| 60 | +test_that("logged side extractor ",{ |
| 61 | + usrDef <- gsplot(mar=c(4,4,4,4), xaxs='r', yaxs='r') %>% |
| 62 | + points(x=1, y=2, side=c(3,2), legend.name="Points 1", cex=3, xlab='cat',log='y') %>% |
| 63 | + points(x=3:10,y=4:11, side=c(1,2), log='xy') |
| 64 | + expect_true(logged(usrDef, side=1)) |
| 65 | + expect_false(logged(usrDef, side=3)) |
| 66 | + |
| 67 | + dual = logged(usrDef, side=c(1,2)) |
| 68 | + expect_equal(length(dual), 2) |
| 69 | + expect_true(all(dual)) |
| 70 | +}) |
0 commit comments