Skip to content

Instantly share code, notes, and snippets.

@null712
Created July 16, 2014 19:02
Show Gist options
  • Save null712/0e954521c1e226d15754 to your computer and use it in GitHub Desktop.
Save null712/0e954521c1e226d15754 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