Formatting code
This commit is contained in:
parent
6dc64ce76b
commit
13a8f07e32
37 changed files with 2242 additions and 2281 deletions
|
|
@ -7,82 +7,82 @@
|
|||
using namespace tp;
|
||||
|
||||
TEST_DEF_STATIC(SimpleReference) {
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
|
||||
list.pushBack(TestClass(5));
|
||||
list.pushFront(TestClass(0));
|
||||
list.pushBack(TestClass(5));
|
||||
list.pushFront(TestClass(0));
|
||||
|
||||
ualni i = -1;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
ualni i = -1;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
|
||||
TEST(i == 5);
|
||||
TEST(i == 5);
|
||||
|
||||
list.removeAll();
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
list.removeAll();
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(SimplePointer) {
|
||||
tp::List<TestClass*, TestAllocator> list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) };
|
||||
tp::List<TestClass*, TestAllocator> list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) };
|
||||
|
||||
list.pushBack(new TestClass(5));
|
||||
list.pushFront(new TestClass(0));
|
||||
list.pushBack(new TestClass(5));
|
||||
list.pushFront(new TestClass(0));
|
||||
|
||||
ualni i = -1;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
ualni i = -1;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
|
||||
TEST(i == 5);
|
||||
TEST(i == 5);
|
||||
|
||||
list.removeAll();
|
||||
list.removeAll();
|
||||
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(Copy) {
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, TestAllocator> list2 = list;
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, TestAllocator> list2 = list;
|
||||
|
||||
TEST_EQUAL(list, list2);
|
||||
TEST_EQUAL(list, list2);
|
||||
|
||||
list.removeAll();
|
||||
list2.removeAll();
|
||||
list.removeAll();
|
||||
list2.removeAll();
|
||||
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
TEST(list2.getAllocator().getAllocationsCount() == 0);
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
TEST(list2.getAllocator().getAllocationsCount() == 0);
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(SaveLoad) {
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, TestAllocator> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
|
||||
TestFile file;
|
||||
TestFile file;
|
||||
|
||||
list.write(file);
|
||||
list.write(file);
|
||||
|
||||
list.removeAll();
|
||||
list.removeAll();
|
||||
|
||||
file.setAddress(0);
|
||||
file.setAddress(0);
|
||||
|
||||
list.read(file);
|
||||
list.read(file);
|
||||
|
||||
ualni i = 0;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
TEST(i == 4);
|
||||
ualni i = 0;
|
||||
for (auto iter : list) {
|
||||
i++;
|
||||
TEST_EQUAL(iter->getVal(), i);
|
||||
}
|
||||
TEST(i == 4);
|
||||
|
||||
list.removeAll();
|
||||
list.removeAll();
|
||||
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
TEST(list.getAllocator().getAllocationsCount() == 0);
|
||||
}
|
||||
|
||||
TEST_DEF(List) {
|
||||
testSimplePointer();
|
||||
testSimpleReference();
|
||||
testSaveLoad();
|
||||
testSimplePointer();
|
||||
testSimpleReference();
|
||||
testSaveLoad();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue