Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04binôme2A
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Gabrielle Van De Vijver
IA04binôme2A
Commits
f0a913bf
Commit
f0a913bf
authored
1 year ago
by
Balthazar Wilson
Browse files
Options
Downloads
Patches
Plain Diff
fix: handle both swf/scf error and tb error
parent
3d9b7d77
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
add: error handling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comsoc/TieBreak.go
+12
-12
12 additions, 12 deletions
comsoc/TieBreak.go
with
12 additions
and
12 deletions
comsoc/TieBreak.go
+
12
−
12
View file @
f0a913bf
...
...
@@ -28,9 +28,9 @@ func SWFFactory(swf func(Profile) (Count, error), tb func([]Alternative) (Altern
return
func
(
p
Profile
)
([]
Alternative
,
error
)
{
//récupération du décompte
count
,
err
:=
swf
(
p
)
if
err
!=
nil
{
return
nil
,
err
count
,
err
SWF
:=
swf
(
p
)
if
err
SWF
!=
nil
{
return
nil
,
err
SWF
}
//préparation de la sortie
var
sortedAlts
[]
Alternative
...
...
@@ -45,7 +45,10 @@ func SWFFactory(swf func(Profile) (Count, error), tb func([]Alternative) (Altern
}
//Départage
for
len
(
bestAlts
)
>
0
{
bestAlt
,
_
:=
tb
(
bestAlts
)
bestAlt
,
errTB
:=
tb
(
bestAlts
)
if
errTB
!=
nil
{
return
nil
,
errTB
}
//ajout de la meilleure alternative post-tie break
sortedAlts
=
append
(
sortedAlts
,
bestAlt
)
//suppression de l'alternative dans bestAlts
...
...
@@ -82,16 +85,13 @@ func Test_sWFFactory() {
func
SCFFactory
(
scf
func
(
p
Profile
)
([]
Alternative
,
error
),
tb
func
([]
Alternative
)
(
Alternative
,
error
))
func
(
Profile
)
(
Alternative
,
error
)
{
return
func
(
p
Profile
)
(
Alternative
,
error
)
{
//récupération des meilleures alternatives
bestAlts
,
err
1
:=
scf
(
p
)
if
err
1
!=
nil
{
return
Alternative
(
0
),
err
1
bestAlts
,
err
SCF
:=
scf
(
p
)
if
err
SCF
!=
nil
{
return
Alternative
(
0
),
err
SCF
}
//récupération de la meilleure alternative
bestAlt
,
err2
:=
tb
(
bestAlts
)
if
err2
!=
nil
{
return
Alternative
(
0
),
err2
}
return
bestAlt
,
nil
bestAlt
,
errTB
:=
tb
(
bestAlts
)
return
bestAlt
,
errTB
}
}
func
Test_sCFFactory
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment