Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
38410081
Commit
38410081
authored
May 15, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer testcase fix
parent
48af72b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
tests/run/buffmt.pyx
tests/run/buffmt.pyx
+32
-32
No files found.
tests/run/buffmt.pyx
View file @
38410081
...
...
@@ -18,16 +18,16 @@ else:
current_endian
=
'>'
other_endian
=
'<'
cdef
struct
align_of_
double
_helper
:
cdef
struct
align_of_
float
_helper
:
char
ch
double
d
float
d
cdef
struct
align_of_int_helper
:
char
ch
int
i
double_align
=
sizeof
(
align_of_double_helper
)
-
sizeof
(
double
)
float_align
=
sizeof
(
align_of_float_helper
)
-
sizeof
(
float
)
int_align
=
sizeof
(
align_of_int_helper
)
-
sizeof
(
int
)
if
double_align
!=
8
or
sizeof
(
double
)
!=
8
:
raise
RuntimeError
(
"Alignment or size of
double is %d on this system, please report to cython-dev for a testcase fix"
%
double
_align
)
if
float_align
!=
4
or
sizeof
(
float
)
!=
4
:
raise
RuntimeError
(
"Alignment or size of
float is %d on this system, please report to cython-dev for a testcase fix"
%
float
_align
)
if
int_align
!=
4
or
sizeof
(
int
)
!=
4
:
raise
RuntimeError
(
"Alignment or size of int is %d on this system, please report to cython-dev for a testcase fix"
%
int_align
)
...
...
@@ -105,9 +105,9 @@ def _obj(fmt):
cdef
object
[
object
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
void
*
))
cdef
struct
Complex
Double
:
double
real
double
imag
cdef
struct
Complex
Float
:
float
real
float
imag
ctypedef
struct
Char3Int
:
char
a
...
...
@@ -115,33 +115,33 @@ ctypedef struct Char3Int:
int
c
int
d
cdef
struct
CharIntC
Double
:
cdef
struct
CharIntC
Float
:
char
a
int
b
Complex
Double
c
double
d
Complex
Float
c
float
d
cdef
struct
UnpackedStruct1
:
char
a
int
b
Complex
Double
c
double
c2
Complex
Float
c
float
c2
Char3Int
d
ctypedef
struct
UnpackedStruct2
:
CharIntC
Double
a
CharIntC
Float
a
Char3Int
b
ctypedef
struct
UnpackedStruct3
:
CharIntC
Double
a
CharIntC
Float
a
char
b
int
c
,
d
,
e
cdef
struct
UnpackedStruct4
:
char
a
int
b
Complex
Double
c
double
c2
Complex
Float
c
float
c2
char
d
int
e
,
f
,
g
...
...
@@ -178,17 +178,17 @@ def char3int(fmt):
obj
=
MockBuffer
(
fmt
,
sizeof
(
Char3Int
))
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
#
@testcase
@
testcase
def
unpacked_struct
(
fmt
):
"""
Native formats:
>>> unpacked_struct("biZ
dd
biii")
>>> unpacked_struct("@bi3
d
b3i")
>>> unpacked_struct("@biZ
dd
bi2i")
>>> unpacked_struct("bi
d
T{biii}")
>>> unpacked_struct("bT{i
ddd
b2i}i")
>>> unpacked_struct("bi
d
b3T{i}")
>>> unpacked_struct("T{b}T{T{iZ
dd
T{bi}}}2T{T{i}}")
>>> unpacked_struct("biZ
ff
biii")
>>> unpacked_struct("@bi3
f
b3i")
>>> unpacked_struct("@biZ
ff
bi2i")
>>> unpacked_struct("bi
Zff
T{biii}")
>>> unpacked_struct("bT{i
fff
b2i}i")
>>> unpacked_struct("bi
Zff
b3T{i}")
>>> unpacked_struct("T{b}T{T{iZ
ff
T{bi}}}2T{T{i}}")
"""
assert
(
sizeof
(
UnpackedStruct1
)
==
sizeof
(
UnpackedStruct2
)
...
...
@@ -200,20 +200,20 @@ def unpacked_struct(fmt):
cdef
object
[
UnpackedStruct4
,
ndim
=
1
]
buf4
=
obj
cdef
struct
ComplexTest
:
Complex
Double
a
,
b
,
c
Complex
Float
a
,
b
,
c
@
testcase
def
complex_test
(
fmt
):
"""
>>> complex_test("Z
dZdZd
")
>>> complex_test("3Z
d
")
>>> complex_test("6
d
")
>>> complex_test("3T{Z
d
}")
>>> complex_test("Z
fZfZf
")
>>> complex_test("3Z
f
")
>>> complex_test("6
f
")
>>> complex_test("3T{Z
f
}")
>>> complex_test("
dZdZdd
")
>>> complex_test("
fZfZff
")
Traceback (most recent call last):
...
ValueError: Buffer dtype mismatch, expected '
double' but got 'complex double' in 'ComplexDouble
.imag'
ValueError: Buffer dtype mismatch, expected '
float' but got 'complex float' in 'ComplexFloat
.imag'
"""
obj
=
MockBuffer
(
fmt
,
sizeof
(
ComplexTest
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment