-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaylistTest.cpp
More file actions
115 lines (90 loc) · 3.47 KB
/
playlistTest.cpp
File metadata and controls
115 lines (90 loc) · 3.47 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <iostream>
#include "TestLib.h"
#include "PlaylistLinkedQueue.h"
// Created by Mariama Diallo on 12/2/19.
// PlaylistLinkedqueue test file
void EnqueueAndCalcDurationTest(){
std::cout << "-------EnqueueAndCalcDurationTest---------" <<std::endl;
PlaylistLinkedQueue testQueue;
testQueue.enqueue("Fruit","Abra",5.41);
//printAssertEquals(5.41,testQueue.calcDuration());
testQueue.enqueue("Nice","The Carters",3.53);
printAssertEquals("Fruit", testQueue.dequeue());
testQueue.enqueue("There will be Sunshine","Snoh",3.36);
testQueue.enqueue("Energy","Sampa",4.58);
// printAssertEquals(11.47,testQueue.calcDuration());
printAssertEquals("Nice", testQueue.dequeue());
printAssertEquals("There will be Sunshine", testQueue.dequeue());
printAssertEquals("Energy", testQueue.dequeue());
// printAssertEquals(0.0,testQueue.calcDuration());
printAssertEquals(true, testQueue.isEmpty());
try {
testQueue.dequeue();
std::cout << "FAIL: should have thrown exception from dequeue"<< std::endl;
}
catch(std::out_of_range& e){
printAssertEquals("Can't dequeue from an empty queue", e.what());
}
std::cout << "--done--" <<std::endl;
}
void AllSongsInPlaylistTest() {
std::cout << "-------AllSongsInPlaylistTest---------" << std::endl;
std::string weekendVibe;
PlaylistLinkedQueue playList1 = PlaylistLinkedQueue();
playList1.enqueue("Fruit", "Abra", 5.41);
playList1.enqueue("Fruit2", "Abra2", 5.41);
playList1.enqueue("Fruit3", "Abra3", 5.41);
if (!playList1.isEmpty()) {
playList1.allSongsInPlaylist(weekendVibe);
} else {
std::cout << "Playlist is empty, please add songs" << std::endl;
}
}
void RemoveSongsTest(){
std::cout << "-------RemoveSongsTest---------" << std::endl;
std::string weekendVibe;
PlaylistLinkedQueue playList1 = PlaylistLinkedQueue();
playList1.enqueue("Fruit", "Abra", 5.41);
playList1.enqueue("Fruit2", "Abra2", 5.41);
playList1.enqueue("Fruit3", "Abra3", 5.41);
if (!playList1.isEmpty()) {
playList1.allSongsInPlaylist(weekendVibe);
std::cout << "----------------" << std::endl;
playList1.removeSong("Fruit2","Abra2",5.41);
std::cout << "----------------" << std::endl;
playList1.allSongsInPlaylist(weekendVibe);
} else {
std::cout << "Playlist is empty, please add songs" << std::endl;
}
}
void PlayNextSongsTest(){
std::cout << "-------PlayNextSongsTest---------" << std::endl;
std::string weekendVibe;
PlaylistLinkedQueue playList1 = PlaylistLinkedQueue();
playList1.enqueue("Fruit", "Abra", 5.41);
playList1.enqueue("Fruit2", "Abra2", 5.41);
playList1.enqueue("Fruit3", "Abra3", 5.41);
if (!playList1.isEmpty()) {
playList1.playNextSong(weekendVibe);
playList1.playNextSong(weekendVibe);
// playList1.playNextSong(weekendVibe);
}
else {
std::cout << "Playlist is empty, please add songs" << std::endl;
}
}
void WriteToFileTest(){
PlaylistLinkedQueue testFile = PlaylistLinkedQueue();
testFile.WriteToFile("SongA","authorA","2.33");
testFile.WriteToFile("SongB","authorB","3.33");
testFile.WriteToFile("SongC","authorC","3.12");
//test throw error (if there's repeat songs)
//testFile.WriteToFile("Skeletun","Tekno","3.12");
}
int main() {
EnqueueAndCalcDurationTest( );
RemoveSongsTest();
AllSongsInPlaylistTest();
// WriteToFileTest();
PlayNextSongsTest();
}