Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS-206 Demos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
CS-206 Demos
Compare revisions
a53c3744e22612630d129d8ebdf0c89b22fb5f3c to main
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
lara/cs206-demos
Select target project
No results found
main
Select Git revision
Branches
main
mb/alt-orderdec
mb/student-159
Swap
Target
gambhir/cs206-demos
Select target project
lara/cs206-demos
gcharles/cs206-demos
gambhir/cs206-demos
3 results
a53c3744e22612630d129d8ebdf0c89b22fb5f3c
Select Git revision
Branches
main
mb
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/midterm23/testBarberShop.scala
+39
-0
39 additions, 0 deletions
src/test/scala/midterm23/testBarberShop.scala
with
39 additions
and
0 deletions
src/test/scala/midterm23/testBarberShop.scala
0 → 100644
View file @
0f473913
package
midterm23
import
instrumentation.
{
Scheduler
,
TestHelper
}
/** Tests a barber shop implementation.
*
* @param nCustomers
* The number of customers to simulate.
* @param makeShop
* A function that creates a barber shop given the number of customers and a
* scheduler.
* @param checkEarlyCustomer
* If true, checks that no customer left early, i.e. that there is always a
* number of terminated customer threads equal or less than to the number of
* haircuts done.
*/
def
testBarberShop
(
nCustomers
:
Int
,
makeShop
:
(
Int
,
Scheduler
)
=>
ScheduledBarberShopSolution
,
checkEarlyCustomer
:
Boolean
=
true
)
=
TestHelper
.
testManySchedules
(
nCustomers
+
1
,
scheduler
=>
val
barberShop
=
makeShop
(
nCustomers
,
scheduler
)
(
(()
=>
barberShop
.
barber
())
::
(
for
i
<-
1
to
nCustomers
yield
()
=>
barberShop
.
customerTrace
(
i
)).
toList
,
results
=>
if
barberShop
.
nHaircuts
!=
nCustomers
then
(
false
,
f
"Unexpected number of hair cuts: ${barberShop.nHaircuts}"
)
else
if
checkEarlyCustomer
&&
barberShop
.
customerLeftEarly
()
then
(
false
,
f
"A customer left early"
)
else
(
true
,
""
)
)
)
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
Next