tests/testthat/test-inference-execution.R

test_that("basic inference execution", {
  library(churon)

  # Check if ONNX Runtime is available
  if (!check_onnx_runtime_available()) {
    skip(
      "ONNX Runtime not installed - run install_onnx_runtime(destdir = tempdir())"
    )
  }

  expect_true(TRUE)
})

test_that("inference with invalid input data", {
  library(churon)

  # Check if ONNX Runtime is available
  if (!check_onnx_runtime_available()) {
    skip(
      "ONNX Runtime not installed - run install_onnx_runtime(destdir = tempdir())"
    )
  }

  model_dir <- system.file("model", package = "churon")
  model_files <- list.files(model_dir, pattern = "\\.onnx$", full.names = TRUE)

  if (length(model_files) > 0) {
    model_path <- model_files[1]
    session <- onnx_session(model_path)

    # Test with empty input
    expect_error(
      onnx_run(session, list()),
      "inputs cannot be empty"
    )

    # Test with unnamed input
    expect_error(
      onnx_run(session, list(matrix(1:4, 2, 2))),
      "All inputs must be named"
    )

    # Test with wrong input names
    expect_error(
      onnx_run(session, list(wrong_name = matrix(1:4, 2, 2))),
      "Missing required input tensor"
    )
  } else {
    skip("No ONNX model files found for testing")
  }
})

Try the churon package in your browser

Any scripts or data that you put into this service are public.

churon documentation built on Sept. 28, 2026, 5:07 p.m.