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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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
Show 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:
...
@@ -18,16 +18,16 @@ else:
current_endian
=
'>'
current_endian
=
'>'
other_endian
=
'<'
other_endian
=
'<'
cdef
struct
align_of_
double
_helper
:
cdef
struct
align_of_
float
_helper
:
char
ch
char
ch
double
d
float
d
cdef
struct
align_of_int_helper
:
cdef
struct
align_of_int_helper
:
char
ch
char
ch
int
i
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
)
int_align
=
sizeof
(
align_of_int_helper
)
-
sizeof
(
int
)
if
double_align
!=
8
or
sizeof
(
double
)
!=
8
:
if
float_align
!=
4
or
sizeof
(
float
)
!=
4
:
raise
RuntimeError
(
"Alignment or size of
double is %d on this system, please report to cython-dev for a testcase fix"
%
double
_align
)
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
:
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
)
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):
...
@@ -105,9 +105,9 @@ def _obj(fmt):
cdef
object
[
object
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
void
*
))
cdef
object
[
object
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
void
*
))
cdef
struct
Complex
Double
:
cdef
struct
Complex
Float
:
double
real
float
real
double
imag
float
imag
ctypedef
struct
Char3Int
:
ctypedef
struct
Char3Int
:
char
a
char
a
...
@@ -115,33 +115,33 @@ ctypedef struct Char3Int:
...
@@ -115,33 +115,33 @@ ctypedef struct Char3Int:
int
c
int
c
int
d
int
d
cdef
struct
CharIntC
Double
:
cdef
struct
CharIntC
Float
:
char
a
char
a
int
b
int
b
Complex
Double
c
Complex
Float
c
double
d
float
d
cdef
struct
UnpackedStruct1
:
cdef
struct
UnpackedStruct1
:
char
a
char
a
int
b
int
b
Complex
Double
c
Complex
Float
c
double
c2
float
c2
Char3Int
d
Char3Int
d
ctypedef
struct
UnpackedStruct2
:
ctypedef
struct
UnpackedStruct2
:
CharIntC
Double
a
CharIntC
Float
a
Char3Int
b
Char3Int
b
ctypedef
struct
UnpackedStruct3
:
ctypedef
struct
UnpackedStruct3
:
CharIntC
Double
a
CharIntC
Float
a
char
b
char
b
int
c
,
d
,
e
int
c
,
d
,
e
cdef
struct
UnpackedStruct4
:
cdef
struct
UnpackedStruct4
:
char
a
char
a
int
b
int
b
Complex
Double
c
Complex
Float
c
double
c2
float
c2
char
d
char
d
int
e
,
f
,
g
int
e
,
f
,
g
...
@@ -178,17 +178,17 @@ def char3int(fmt):
...
@@ -178,17 +178,17 @@ def char3int(fmt):
obj
=
MockBuffer
(
fmt
,
sizeof
(
Char3Int
))
obj
=
MockBuffer
(
fmt
,
sizeof
(
Char3Int
))
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
#
@testcase
@
testcase
def
unpacked_struct
(
fmt
):
def
unpacked_struct
(
fmt
):
"""
"""
Native formats:
Native formats:
>>> unpacked_struct("biZ
dd
biii")
>>> unpacked_struct("biZ
ff
biii")
>>> unpacked_struct("@bi3
d
b3i")
>>> unpacked_struct("@bi3
f
b3i")
>>> unpacked_struct("@biZ
dd
bi2i")
>>> unpacked_struct("@biZ
ff
bi2i")
>>> unpacked_struct("bi
d
T{biii}")
>>> unpacked_struct("bi
Zff
T{biii}")
>>> unpacked_struct("bT{i
ddd
b2i}i")
>>> unpacked_struct("bT{i
fff
b2i}i")
>>> unpacked_struct("bi
d
b3T{i}")
>>> unpacked_struct("bi
Zff
b3T{i}")
>>> unpacked_struct("T{b}T{T{iZ
dd
T{bi}}}2T{T{i}}")
>>> unpacked_struct("T{b}T{T{iZ
ff
T{bi}}}2T{T{i}}")
"""
"""
assert
(
sizeof
(
UnpackedStruct1
)
==
sizeof
(
UnpackedStruct2
)
assert
(
sizeof
(
UnpackedStruct1
)
==
sizeof
(
UnpackedStruct2
)
...
@@ -200,20 +200,20 @@ def unpacked_struct(fmt):
...
@@ -200,20 +200,20 @@ def unpacked_struct(fmt):
cdef
object
[
UnpackedStruct4
,
ndim
=
1
]
buf4
=
obj
cdef
object
[
UnpackedStruct4
,
ndim
=
1
]
buf4
=
obj
cdef
struct
ComplexTest
:
cdef
struct
ComplexTest
:
Complex
Double
a
,
b
,
c
Complex
Float
a
,
b
,
c
@
testcase
@
testcase
def
complex_test
(
fmt
):
def
complex_test
(
fmt
):
"""
"""
>>> complex_test("Z
dZdZd
")
>>> complex_test("Z
fZfZf
")
>>> complex_test("3Z
d
")
>>> complex_test("3Z
f
")
>>> complex_test("6
d
")
>>> complex_test("6
f
")
>>> complex_test("3T{Z
d
}")
>>> complex_test("3T{Z
f
}")
>>> complex_test("
dZdZdd
")
>>> complex_test("
fZfZff
")
Traceback (most recent call last):
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
))
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