FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/embed_tests/TestPyLong.cs at drop-python2 · filmor/pythonnet · GitHub
filmor
/
pythonnet
Public
forked from
pythonnet/pythonnet
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestPyLong.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
208 lines (179 loc) · 4.97 KB
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestPyLong.cs
Copy path
File metadata and controls
208 lines (179 loc) · 4.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using
System
;
using
NUnit
.
Framework
;
using
Python
.
Runtime
;
namespace
Python
.
EmbeddingTest
{
public
class
TestPyLong
{
[
OneTimeSetUp
]
public
void
SetUp
(
)
{
PythonEngine
.
Initialize
(
)
;
}
[
OneTimeTearDown
]
public
void
Dispose
(
)
{
PythonEngine
.
Shutdown
(
)
;
}
[
Test
]
public
void
TestToInt64
(
)
{
long
largeNumber
=
8L
*
1024L
*
1024L
*
1024L
;
// 8 GB
var
pyLargeNumber
=
new
PyLong
(
largeNumber
)
;
Assert
.
AreEqual
(
largeNumber
,
pyLargeNumber
.
ToInt64
(
)
)
;
}
[
Test
]
public
void
TestCtorInt
(
)
{
const
int
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorUInt
(
)
{
const
uint
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorLong
(
)
{
const
long
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorULong
(
)
{
const
ulong
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorShort
(
)
{
const
short
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorUShort
(
)
{
const
ushort
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorByte
(
)
{
const
byte
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorSByte
(
)
{
const
sbyte
i
=
5
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorDouble
(
)
{
double
i
=
5.0
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorPtr
(
)
{
var
i
=
new
PyLong
(
5
)
;
Runtime
.
Runtime
.
XIncref
(
i
.
Handle
)
;
var
a
=
new
PyLong
(
i
.
Handle
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorPyObject
(
)
{
var
i
=
new
PyLong
(
5
)
;
Runtime
.
Runtime
.
XIncref
(
i
.
Handle
)
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorBadPyObject
(
)
{
var
i
=
new
PyString
(
"Foo"
)
;
PyLong
a
=
null
;
var
ex
=
Assert
.
Throws
<
ArgumentException
>
(
(
)
=>
a
=
new
PyLong
(
i
)
)
;
StringAssert
.
StartsWith
(
"object is not a long"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestCtorString
(
)
{
const
string
i
=
"5"
;
var
a
=
new
PyLong
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorBadString
(
)
{
const
string
i
=
"Foo"
;
PyLong
a
=
null
;
var
ex
=
Assert
.
Throws
<
PythonException
>
(
(
)
=>
a
=
new
PyLong
(
i
)
)
;
StringAssert
.
StartsWith
(
"ValueError : invalid literal"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestIsIntTypeTrue
(
)
{
var
i
=
new
PyLong
(
5
)
;
Assert
.
True
(
PyLong
.
IsLongType
(
i
)
)
;
}
[
Test
]
public
void
TestIsLongTypeFalse
(
)
{
var
s
=
new
PyString
(
"Foo"
)
;
Assert
.
False
(
PyLong
.
IsLongType
(
s
)
)
;
}
[
Test
]
public
void
TestAsLongGood
(
)
{
var
i
=
new
PyLong
(
5
)
;
var
a
=
PyLong
.
AsLong
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestAsLongBad
(
)
{
var
s
=
new
PyString
(
"Foo"
)
;
PyLong
a
=
null
;
var
ex
=
Assert
.
Throws
<
PythonException
>
(
(
)
=>
a
=
PyLong
.
AsLong
(
s
)
)
;
StringAssert
.
StartsWith
(
"ValueError : invalid literal"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestConvertToInt32
(
)
{
var
a
=
new
PyLong
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
int
)
,
a
.
ToInt32
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestConvertToInt16
(
)
{
var
a
=
new
PyLong
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
short
)
,
a
.
ToInt16
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt16
(
)
)
;
}
[
Test
]
public
void
TestConvertToInt64
(
)
{
var
a
=
new
PyLong
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
long
)
,
a
.
ToInt64
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt64
(
)
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL