-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feat_takeWhile
- Loading branch information
Showing
6 changed files
with
485 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ox.channels | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import ox.* | ||
|
||
class SourceOpsDropTest extends AnyFlatSpec with Matchers { | ||
behavior of "Source.drop" | ||
|
||
it should "not drop from the empty source" in supervised { | ||
val s = Source.empty[Int] | ||
s.drop(1).toList shouldBe List.empty | ||
} | ||
|
||
it should "drop elements from the source" in supervised { | ||
val s = Source.fromValues(1, 2, 3) | ||
s.drop(2).toList shouldBe List(3) | ||
} | ||
|
||
it should "return empty source when more elements than source length was dropped" in supervised { | ||
val s = Source.fromValues(1, 2) | ||
s.drop(3).toList shouldBe List.empty | ||
} | ||
|
||
it should "not drop when 'n == 0'" in supervised { | ||
val s = Source.fromValues(1, 2, 3) | ||
s.drop(0).toList shouldBe List(1, 2, 3) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
core/src/test/scala/ox/channels/SourceOpsIntersperseTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ox.channels | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import ox.* | ||
|
||
class SourceOpsIntersperseTest extends AnyFlatSpec with Matchers { | ||
behavior of "Source.intersperse" | ||
|
||
it should "intersperse with inject only over an empty source" in supervised { | ||
val s = Source.empty[String] | ||
s.intersperse(", ").toList shouldBe List.empty | ||
} | ||
|
||
it should "intersperse with inject only over a source with one element" in supervised { | ||
val s = Source.fromValues("foo") | ||
s.intersperse(", ").toList shouldBe List("foo") | ||
} | ||
|
||
it should "intersperse with inject only over a source with multiple elements" in supervised { | ||
val s = Source.fromValues("foo", "bar") | ||
s.intersperse(", ").toList shouldBe List("foo", ", ", "bar") | ||
} | ||
|
||
it should "intersperse with start, inject and end over an empty source" in supervised { | ||
val s = Source.empty[String] | ||
s.intersperse("[", ", ", "]").toList shouldBe List("[", "]") | ||
} | ||
|
||
it should "intersperse with start, inject and end over a source with one element" in supervised { | ||
val s = Source.fromValues("foo") | ||
s.intersperse("[", ", ", "]").toList shouldBe List("[", "foo", "]") | ||
} | ||
|
||
it should "intersperse with start, inject and end over a source with multiple elements" in supervised { | ||
val s = Source.fromValues("foo", "bar") | ||
s.intersperse("[", ", ", "]").toList shouldBe List("[", "foo", ", ", "bar", "]") | ||
} | ||
} |
Oops, something went wrong.