|
| 1 | +/* |
| 2 | + * Copyright (C) 2010-2025, Danilo Pianini and contributors |
| 3 | + * listed, for each module, in the respective subproject's build.gradle.kts file. |
| 4 | + * |
| 5 | + * This file is part of Alchemist, and is distributed under the terms of the |
| 6 | + * GNU General Public License, with a linking exception, |
| 7 | + * as described in the file LICENSE in the Alchemist distribution's top directory. |
| 8 | + */ |
| 9 | +package it.unibo.alchemist.model.sapere |
| 10 | + |
| 11 | +import io.kotest.assertions.throwables.shouldThrow |
| 12 | +import io.kotest.core.spec.style.StringSpec |
| 13 | +import io.kotest.matchers.string.shouldContain |
| 14 | +import it.unibo.alchemist.model.environments.Continuous2DEnvironment |
| 15 | +import it.unibo.alchemist.model.incarnations.SAPEREIncarnation |
| 16 | +import it.unibo.alchemist.model.positions.Euclidean2DPosition |
| 17 | +import it.unibo.alchemist.model.sapere.actions.SAPEREChemotaxis |
| 18 | +import it.unibo.alchemist.model.sapere.nodes.LsaNode |
| 19 | + |
| 20 | +class TestSAPEREChemotaxis : |
| 21 | + StringSpec( |
| 22 | + { |
| 23 | + "SAPEREChemotaxis constructor should throw IllegalArgumentException for negative idPosition" { |
| 24 | + val incarnation = SAPEREIncarnation<Euclidean2DPosition>() |
| 25 | + val environment = Continuous2DEnvironment<List<ILsaMolecule>>(incarnation) |
| 26 | + val node = LsaNode(environment) |
| 27 | + val response = incarnation.createMolecule("response") |
| 28 | + val gradient = incarnation.createMolecule("gradient, Dest") |
| 29 | + val invalidPosition = -1 |
| 30 | + val exception = shouldThrow<IllegalArgumentException> { |
| 31 | + SAPEREChemotaxis(environment, node, response, gradient, invalidPosition) |
| 32 | + } |
| 33 | + exception.message shouldContain "idPosition" |
| 34 | + exception.message shouldContain invalidPosition.toString() |
| 35 | + } |
| 36 | + }, |
| 37 | + ) |
0 commit comments