Skip to content

Commit e441b37

Browse files
committed
Complete unit tests
1 parent 10d722c commit e441b37

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/run/lst/LstTest.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,39 @@ object Test extends App {
139139
assert(xs0.take(10).length == 0)
140140
}
141141

142+
def zipWithTest() = {
143+
val ys4a = xs4.zipWith(xs5)(_ + _)
144+
val ys4b = xs5.zipWith(xs4)(_ + _)
145+
assert(ys4a.mkString("") == "aabbccdd")
146+
assert(ys4a === ys4b)
147+
val ys1a = xs1.zipWith(xs1)(_ + _)
148+
assert(ys1a === Lst("aa"))
149+
val ys1b = xs1.zipWith(xs2)(_ + _)
150+
assert(ys1b === Lst("aa"))
151+
val ys1c = xs2.zipWith(xs1)(_ + _)
152+
assert(ys1c === Lst("aa"))
153+
val ys0a = xs1.zipWith(xs0)(_ + _)
154+
val ys0b = xs0.zipWith(xs1)(_ + _)
155+
assert((ys0a ++ ys0b).isEmpty)
156+
val ys3i = xs3.zipWithIndex.map((x, y) => (x, y + 1))
157+
assert(ys3i === Lst(("a", 1), ("b", 2), ("c", 3)), ys3i)
158+
}
159+
160+
def correspondsTest() = {
161+
assert(xs4.corresponds(xs4)(_ == _))
162+
assert(!xs4.corresponds(xs5)(_ == _))
163+
assert(xs1.corresponds(xs1)(_ == _))
164+
assert(!xs1.corresponds(Lst("b"))(_ == _))
165+
assert(xs0.corresponds(xs0)(_ == _))
166+
assert(!xs0.corresponds(xs1)(_ == _))
167+
val zs1 = Lst(new Object, new Object)
168+
val zs2 = Lst(zs1(0), zs1(1))
169+
val zs3 = Lst(new Object, new Object)
170+
assert(zs1.eqElements(zs1))
171+
assert(zs1.eqElements(zs2))
172+
assert(!zs1.eqElements(zs3))
173+
}
174+
142175
println("testing")
143176
lengthTest()
144177
concatTest()
@@ -154,4 +187,6 @@ object Test extends App {
154187
reverseTest()
155188
applyTest()
156189
sliceTest()
190+
zipWithTest()
191+
correspondsTest()
157192
}

0 commit comments

Comments
 (0)