@@ -131,6 +131,8 @@ BOOST_FIXTURE_TEST_CASE(test_pda_unit_change, FixtureOpenClose)
131131
132132 error = EN_setflowunits (ph, EN_LPS);
133133 BOOST_REQUIRE (error == 0 );
134+ error = EN_setoption (ph, EN_PRESS_UNITS, EN_METERS);
135+ BOOST_REQUIRE (error == 0 );
134136
135137 error = EN_getdemandmodel (ph, &type, &pmin, &preq, &pexp);
136138 BOOST_REQUIRE (error == 0 );
@@ -180,6 +182,8 @@ BOOST_FIXTURE_TEST_CASE(test_rule_unit_change, FixtureOpenClose)
180182 // Change flow units to lps and pressure to meters
181183 error = EN_setflowunits (ph, EN_LPS);
182184 BOOST_REQUIRE (error == 0 );
185+ error = EN_setoption (ph, EN_PRESS_UNITS, EN_METERS);
186+ BOOST_REQUIRE (error == 0 );
183187
184188 error = EN_getoption (ph, EN_PRESS_UNITS, &units);
185189 BOOST_REQUIRE (error == 0 );
@@ -312,10 +316,10 @@ BOOST_FIXTURE_TEST_CASE(test_decoupled_pressure_units, FixtureInitClose)
312316 error = EN_setflowunits (ph, EN_LPS);
313317 BOOST_REQUIRE (error == 0 );
314318
315- // Pressure units should change to metric default of meters
319+ // Pressure units should not change
316320 error = EN_getoption (ph, EN_PRESS_UNITS, &units);
317321 BOOST_REQUIRE (error == 0 );
318- BOOST_CHECK (units == EN_METERS);
322+ BOOST_CHECK (units == EN_KPA);
319323
320324 // Test 5: With SI flow units, set pressure to PSI (should now work)
321325 error = EN_setoption (ph, EN_PRESS_UNITS, EN_PSI);
@@ -351,110 +355,5 @@ BOOST_FIXTURE_TEST_CASE(test_decoupled_pressure_units, FixtureInitClose)
351355 BOOST_REQUIRE (error == 0 );
352356}
353357
354- BOOST_FIXTURE_TEST_CASE (test_automatic_pressure_unit_switching, FixtureInitClose)
355- {
356- int index;
357- double pressure_units;
358-
359- // Create basic network
360- error = EN_addnode (ph, " R1" , EN_RESERVOIR, &index);
361- BOOST_REQUIRE (error == 0 );
362- error = EN_setnodevalue (ph, index, EN_ELEVATION, 100 );
363- BOOST_REQUIRE (error == 0 );
364- error = EN_addnode (ph, " J1" , EN_JUNCTION, &index);
365- BOOST_REQUIRE (error == 0 );
366- error = EN_addlink (ph, " P1" , EN_PIPE, " R1" , " J1" , &index);
367- BOOST_REQUIRE (error == 0 );
368-
369- // Test 1: Start with US flow units (CFS) - should have PSI pressure units
370- error = EN_setflowunits (ph, EN_CFS);
371- BOOST_REQUIRE (error == 0 );
372- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
373- BOOST_REQUIRE (error == 0 );
374- BOOST_CHECK (pressure_units == EN_PSI);
375-
376- // Test 2: Change from US flow units (CFS) to metric flow units (LPS)
377- // Pressure units should automatically change from PSI to METERS
378- error = EN_setflowunits (ph, EN_LPS);
379- BOOST_REQUIRE (error == 0 );
380- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
381- BOOST_REQUIRE (error == 0 );
382- BOOST_CHECK (pressure_units == EN_METERS);
383-
384- // Test 3: Change from metric flow units (LPS) back to US flow units (GPM)
385- // Pressure units should automatically change from METERS to PSI
386- error = EN_setflowunits (ph, EN_GPM);
387- BOOST_REQUIRE (error == 0 );
388- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
389- BOOST_REQUIRE (error == 0 );
390- BOOST_CHECK (pressure_units == EN_PSI);
391-
392- // Test 4: Change from US flow units (GPM) to another metric flow unit (MLD)
393- // Pressure units should automatically change from PSI to METERS
394- error = EN_setflowunits (ph, EN_MLD);
395- BOOST_REQUIRE (error == 0 );
396- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
397- BOOST_REQUIRE (error == 0 );
398- BOOST_CHECK (pressure_units == EN_METERS);
399-
400- // Test 5: Manually set pressure units to kPa while using metric flow units
401- error = EN_setoption (ph, EN_PRESS_UNITS, EN_KPA);
402- BOOST_REQUIRE (error == 0 );
403- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
404- BOOST_REQUIRE (error == 0 );
405- BOOST_CHECK (pressure_units == EN_KPA);
406-
407- // Test 6: Change from metric flow units (MLD) to US flow units (MGD)
408- // Pressure units should automatically change from kPa to PSI
409- error = EN_setflowunits (ph, EN_MGD);
410- BOOST_REQUIRE (error == 0 );
411- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
412- BOOST_REQUIRE (error == 0 );
413- BOOST_CHECK (pressure_units == EN_PSI);
414-
415- // Test 7: Change from US flow units (MGD) to metric flow units (CMH)
416- // Pressure units should automatically change from PSI to METERS
417- error = EN_setflowunits (ph, EN_CMH);
418- BOOST_REQUIRE (error == 0 );
419- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
420- BOOST_REQUIRE (error == 0 );
421- BOOST_CHECK (pressure_units == EN_METERS);
422-
423- // Test 8: Set pressure to kPa again with metric flow units
424- error = EN_setoption (ph, EN_PRESS_UNITS, EN_KPA);
425- BOOST_REQUIRE (error == 0 );
426-
427- // Test 9: Change between metric flow units (CMH to CMD)
428- // Pressure units should remain kPa (not changed to METERS since not switching from PSI)
429- error = EN_setflowunits (ph, EN_CMD);
430- BOOST_REQUIRE (error == 0 );
431- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
432- BOOST_REQUIRE (error == 0 );
433- BOOST_CHECK (pressure_units == EN_KPA);
434-
435- // Test 10: Change from metric flow units (CMD) to US flow units (AFD)
436- // Pressure units should automatically change from kPa to PSI
437- error = EN_setflowunits (ph, EN_AFD);
438- BOOST_REQUIRE (error == 0 );
439- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
440- BOOST_REQUIRE (error == 0 );
441- BOOST_CHECK (pressure_units == EN_PSI);
442-
443- // Test 11: Change between US flow units (AFD to IMGD)
444- // Pressure units should remain PSI
445- error = EN_setflowunits (ph, EN_IMGD);
446- BOOST_REQUIRE (error == 0 );
447- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
448- BOOST_REQUIRE (error == 0 );
449- BOOST_CHECK (pressure_units == EN_PSI);
450-
451- // Test 12: Final test - metric flow units (CMS) should change PSI to METERS
452- error = EN_setflowunits (ph, EN_CMS);
453- BOOST_REQUIRE (error == 0 );
454- error = EN_getoption (ph, EN_PRESS_UNITS, &pressure_units);
455- BOOST_REQUIRE (error == 0 );
456- BOOST_CHECK (pressure_units == EN_METERS);
457- }
458-
459358
460359BOOST_AUTO_TEST_SUITE_END ()
0 commit comments