Skip to content

Instantly share code, notes, and snippets.

@null712
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save null712/2bbcf9a7e64fdf6ecd49 to your computer and use it in GitHub Desktop.
Save null712/2bbcf9a7e64fdf6ecd49 to your computer and use it in GitHub Desktop.
test_that("CalcAvg", {
cust = c("28456", "19946", "56456", "12435", "76465")
inst = rep("2345", 5)
quant = c(12, 67, 60, 12, 56)
price = c(794, 124, 69, 123, 678)
fee = c(12, 0.02, 0.01, 3, 34)
act = c("BUY", "SELL", "BUY", "SELL", "BUY")
date = as.Date(c(rep("2014-04-02", 2), rep("2014-04-06", 2), "2012-06-03"))
dftemp = data.frame(cust, inst, quant, price, fee, act, date)
names(dftemp) = c("customer_id", "instrument_id", "quant", "price", "fees", "action", "date")
results = CalcAvg(dftemp)
expect_equal(class(results), "data.frame")
expect_equal(nrow(results), 2)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment