Skip to content

[Step1] 코틀린 기초 #1587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: hwasikjung
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed src/main/kotlin/.gitkeep
Empty file.
Empty file removed src/test/kotlin/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions src/test/kotlin/study/Person.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package study

data class Person(val name: String, val age: Int, var nickname: String? = name)
33 changes: 33 additions & 0 deletions src/test/kotlin/study/PersonTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package study

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class PersonTest {
@Test
fun `이름 붙인 인자`() {
val actual = Person(name = "홍길동", nickname = "홍", age = 20)
assertThat(actual.name).isEqualTo("홍길동")
assertThat(actual.age).isEqualTo(20)
assertThat(actual.nickname).isEqualTo("길동")
}

@Test
fun `널 타입`() {
val actual = Person(name = "홍길동", nickname = null, age = 20)
assertThat(actual.nickname).isNull()
}

@Test
fun `기본 인자`() {
val actual = Person(name = "홍길동", age = 20)
assertThat(actual.nickname).isEqualTo("홍길동")
}

@Test
fun `데이터 클래스`() {
val actual1 = Person(name = "홍길동", age = 20)
val actual2 = Person(name = "홍길동", age = 20)
assertThat(actual1).isEqualTo(actual2)
}
}
12 changes: 12 additions & 0 deletions src/test/kotlin/study/StringTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package study

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class StringTest {
@Test
fun isBlank() {
val actual = "".isBlank()
assertThat("".isBlank()).isEqualTo(true)
}
}