## autogenerated unit-test ## from codegen/generate_unit-tests.sh ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz ## alias and function similarity ## checks this ensures that ## kicking and CDLKICKING produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values output <- kicking(SPY) alias <- CDLKICKING(SPY) ## 1.1) check if the values ## are equal testthat::expect_equal( object = output, expected = alias ) }) ## type-checks for data.frames and ## matrices ## ## object testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( inherits(kicking(SPY), class(SPY)) ) }) ## object testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( inherits(kicking(BTC), class(BTC)) ) }) ## check that the default calls ## matches that of the constructed call ## with default values. ## ## NOTE: This test is more of a test of the internal ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( object = kicking( BTC ), expected = kicking( BTC, cols = ~ open + high + low + close ) ) }) ## check that the length of the input ## matches the output length with na.bridge = TRUE ## ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( object = nrow(kicking( ATOM, na.bridge = TRUE )), expected = nrow(ATOM) ) }) ## check that the rownames are being ## respected for with na.bridge = TRUE testthat::test_that(desc = 'Row names are respected for , na.bridge = TRUE', code = { ## extract row names x_names <- row.names(ATOM) ## calculate indicator indicator <- kicking(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, expected = rownames(indicator) ) }) ## check that the length of the input ## matches the output length ## ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( object = nrow(kicking( BTC )), expected = nrow(BTC) ) }) ## check that the rownames are being ## respected for testthat::test_that(desc = 'Row names are respected for ', code = { ## extract row names x_names <- row.names(BTC) ## calculate indicator indicator <- kicking(BTC) testthat::expect_equal( object = x_names, expected = rownames(indicator) ) }) ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( object = nrow(kicking( SPY )), expected = nrow(SPY) ) }) ## check that the rownames are being ## respected for testthat::test_that(desc = 'Row names are respected for ', code = { ## extract row names ## NOTE: by default the SPY has no ## rownames rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator indicator <- kicking(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), expected = rownames(indicator) ) }) ## -method checks for ## and ## ## checks testthat::test_that(desc = '-methods for ', code = { ## check that kicking can ## use without any issues output <- testthat::expect_no_error( { chart(BTC) indicator(kicking) } ) ## check that the output ## is a -object testthat::expect_true( inherits(output, "plotly") ) }) ## checks testthat::test_that(desc = '-methods for ', code = { ## check that kicking can ## use without any issues output <- testthat::expect_no_error( { chart(SPY) indicator(kicking) } ) ## check that the output ## is a -object testthat::expect_true( inherits(output, "plotly") ) }) ## -method checks for ## and ## ## checks testthat::test_that(desc = '-methods for ', code = { testthat::skip_if_not_installed("ggplot2") ## check that kicking can ## use without any issues output <- testthat::expect_no_error( { options(talib.chart.backend = "ggplot2") on.exit(options(talib.chart.backend = "plotly")) chart(BTC) indicator(kicking) } ) ## check that the output ## is a -object or testthat::expect_true( inherits(output, "gg") || inherits(output, "talib_chart") ) }) ## checks testthat::test_that(desc = '-methods for ', code = { testthat::skip_if_not_installed("ggplot2") ## check that kicking can ## use without any issues output <- testthat::expect_no_error( { options(talib.chart.backend = "ggplot2") on.exit(options(talib.chart.backend = "plotly")) chart(SPY) indicator(kicking) } ) ## check that the output ## is a -object or testthat::expect_true( inherits(output, "gg") || inherits(output, "talib_chart") ) })