kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
More test coverage
rodzic
6d74ae52a3
commit
0c217541e0
|
@ -16,6 +16,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import math
|
||||
import unittest
|
||||
|
||||
# Import targets to be tested
|
||||
|
@ -25,7 +26,6 @@ from NanoVNASaver.RFTools import Datapoint, \
|
|||
parallel_to_serial, serial_to_parallel, \
|
||||
impedance_to_capacitance, impedance_to_inductance, \
|
||||
groupDelay, corr_att_data
|
||||
import math
|
||||
|
||||
|
||||
class TestRFTools(unittest.TestCase):
|
||||
|
@ -146,6 +146,7 @@ class TestRFToolsDatapoint(unittest.TestCase):
|
|||
|
||||
def test_properties(self):
|
||||
self.assertEqual(self.dp.z, complex(0.1091, 0.3118))
|
||||
self.assertEqual(self.dp.wavelength, 2997.92458)
|
||||
self.assertAlmostEqual(self.dp.phase, 1.23420722)
|
||||
self.assertEqual(self.dp0.gain, -math.inf)
|
||||
self.assertAlmostEqual(self.dp.gain, -9.6208748)
|
||||
|
|
|
@ -82,6 +82,10 @@ class TestTSIToolsValue(unittest.TestCase):
|
|||
self.assertEqual(str(Value(1e27)), "\N{INFINITY}")
|
||||
self.assertEqual(str(Value(-1e27)), "-\N{INFINITY}")
|
||||
self.assertEqual(float(Value(1e27)), 1e27)
|
||||
self.assertEqual(
|
||||
str(Value(11, fmt=Format(printable_max=10))), '')
|
||||
self.assertEqual(
|
||||
str(Value(11, fmt=Format(allways_signed=True))), '+11.0000')
|
||||
|
||||
self.assertEqual(str(Value(.1)), "100.000m")
|
||||
self.assertEqual(str(Value(.01)), "10.0000m")
|
||||
|
@ -138,6 +142,21 @@ class TestTSIToolsValue(unittest.TestCase):
|
|||
self.assertEqual(str(v.parse("1e-1")), "100.0m")
|
||||
self.assertEqual(str(v.parse("1e-2")), "10.00m")
|
||||
self.assertEqual(str(v.parse("1e-3")), "1.000m")
|
||||
self.assertEqual(v.parse("\N{INFINITY}").value, inf)
|
||||
self.assertEqual(v.parse("-\N{INFINITY}").value, -inf)
|
||||
|
||||
|
||||
def test_format_attributes(self):
|
||||
v = Value("10.0", "Hz", fmt=F_DIGITS_4)
|
||||
self.assertEqual(v.value, 10.0)
|
||||
v.value = 11
|
||||
self.assertEqual(v.value, 11)
|
||||
v.parse(12)
|
||||
self.assertEqual(v.value, 12)
|
||||
v.parse("12 GHz")
|
||||
self.assertEqual(v.unit, "Hz")
|
||||
|
||||
|
||||
|
||||
# TODO: test F_DIGITS_31
|
||||
# F_WITH_SPACE
|
||||
|
|
Ładowanie…
Reference in New Issue