#' @export
print.dctest <- function(x, ...) {
  dctest <- x
  if (dctest$method == "none")
    testout <- "None"
  else if (dctest$method == "permutation")
    testout <- paste("Permutation test with ",dctest$b," permutations")
  else if (dctest$method == "gamma")
    testout <- "Gamma moment matching"               
  else if (dctest$method == "conservativebb")
    testout <- "Two-moment approximation by Berschneider and Boettcher (2019). This method is typically conservative." 
  else if (dctest$method == "conservativesz")
    testout <- "Chi-Square approximation by Szekely, Rizzo, Bakirov (2007). This method is typically markedly conservative." 
  else if (dctest$method == "conservativespv")
    testout <- "Chi-Square approximation by Shen, Panda, Vogelstein (2021). This method is aymptotically conservative for p-values smaller than 0.215, but can be anti-conservative in small samples." 
  else if (dctest$method == "bb3")
    testout <- "Three moment approximation by Berschneider and Boettcher (2019)."
  else if (dctest$method == "spectral")
    testout <- "Spectral approach using the asymptotic distribution. Asymptotically valid and tight (Edelmann, 2026)."
  else if (dctest$method == "wildbs1")
    testout <- "Wild bootstrap by Chwialkowksi, et al., Method 1"
  else if (dctest$method == "wildbs2")
    testout <- "Wild bootstrap by Chwialkowksi, et al., Method 2"
  
  #if (dctest$pvalue<1e-6)
 #   pvalout <- "< 1E-6"
 # else
#pvalout <- round(dctest$pvalue,6)
  
  pvalout <- dctest$pvalue
  
  cat(paste("pvalue: ",pvalout,"   dcov: ",round(dctest$dcov,6),"   dcor: ",round(dctest$dcor,6)))
  cat("\n")
  cat("\n")
  cat(paste("Method:",testout, "\n") )
  cat("\n")
  cat("Call:", "\n")
  cat(paste(deparse(dctest$call), "\n"))
  cat("\n")
  cat(paste("Bias correction: ", ifelse(dctest$bias.corr,"Yes \n", "No \n")) )
  cat(paste("Affinely invariant: ", ifelse(dctest$affine,"Yes \n", "No \n")) )
  cat(paste("Standardization applied: ", ifelse(dctest$standardize,"Yes \n", "No \n")) )
  cat(paste("Metric for X: ", dctest$metr.X, "\n") )
  cat(paste("Metric for Y: ", dctest$metr.Y, "\n") )
}


is.dctest <- function(x) inherits(x, "dctest")