annotate src/test-ValidateData/test-ValidateData.R @ 8:e9677425c6c3 default tip

Updated the structure of the libraries
author george.weingart@gmail.com
date Mon, 09 Feb 2015 12:17:40 -0500
parents e0b5980139d9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
1 c_strDir <- file.path(getwd( ),"..")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
2
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
3 source(file.path(c_strDir,"lib","Constants.R"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
4 source(file.path(c_strDir,"lib","ValidateData.R"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
5
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
6 context("Test funcIsValid")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
7 test_that("NA and NUll are false, all others are true",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
8 expect_equal(funcIsValid(NA),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
9 expect_equal(funcIsValid(NULL),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
10 expect_equal(funcIsValid(1), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
11 expect_equal(funcIsValid("3"), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
12 expect_equal(funcIsValid(c("3","4")), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
13 expect_equal(funcIsValid(c(3,NA)), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
14 expect_equal(funcIsValid(""), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
15 expect_equal(funcIsValid(list()), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
16 expect_equal(funcIsValid(2.3), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
17 expect_equal(funcIsValid(TRUE), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
18 expect_equal(funcIsValid(FALSE), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
19 expect_equal(funcIsValid(as.factor(3)), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
20 })
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
21
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
22 context("Test funcIsValidString")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
23 test_that("Test only strings are true",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
24 expect_equal(funcIsValidString(NA),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
25 expect_equal(funcIsValidString(NULL),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
26 expect_equal(funcIsValidString(1), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
27 expect_equal(funcIsValidString("3"), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
28 expect_equal(funcIsValidString(c("3","4")), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
29 expect_equal(funcIsValidString(""), TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
30 expect_equal(funcIsValidString(list()), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
31 expect_equal(funcIsValidString(2.3), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
32 expect_equal(funcIsValidString(TRUE), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
33 expect_equal(funcIsValidString(FALSE), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
34 })
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
35
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
36 context("Test funcIsValidFileName")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
37 strFileSimpleRCFileAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncWriteMatrixToReadConfigFile_SimpleAnswer.read.config")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
38 strFileUseAllRCFileAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncWriteMatrixToReadConfigFile_AllAnswer.read.config")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
39
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
40 test_that("Test only strings pointing to existing files are true",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
41 expect_equal(funcIsValidFileName(NA),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
42 expect_equal(funcIsValidFileName(NULL),FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
43 expect_equal(funcIsValidFileName(1), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
44 expect_equal(funcIsValidFileName("3"), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
45 expect_equal(funcIsValidFileName(c("3","4")), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
46 expect_equal(funcIsValidFileName(""), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
47 expect_equal(funcIsValidFileName(list()), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
48 expect_equal(funcIsValidFileName(2.3), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
49 expect_equal(funcIsValidFileName(TRUE), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
50 expect_equal(funcIsValidFileName(FALSE), FALSE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
51 expect_equal(funcIsValidFileName(strFileSimpleRCFileAnswer),TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
52 expect_equal(funcIsValidFileName(strFileUseAllRCFileAnswer),TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
53 })