This file contains hidden or 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
package main | |
import ( | |
"context" | |
"errors" | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
"strconv" |
This file contains hidden or 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
package main | |
import "testing" | |
func TestGetScore(t *testing.T) { | |
tests := []struct { | |
name string | |
input []ScoreStamp | |
offset int | |
expected Score |
This file contains hidden or 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
// getScore returns score for specified offset from slice gameStamps. | |
// If offset is not found, it returns empty Score. | |
func getScore(gameStamps []ScoreStamp, offset int) Score { | |
if len(gameStamps) == 0 { | |
return Score{} | |
} | |
for _, stamp := range gameStamps { | |
if stamp.Offset == offset { | |
return stamp.Score |