-
Notifications
You must be signed in to change notification settings - Fork 1
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 #331 from timwangmusic/sort-before-solve
[Enhancement] Sort places by score before solving combinatorics
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 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
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,43 @@ | ||
package matching | ||
|
||
import ( | ||
"github.com/weihesdlegend/Vacation-planner/POI" | ||
"testing" | ||
) | ||
|
||
func TestPlaceScore(t *testing.T) { | ||
type args struct { | ||
place Place | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want float64 | ||
}{ | ||
{ | ||
name: "test compute place score with zero price should return correct result", | ||
args: args{place: Place{ | ||
Place: &POI.Place{Name: "Local Park", UserRatingsTotal: 99, Rating: 4.0}, | ||
Category: POI.PlaceCategoryVisit, | ||
Price: 0, | ||
}}, | ||
want: 1.6, | ||
}, | ||
{ | ||
name: "test compute place score with price at level two should return correct result", | ||
args: args{place: Place{ | ||
Place: &POI.Place{Name: "Uncle Pizza", UserRatingsTotal: 999, Rating: 4.0}, | ||
Category: POI.PlaceCategoryEatery, | ||
Price: 2, | ||
}}, | ||
want: 6.0, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := PlaceScore(tt.args.place); got != tt.want { | ||
t.Errorf("PlaceScore() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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