If cmap_info contains any entry with levels=-1, cover the check_name (levels==-1) branch.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | id | |||
| integer, | intent(inout) | :: | nfail |
subroutine test_082(id, nfail) use forcolormap, only: Colormap, wp, cmap_info integer, intent(inout) :: id, nfail character(len=*), parameter :: name = "check_name: cover levels==-1 branch if present in cmap_info" logical :: ok type(Colormap) :: cm integer :: i, n, idx character(len=:), allocatable :: nm n = cmap_info%get_ncolormaps() idx = 0 do i = 1, n if (cmap_info%get_levels(i) == -1) then idx = i exit end if end do if (idx == 0) then ! This build has no “levels==-1” entries, so that branch cannot be exercised here. ok = .true. call report_test(name//" (no levels==-1 in cmap_info; skipped)", ok, id, nfail) return end if nm = trim(cmap_info%get_name(idx)) ! Request a mismatched levels value; for levels==-1, check_name should not override it. call cm%set(nm, 0.0_wp, 1.0_wp, 17) call cm%print_status() ok = (trim(cm%get_name()) == nm) .and. (cm%get_levels() == 17) call report_test(name, ok, id, nfail) end subroutine test_082