Skip to content

Commit 40c80d8

Browse files
author
karosc
committed
Debug swmm_get_version()
- add type map for swmm_getVersion - add custom exception handling for swmm_getVersion - add test for legacy version getter
1 parent 2e7ee86 commit 40c80d8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

swmm-toolkit/src/swmm/toolkit/solver.i

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
Py_INCREF($result);
4040
}
4141

42+
%typemap(out) int swmm_getVersion {
43+
$result = PyInt_FromLong($1);
44+
}
45+
4246

4347
%apply int *OUTPUT {
4448
int *index,
@@ -189,6 +193,11 @@
189193
$function
190194
}
191195

196+
%exception swmm_getVersion
197+
{
198+
$function
199+
}
200+
192201
/* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */
193202
%exception
194203
{

swmm-toolkit/tests/test_solver.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ def test_version(handle):
114114
major, minor, patch = solver.swmm_version_info().split('.')
115115
print(major, minor, patch)
116116
assert major == '5'
117-
117+
118+
def test_legacy_version(handle):
119+
version = solver.swmm_get_version()
120+
major = str(version)[0]
121+
assert isinstance(version, int)
122+
assert major == '5'
118123

119124
def test_simulation_unit(handle):
120125
simulation_system_unit_option = solver.simulation_get_unit(shared_enum.UnitProperty.SYSTEM_UNIT)

0 commit comments

Comments
 (0)