-
Notifications
You must be signed in to change notification settings - Fork 587
/
MultiReaderFastListScalaTest.scala
268 lines (232 loc) · 7.01 KB
/
MultiReaderFastListScalaTest.scala
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*
* Copyright (c) 2018 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.collections.impl.list.mutable
import org.eclipse.collections.api.list.MutableList
import org.eclipse.collections.impl.Prelude._
import org.junit.Test
class MultiReaderFastListScalaTest extends MultiReaderFastListTestTrait
{
override val classUnderTest = MultiReaderFastList.newListWith(1, 2, 3)
@Test
def listIterator_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
try
{
this.classUnderTest.listIterator
}
catch
{
case e: Exception => ()
}
}
@Test
def listIteratorIndex_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
try
{
this.classUnderTest.listIterator(1)
}
catch
{
case e: Exception => ()
}
}
@Test
def iteratorWithReadLock_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.withReadLockAndDelegate((each: MutableList[Int]) =>
{
each.iterator
()
})
}
@Test
def iteratorWithWriteLock_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.withWriteLockAndDelegate((each: MutableList[Int]) =>
{
each.iterator
()
})
}
@Test
def newList_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
MultiReaderFastList.newList
}
@Test
def newListCapacity_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
MultiReaderFastList.newList(5)
}
@Test
def newListIterable_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
MultiReaderFastList.newList(new FastList[Int])
}
@Test
def newListWith_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = false)
{
MultiReaderFastList.newListWith(1, 2)
}
@Test
def clone_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.clone
}
@Test
def addWithIndex_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.add(1, 4)
}
@Test
def addAllWithIndex_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.addAll(1, FastList.newListWith(3, 4, 5))
}
@Test
def removeWithIndex_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.remove(1)
}
@Test
def set_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.set(1, 4)
}
@Test
def reverseThis_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.reverseThis
}
@Test
def sort_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.sort(null)
}
@Test
def sortThis_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.sortThis
}
@Test
def sortThis_withComparator_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.sortThis(null)
}
@Test
def sortThisBy_safe(): Unit =
this.assert(readersBlocked = true, writersBlocked = true)
{
this.classUnderTest.sortThisBy[String]((_: Int) => "")
}
@Test
def distinct_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.distinct
}
@Test
def subList_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.subList(0, 1)
}
@Test
def get_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.get(1)
}
@Test
def indexOf_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.get(1)
}
@Test
def lastIndexOf_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.get(1)
}
@Test
def reverseForEach_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.reverseForEach((_: Int) => ())
}
@Test
def asReversed_safe(): Unit =
{
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.asReversed()
}
val reverseIterable = this.classUnderTest.asReversed()
this.assert(readersBlocked = false, writersBlocked = true)
{
reverseIterable.forEach((_: Int) => ())
}
}
@Test
def forEachWithIndex_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.forEachWithIndex(0, 2, (_: Int, _: Int) => ())
}
@Test
def toReversed_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.toReversed
}
@Test
def toStack_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.toStack
}
@Test
def takeWhile_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.takeWhile((_: Int) => true)
}
@Test
def dropWhile_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.dropWhile((_: Int) => true)
}
@Test
def partitionWhile_safe(): Unit =
this.assert(readersBlocked = false, writersBlocked = true)
{
this.classUnderTest.partitionWhile((_: Int) => true)
}
}