switch fpdiv/test/test_fp*.py to use unittest
[ieee754fpu.git] / src / ieee754 / fpdiv / test / test_fprsqrt_pipe.py
index 72e619b701248a914e8ddf09c2a784cb657544f7..d8e47235f3ed68c7a851173a046a4422077dccdc 100644 (file)
@@ -4,27 +4,31 @@
 from ieee754.fpdiv.pipeline import (FPDIVMuxInOut,)
 from ieee754.fpcommon.test.fpmux import runfp
 
+import unittest
 from sfpy import Float64, Float32, Float16
 
+
 def rsqrt(x):
+    # FIXME: switch to correct implementation (rounding once)
     return x.__class__(1.0) / x.sqrt()
 
-def test_pipe_rsqrt_fp16():
-    dut = FPDIVMuxInOut(16, 4)
-    runfp(dut, 16, "test_fprsqrt_pipe_fp16", Float16, rsqrt,
-          single_op=True, opcode=2, n_vals=100)
 
-def test_pipe_rsqrt_fp32():
-    dut = FPDIVMuxInOut(32, 4)
-    runfp(dut, 32, "test_fprsqrt_pipe_fp32", Float32, rsqrt,
-          single_op=True, opcode=2, n_vals=100)
+class TestDivPipe(unittest.TestCase):
+    def test_pipe_rsqrt_fp16(self):
+        dut = FPDIVMuxInOut(16, 4)
+        runfp(dut, 16, "test_fprsqrt_pipe_fp16", Float16, rsqrt,
+              single_op=True, opcode=2, n_vals=100)
+
+    def test_pipe_rsqrt_fp32(self):
+        dut = FPDIVMuxInOut(32, 4)
+        runfp(dut, 32, "test_fprsqrt_pipe_fp32", Float32, rsqrt,
+              single_op=True, opcode=2, n_vals=100)
+
+    def test_pipe_rsqrt_fp64(self):
+        dut = FPDIVMuxInOut(64, 4)
+        runfp(dut, 64, "test_fprsqrt_pipe_fp64", Float64, rsqrt,
+              single_op=True, opcode=2, n_vals=100)
 
-def test_pipe_rsqrt_fp64():
-    dut = FPDIVMuxInOut(64, 4)
-    runfp(dut, 64, "test_fprsqrt_pipe_fp64", Float64, rsqrt,
-          single_op=True, opcode=2, n_vals=100)
 
 if __name__ == '__main__':
-    test_pipe_rsqrt_fp32()
-    test_pipe_rsqrt_fp16()
-    test_pipe_rsqrt_fp64()
+    unittest.main()