-
Notifications
You must be signed in to change notification settings - Fork 3
/
Tests.hs
80 lines (72 loc) · 1.97 KB
/
Tests.hs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{-
Author: Pranav Vishnu Ramabhadran
-}
module Tests where
import Responses
import Main
import qualified Data.ByteString as BS
import Data.Text (Text, unpack, split, pack, dropAround, toLower, words)
import Data.Aeson
import GHC.Generics
import Data.List
import qualified Data.Trie as T
import qualified Codec.Binary.UTF8.String as C
import Test.HUnit
testCleanString :: Test
testCleanString =
TestList [(pack "blah") ~=? cleanString (pack " blah?,"),
(pack "blah blah") ~=? cleanString (pack "blah blah ?")]
testingTrie :: T.Trie(String)
testingTrie =
T.fromList [(BS.pack $ C.encode "dystopia", "hunger games"),
(BS.pack $ C.encode "jk rowling", "harry potter")]
testTrie :: Test
testTrie =
TestList [testingTrie
~=?
addToTrie ["Dystopia, Hunger Games", "JK Rowling, Harry Potter"],
T.fromList [(BS.pack $ C.encode "dystopia", "hunger games")]
~=?
addToTrie ["Dystopia, Hunger Games"],
T.fromList []
~=?
addToTrie []]
testSearch :: Test
testSearch =
TestList [Nothing
~=?
searchForTopic testingTrie ["hunger" , "games"] ,
Just "hunger games"
~=?
searchForTopic testingTrie ["dystopia"],
Nothing
~=?
searchForTopic testingTrie []]
testingEmoTrie :: T.Trie(String)
testingEmoTrie =
T.fromList [(BS.pack $ C.encode "good", "2"),
(BS.pack $ C.encode "just okay", "-1"),
(BS.pack $ C.encode "worst", "-5")]
testScore :: Test
testScore =
TestList [0
~=?
scoreEmotions testingEmoTrie ["hunger" , "games"] ,
-3
~=?
scoreEmotions testingEmoTrie ["good", "whatever", "worst"],
0
~=?
scoreEmotions testingEmoTrie []]
testingTweet :: Tweet
testingTweet = Tweet (pack " ? Here is, a test Tweet? . ") 1
testWords :: Test
testWords =
TestList [["here", "is", "a", "test", "tweet"]
~=?
getWords testingTweet]
testText :: Test
testText =
TestList [["a", "a test", "test", "test tweet", "tweet"]
~=?
getText ["a", "test", "tweet"]]