Skip to content

Commit

Permalink
Missing tests for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
neonailol committed Jun 28, 2018
1 parent 33cbd63 commit d07d62f
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/nnl.rocks.kactoos.collection/-reversed/-init-.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# <init>

`Reversed(src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`X`](index.md#X)`>)`
`Reversed(vararg src: `[`X`](index.md#X)`)`
`Reversed(src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`X`](index.md#X)`>)`
`Reversed(src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`X`](index.md#X)`>)`
`Reversed(vararg src: `[`X`](index.md#X)`)`
2 changes: 1 addition & 1 deletion docs/nnl.rocks.kactoos.collection/-reversed/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ There is no thread-safety guarantee.

| Name | Summary |
|---|---|
| [&lt;init&gt;](-init-.md) | `Reversed(src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`X`](index.md#X)`>)`<br>`Reversed(vararg src: `[`X`](index.md#X)`)`<br>`Reversed(src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`X`](index.md#X)`>)` |
| [&lt;init&gt;](-init-.md) | `Reversed(src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`X`](index.md#X)`>)`<br>`Reversed(src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`X`](index.md#X)`>)`<br>`Reversed(vararg src: `[`X`](index.md#X)`)` |

### Inherited Functions

Expand Down
4 changes: 2 additions & 2 deletions docs/nnl.rocks.kactoos.collection/-skipped/-init-.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# &lt;init&gt;

`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)`
`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)``Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`
`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)`
`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)``Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`

Skipped collection.

Expand Down
2 changes: 1 addition & 1 deletion docs/nnl.rocks.kactoos.collection/-skipped/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There is no thread-safety guarantee.

| Name | Summary |
|---|---|
| [&lt;init&gt;](-init-.md) | `Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)`<br>`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)``Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`<br>Skipped collection. |
| [&lt;init&gt;](-init-.md) | `Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)`<br>`Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)``Skipped(skip: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`<br>Skipped collection. |

### Inherited Functions

Expand Down
4 changes: 2 additions & 2 deletions docs/nnl.rocks.kactoos.collection/-tail-of/-init-.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# &lt;init&gt;

`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)`
`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)``TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`
`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)`
`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)``TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`

Tail portion of the collection.

Expand Down
2 changes: 1 addition & 1 deletion docs/nnl.rocks.kactoos.collection/-tail-of/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There is no thread-safety guarantee.

| Name | Summary |
|---|---|
| [&lt;init&gt;](-init-.md) | `TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)`<br>`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)``TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`<br>Tail portion of the collection. |
| [&lt;init&gt;](-init-.md) | `TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](index.md#T)`>)`<br>`TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, vararg src: `[`T`](index.md#T)`)``TailOf(num: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, src: `[`Collection`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)`<`[`T`](index.md#T)`>)`<br>Tail portion of the collection. |

### Inherited Functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Reversed<X : Any> : CollectionEnvelope<X> {

constructor(src: Collection<X>) : super({ src.reversed() })

constructor(vararg src: X) : this(src.asIterable())

constructor(src: Iterable<X>) : this(CollectionOf(src))

constructor(vararg src: X) : this(src.asIterable())
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class Skipped<T : Any>(

constructor(
skip: Int,
vararg src: T
) : this(skip, IterableOf(src.asIterable()))
src: Iterable<T>
) : this(skip, CollectionOf(src))

constructor(
skip: Int,
src: Iterable<T>
) : this(skip, CollectionOf(src))
vararg src: T
) : this(skip, IterableOf(src.asIterable()))

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TailOf<T : Any>(
src: Collection<T>
) : CollectionEnvelope<T>({ CollectionOf(TailOf(num, src)) }) {

constructor(num: Int, vararg src: T) : this(num, IterableOf(src.asIterable()))

constructor(num: Int, src: Iterable<T>) : this(num, CollectionOf(src))

constructor(num: Int, vararg src: T) : this(num, IterableOf(src.asIterable()))
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package nnl.rocks.kactoos.collection

import nnl.rocks.kactoos.func.FuncOf
import nnl.rocks.kactoos.test.BehavesAsCollection
import kotlin.test.Test

class FilteredTest {

@Test
fun filtered() {
fun filteredKFuncVarargs() {
BehavesAsCollection(
Filtered(
{ it -> it > 3 },
Expand All @@ -15,4 +16,26 @@ class FilteredTest {
arrayOf(4, 8)
)
}

@Test
fun filteredFuncVarargs() {
BehavesAsCollection(
Filtered(
FuncOf { it -> it > 3 },
1, 4, 8
),
arrayOf(4, 8)
)
}

@Test
fun filteredFuncIterable() {
BehavesAsCollection(
Filtered(
FuncOf { it: Int -> it > 3 },
CollectionOf(1, 4, 8)
),
arrayOf(4, 8)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package nnl.rocks.kactoos.collection

import nnl.rocks.kactoos.func.FuncOf
import nnl.rocks.kactoos.iterable.IterableOf
import nnl.rocks.kactoos.test.BehavesAsCollection
import kotlin.test.Test

class MappedTest {

@Test
fun mappedVarargs() {
fun mappedKFuncVarargs() {
BehavesAsCollection(
Mapped(
{ x -> x.toString() },
Expand All @@ -18,7 +19,7 @@ class MappedTest {
}

@Test
fun mappedIterable() {
fun mappedKFuncIterable() {
BehavesAsCollection(
Mapped(
{ x: Int -> x.toString() },
Expand All @@ -27,4 +28,26 @@ class MappedTest {
arrayOf("1", "2", "3")
)
}

@Test
fun mappedFuncVarargs() {
BehavesAsCollection(
Mapped(
FuncOf { x -> x.toString() },
1, 2, 3
),
arrayOf("1", "2", "3")
)
}

@Test
fun mappedFuncIterable() {
BehavesAsCollection(
Mapped(
FuncOf { x: Int -> x.toString() },
IterableOf(1, 2, 3)
),
arrayOf("1", "2", "3")
)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package nnl.rocks.kactoos.collection

import nnl.rocks.kactoos.iterable.IterableOf
import kotlin.test.Test
import kotlin.test.assertTrue

class ShuffledTest {

@Test
fun shuffles() {
fun shufflesVarargs() {
val shuffled = Shuffled(1, 2, 3)
assertTrue(shuffled.size == 3)
assertTrue(shuffled.contains(1))
assertTrue(shuffled.contains(2))
assertTrue(shuffled.contains(3))
}

@Test
fun shufflesIterable() {
val shuffled = Shuffled(IterableOf(1, 2, 3))
assertTrue(shuffled.size == 3)
assertTrue(shuffled.contains(1))
assertTrue(shuffled.contains(2))
assertTrue(shuffled.contains(3))
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
package nnl.rocks.kactoos.collection

import nnl.rocks.kactoos.iterable.IterableOf
import nnl.rocks.kactoos.test.BehavesAsCollection
import kotlin.test.Test

class SortedTest {

@Test
fun sorts() {
fun sortsNaturalVarargs() {
BehavesAsCollection(
Sorted(3, 2, 1),
arrayOf(1, 2, 3)
)
}

@Test
fun sortsNaturalIterable() {
BehavesAsCollection(
Sorted(IterableOf(3, 2, 1)),
arrayOf(1, 2, 3)
)
}

@Test
fun sortsVarargs() {
BehavesAsCollection(
Sorted(
Comparator { a: Int, b: Int -> a.compareTo(b) },
3, 2, 1
),
arrayOf(1, 2, 3)
)
}

@Test
fun sortsIterable() {
BehavesAsCollection(
Sorted(
Comparator { a: Int, b: Int -> a.compareTo(b) },
IterableOf(3, 2, 1)
),
arrayOf(1, 2, 3)
)
}
}

0 comments on commit d07d62f

Please sign in to comment.