-
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.
Merge pull request #16 from onera/13-components-services
Support non load/store components
- Loading branch information
Showing
2 changed files
with
109 additions
and
19 deletions.
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
57 changes: 57 additions & 0 deletions
57
src/test/scala/onera/pmlanalyzer/pml/model/hardware/HardwareTest.scala
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,57 @@ | ||
package onera.pmlanalyzer.pml.model.hardware | ||
|
||
import onera.pmlanalyzer.pml.model.hardware.* | ||
import onera.pmlanalyzer.pml.model.service.{Load, Store} | ||
import onera.pmlanalyzer.pml.operators.* | ||
import sourcecode.Name | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should | ||
|
||
class HardwareTest extends AnyFlatSpec with should.Matchers { | ||
|
||
/* Create a default platform to act as a container for components. */ | ||
object PlatformFixture extends Platform(Symbol("fixture")) | ||
|
||
import PlatformFixture.* | ||
|
||
"A Hardware" should "have default services" in { | ||
val t: Target = Target() | ||
val s: SimpleTransporter = SimpleTransporter() | ||
val i: Initiator = Initiator() | ||
val v: Virtualizer = Virtualizer() | ||
|
||
for (h <- List(t, s, i, v)) { | ||
exactly(1, h.services) shouldBe a [Load] | ||
exactly(1, h.services) shouldBe a [Store] | ||
h.services.size shouldBe 2 | ||
} | ||
} | ||
|
||
it should "have no services when specified" in { | ||
val t: Target = Target(withDefaultServices = false) | ||
val s: SimpleTransporter = SimpleTransporter(withDefaultServices = false) | ||
val i: Initiator = Initiator(withDefaultServices = false) | ||
val v: Virtualizer = Virtualizer(withDefaultServices = false) | ||
|
||
for (h <- List(t, s, i, v)) { | ||
h.services shouldBe empty | ||
} | ||
} | ||
|
||
it should "have only specified services when specified" in { | ||
val t: Target = Target(Set(Load("a"), Load("b")), withDefaultServices = false) | ||
t.services.size shouldEqual 2 | ||
exactly(2, t.services) shouldBe a [Load] | ||
|
||
val s = Target(Set(Store("a")), withDefaultServices = false) | ||
s.services.size shouldEqual 1 | ||
exactly(1, s.services) shouldBe a[Store] | ||
|
||
val i = Target(Set.empty, withDefaultServices = false) | ||
i.services.size shouldEqual 0 | ||
|
||
val j = Target(Symbol("j"), withDefaultServices = false) | ||
j.services.size shouldEqual 0 | ||
} | ||
|
||
} |