@@ -85,6 +85,43 @@ def test_delta_backend_structure():
8585 else :
8686 print ("\n [Delta] Flat script verified (ran on import)." )
8787
88+ # ---------------------------------------------------------------------------
89+ # 4. Data Parsing Test
90+ # ---------------------------------------------------------------------------
91+ def test_keithley_data_parser ():
92+ """
93+ Tests the utility function that parses comma-separated scientific notation strings.
94+ This is a functional test, not just a structural one.
95+ """
96+ try :
97+ from pica .utils .parser import parse_keithley_output
98+ except ImportError :
99+ pytest .skip ("Could not import the parser module." )
100+
101+ # Test case 1: Standard scientific notation
102+ raw_string_1 = "+1.2345E-06,+2.5000E+00"
103+ expected_1 = [1.2345e-6 , 2.5 ]
104+ assert parse_keithley_output (raw_string_1 ) == expected_1 , "Failed on standard scientific notation."
105+ print (f"\n [Parser] Verified: '{ raw_string_1 } ' -> { expected_1 } " )
106+
107+ # Test case 2: Negative values and different spacing
108+ raw_string_2 = "-5.0E-03, -1.0E+01"
109+ expected_2 = [- 0.005 , - 10.0 ]
110+ assert parse_keithley_output (raw_string_2 ) == expected_2 , "Failed on negative values."
111+ print (f"[Parser] Verified: '{ raw_string_2 } ' -> { expected_2 } " )
112+
113+ # Test case 3: Single value
114+ raw_string_3 = "+3.14159E+00"
115+ expected_3 = [3.14159 ]
116+ assert parse_keithley_output (raw_string_3 ) == expected_3 , "Failed on single value."
117+ print (f"[Parser] Verified: '{ raw_string_3 } ' -> { expected_3 } " )
118+
119+ # Test case 4: Malformed string (should raise ValueError)
120+ with pytest .raises (ValueError ):
121+ parse_keithley_output ("1.23, NOT_A_NUMBER" )
122+ print ("[Parser] Verified: Correctly raises ValueError on malformed string." )
123+
124+
88125# ---------------------------------------------------------------------------
89126# 3. Keithley 2400 Test
90127# ---------------------------------------------------------------------------
0 commit comments