Mercurial > repos > george-weingart > maaslin
comparison maaslin-4450aa4ecc84/maaslin-4450aa4ecc84/src/test-ValidateData/test-ValidateData.R @ 6:ca61989bc3b4
Uploaded
author | george-weingart |
---|---|
date | Sun, 08 Feb 2015 23:39:43 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:232e262654eb | 6:ca61989bc3b4 |
---|---|
1 c_strDir <- file.path(getwd( ),"..") | |
2 | |
3 source(file.path(c_strDir,"lib","Constants.R")) | |
4 source(file.path(c_strDir,"lib","ValidateData.R")) | |
5 | |
6 context("Test funcIsValid") | |
7 test_that("NA and NUll are false, all others are true",{ | |
8 expect_equal(funcIsValid(NA),FALSE) | |
9 expect_equal(funcIsValid(NULL),FALSE) | |
10 expect_equal(funcIsValid(1), TRUE) | |
11 expect_equal(funcIsValid("3"), TRUE) | |
12 expect_equal(funcIsValid(c("3","4")), TRUE) | |
13 expect_equal(funcIsValid(c(3,NA)), TRUE) | |
14 expect_equal(funcIsValid(""), TRUE) | |
15 expect_equal(funcIsValid(list()), TRUE) | |
16 expect_equal(funcIsValid(2.3), TRUE) | |
17 expect_equal(funcIsValid(TRUE), TRUE) | |
18 expect_equal(funcIsValid(FALSE), TRUE) | |
19 expect_equal(funcIsValid(as.factor(3)), TRUE) | |
20 }) | |
21 | |
22 context("Test funcIsValidString") | |
23 test_that("Test only strings are true",{ | |
24 expect_equal(funcIsValidString(NA),FALSE) | |
25 expect_equal(funcIsValidString(NULL),FALSE) | |
26 expect_equal(funcIsValidString(1), FALSE) | |
27 expect_equal(funcIsValidString("3"), TRUE) | |
28 expect_equal(funcIsValidString(c("3","4")), FALSE) | |
29 expect_equal(funcIsValidString(""), TRUE) | |
30 expect_equal(funcIsValidString(list()), FALSE) | |
31 expect_equal(funcIsValidString(2.3), FALSE) | |
32 expect_equal(funcIsValidString(TRUE), FALSE) | |
33 expect_equal(funcIsValidString(FALSE), FALSE) | |
34 }) | |
35 | |
36 context("Test funcIsValidFileName") | |
37 strFileSimpleRCFileAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncWriteMatrixToReadConfigFile_SimpleAnswer.read.config") | |
38 strFileUseAllRCFileAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncWriteMatrixToReadConfigFile_AllAnswer.read.config") | |
39 | |
40 test_that("Test only strings pointing to existing files are true",{ | |
41 expect_equal(funcIsValidFileName(NA),FALSE) | |
42 expect_equal(funcIsValidFileName(NULL),FALSE) | |
43 expect_equal(funcIsValidFileName(1), FALSE) | |
44 expect_equal(funcIsValidFileName("3"), FALSE) | |
45 expect_equal(funcIsValidFileName(c("3","4")), FALSE) | |
46 expect_equal(funcIsValidFileName(""), FALSE) | |
47 expect_equal(funcIsValidFileName(list()), FALSE) | |
48 expect_equal(funcIsValidFileName(2.3), FALSE) | |
49 expect_equal(funcIsValidFileName(TRUE), FALSE) | |
50 expect_equal(funcIsValidFileName(FALSE), FALSE) | |
51 expect_equal(funcIsValidFileName(strFileSimpleRCFileAnswer),TRUE) | |
52 expect_equal(funcIsValidFileName(strFileUseAllRCFileAnswer),TRUE) | |
53 }) |