-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.cpp
More file actions
39 lines (31 loc) · 842 Bytes
/
Copy pathtests.cpp
File metadata and controls
39 lines (31 loc) · 842 Bytes
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
#include "TSQueue.h"
#include <iostream>
#include <cassert>
#include <iostream>
#include <memory>
void run_unit_tests() {
std::cout << "Running Unit Tests..." << std::endl;
// Test 1: Move Semantics with unique_ptr
{
TSQueue<std::unique_ptr<int>> moveQ;
auto p = std::make_unique<int>(100);
moveQ.insert(std::move(p));
assert(p == nullptr); // Ownership should be transferred!
std::unique_ptr<int> result;
moveQ.pop(result);
assert(*result == 100);
std::cout << "[PASS] Move Semantics Test" << std::endl;
}
// Test 2: Basic FIFO Logic
{
TSQueue<int> q;
q.insert(10);
q.insert(20);
int v1, v2;
q.pop(v1);
q.pop(v2);
assert(v1 == 10 && v2 == 20);
std::cout << "[PASS] FIFO Logic Test" << std::endl;
}
std::cout << "All Unit Tests Passed!" << std::endl;
}