Permalink
Browse files

Move UTF-8 tests to another file to conceal them from platforms that …

…cannot parse them
  • Loading branch information...
nealrichardson committed Apr 14, 2015
1 parent 544198d commit 7f749717f6b796046671981edaeabf41edf49947
Showing with 37 additions and 32 deletions.
  1. +3 −32 pkg/tests/testthat/test-encoding.R
  2. +34 −0 pkg/tests/testthat/utftesting.R
@@ -1,36 +1,7 @@
context("UTF-8 Encoding")
if (run.integration.tests) {
test_that("encoding + JSON reads correctly", {
s <- iconv("aided_follow_grid:ElCorteInglés", to="UTF-8")
expect_identical(Encoding(s), "UTF-8")
expect_true(grepl("Inglés", s))
sj <- toJSON(s)
expect_true(grepl("Inglés", sj))
s2 <- fromJSON(sj)
expect_identical(s2, s)
expect_identical(fromJSON("utf-test.json"), "Budějovický Budvar")
})
with(fake.HTTP, {
ds <- loadDataset("test ds")
test_that("Reading UTF in tests", {
expect_identical(description(ds$mymrset), "Budějovický Budvar")
})
})
with(test.authentication, {
with(test.dataset(df), {
test_that("Properly encoded UTF is sent and received", {
s <- iconv("aided_follow_grid:ElCorteInglés", to="UTF-8")
name(ds$v1) <- s
expect_identical(name(ds$v1), s)
expect_identical(name(refresh(ds)$v1), s)
s2 <- "Budějovický Budvar"
name(ds$v2) <- s2
expect_identical(name(ds$v2), s2)
expect_identical(name(refresh(ds)$v2), s2)
})
})
})
## Move the actual tests to a different file so that non-Unicode
## environments won't fail to parse (even if not running these tests)
source("utftesting.R", local=TRUE)
}
@@ -0,0 +1,34 @@
test_that("encoding + JSON reads correctly", {
s <- iconv("aided_follow_grid:ElCorteInglés", to="UTF-8")
expect_identical(Encoding(s), "UTF-8")
expect_true(grepl("Inglés", s))
sj <- toJSON(s)
expect_true(grepl("Inglés", sj))
s2 <- fromJSON(sj)
expect_identical(s2, s)
expect_identical(fromJSON("utf-test.json"), "Budějovický Budvar")
})
with(fake.HTTP, {
ds <- loadDataset("test ds")
test_that("Reading UTF in tests", {
expect_identical(description(ds$mymrset), "Budějovický Budvar")
})
})
with(test.authentication, {
with(test.dataset(df), {
test_that("Properly encoded UTF is sent and received", {
s <- iconv("aided_follow_grid:ElCorteInglés", to="UTF-8")
name(ds$v1) <- s
expect_identical(name(ds$v1), s)
expect_identical(name(refresh(ds)$v1), s)
s2 <- "Budějovický Budvar"
name(ds$v2) <- s2
expect_identical(name(ds$v2), s2)
expect_identical(name(refresh(ds)$v2), s2)
})
})
})
(

0 comments on commit 7f74971

Please sign in to comment.