Cotton code
30 lines · 1.5 KB · KotlinRaw
package com.cottondb.photosimport com.cottondb.photos.faces.CarouselSlidesimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.JsonObjectimport kotlinx.serialization.json.jsonObjectimport org.junit.Assert.assertEqualsimport org.junit.Test/** The slide carousel's reading of an album card (AlbumCarouselFace.swift's CarouselSlides), over synthetic keys. */class CarouselSlidesTest {    private fun card(text: String): JsonObject = Json.parseToJsonElement(text).jsonObject    /** The cover comes first, then the album's other prints as it holds them, each once, three at most; none leaves the bench bare. */    @Test    fun the_cover_lies_first_and_three_at_most() {        assertEquals(listOf("c", "a", "b"), CarouselSlides.shown(card("""{"slots":{"photo":"c"},"prints":["a","c","b","d"]}""")))        assertEquals(listOf("a"), CarouselSlides.shown(card("""{"slots":{},"prints":["a",""]}""")))        assertEquals(emptyList<String>(), CarouselSlides.shown(card("""{"slots":{}}""")))    }    /** A slot holds a slide for each photo the album holds as the core counts it, the tray's eighty at most. */    @Test    fun the_slots_fill_by_the_count_to_eighty() {        assertEquals(12, CarouselSlides.filled(card("""{"slots":{"count":"12"}}""")))        assertEquals(80, CarouselSlides.filled(card("""{"slots":{"count":"1,204"}}""")))        assertEquals(0, CarouselSlides.filled(card("""{"slots":{}}""")))        assertEquals(-90.0 + 360.0 * 0.5 / 80, CarouselSlides.angle(0), 1e-9)    }}