tests/testthat/test_fnExtension.R

## library(devtools)
## setwd("tests/testthat")
## load_all("../../")

context("fnExtension")

test_that("basic",{

    fileRef <- "testReference/fnExtension_1.rds"
    
    res1 <- list(
        fnExtension("feww.csv",".rds")
       ,
        ## Adding extension where not existing is also supported
        fnExtension("feww",".rds")
        ,
        ## we don't need the period
        fnExtension("feww","rds")
       ,
        ## we can remove extension
        fnExtension("feww.csv","")
    
    )

    expect_equal_to_reference(res1,fileRef)
    
})

test_that("Retrieve extension",{

    expect_equal(fnExtension("feww.csv"),"csv")
    expect_equal(fnExtension("feww.aa.csv"),"csv")
    expect_equal(fnExtension(".csv"),"csv")
## no extension to retrieve
    expect_equal(fnExtension("egef"),"")
        
})


test_that("skip directory .s",{
    expect_equal(fnExtension("fe/../egef",".csv"),"fe/../egef.csv")
    expect_equal(fnExtension("fe/./egef",".csv"),"fe/./egef.csv")
})

Try the NMdata package in your browser

Any scripts or data that you put into this service are public.

NMdata documentation built on Nov. 11, 2023, 5:07 p.m.