-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.erl
71 lines (54 loc) · 1.87 KB
/
tester.erl
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
%Author: Tudor Dragan
-module(tester).
-import(facein,[start/1,name/1,add_friend/2,friends/1,broadcast/3,received_messages/1]).
-include_lib("eunit/include/eunit.hrl").
% process start test
start_test() ->
And = facein:start("Andrzej"),
?_assert(facein:name(And) == "Andrzej").
% adding a friend test
add_friend_test()->
And = facein:start("Andrzej"),
Ken = facein:start("Ken"),
facein:add_friend(Ken,And),
facein:add_friend(And,Ken),
[?_assert(facein:friends(And) == [{"Ken", Ken}]),
?_assert(facein:friends(And) == [{"Andrzej", And}])].
% the BIG graph test
broadcast_test()->
And = facein:start("Andrzej"),
Ken = facein:start("Ken"),
Sus = facein:start("Susan"),
Jes = facein:start("Jessica"),
Jen = facein:start("Jen"),
Ton = facein:start("Tony"),
Ree = facein:start("Reed"),
facein:add_friend(Ken,And),
facein:add_friend(And,Ken),
facein:add_friend(And,Sus),
facein:add_friend(Sus,And),
facein:add_friend(Jen,Sus),
facein:add_friend(Sus,Jen),
facein:add_friend(Jen,Jes),
facein:add_friend(Jes,Jen),
facein:add_friend(Sus,Jes),
facein:add_friend(Sus,Ree),
facein:add_friend(Ree,Jes),
facein:add_friend(Ree,Ton),
facein:add_friend(Jen,Ton),
facein:friends(And),
facein:friends(Ken),
facein:friends(Sus),
facein:friends(Jes),
facein:friends(Jen),
facein:friends(Ton),
facein:friends(Ree),
facein:broadcast(Jes,"First message From Jes", 2),
facein:broadcast(Ken,"Second message From Ken", 3),
facein:received_messages(Ton),
facein:received_messages(Sus),
facein:received_messages(Ree),
[?_assert(list:member({"Jessica","First message From Jes"}, facein:received_messages(Ton))),
?_assert(list:member({"Jessica","First message From Jes"}, facein:received_messages(Sus))),
?_assert(list:member({"Ken","Second message From Ken"}, facein:received_messages(Sus))),
?_assert(list:member({"Ken","Second message From Ken"}, facein:received_messages(Ree)))].