File: test-cos_sim.R

package info (click to toggle)
r-bioc-mutationalpatterns 3.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,908 kB
  • sloc: sh: 8; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 448 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
context("test-cos_sim")

# Calculate cosine similarity
x <- c(1.1, 2.1, 0.2, 0.1, 2.9)
y <- c(0.9, 1.9, 0.5, 0.4, 3.1)
output <- cos_sim(x, y)


test_that("Output has correct class and data type", {
  expect_true(inherits(output, c("numeric")))
  expect_equal(typeof(output), "double")
})

test_that("Output has expected size", {
  expect_equal(length(output), 1)
})

test_that("Output is equal to expected", {
  expect_equal(output, 0.9895599)
})