Skip to content

Commit

Permalink
Fix bug on slot-forced topics, and adds test
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelrenoux committed May 7, 2023
1 parent f7e492b commit cec81c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/fr/renoux/gaston/model/impl/ProblemImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ final class ProblemImpl(
val couples = for {
slot <- slots
topic <- topics
if topic.mandatory.exists(!slot.personsPresent.contains(_))
if topic.slots.exists(!_.contains(slot))
if !topic.virtual // Virtual topics are never moved anyway
if topic.mandatory.exists(!slot.personsPresent.contains(_)) || topic.slots.exists(!_.contains(slot))
} yield (slot, topic)
couples.groupToMap.toBitMap(Set.empty)
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/scala/fr/renoux/gaston/input/InputTranscriptionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,25 @@ class InputTranscriptionSpec extends AnyFlatSpec with Matchers {
}
}



behavior of "Incompatible topics per slot"

{
it should "work for slot-specific topics" in {
val inputSlots = List(List(InputSlot("one"), InputSlot("two")))
val inputTopics = List(InputTopic("alpha", slots = Some(Set("two"))), InputTopic("beta"))
val inputPersons = List(InputPerson("Arnold", mandatory = Set("alpha")))
val inputModel = InputModel(
slots = inputSlots,
topics = inputTopics,
persons = inputPersons
)
implicit val problem: Problem = from(inputModel)
problem.incompatibleTopicsBySlot.get(slot"one").get should be(Set(t"alpha"))
problem.incompatibleTopicsBySlot.get(slot"two").get should be(Set.empty)
}

}

}

0 comments on commit cec81c0

Please sign in to comment.