"""
Authors: Peter Mawhorter
Consulted:
Date: 2022-2-25
Purpose: Testing code for audioToolkit task.
"""

import optimism

import audioToolkit

print(
    "Reminder: some of your result values may include small"
  + " floating-point errors. These tests should still pass."
)

# Test makeSofter
manager = optimism.testFunctionMaybe(audioToolkit, "makeSofter")
manager.case([0, -0.2, 0.4, -0.6]).checkReturnValue(
    [0, -0.02, 0.04, -0.06]
)
manager.case([0.1, -0.4]).checkReturnValue([0.01, -0.04])
manager.case([]).checkReturnValue([])

# Test chipmunk
manager = optimism.testFunctionMaybe(audioToolkit, "chipmunk")
manager.case([0, -0.2, 0.4, -0.6]).checkReturnValue([0, 0.4])
manager.case([-0.3, 0.2, 0.1]).checkReturnValue([-0.3, 0.1])
manager.case([]).checkReturnValue([])

# Test removeVocals
manager = optimism.testFunctionMaybe(audioToolkit, "removeVocals")
manager.case(
    [0.1, 0.5, -0.2],
    [-0.1, -0.6, 0.3]
).checkReturnValue([0.1, 0.55, -0.25])
manager.case([0.7, 0.2], [0.3, -0.4]).checkReturnValue([0.2, 0.3])
manager.case([], []).checkReturnValue([])

# Test reverse
manager = optimism.testFunctionMaybe(audioToolkit, "reverse")
manager.case(
    [0.1, -0.2, 0.5, 0.2]
).checkReturnValue([0.2, 0.5, -0.2, 0.1])
manager.case([0.1, -0.9, 0.3]).checkReturnValue([0.3, -0.9, 0.1])
manager.case([]).checkReturnValue([])

# Test twoSampleDelay
manager = optimism.testFunctionMaybe(audioToolkit, "twoSampleDelay")
manager.case(
    [0.1, -0.2, 0.5, 0.6],
    -0.9,
    -0.7
).checkReturnValue([-0.4, -0.45, 0.3, 0.2])
manager.case(
    [0.1, 0.6, -0.2, 0.25, 0.3],
    0,
    -0.5
).checkReturnValue([0.05, 0.05, -0.05, 0.425, 0.05])
manager.case([], 0.2, 0.1).checkReturnValue([])

# Test ohYeah

manager = optimism.testFunctionMaybe(audioToolkit, "ohYeah")
manager.case(
    [0.5, -0.1, 0.4],
    -0.1
).checkReturnValue([0.2, 0.5, 0.2, -0.1, 0.15, 0.4])
manager.case([0.1], 0.1).checkReturnValue([0.1, 0.1])
manager.case([], -0.9).checkReturnValue([])

# Test crescendo

manager = optimism.testFunctionMaybe(audioToolkit, "crescendo")
manager.case([1.0, 1.0, 1.0], 0.2, 0.8).checkReturnValue([0.2, 0.5, 0.8])
manager.case([0.9, 0.3, 0.6, 0.2], 0, 1).checkReturnValue(
    [0, 0.1, 0.4, 0.2]
)
manager.case([], 0, 1).checkReturnValue([])

# You could write your own tests for custom here if you wanted
