FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/embed_tests/TestPyInt.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
/
TestPyInt.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
192 lines (165 loc) · 4.52 KB
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestPyInt.cs
Copy path
File metadata and controls
192 lines (165 loc) · 4.52 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
using
System
;
using
NUnit
.
Framework
;
using
Python
.
Runtime
;
namespace
Python
.
EmbeddingTest
{
public
class
TestPyInt
{
[
OneTimeSetUp
]
public
void
SetUp
(
)
{
PythonEngine
.
Initialize
(
)
;
}
[
OneTimeTearDown
]
public
void
Dispose
(
)
{
PythonEngine
.
Shutdown
(
)
;
}
[
Test
]
public
void
TestCtorInt
(
)
{
const
int
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorUInt
(
)
{
const
uint
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorLong
(
)
{
const
long
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorULong
(
)
{
const
ulong
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorShort
(
)
{
const
short
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorUShort
(
)
{
const
ushort
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorByte
(
)
{
const
byte
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorSByte
(
)
{
const
sbyte
i
=
5
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
i
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorPtr
(
)
{
var
i
=
new
PyInt
(
5
)
;
Runtime
.
Runtime
.
XIncref
(
i
.
Handle
)
;
var
a
=
new
PyInt
(
i
.
Handle
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorPyObject
(
)
{
var
i
=
new
PyInt
(
5
)
;
Runtime
.
Runtime
.
XIncref
(
i
.
Handle
)
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorBadPyObject
(
)
{
var
i
=
new
PyString
(
"Foo"
)
;
PyInt
a
=
null
;
var
ex
=
Assert
.
Throws
<
ArgumentException
>
(
(
)
=>
a
=
new
PyInt
(
i
)
)
;
StringAssert
.
StartsWith
(
"object is not an int"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestCtorString
(
)
{
const
string
i
=
"5"
;
var
a
=
new
PyInt
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestCtorBadString
(
)
{
const
string
i
=
"Foo"
;
PyInt
a
=
null
;
var
ex
=
Assert
.
Throws
<
PythonException
>
(
(
)
=>
a
=
new
PyInt
(
i
)
)
;
StringAssert
.
StartsWith
(
"ValueError : invalid literal for int"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestIsIntTypeTrue
(
)
{
var
i
=
new
PyInt
(
5
)
;
Assert
.
True
(
PyInt
.
IsIntType
(
i
)
)
;
}
[
Test
]
public
void
TestIsIntTypeFalse
(
)
{
var
s
=
new
PyString
(
"Foo"
)
;
Assert
.
False
(
PyInt
.
IsIntType
(
s
)
)
;
}
[
Test
]
public
void
TestAsIntGood
(
)
{
var
i
=
new
PyInt
(
5
)
;
var
a
=
PyInt
.
AsInt
(
i
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestAsIntBad
(
)
{
var
s
=
new
PyString
(
"Foo"
)
;
PyInt
a
=
null
;
var
ex
=
Assert
.
Throws
<
PythonException
>
(
(
)
=>
a
=
PyInt
.
AsInt
(
s
)
)
;
StringAssert
.
StartsWith
(
"ValueError : invalid literal for int"
,
ex
.
Message
)
;
Assert
.
IsNull
(
a
)
;
}
[
Test
]
public
void
TestConvertToInt32
(
)
{
var
a
=
new
PyInt
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
int
)
,
a
.
ToInt32
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt32
(
)
)
;
}
[
Test
]
public
void
TestConvertToInt16
(
)
{
var
a
=
new
PyInt
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
short
)
,
a
.
ToInt16
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt16
(
)
)
;
}
[
Test
]
public
void
TestConvertToInt64
(
)
{
var
a
=
new
PyInt
(
5
)
;
Assert
.
IsInstanceOf
(
typeof
(
long
)
,
a
.
ToInt64
(
)
)
;
Assert
.
AreEqual
(
5
,
a
.
ToInt64
(
)
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL