28 lines
591 B
Python
28 lines
591 B
Python
import unittest
|
|
import sys
|
|
from pathlib import Path
|
|
# Add the project root to sys.path
|
|
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
|
|
|
from Float import *
|
|
|
|
class FloatTest(unittest.TestCase):
|
|
def test_Clamp(self):
|
|
r = Float.Clamp(1, 0, 2)
|
|
assert(r == 1)
|
|
|
|
r = Float.Clamp(-1, 0, 2)
|
|
assert(r == 0)
|
|
|
|
r = Float.Clamp(3, 0, 2)
|
|
assert(r == 2)
|
|
|
|
r = Float.Clamp(1, 0, 0)
|
|
assert(r == 0)
|
|
|
|
r = Float.Clamp(0, 0, 0)
|
|
assert(r == 0)
|
|
|
|
r = Float.Clamp(0, 1, -1)
|
|
assert(r == 0)
|