-
Notifications
You must be signed in to change notification settings - Fork 1
/
measure_test.go
48 lines (41 loc) · 1.15 KB
/
measure_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package sentimental
import (
"testing"
)
// Test the score of an empty string.
func TestMeasureEmpty(t *testing.T) {
score := Measure("")
if score != 0 {
t.Error("Empty string score is not equal to 0")
}
}
func TestMeasureSinglePositiveWord(t *testing.T) {
score := Measure("fantastic")
if score <= 0 {
t.Error("\"Fantastic\" does not score positively")
}
}
func TestMeasureSingleNegativeWord(t *testing.T) {
score := Measure("obnoxious")
if score >= 0 {
t.Error("\"obnoxious\" does not score negatively")
}
}
func TestMeasureMixed(t *testing.T) {
score := Measure("Come out to the farm and eat my ass, idiot.")
if score == 0 {
t.Error("Mixed tokens test failed")
}
}
func TestFullMeasureNegative(t *testing.T) {
score := FullMeasure("I'm real mad about the awful churro I just ate.")
if score.Score == 0 {
t.Error("Negative FullMeasure test failed")
}
}
func TestFullMeasureNeutral(t *testing.T) {
score := FullMeasure("I opened the .XFL file and was thrust into an incredible world of high octane hardcore football for all the real daredevils out there.")
if score.Comparative != 0 {
t.Error("Neutral phrase FullMeasure test failed")
}
}