1524
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
|
|
4 |
New code and modifications done at SWING Research Group [1]:
|
|
5 |
|
|
6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
7 |
SWING Research Group, Czech Technical University in Prague
|
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
|
15 |
|
|
16 |
[1] Code written at SWING Research Group contains a signature
|
|
17 |
of one of the above copright owners. For exact set of such code,
|
|
18 |
see the differences between this version and version stx:libjava
|
|
19 |
as of 1.9.2010
|
|
20 |
"
|
|
21 |
"{ Package: 'stx:libjava' }"
|
|
22 |
|
|
23 |
TestCase subclass:#JavaNativeMemoryTests
|
|
24 |
instanceVariableNames:'mem'
|
|
25 |
classVariableNames:''
|
|
26 |
poolDictionaries:''
|
|
27 |
category:'Languages-Java-Tests'
|
|
28 |
!
|
|
29 |
|
|
30 |
!JavaNativeMemoryTests class methodsFor:'documentation'!
|
|
31 |
|
|
32 |
copyright
|
|
33 |
"
|
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
35 |
|
|
36 |
New code and modifications done at SWING Research Group [1]:
|
|
37 |
|
|
38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
39 |
SWING Research Group, Czech Technical University in Prague
|
|
40 |
|
|
41 |
This software is furnished under a license and may be used
|
|
42 |
only in accordance with the terms of that license and with the
|
|
43 |
inclusion of the above copyright notice. This software may not
|
|
44 |
be provided or otherwise made available to, or used by, any
|
|
45 |
other person. No title to or ownership of the software is
|
|
46 |
hereby transferred.
|
|
47 |
|
|
48 |
[1] Code written at SWING Research Group contains a signature
|
|
49 |
of one of the above copright owners. For exact set of such code,
|
|
50 |
see the differences between this version and version stx:libjava
|
|
51 |
as of 1.9.2010
|
|
52 |
|
|
53 |
"
|
|
54 |
! !
|
|
55 |
|
|
56 |
!JavaNativeMemoryTests methodsFor:'initialization & release'!
|
|
57 |
|
|
58 |
setUp
|
|
59 |
mem := JavaNativeMemory new.
|
|
60 |
mem defaultMallocatedMemoryChunkSize:16"B"
|
|
61 |
|
|
62 |
"Created: / 11-07-2012 / 09:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
63 |
! !
|
|
64 |
|
|
65 |
!JavaNativeMemoryTests methodsFor:'tests-malloc/free'!
|
|
66 |
|
|
67 |
test_01
|
|
68 |
|
|
69 |
mem malloc: 8.
|
|
70 |
mem malloc: 8.
|
|
71 |
mem malloc: 8.
|
|
72 |
|
|
73 |
self assert: mem chunks size == 2
|
|
74 |
|
|
75 |
"Created: / 11-07-2012 / 09:15:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
76 |
!
|
|
77 |
|
|
78 |
test_02a
|
|
79 |
|
|
80 |
| addr1 addr2 |
|
|
81 |
|
|
82 |
addr1 := mem malloc: 8.
|
|
83 |
addr2 := mem malloc: 8.
|
|
84 |
mem free: addr1.
|
|
85 |
mem free: addr2.
|
|
86 |
mem malloc: 16.
|
|
87 |
|
|
88 |
self assert: mem chunks size == 1
|
|
89 |
|
|
90 |
"Created: / 11-07-2012 / 09:32:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
91 |
!
|
|
92 |
|
|
93 |
test_02b
|
|
94 |
|
|
95 |
| addr1 addr2 |
|
|
96 |
|
|
97 |
addr1 := mem malloc: 8.
|
|
98 |
addr2 := mem malloc: 8.
|
|
99 |
mem free: addr2.
|
|
100 |
mem free: addr1.
|
|
101 |
mem malloc: 16.
|
|
102 |
|
|
103 |
self assert: mem chunks size == 1
|
|
104 |
|
|
105 |
"Created: / 11-07-2012 / 09:32:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
106 |
!
|
|
107 |
|
|
108 |
test_02c
|
|
109 |
|
|
110 |
| addr1 addr2 addr3 |
|
|
111 |
|
|
112 |
addr1 := mem malloc: 4.
|
|
113 |
addr2 := mem malloc: 4.
|
|
114 |
addr3 := mem malloc: 8.
|
|
115 |
mem free: addr2.
|
|
116 |
mem free: addr1.
|
|
117 |
mem free: addr3.
|
|
118 |
mem malloc: 16.
|
|
119 |
|
|
120 |
self assert: mem chunks size == 1
|
|
121 |
|
|
122 |
"Created: / 11-07-2012 / 09:33:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
123 |
!
|
|
124 |
|
|
125 |
test_02d
|
|
126 |
|
|
127 |
| addr1 addr2 addr3 |
|
|
128 |
|
|
129 |
addr1 := mem malloc: 4.
|
|
130 |
addr2 := mem malloc: 4.
|
|
131 |
addr3 := mem malloc: 8.
|
|
132 |
mem free: addr2.
|
|
133 |
mem free: addr3.
|
|
134 |
mem free: addr1.
|
|
135 |
mem malloc: 16.
|
|
136 |
|
|
137 |
self assert: mem chunks size == 1
|
|
138 |
|
|
139 |
"Created: / 11-07-2012 / 09:33:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
140 |
!
|
|
141 |
|
|
142 |
test_03
|
|
143 |
|
|
144 |
| addr1 addr2 |
|
|
145 |
|
|
146 |
addr1 := mem malloc: 16.
|
|
147 |
addr2 := mem malloc: 16.
|
|
148 |
|
|
149 |
mem byteAt: addr1 put: 10.
|
|
150 |
mem byteAt: addr1 + 15 put: 9.
|
|
151 |
mem byteAt: addr2 put: 30.
|
|
152 |
mem byteAt: addr2 + 15 put: 33.
|
|
153 |
|
|
154 |
self assert: (mem byteAt: addr1) == 10.
|
|
155 |
self assert: (mem byteAt: addr1 + 15) == 9.
|
|
156 |
self assert: (mem byteAt: addr2) == 30.
|
|
157 |
self assert: (mem byteAt: addr2 + 15) == 33.
|
|
158 |
|
|
159 |
"Created: / 11-07-2012 / 10:03:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
160 |
! !
|
|
161 |
|
|
162 |
!JavaNativeMemoryTests class methodsFor:'documentation'!
|
|
163 |
|
|
164 |
version_SVN
|
|
165 |
^ '$Id:: $'
|
|
166 |
! !
|