-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderlist_test.cpp
36 lines (33 loc) · 974 Bytes
/
orderlist_test.cpp
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
#define BOOST_TEST_MODULE orderlist
#include <boost/test/included/unit_test.hpp>
#include "orderbook.h"
#include "test.h"
BOOST_AUTO_TEST_CASE( orderlist ) {
OrderList list(100);
BOOST_TEST(list.front()==nullptr);
auto o = new TestOrder(1,100,10,BUY);
list.pushback(o);
auto o2 = new TestOrder(2,100,10,BUY);
list.pushback(o2);
BOOST_TEST(list.front()==o);
list.remove(o);
BOOST_TEST(list.front()==o2);
list.remove(o2);
BOOST_TEST(list.front()==nullptr);
}
BOOST_AUTO_TEST_CASE( orderlist_iterator ) {
OrderList list(100);
BOOST_TEST(list.begin()==list.end());
auto o = new TestOrder(1,100,10,BUY);
list.pushback(o);
BOOST_TEST(list.begin()!=list.end());
BOOST_TEST(*(list.begin())==o);
auto o2 = new TestOrder(2,100,10,BUY);
list.pushback(o2);
BOOST_TEST(*(list.begin())==o);
auto itr = list.begin();
++itr;
BOOST_TEST(*(itr)==o2);
++itr;
BOOST_TEST(itr==list.end());
}