Skip to content

Commit

Permalink
[api]: Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Jun 13, 2024
1 parent 0b76e71 commit b760e97
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package nebulosa.image.format
import java.io.Serializable
import java.util.*

abstract class AbstractHeader protected constructor(@JvmField protected val cards: LinkedList<HeaderCard>) :
Header, MutableCollection<HeaderCard> by cards, Serializable {
abstract class AbstractHeader protected constructor(@JvmField protected val cards: LinkedList<HeaderCard>) : Header, Serializable {

constructor() : this(LinkedList<HeaderCard>())

Expand All @@ -27,6 +26,41 @@ abstract class AbstractHeader protected constructor(@JvmField protected val card
}
}

override val size
get() = cards.size

override fun contains(element: HeaderCard): Boolean {
return element in cards
}

override fun containsAll(elements: Collection<HeaderCard>): Boolean {
return cards.containsAll(elements)
}

override fun isEmpty(): Boolean {
return cards.isEmpty()
}

override fun iterator(): MutableIterator<HeaderCard> {
return cards.iterator()
}

override fun clear() {
cards.clear()
}

override fun remove(element: HeaderCard): Boolean {
return cards.remove(element)
}

override fun removeAll(elements: Collection<HeaderCard>): Boolean {
return cards.removeAll(elements.toSet())
}

override fun retainAll(elements: Collection<HeaderCard>): Boolean {
return cards.retainAll(elements.toSet())
}

override fun delete(key: String): Boolean {
return cards.removeIf { it.key == key }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface WritableHeader : MutableCollection<HeaderCard> {

fun addAll(cards: Iterable<HeaderCard>) = cards.forEach(::add)

override fun addAll(elements: Collection<HeaderCard>) = elements.fold(false) { a, b -> add(b) || a }

fun delete(key: HeaderKey) = delete(key.key)

fun delete(key: String): Boolean
Expand Down

0 comments on commit b760e97

Please sign in to comment.