-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add working knownSize implementation to ChunkBuilder instances (Scala…
… 2.13+) (#8892) * Add knownSize to ChunkBuilder instances * add test * fix ChunkBuilder.Boolean * add to Scala 2.12 impl * Add version specific test for ChunkBuilder.knowSize * cleanup
- Loading branch information
Showing
3 changed files
with
106 additions
and
16 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
core-tests/shared/src/test/scala-2.13+/ChunkBuilderVersionSpecific.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,81 @@ | ||
import zio.ChunkBuilder | ||
import zio.ZIOBaseSpec | ||
import zio.test._ | ||
|
||
object ChunkBuilderVersionSpecific extends ZIOBaseSpec { | ||
|
||
def spec = suite("ChunkBuilderVersionSpecific")( | ||
suite("Boolean")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.boolean)) { as => | ||
val builder = new ChunkBuilder.Boolean | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Byte")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.byte)) { as => | ||
val builder = new ChunkBuilder.Byte | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Char")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.char)) { as => | ||
val builder = new ChunkBuilder.Char | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Double")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.double)) { as => | ||
val builder = new ChunkBuilder.Double | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Float")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.float)) { as => | ||
val builder = new ChunkBuilder.Float | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Int")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.int)) { as => | ||
val builder = new ChunkBuilder.Int | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Long")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.long)) { as => | ||
val builder = new ChunkBuilder.Long | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
), | ||
suite("Short")( | ||
test("knownSize")( | ||
check(Gen.chunkOf(Gen.short)) { as => | ||
val builder = new ChunkBuilder.Short | ||
as.foreach(builder += _) | ||
assertTrue(builder.knownSize == as.size) | ||
} | ||
) | ||
) | ||
) | ||
} |
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