summaryrefslogtreecommitdiff
path: root/AK/Tests/TestQueue.cpp
blob: b5496c052a2c581f9b5d4ed488674ea95bc4b32d (plain)
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
#include "TestHelpers.h"
#include <AK/AKString.h>
#include <AK/Queue.h>

int main()
{
    EXPECT(Queue<int>().is_empty());
    EXPECT(Queue<int>().size() == 0);

    Queue<int> ints;
    ints.enqueue(1);
    ints.enqueue(2);
    ints.enqueue(3);
    EXPECT(ints.size() == 3);
    EXPECT(ints.dequeue() == 1);
    EXPECT(ints.size() == 2);
    EXPECT(ints.dequeue() == 2);
    EXPECT(ints.size() == 1);
    EXPECT(ints.dequeue() == 3);
    EXPECT(ints.size() == 0);

    Queue<String> strings;
    strings.enqueue("ABC");
    strings.enqueue("DEF");
    EXPECT(strings.size() == 2);
    EXPECT(strings.dequeue() == "ABC");
    EXPECT(strings.dequeue() == "DEF");
    EXPECT(strings.is_empty());

    return 0;
}