From 3abed3b19cc4dcd2df0e93f6585a0e4287ac9d3b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 23:22:37 +0000 Subject: [PATCH] test(nmea): add comprehensive tests for make_float function Added test coverage for the znt.make_float function to handle missing keys, invalid float conversions, and invalid typing. --- tests/test_nmea/test_znt.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_nmea/test_znt.py b/tests/test_nmea/test_znt.py index ae3ce1a..074796c 100644 --- a/tests/test_nmea/test_znt.py +++ b/tests/test_nmea/test_znt.py @@ -29,6 +29,24 @@ def test_make_float(): assert d["otherval"] == "4.56" +def test_make_float_missing_key(): + d = {"val": "1.23"} + with pytest.raises(KeyError): + znt.make_float(d, "missing_key") + + +def test_make_float_invalid_value(): + d = {"val": "not_a_float"} + with pytest.raises(ValueError): + znt.make_float(d, "val") + + +def test_make_float_invalid_type(): + d = {"val": None} + with pytest.raises(TypeError): + znt.make_float(d, "val") + + def test_znt_decode_success(): nmea_str = "$PNTZNT,1270567048.57,127.0.0.1,17.151.16.21,4,1270565749.41,0.000080,-20,0.117325,0.046249*14" z = znt.Znt(nmea_str=nmea_str)