| 1 |
/* |
| 2 |
* Copyright (c) 2022 Goldman Sachs and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* and Eclipse Distribution License v. 1.0 which accompany this distribution. |
| 6 |
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* and the Eclipse Distribution License is available at |
| 8 |
* http://www.eclipse.org/org/documents/edl-v10.php. |
| 9 |
*/ |
| 10 |
|
| 11 |
package org.eclipse.collections.impl.set.mutable |
| 12 |
|
| 13 |
import org.eclipse.collections.api.set.MutableSet |
| 14 |
import org.eclipse.collections.impl.Prelude._ |
| 15 |
import org.eclipse.collections.impl.list.mutable.FastList |
| 16 |
import org.junit.Test |
| 17 |
|
| 18 |
class MultiReaderUnifiedSetScalaTest extends MultiReaderUnifiedSetTestTrait |
| 19 |
{ |
| 20 |
val classUnderTest = MultiReaderUnifiedSet.newSetWith(1, 2, 3) |
| 21 |
|
| 22 |
@Test |
| 23 |
override def equals_safe(): Unit = |
| 24 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 25 |
{ |
| 26 |
this.classUnderTest.equals(MultiReaderUnifiedSet.newSet()) |
| 27 |
} |
| 28 |
|
| 29 |
@Test |
| 30 |
def newSet_safe(): Unit = |
| 31 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 32 |
{ |
| 33 |
MultiReaderUnifiedSet.newSet |
| 34 |
} |
| 35 |
|
| 36 |
@Test |
| 37 |
def newBagCapacity_safe(): Unit = |
| 38 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 39 |
{ |
| 40 |
MultiReaderUnifiedSet.newSet(5) |
| 41 |
} |
| 42 |
|
| 43 |
@Test |
| 44 |
def newSetIterable_safe(): Unit = |
| 45 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 46 |
{ |
| 47 |
MultiReaderUnifiedSet.newSet(new FastList[Int]) |
| 48 |
} |
| 49 |
|
| 50 |
@Test |
| 51 |
def newSetWith_safe(): Unit = |
| 52 |
this.assert(readersBlocked = false, writersBlocked = false) |
| 53 |
{ |
| 54 |
MultiReaderUnifiedSet.newSetWith(1, 2) |
| 55 |
} |
| 56 |
|
| 57 |
@Test |
| 58 |
def union_safe(): Unit = |
| 59 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 60 |
{ |
| 61 |
this.classUnderTest.union(new UnifiedSet[Int]) |
| 62 |
} |
| 63 |
|
| 64 |
@Test |
| 65 |
def unionInto_safe(): Unit = |
| 66 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 67 |
{ |
| 68 |
this.classUnderTest.unionInto(new UnifiedSet[Int], new UnifiedSet[Int]) |
| 69 |
} |
| 70 |
|
| 71 |
@Test |
| 72 |
def intersect_safe(): Unit = |
| 73 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 74 |
{ |
| 75 |
this.classUnderTest.intersect(new UnifiedSet[Int]) |
| 76 |
} |
| 77 |
|
| 78 |
@Test |
| 79 |
def intersectInto_safe(): Unit = |
| 80 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 81 |
{ |
| 82 |
this.classUnderTest.intersectInto(new UnifiedSet[Int], new UnifiedSet[Int]) |
| 83 |
} |
| 84 |
|
| 85 |
@Test |
| 86 |
def difference_safe(): Unit = |
| 87 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 88 |
{ |
| 89 |
this.classUnderTest.difference(new UnifiedSet[Int]) |
| 90 |
} |
| 91 |
|
| 92 |
@Test |
| 93 |
def differenceInto_safe(): Unit = |
| 94 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 95 |
{ |
| 96 |
this.classUnderTest.differenceInto(new UnifiedSet[Int], new UnifiedSet[Int]) |
| 97 |
} |
| 98 |
|
| 99 |
@Test |
| 100 |
def symmetricDifference_safe(): Unit = |
| 101 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 102 |
{ |
| 103 |
this.classUnderTest.symmetricDifference(new UnifiedSet[Int]) |
| 104 |
} |
| 105 |
|
| 106 |
@Test |
| 107 |
def symmetricDifferenceInto_safe(): Unit = |
| 108 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 109 |
{ |
| 110 |
this.classUnderTest.symmetricDifferenceInto(new UnifiedSet[Int], new UnifiedSet[Int]) |
| 111 |
} |
| 112 |
|
| 113 |
@Test |
| 114 |
def isSubsetOf_safe(): Unit = |
| 115 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 116 |
{ |
| 117 |
this.classUnderTest.isSubsetOf(new UnifiedSet[Int]) |
| 118 |
} |
| 119 |
|
| 120 |
@Test |
| 121 |
def isProperSubsetOf_safe(): Unit = |
| 122 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 123 |
{ |
| 124 |
this.classUnderTest.isProperSubsetOf(new UnifiedSet[Int]) |
| 125 |
} |
| 126 |
|
| 127 |
@Test |
| 128 |
def powerSet_safe(): Unit = |
| 129 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 130 |
{ |
| 131 |
this.classUnderTest.powerSet |
| 132 |
} |
| 133 |
|
| 134 |
@Test |
| 135 |
def cartesianProduct_safe(): Unit = |
| 136 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 137 |
{ |
| 138 |
this.classUnderTest.cartesianProduct(new UnifiedSet[Int]) |
| 139 |
} |
| 140 |
|
| 141 |
@Test |
| 142 |
def clone_safe(): Unit = |
| 143 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 144 |
{ |
| 145 |
this.classUnderTest.clone |
| 146 |
} |
| 147 |
|
| 148 |
@Test |
| 149 |
def iteratorWithReadLock_safe(): Unit = |
| 150 |
this.assert(readersBlocked = false, writersBlocked = true) |
| 151 |
{ |
| 152 |
this.classUnderTest.withReadLockAndDelegate((each: MutableSet[Int]) => |
| 153 |
{ |
| 154 |
each.iterator |
| 155 |
() |
| 156 |
}) |
| 157 |
} |
| 158 |
|
| 159 |
@Test |
| 160 |
def iteratorWithWriteLock_safe(): Unit = |
| 161 |
this.assert(readersBlocked = true, writersBlocked = true) |
| 162 |
{ |
| 163 |
this.classUnderTest.withWriteLockAndDelegate((each: MutableSet[Int]) => |
| 164 |
{ |
| 165 |
each.iterator |
| 166 |
() |
| 167 |
}) |
| 168 |
} |
| 169 |
} |