Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c5c9ce95
Kaydet (Commit)
c5c9ce95
authored
Nis 16, 2006
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add missing SVN eol-style property to text files.
üst
715a4cde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
45 deletions
+45
-45
test_unaligned_structures.py
Lib/ctypes/test/test_unaligned_structures.py
+45
-45
No files found.
Lib/ctypes/test/test_unaligned_structures.py
Dosyayı görüntüle @
c5c9ce95
import
sys
,
unittest
from
ctypes
import
*
structures
=
[]
byteswapped_structures
=
[]
if
sys
.
byteorder
==
"little"
:
SwappedStructure
=
BigEndianStructure
else
:
SwappedStructure
=
LittleEndianStructure
for
typ
in
[
c_short
,
c_int
,
c_long
,
c_longlong
,
c_float
,
c_double
,
c_ushort
,
c_uint
,
c_ulong
,
c_ulonglong
]:
class
X
(
Structure
):
_pack_
=
1
_fields_
=
[(
"pad"
,
c_byte
),
(
"value"
,
typ
)]
class
Y
(
SwappedStructure
):
_pack_
=
1
_fields_
=
[(
"pad"
,
c_byte
),
(
"value"
,
typ
)]
structures
.
append
(
X
)
byteswapped_structures
.
append
(
Y
)
class
TestStructures
(
unittest
.
TestCase
):
def
test_native
(
self
):
for
typ
in
structures
:
## print typ.value
self
.
failUnlessEqual
(
typ
.
value
.
offset
,
1
)
o
=
typ
()
o
.
value
=
4
self
.
failUnlessEqual
(
o
.
value
,
4
)
def
test_swapped
(
self
):
for
typ
in
byteswapped_structures
:
## print >> sys.stderr, typ.value
self
.
failUnlessEqual
(
typ
.
value
.
offset
,
1
)
o
=
typ
()
o
.
value
=
4
self
.
failUnlessEqual
(
o
.
value
,
4
)
if
__name__
==
'__main__'
:
unittest
.
main
()
import
sys
,
unittest
from
ctypes
import
*
structures
=
[]
byteswapped_structures
=
[]
if
sys
.
byteorder
==
"little"
:
SwappedStructure
=
BigEndianStructure
else
:
SwappedStructure
=
LittleEndianStructure
for
typ
in
[
c_short
,
c_int
,
c_long
,
c_longlong
,
c_float
,
c_double
,
c_ushort
,
c_uint
,
c_ulong
,
c_ulonglong
]:
class
X
(
Structure
):
_pack_
=
1
_fields_
=
[(
"pad"
,
c_byte
),
(
"value"
,
typ
)]
class
Y
(
SwappedStructure
):
_pack_
=
1
_fields_
=
[(
"pad"
,
c_byte
),
(
"value"
,
typ
)]
structures
.
append
(
X
)
byteswapped_structures
.
append
(
Y
)
class
TestStructures
(
unittest
.
TestCase
):
def
test_native
(
self
):
for
typ
in
structures
:
## print typ.value
self
.
failUnlessEqual
(
typ
.
value
.
offset
,
1
)
o
=
typ
()
o
.
value
=
4
self
.
failUnlessEqual
(
o
.
value
,
4
)
def
test_swapped
(
self
):
for
typ
in
byteswapped_structures
:
## print >> sys.stderr, typ.value
self
.
failUnlessEqual
(
typ
.
value
.
offset
,
1
)
o
=
typ
()
o
.
value
=
4
self
.
failUnlessEqual
(
o
.
value
,
4
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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