Skip to content

Commit 4071aa3

Browse files
committed
Add more object overload method tests
1 parent 2cabc9f commit 4071aa3

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/testing/methodtest.cs

+50
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,56 @@ public static string TestOverloadedObject(object o)
131131
return "Got object";
132132
}
133133

134+
public static string TestOverloadedObjectTwo(int a, int b)
135+
{
136+
return "Got int-int";
137+
}
138+
139+
public static string TestOverloadedObjectTwo(string a, string b)
140+
{
141+
return "Got string-string";
142+
}
143+
144+
public static string TestOverloadedObjectTwo(string a, int b)
145+
{
146+
return "Got string-int";
147+
}
148+
149+
public static string TestOverloadedObjectTwo(string a, object b)
150+
{
151+
return "Got string-object";
152+
}
153+
154+
public static string TestOverloadedObjectTwo(int a, object b)
155+
{
156+
return "Got int-object";
157+
}
158+
159+
public static string TestOverloadedObjectTwo(object a, int b)
160+
{
161+
return "Got object-int";
162+
}
163+
164+
public static string TestOverloadedObjectTwo(object a, object b)
165+
{
166+
return "Got object-object";
167+
}
168+
169+
public static string TestOverloadedObjectTwo(int a, string b)
170+
{
171+
return "Got int-string";
172+
}
173+
174+
public static string TestOverloadedObjectThree(object a, int b)
175+
{
176+
return "Got object-int";
177+
}
178+
179+
public static string TestOverloadedObjectThree(int a, object b)
180+
{
181+
return "Got int-object";
182+
}
183+
134184
public static bool TestStringOutParams(string s, out string s1)
135185
{
136186
s1 = "output string";

src/tests/test_method.py

+29
Original file line numberDiff line numberDiff line change
@@ -790,3 +790,32 @@ def test_object_in_param():
790790

791791
res = MethodTest.TestOverloadedObject("test")
792792
assert res == "Got object"
793+
794+
795+
def test_object_in_multiparam():
796+
"""Test method with object multiparams behaves"""
797+
798+
res = MethodTest.TestOverloadedObjectTwo(5, 5)
799+
assert res == "Got int-int"
800+
801+
res = MethodTest.TestOverloadedObjectTwo(5, "foo")
802+
assert res == "Got int-string"
803+
804+
res = MethodTest.TestOverloadedObjectTwo("foo", 7.24)
805+
assert res == "Got string-object"
806+
807+
res = MethodTest.TestOverloadedObjectTwo("foo", "bar")
808+
assert res == "Got string-string"
809+
810+
res = MethodTest.TestOverloadedObjectTwo("foo", 5)
811+
assert res == "Got string-int"
812+
813+
res = MethodTest.TestOverloadedObjectTwo(7.24, 7.24)
814+
assert res == "Got object-object"
815+
816+
817+
def test_object_in_multiparam_exception():
818+
"""Test method with object multiparams behaves"""
819+
820+
with pytest.raises(TypeError):
821+
MethodTest.TestOverloadedObjectThree("foo", "bar")

0 commit comments

Comments
 (0)