From 20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec Mon Sep 17 00:00:00 2001 From: aqua Date: Fri, 8 Mar 2024 17:24:49 +0200 Subject: Bazel build --- src/sched/test_taskqueue.cc | 122 -------------------------------------------- 1 file changed, 122 deletions(-) delete mode 100644 src/sched/test_taskqueue.cc (limited to 'src/sched/test_taskqueue.cc') diff --git a/src/sched/test_taskqueue.cc b/src/sched/test_taskqueue.cc deleted file mode 100644 index 217c44d..0000000 --- a/src/sched/test_taskqueue.cc +++ /dev/null @@ -1,122 +0,0 @@ -#include - -#include "../sched.hpp" - -struct DebugQueue : public Queue { -public: - void - expect_ordered() const - { - int id = 1; - for (auto *it = head; it != nullptr; it = it->next) { - // std::cout << it->node->name << std::endl; - EXPECT_EQ(it->node->id, id++); - } - } -}; - -TEST(taskqueue, insert) -{ - DebugQueue queue; - auto *p1 = new Task{"P1", 1, 1, 10}; - queue.insert(p1); - queue.insert(new Task{"P2", 2, 1, 10}); - queue.insert(new Task{"P3", 3, 1, 10}); - auto *p4 = new Task{"P4", 4, 1, 10}; - queue.insert(p4); - queue.expect_ordered(); - - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p4); -} - -TEST(taskqueue, removeHead) -{ - DebugQueue queue; - auto *p0 = new Task{"P0", 0, 1, 10}; - queue.insert(p0); - auto *p1 = new Task{"P1", 1, 1, 10}; - queue.insert(p1); - queue.insert(new Task{"P2", 2, 1, 10}); - queue.insert(new Task{"P3", 3, 1, 10}); - auto *p4 = new Task{"P4", 4, 1, 10}; - queue.insert(p4); - queue.remove(p0); - delete p0; - - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p4); - queue.expect_ordered(); -} - -TEST(taskqueue, removeTail) -{ - DebugQueue queue; - auto *p1 = new Task{"P1", 1, 1, 10}; - queue.insert(p1); - queue.insert(new Task{"P2", 2, 1, 10}); - queue.insert(new Task{"P3", 3, 1, 10}); - auto *p4 = new Task{"P4", 4, 1, 10}; - queue.insert(p4); - auto *p5 = new Task{"P5", 5, 1, 10}; - queue.insert(p5); - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p5); - - queue.remove(p5); - delete p5; - - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p4); - queue.expect_ordered(); -} - -TEST(taskqueue, removeLast) -{ - DebugQueue queue; - - auto *p0 = new Task{"P0", 0, 1, 10}; - queue.insert(p0); - EXPECT_EQ(queue.head->node, p0); - EXPECT_EQ(queue.tail->node, p0); - - queue.remove(p0); - delete p0; - - EXPECT_EQ(queue.head, nullptr); - EXPECT_EQ(queue.tail, nullptr); -} - -TEST(taskqueue, removeNullptr) -{ - DebugQueue queue; - queue.insert(new Task{"P1", 1, 1, 10}); - queue.insert(new Task{"P2", 2, 1, 10}); - queue.insert(new Task{"P3", 3, 1, 10}); - queue.insert(new Task{"P4", 4, 1, 10}); - queue.remove(nullptr); - queue.expect_ordered(); -} - -TEST(taskqueue, remove) -{ - DebugQueue queue; - auto *p1 = new Task{"P1", 1, 1, 10}; - queue.insert(p1); - queue.insert(new Task{"P2", 2, 1, 10}); - auto *p0 = new Task{"P0", 0, 1, 10}; - queue.insert(p0); - queue.insert(new Task{"P3", 3, 1, 10}); - auto *p4 = new Task{"P4", 4, 1, 10}; - queue.insert(p4); - - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p4); - - queue.remove(p0); - delete p0; - - EXPECT_EQ(queue.head->node, p1); - EXPECT_EQ(queue.tail->node, p4); - queue.expect_ordered(); -} -- cgit v1.2.1