Introduce 'pairwise' function, KEEP-11
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -837,6 +837,18 @@ class StringTest {
|
||||
assertContentEquals("abc", pair.second, "pair.second")
|
||||
}
|
||||
|
||||
@Test fun pairwise() = withOneCharSequenceArg { arg1 ->
|
||||
assertEquals(listOf("ab", "bc"), arg1("abc").pairwise { a, b -> a.toString() + b })
|
||||
assertTrue(arg1("").pairwise { a, b -> a.toString() + b }.isEmpty())
|
||||
assertTrue(arg1("a").pairwise { a, b -> a.toString() + b }.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun pairwisePairs() = withOneCharSequenceArg { arg1 ->
|
||||
assertEquals(listOf('a' to 'b', 'b' to 'c'), arg1("abc").pairwise())
|
||||
assertTrue(arg1("").pairwise().isEmpty())
|
||||
assertTrue(arg1("a").pairwise().isEmpty())
|
||||
}
|
||||
|
||||
@Test fun map() = withOneCharSequenceArg { arg1 ->
|
||||
assertEquals(listOf('a', 'b', 'c'), arg1("abc").map { it })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user