Skip to content

Commit

Permalink
extend hypervolume test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Aug 26, 2015
1 parent 61fae65 commit fc16aec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/test_hypervolume.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,30 @@ test_that("calculation of dominated hypervolume works as expected", {
nrow = 2L)
ref.point = c(6, 6)

# HV with passed reference point
hv = computeDominatedHypervolume(points, ref.point)
expect_true(is.numeric(hv))
expect_equal(hv, hv.exp)

# HV with self computed reference point
hv = computeDominatedHypervolume(points)
expect_true(is.numeric(hv))

# check sanity checks
# Unequal dimensions
expect_error(computeDominatedHypervolume(points, ref.point[-1L]))

# check for warnings on infinite values
points2 = points
points2[1L, 1L] = Inf
expect_warning(computeDominatedHypervolume(points2, ref.point), "point", ignore.case = TRUE)
expect_true(is.nan(computeDominatedHypervolume(points2, ref.point)))

ref.point2 = ref.point
ref.point2[2L] = Inf
expect_warning(computeDominatedHypervolume(points, ref.point2), "Reference point", ignore.case = TRUE)
expect_true(is.nan(computeDominatedHypervolume(points, ref.point2)))

# now check the hypervolume contributions
hv.contribs = computeHypervolumeContribution(points, ref.point)
expect_true(all(hv.contribs == 1))
Expand Down

0 comments on commit fc16aec

Please sign in to comment.