test_that("sm.coords returns valid dx performance and cutoff estimates",{

  skip_if_not_installed("pROC")
  library(pROC)

  data(blood_data)

  roc_obj<-roc(
    blood_data,
    response="Diagnosis",
    predictor="NfL",
    quiet=TRUE
  )

  fits<-find.distr(roc_obj, quiet=TRUE)

  smooth_roc<-do.call(
    smooth,
    c(list(roc_obj, method="fitdistr"), fits)
  )

  res<-sm.coords(smooth_roc, type="best", quiet=TRUE)

  expect_type(res, "double")
  expect_named(res, c("threshold", "specificity", "sensitivity"))

  expect_true(res["specificity"]>=0&&res["specificity"]<=1)
  expect_true(res["sensitivity"]>=0&&res["sensitivity"]<=1)
})

test_that("sm.coords errors on invalid input",{

  expect_error(
    sm.coords("not a smooth.roc"),
    "smooth.roc"
  )
})
