diff --git a/include/orderqueue.hpp b/include/orderqueue.hpp index bbe94c0..20cf7a0 100644 --- a/include/orderqueue.hpp +++ b/include/orderqueue.hpp @@ -26,11 +26,10 @@ class OrderQueue : public boost::intrusive::set_base_hook(const OrderQueue &a, const OrderQueue &b) { return a.price_ > b.price_; } diff --git a/include/pricelevel.hpp b/include/pricelevel.hpp index 14f8c07..a2cf469 100644 --- a/include/pricelevel.hpp +++ b/include/pricelevel.hpp @@ -55,7 +55,7 @@ class PriceLevel { template Decimal processLimitOrder(const TradeNotification& tn, const PostOrderFill& pf, OrderID takerOrderID, Decimal price, Decimal qty, Flag flag); - PriceTree& price_tree() { return price_tree_; }; + const PriceTree& price_tree() const { return price_tree_; }; }; } // namespace orderbook diff --git a/src/orderqueue.cpp b/src/orderqueue.cpp index cb1c824..456d4bf 100644 --- a/src/orderqueue.cpp +++ b/src/orderqueue.cpp @@ -10,10 +10,6 @@ namespace orderbook { -Order* OrderQueue::head() { return &orders_.front(); } - -Order* OrderQueue::tail() { return &orders_.back(); } - Decimal OrderQueue::price() const { return price_; } Decimal OrderQueue::totalQty() const { return total_qty_; } diff --git a/test/orderqueue_test.cpp b/test/orderqueue_test.cpp index 62a7803..7e00b1b 100644 --- a/test/orderqueue_test.cpp +++ b/test/orderqueue_test.cpp @@ -4,9 +4,7 @@ #include "util.cpp" -namespace orderbook { - -namespace test { +namespace orderbook::test { class OrderQueueTest : public ::testing::Test { protected: @@ -25,8 +23,8 @@ TEST_F(OrderQueueTest, TestOrderQueue) { oq->append(&o1); oq->append(&o2); - auto* head = oq->head(); - auto* tail = oq->tail(); + auto* head = &oq->order_list().front(); + auto* tail = &oq->order_list().back(); ASSERT_NE(head, nullptr); ASSERT_NE(tail, nullptr); @@ -36,8 +34,8 @@ TEST_F(OrderQueueTest, TestOrderQueue) { oq->remove(&o1); - ASSERT_EQ(oq->head(), &o2); - ASSERT_EQ(oq->head(), oq->tail()); + ASSERT_EQ(&oq->order_list().front(), &o2); + ASSERT_EQ(oq->order_list().front(), oq->order_list().back()); ASSERT_EQ(oq->len(), 1); ASSERT_EQ(oq->totalQty(), Decimal(100, 0)); @@ -46,6 +44,5 @@ TEST_F(OrderQueueTest, TestOrderQueue) { oq->remove(&o2); } -} // namespace test -} // namespace orderbook +} // namespace orderbook::test diff --git a/test/pricelevel_test.cpp b/test/pricelevel_test.cpp index 911160f..a60622b 100644 --- a/test/pricelevel_test.cpp +++ b/test/pricelevel_test.cpp @@ -43,10 +43,10 @@ TEST_F(PriceLevelTest, TestPriceLevel) { ASSERT_EQ(bidLevel.depth(), 2); ASSERT_EQ(bidLevel.len(), 2); - ASSERT_EQ(tree.begin()->head(), o2.get()) << "Invalid price levels: head of the first element does not match o1"; - ASSERT_EQ(tree.begin()->tail(), o2.get()) << "Invalid price levels: tail of the first element does not match o1"; - ASSERT_EQ(tree.rbegin()->head(), o1.get()) << "Invalid price levels: head of the last element does not match o2"; - ASSERT_EQ(tree.rbegin()->tail(), o1.get()) << "Invalid price levels: tail of the last element does not match o2"; + ASSERT_EQ(&tree.begin()->order_list().front(), o2.get()) << "Invalid price levels: head of the first element does not match o1"; + ASSERT_EQ(&tree.begin()->order_list().back(), o2.get()) << "Invalid price levels: tail of the first element does not match o1"; + ASSERT_EQ(&tree.rbegin()->order_list().front(), o1.get()) << "Invalid price levels: head of the last element does not match o2"; + ASSERT_EQ(&tree.rbegin()->order_list().back(), o1.get()) << "Invalid price levels: tail of the last element does not match o2"; bidLevel.remove(o1.get());