#--------------------------------------------------------------------------------------------------
# Linear mapping tests
#--------------------------------------------------------------------------------------------------
using Test
using Hensel

#--------------------------------------------------------------------------------------------------

@test Hensel.to01(0.5, 0, 1)    == 0.5
@test Hensel.to01(1.5, 1, 2)    == 0.5
@test Hensel.to01(1.3, 1, 2)    ≈  0.3
@test Hensel.to01(1.7, 1, 2)    ≈  0.7
@test Hensel.to01(-1.3, -2, -1) ≈  0.7
@test Hensel.to01(-1.7, -2, -1) ≈  0.3

@test Hensel.to01(3//2, 1, 2) == 1//2

@test Hensel.to01(0.5, (0, 1))    == 0.5
@test Hensel.to01(1.5, (1, 2))    == 0.5
@test Hensel.to01(1.3, (1, 2))    ≈  0.3
@test Hensel.to01(1.7, (1, 2))    ≈  0.7
@test Hensel.to01(-1.3, (-2, -1)) ≈  0.7
@test Hensel.to01(-1.7, (-2, -1)) ≈  0.3

@test Hensel.from01(1//2, 1, 2) == 3//2

@test Hensel.from01(0.5, 0, 1)   == 0.5
@test Hensel.from01(0.5, 1, 2)   == 1.5
@test Hensel.from01(0.3, 1, 2)   ≈  1.3
@test Hensel.from01(0.7, 1, 2)   ≈  1.7
@test Hensel.from01(0.7, -2, -1) ≈  -1.3
@test Hensel.from01(0.3, -2, -1) ≈  -1.7

@test Hensel.from01(0.5, (0, 1))   == 0.5
@test Hensel.from01(0.5, (1, 2))   == 1.5
@test Hensel.from01(0.3, (1, 2))   ≈  1.3
@test Hensel.from01(0.7, (1, 2))   ≈  1.7
@test Hensel.from01(0.7, (-2, -1)) ≈  -1.3
@test Hensel.from01(0.3, (-2, -1)) ≈  -1.7

#--------------------------------------------------------------------------------------------------
