@@ -112,4 +112,36 @@ public void fourPersonsWithTwoSignificantlyMore() {
112
112
String actual = cc .greedy (transactionList );
113
113
assertEquals (expected , actual );
114
114
}
115
+
116
+ @ Test
117
+ public void allPersonsSame () {
118
+ HashMap <String , Transaction > transactions = new HashMap <>();
119
+ transactions .put ("Alice" , new Transaction ("Alice" , 12.34 ));
120
+ transactions .put ("Bob" , new Transaction ("Bob" , 12.34 ));
121
+ transactions .put ("Charlie" , new Transaction ("Charlie" , 12.34 ));
122
+ transactions .put ("Don" , new Transaction ("Don" , 12.34 ));
123
+ List <Transaction > transactionList = cc .preprocess (transactions );
124
+
125
+ String expected = "All good! No transactions required!" ;
126
+ String actual = cc .greedy (transactionList );
127
+ assertEquals (expected , actual );
128
+ }
129
+
130
+ @ Test
131
+ public void onlyOneContributor () {
132
+ HashMap <String , Transaction > transactions = new HashMap <>();
133
+ transactions .put ("Alice" , new Transaction ("Alice" , 123.34 ));
134
+ transactions .put ("Bob" , new Transaction ("Bob" , 0 ));
135
+ transactions .put ("Charlie" , new Transaction ("Charlie" , 0 ));
136
+ transactions .put ("Don" , new Transaction ("Don" , 0 ));
137
+ List <Transaction > transactionList = cc .preprocess (transactions );
138
+
139
+ String expected = "Don has to pay Alice $30.84\n "
140
+ + "Bob has to pay Alice $30.84\n "
141
+ + "Charlie has to pay Alice $30.83\n "
142
+ + "\n "
143
+ + "Number of transactions: 3" ;
144
+ String actual = cc .greedy (transactionList );
145
+ assertEquals (expected , actual );
146
+ }
115
147
}
0 commit comments