tests/test-sink.R

library( colorSpec )

testSink <- function()
    {
    cs.options( stop=FALSE )

    path    = 'junk.log'
    
    #   start the sink
    con = file( path, open = "wt")
    sink( file=con, append=FALSE, type="message" )
    
    #   read 2 non-existent files
    readSpectra( "nonexistent.txt" )
    readSpectra( "nonexistent2.txt" )

    #   stop the sink
    sink( NULL, type='message' )
    close( con )
    
    cs.options( stop=TRUE )
    
    #   path should have 4 lines in it
    line    = readLines( path )   #;   cat( length(line), '\n' )
    
    if( length(line) != 4 )   return(FALSE)
    
    return(TRUE)
    }

    
if( ! testSink() )  stop( "testSink() failed !" )

cat( "Passed all sink tests !\n", file=stderr() )

Try the colorSpec package in your browser

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

colorSpec documentation built on April 2, 2018, 5:05 p.m.