Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c21526

Browse files
committed
Add unit tests for (U)IntPtr conversions
1 parentd484797 commit1c21526

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

‎src/testing/conversiontest.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespacePython.Test
22
{
3+
usingSystem;
34
usingSystem.Collections.Generic;
45

56
/// <summary>
@@ -26,6 +27,8 @@ public ConversionTest()
2627
publiculongUInt64Field=0;
2728
publicfloatSingleField=0.0F;
2829
publicdoubleDoubleField=0.0;
30+
publicIntPtrIntPtrField=IntPtr.Zero;
31+
publicUIntPtrUIntPtrField=UIntPtr.Zero;
2932
publicdecimalDecimalField=0;
3033
publicstringStringField;
3134
publicShortEnumEnumField;
@@ -42,7 +45,7 @@ public ConversionTest()
4245

4346
}
4447

45-
48+
4649

4750
publicinterfaceISpam
4851
{
@@ -63,7 +66,7 @@ public string GetValue()
6366
returnvalue;
6467
}
6568
}
66-
69+
6770
publicclassUnicodeString
6871
{
6972
publicstringvalue="안녕";

‎tests/test_conversion.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_bool_conversion():
2525

2626
withpytest.raises(TypeError):
2727
ob.BooleanField=1
28-
28+
2929
withpytest.raises(TypeError):
3030
ob.BooleanField=0
3131

@@ -679,3 +679,20 @@ def test_iconvertible_conversion():
679679
assert1024==change_type(1024,System.Int32)
680680
assert1024==change_type(1024,System.Int64)
681681
assert1024==change_type(1024,System.Int16)
682+
683+
deftest_intptr_conversion():
684+
fromSystemimportIntPtr,UIntPtr,Int64
685+
686+
ob=ConversionTest()
687+
688+
assertob.IntPtrField==IntPtr.Zero
689+
assertob.UIntPtrField==UIntPtr.Zero
690+
691+
ob.IntPtrField=IntPtr(-1)
692+
assertob.IntPtrField==IntPtr(-1)
693+
694+
ob.IntPtrField=IntPtr(Int64(1024))
695+
assertob.IntPtrField==IntPtr(1024)
696+
697+
ob.UIntPtrField=ob.IntPtrField
698+
assertob.UIntPtrField==UIntPtr(1024)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp