This repository has been archived by the owner on Aug 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
385 additions
and
303 deletions.
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package i_introduction._0_Hello_World | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N00StartKtTest { | ||
@Test fun testOk() { | ||
@Test | ||
fun testOk() { | ||
assertEquals("OK", task0()) | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
test/i_introduction/_10_Object_Expressions/N10ObjectExpressionsKtTest.kt
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package i_introduction._10_Object_Expressions | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N10ObjectExpressionsKtTest { | ||
@Test fun testSort() { | ||
@Test | ||
fun testSort() { | ||
assertEquals(listOf(5, 2, 1), task10()) | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
test/i_introduction/_11_SAM_Conversions/N11SAMConversionsKtTest.kt
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package i_introduction._11_SAM_Conversions | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N11SAMConversionsKtTest { | ||
@Test fun testSort() { | ||
@Test | ||
fun testSort() { | ||
assertEquals(listOf(5, 2, 1), task11()) | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
test/i_introduction/_12_Extensions_On_Collections/N12ExtensionsOnCollectionsKtTest.kt
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package i_introduction._12_Extensions_On_Collections | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N12ExtensionsOnCollectionsKtTest { | ||
@Test fun testSort() { | ||
@Test | ||
fun testSort() { | ||
assertEquals(listOf(5, 2, 1), task12()) | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
test/i_introduction/_1_Java_To_Kotlin_Converter/N01JavaToKotlinConverterKtTest.kt
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package i_introduction._1_Java_To_Kotlin_Converter | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N01JavaToKotlinConverterKtTest { | ||
@Test fun collection() { | ||
@Test | ||
fun collection() { | ||
assertEquals("{1, 2, 3, 42, 555}", task1(listOf(1, 2, 3, 42, 555))) | ||
} | ||
} |
6 changes: 4 additions & 2 deletions
6
test/i_introduction/_2_Named_Arguments/N02NamedArgumentsKtTest.kt
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
7 changes: 4 additions & 3 deletions
7
test/i_introduction/_3_Default_Arguments/N03DefaultArgumentsKtTest.kt
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package i_introduction._3_Default_Arguments | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N03DefaultArgumentsKtTest { | ||
|
||
@Test fun testDefaultAndNamedParams() { | ||
@Test | ||
fun testDefaultAndNamedParams() { | ||
assertEquals("a42b1C42D2", task3()) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package i_introduction._4_Lambdas | ||
|
||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
class N04LambdasKtTest { | ||
@Test fun contains() { | ||
@Test | ||
fun contains() { | ||
assertTrue(task4(listOf(1, 2, 3))) | ||
} | ||
|
||
@Test fun notContains() { | ||
@Test | ||
fun notContains() { | ||
assertFalse(task4(listOf(1, 3, 5))) | ||
} | ||
} |
16 changes: 9 additions & 7 deletions
16
test/i_introduction/_5_String_Templates/N05StringTemplatesKtTest.kt
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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package i_introduction._5_String_Templates | ||
|
||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
import java.util.regex.Pattern | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
class N05StringTemplatesKtTest { | ||
@Test fun match() { | ||
@Test | ||
fun match() { | ||
assertTrue("11 MAR 1952".matches(task5().toRegex())) | ||
} | ||
|
||
@Test fun match1() { | ||
@Test | ||
fun match1() { | ||
assertTrue("24 AUG 1957".matches(task5().toRegex())) | ||
} | ||
|
||
@Test fun doNotMatch() { | ||
@Test | ||
fun doNotMatch() { | ||
assertFalse("24 RRR 1957".matches(task5().toRegex())) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package i_introduction._6_Data_Classes | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
|
||
class N06DataClassesKtTest { | ||
@Test fun testListOfPeople() { | ||
@Test | ||
fun testListOfPeople() { | ||
assertEquals("[Person(name=Alice, age=29), Person(name=Bob, age=31)]", task6().toString()) | ||
} | ||
} |
45 changes: 24 additions & 21 deletions
45
test/i_introduction/_7_Nullable_Types/N07NullableTypesKtTest.kt
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 |
---|---|---|
@@ -1,49 +1,52 @@ | ||
package i_introduction._7_Nullable_Types | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N07NullableTypesKtTest { | ||
fun testSendMessageToClient( | ||
client: Client?, | ||
message: String?, | ||
email: String? = null, | ||
shouldBeInvoked: Boolean = false | ||
private fun testSendMessageToClient( | ||
client: Client?, | ||
message: String?, | ||
email: String? = null, | ||
shouldBeInvoked: Boolean = false | ||
) { | ||
var invoked = false | ||
sendMessageToClient(client, message, object : Mailer { | ||
override fun sendMessage(actualEmail: String, actualMessage: String) { | ||
invoked = true | ||
assertEquals("The message is not as expected:", | ||
message, actualMessage) | ||
assertEquals("The email is not as expected:", | ||
email, actualEmail) | ||
assertEquals(message, actualMessage, "The message is not as expected:") | ||
assertEquals(email, actualEmail, "The email is not as expected:") | ||
} | ||
}) | ||
assertEquals("The function 'sendMessage' should${if (shouldBeInvoked) "" else "n't"} be invoked", | ||
shouldBeInvoked, invoked) | ||
assertEquals(shouldBeInvoked, invoked, | ||
"The function 'sendMessage' should${if (shouldBeInvoked) "" else "n't"} be invoked") | ||
} | ||
|
||
@Test fun everythingIsOk() { | ||
@Test | ||
fun everythingIsOk() { | ||
testSendMessageToClient(Client(PersonalInfo("[email protected]")), | ||
"Hi Bob! We have an awesome proposition for you...", | ||
"[email protected]", | ||
true) | ||
"Hi Bob! We have an awesome proposition for you...", | ||
"[email protected]", | ||
true) | ||
} | ||
|
||
@Test fun noMessage() { | ||
@Test | ||
fun noMessage() { | ||
testSendMessageToClient(Client(PersonalInfo("[email protected]")), null) | ||
} | ||
|
||
@Test fun noEmail() { | ||
@Test | ||
fun noEmail() { | ||
testSendMessageToClient(Client(PersonalInfo(null)), "Hi Bob! We have an awesome proposition for you...") | ||
} | ||
|
||
@Test fun noPersonalInfo() { | ||
@Test | ||
fun noPersonalInfo() { | ||
testSendMessageToClient(Client(null), "Hi Bob! We have an awesome proposition for you...") | ||
} | ||
|
||
@Test fun noClient() { | ||
@Test | ||
fun noClient() { | ||
testSendMessageToClient(null, "Hi Bob! We have an awesome proposition for you...") | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,21 @@ | ||
package i_introduction._8_Smart_Casts | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N08SmartCastsKtTest { | ||
@Test fun testNum() { | ||
assertEquals("'eval' on Num should work:", 2, eval(Num(2))) | ||
@Test | ||
fun testNum() { | ||
assertEquals(2, eval(Num(2)), "'eval' on Num should work:") | ||
} | ||
|
||
@Test fun testSum() { | ||
assertEquals("'eval' on Sum should work:", 3, eval(Sum(Num(2), Num(1)))) | ||
@Test | ||
fun testSum() { | ||
assertEquals(3, eval(Sum(Num(2), Num(1))), "'eval' on Sum should work:") | ||
} | ||
|
||
@Test fun testRecursion() { | ||
assertEquals("'eval' should work recursively:", 6, eval(Sum(Sum(Num(1), Num(2)), Num(3)))) | ||
@Test | ||
fun testRecursion() { | ||
assertEquals(6, eval(Sum(Sum(Num(1), Num(2)), Num(3))), "'eval' should work recursively:") | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
test/i_introduction/_9_Extension_Functions/N09ExtensionFunctionsKtTest.kt
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package i_introduction._9_Extension_Functions | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N09ExtensionFunctionsKtTest { | ||
@Test fun testIntExtension() { | ||
assertEquals("Rational number creation error: ", RationalNumber(4, 1), 4.r()) | ||
@Test | ||
fun testIntExtension() { | ||
assertEquals(RationalNumber(4, 1), 4.r(), "Rational number creation error: ") | ||
} | ||
|
||
@Test fun testPairExtension() { | ||
assertEquals("Rational number creation error: ", RationalNumber(2, 3), Pair(2, 3).r()) | ||
@Test | ||
fun testPairExtension() { | ||
assertEquals(RationalNumber(2, 3), Pair(2, 3).r(), "Rational number creation error: ") | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
package ii_collections | ||
|
||
import ii_collections.data.* | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class N14FilterMapKtTest { | ||
@Test fun testCitiesCustomersAreFrom() { | ||
@Test | ||
fun testCitiesCustomersAreFrom() { | ||
assertEquals(setOf(Canberra, Vancouver, Budapest, Ankara, Tokyo), shop.getCitiesCustomersAreFrom()) | ||
} | ||
|
||
/** | ||
* Returns the list of the customers who live in the city 'city' | ||
*/ | ||
@Test fun testCustomersFromCity() { | ||
@Test | ||
fun testCustomersFromCity() { | ||
assertEquals(listOf(customers[lucas], customers[cooper]), shop.getCustomersFrom(Canberra)) | ||
} | ||
} |
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
Oops, something went wrong.