@@ -26,6 +27,8 @@ public ConversionTest()
public ulong UInt64Field = 0;
public float SingleField = 0.0F;
public double DoubleField = 0.0;
+ public IntPtr IntPtrField = IntPtr.Zero;
+ public UIntPtr UIntPtrField = UIntPtr.Zero;
public decimal DecimalField = 0;
public string StringField;
public ShortEnum EnumField;
@@ -42,7 +45,7 @@ public ConversionTest()
}
-
+
public interface ISpam
{
@@ -63,7 +66,7 @@ public string GetValue()
return value;
}
}
-
+
public class UnicodeString
{
public string value = "안녕";
diff --git a/tests/test_constructors.py b/tests/test_constructors.py
index 8e7ef2794..6d8f00c12 100644
--- a/tests/test_constructors.py
+++ b/tests/test_constructors.py
@@ -69,3 +69,20 @@ def test_default_constructor_fallback():
with pytest.raises(TypeError):
ob = DefaultConstructorMatching("2")
+
+
+def test_string_constructor():
+ from System import String, Char, Array
+
+ ob = String('A', 10)
+ assert ob == 'A' * 10
+
+ arr = Array[Char](10)
+ for i in range(10):
+ arr[i] = Char(str(i))
+
+ ob = String(arr)
+ assert ob == "0123456789"
+
+ ob = String(arr, 5, 4)
+ assert ob == "5678"
diff --git a/tests/test_conversion.py b/tests/test_conversion.py
index 6693d8000..a5b4c6fd9 100644
--- a/tests/test_conversion.py
+++ b/tests/test_conversion.py
@@ -25,7 +25,7 @@ def test_bool_conversion():
with pytest.raises(TypeError):
ob.BooleanField = 1
-
+
with pytest.raises(TypeError):
ob.BooleanField = 0
@@ -679,3 +679,37 @@ def test_iconvertible_conversion():
assert 1024 == change_type(1024, System.Int32)
assert 1024 == change_type(1024, System.Int64)
assert 1024 == change_type(1024, System.Int16)
+
+def test_intptr_construction():
+ from System import IntPtr, UIntPtr, Int64, UInt64
+ from ctypes import sizeof, c_void_p
+
+ ptr_size = sizeof(c_void_p)
+ max_intptr = 2 ** (ptr_size * 8 - 1) - 1
+ min_intptr = -max_intptr - 1
+ max_uintptr = 2 ** (ptr_size * 8) - 1
+ min_uintptr = 0
+
+ ob = ConversionTest()
+
+ assert ob.IntPtrField == IntPtr.Zero
+ assert ob.UIntPtrField == UIntPtr.Zero
+
+ for v in [0, -1, 1024, max_intptr, min_intptr]:
+ ob.IntPtrField = IntPtr(Int64(v))
+ assert ob.IntPtrField == IntPtr(v)
+ assert ob.IntPtrField.ToInt64() == v
+
+ for v in [min_intptr - 1, max_intptr + 1]:
+ with pytest.raises(OverflowError):
+ IntPtr(v)
+
+ for v in [0, 1024, min_uintptr, max_uintptr, max_intptr]:
+ ob.UIntPtrField = UIntPtr(UInt64(v))
+ assert ob.UIntPtrField == UIntPtr(v)
+ assert ob.UIntPtrField.ToUInt64() == v
+
+ for v in [min_uintptr - 1, max_uintptr + 1, min_intptr]:
+ with pytest.raises(OverflowError):
+ UIntPtr(v)
+
diff --git a/tests/test_docstring.py b/tests/test_docstring.py
index 640a61915..36c925a74 100644
--- a/tests/test_docstring.py
+++ b/tests/test_docstring.py
@@ -25,3 +25,10 @@ def test_doc_without_ctor():
assert DocWithoutCtorTest.__doc__ == 'DocWithoutCtorTest Class'
assert DocWithoutCtorTest.TestMethod.__doc__ == 'DocWithoutCtorTest TestMethod'
assert DocWithoutCtorTest.StaticTestMethod.__doc__ == 'DocWithoutCtorTest StaticTestMethod'
+
+
+def test_doc_primitve():
+ from System import Int64, String
+
+ assert Int64.__doc__ is not None
+ assert String.__doc__ is not None
diff --git a/tests/test_enum.py b/tests/test_enum.py
index 981fb735c..f24f95b36 100644
--- a/tests/test_enum.py
+++ b/tests/test_enum.py
@@ -15,7 +15,6 @@ def test_enum_standard_attrs():
assert DayOfWeek.__name__ == 'DayOfWeek'
assert DayOfWeek.__module__ == 'System'
assert isinstance(DayOfWeek.__dict__, DictProxyType)
- assert DayOfWeek.__doc__ is None
def test_enum_get_member():
@@ -139,7 +138,7 @@ def test_enum_undefined_value():
# This should fail because our test enum doesn't have it.
with pytest.raises(ValueError):
Test.FieldTest().EnumField = Test.ShortEnum(20)
-
+
# explicitly permit undefined values
Test.FieldTest().EnumField = Test.ShortEnum(20, True)
@@ -157,6 +156,6 @@ def test_enum_conversion():
with pytest.raises(TypeError):
Test.FieldTest().EnumField = "str"
-
+
with pytest.raises(TypeError):
Test.FieldTest().EnumField = 1
diff --git a/version.txt b/version.txt
index d15be84db..b9eb748c0 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-3.0.0-rc2
+3.0.0-rc3
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy