From 3f7f69cd40a88a9f9da565d98a14851f6185a562 Mon Sep 17 00:00:00 2001 From: hwasikJung <83931503+hwasikJung@users.noreply.github.com> Date: Tue, 12 Nov 2024 22:20:03 +0900 Subject: [PATCH 1/2] test: study kotlin --- src/main/kotlin/.gitkeep | 0 src/test/kotlin/.gitkeep | 0 src/test/kotlin/study/Person.kt | 3 +++ src/test/kotlin/study/PersonTest.kt | 31 +++++++++++++++++++++++++++++ src/test/kotlin/study/StringTest.kt | 12 +++++++++++ 5 files changed, 46 insertions(+) delete mode 100644 src/main/kotlin/.gitkeep delete mode 100644 src/test/kotlin/.gitkeep create mode 100644 src/test/kotlin/study/Person.kt create mode 100644 src/test/kotlin/study/PersonTest.kt create mode 100644 src/test/kotlin/study/StringTest.kt diff --git a/src/main/kotlin/.gitkeep b/src/main/kotlin/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/test/kotlin/.gitkeep b/src/test/kotlin/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/test/kotlin/study/Person.kt b/src/test/kotlin/study/Person.kt new file mode 100644 index 0000000000..b9e442c417 --- /dev/null +++ b/src/test/kotlin/study/Person.kt @@ -0,0 +1,3 @@ +package study + +data class Person(val name: String, val age: Int, var nickname: String? = name) diff --git a/src/test/kotlin/study/PersonTest.kt b/src/test/kotlin/study/PersonTest.kt new file mode 100644 index 0000000000..55855176f4 --- /dev/null +++ b/src/test/kotlin/study/PersonTest.kt @@ -0,0 +1,31 @@ +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("홍길동") + } + + @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) + } +} diff --git a/src/test/kotlin/study/StringTest.kt b/src/test/kotlin/study/StringTest.kt new file mode 100644 index 0000000000..9b9d6170b1 --- /dev/null +++ b/src/test/kotlin/study/StringTest.kt @@ -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) + } +} From edfd4446de9649338aaa52e2ac0fa1bb11713782 Mon Sep 17 00:00:00 2001 From: hwasikJung Date: Thu, 9 Jan 2025 00:07:10 +0900 Subject: [PATCH 2/2] test: study kotlin basics --- src/test/kotlin/study/PersonTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/kotlin/study/PersonTest.kt b/src/test/kotlin/study/PersonTest.kt index 55855176f4..7398f61958 100644 --- a/src/test/kotlin/study/PersonTest.kt +++ b/src/test/kotlin/study/PersonTest.kt @@ -8,6 +8,8 @@ class PersonTest { fun `이름 붙인 인자`() { val actual = Person(name = "홍길동", nickname = "홍", age = 20) assertThat(actual.name).isEqualTo("홍길동") + assertThat(actual.age).isEqualTo(20) + assertThat(actual.nickname).isEqualTo("길동") } @Test