-
Notifications
You must be signed in to change notification settings - Fork 0
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
Alessio Coser
committed
Nov 5, 2020
1 parent
1d544d4
commit 8b7ade0
Showing
4 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package daikon.core | ||
|
||
data class Part(val name: String, val type: String?, val content: ByteArray) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Part | ||
|
||
if (name != other.name) return false | ||
if (type != other.type) return false | ||
if (!content.contentEquals(other.content)) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = name.hashCode() | ||
result = 31 * result + (type?.hashCode() ?: 0) | ||
result = 31 * result + content.contentHashCode() | ||
return result | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package daikon.core | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class PartTest { | ||
@Test | ||
fun `same parts are equal`() { | ||
val part1 = Part("name", null, byteArrayOf(112, 124, 111, 54)) | ||
val part2 = Part("name", null, byteArrayOf(112, 124, 111, 54)) | ||
|
||
assertThat(part1).isEqualTo(part2) | ||
} | ||
|
||
@Test | ||
fun `parts with different bytearray are different`() { | ||
val part1 = Part("name", null, byteArrayOf(112, 124, 111, 54)) | ||
val part2 = Part("name", null, byteArrayOf(112, 124, 111, 0)) | ||
|
||
assertThat(part1).isNotEqualTo(part2) | ||
} | ||
} |
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