diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-01 13:36:20 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-01 13:36:20 -0500 |
commit | ee4857cdd5416686e36624621b3460f1bc334c54 (patch) | |
tree | cf40832f85dccc666278fe4839486ec2e6b30f8a /internal/feed/score_test.go | |
parent | a40213480929a93a78239053a40a6ee93547c063 (diff) | |
download | cvez-ee4857cdd5416686e36624621b3460f1bc334c54.tar.bz2 cvez-ee4857cdd5416686e36624621b3460f1bc334c54.zip |
internal/feed: represent scores as uint8
Diffstat (limited to 'internal/feed/score_test.go')
-rw-r--r-- | internal/feed/score_test.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/internal/feed/score_test.go b/internal/feed/score_test.go index 0bda1b2..2baa7ab 100644 --- a/internal/feed/score_test.go +++ b/internal/feed/score_test.go @@ -43,14 +43,14 @@ func TestScoreUnmarshalInvalidValues(t *testing.T) { func TestScoreUnmarshalValidValues(t *testing.T) { tests := []struct { val string - exp float32 + exp uint8 } { - { `0.0`, 0.0 }, - { `0.1`, 0.1 }, - { `1.2`, 1.2 }, - { `5.9`, 5.9 }, - { `9.9`, 9.9 }, - { `10.0`, 10.0 }, + { `0.0`, 0 }, + { `0.1`, 1 }, + { `1.2`, 12 }, + { `5.9`, 59 }, + { `9.9`, 99 }, + { `10.0`, 100 }, } for _, test := range(tests) { @@ -60,8 +60,8 @@ func TestScoreUnmarshalValidValues(t *testing.T) { if err := json.Unmarshal([]byte(test.val), &got); err != nil { t.Error(err) return - } else if float32(got) != test.exp { - t.Errorf("got \"%f\", exp \"%f\"", float32(got), test.exp) + } else if uint8(got) != test.exp { + t.Errorf("got \"%d\", exp \"%d\"", uint8(got), test.exp) } }) } @@ -69,16 +69,16 @@ func TestScoreUnmarshalValidValues(t *testing.T) { func TestScoreString(t *testing.T) { tests := []struct { - val float32 + val uint8 exp string } { - { 0.0, "0.0" }, - { 0.01, "0.0" }, - { 0.09, "0.0" }, - { 1.2222, "1.2" }, - { 5.9, "5.9" }, - { 9.99, "9.9" }, - { 10.0, "10.0" }, + { 0, "0.0" }, + { 1, "0.1" }, + { 9, "0.9" }, + { 12, "1.2" }, + { 59, "5.9" }, + { 99, "9.9" }, + { 100, "10.0" }, } for _, test := range(tests) { |