Tue, 09 Jan 2024 21:25:08 +0100
migrate cxEmptyList tests - relates to #342
390 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
398
8d506ed6c1c0
adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
29 | #include "cx/linked_list.h" |
606 | 30 | #include "cx/array_list.h" |
509
0d3c6075f82c
#129 - remove test code duplication
Mike Becker <universe@uap-core.de>
parents:
507
diff
changeset
|
31 | #include "cx/utils.h" |
602
3b071ea0e9cf
use ucx compare function in list tests
Mike Becker <universe@uap-core.de>
parents:
552
diff
changeset
|
32 | #include "cx/compare.h" |
422
afd87df80b13
add utility to verify allocations
Mike Becker <universe@uap-core.de>
parents:
413
diff
changeset
|
33 | #include "util_allocator.h" |
398
8d506ed6c1c0
adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
34 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
35 | #include <gtest/gtest.h> |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
36 | #include <array> |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
37 | #include <vector> |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
38 | #include <unordered_set> |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
39 | #include <algorithm> |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
40 | |
498
435c9965b2dd
reorder the list test functions
Mike Becker <universe@uap-core.de>
parents:
497
diff
changeset
|
41 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
42 | class HighLevelTest : public ::testing::Test { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
43 | mutable std::unordered_set<CxList *> lists; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
44 | protected: |
518
74d0372f5c6f
improve testing allocator + add tests for it
Mike Becker <universe@uap-core.de>
parents:
517
diff
changeset
|
45 | CxTestingAllocator testingAllocator; |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
46 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
47 | void TearDown() override { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
48 | for (auto &&l: lists) cxListDestroy(l); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
49 | CX_TEST_ASSERT(testingAllocator.verify()); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
50 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
51 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
52 | static constexpr size_t testdata_len = 250; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
53 | int_test_data<testdata_len> testdata; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
54 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
55 | auto autofree(CxList *list) const -> CxList * { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
56 | if (list != NULL) lists.insert(list); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
57 | return list; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
58 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
59 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
60 | auto linkedListFromTestData() const -> CxList * { |
629
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
61 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
62 | cxListAddArray(list, testdata.data.data(), testdata_len); |
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
63 | return list; |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
64 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
65 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
66 | auto pointerLinkedListFromTestData() const -> CxList * { |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
67 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
68 | // note: cannot use cxListAddArray() because we don't have a list of pointers |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
69 | cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
70 | return list; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
71 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
72 | |
606 | 73 | auto arrayListFromTestData() const -> CxList * { |
74 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), testdata_len)); | |
629
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
75 | cxListAddArray(list, testdata.data.data(), testdata_len); |
606 | 76 | return list; |
77 | } | |
78 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
79 | auto pointerArrayListFromTestData() const -> CxList * { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
80 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 256)); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
81 | // note: cannot use cxListAddArray() because we don't have a list of pointers |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
82 | cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
83 | return list; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
84 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
85 | |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
86 | void verifyAdd( |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
87 | CxList *list, |
606 | 88 | bool as_pointer |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
89 | ) { |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
90 | auto len = testdata_len; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
91 | cx_for_n (i, len) EXPECT_EQ(cxListAdd(list, &testdata.data[i]), 0); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
92 | CX_TEST_ASSERT(cxListSize(list) == len); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
93 | cx_for_n (i, len) EXPECT_EQ(*(int *) cxListAt(list, i), testdata.data[i]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
94 | cx_for_n (i, len) ++testdata.data[i]; |
606 | 95 | if (as_pointer) { |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
96 | cx_for_n (i, len) EXPECT_EQ(*(int *) cxListAt(list, i), testdata.data[i]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
97 | } else { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
98 | cx_for_n (i, len) EXPECT_EQ(*(int *) cxListAt(list, i), testdata.data[i] - 1); |
509
0d3c6075f82c
#129 - remove test code duplication
Mike Becker <universe@uap-core.de>
parents:
507
diff
changeset
|
99 | } |
0d3c6075f82c
#129 - remove test code duplication
Mike Becker <universe@uap-core.de>
parents:
507
diff
changeset
|
100 | } |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
101 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
102 | static void verifyInsert(CxList *list) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
103 | int a = 5, b = 47, c = 13, d = 42; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
104 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
105 | EXPECT_NE(cxListInsert(list, 1, &a), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
106 | EXPECT_EQ(cxListSize(list), 0); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
107 | EXPECT_EQ(cxListInsert(list, 0, &a), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
108 | EXPECT_EQ(cxListSize(list), 1); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
109 | EXPECT_EQ(cxListInsert(list, 0, &b), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
110 | EXPECT_EQ(cxListSize(list), 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
111 | EXPECT_EQ(cxListInsert(list, 1, &c), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
112 | EXPECT_EQ(cxListSize(list), 3); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
113 | EXPECT_EQ(cxListInsert(list, 3, &d), 0); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
114 | |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
115 | CX_TEST_ASSERT(cxListSize(list) == 4); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
116 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
117 | EXPECT_EQ(*(int *) cxListAt(list, 0), 47); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
118 | EXPECT_EQ(*(int *) cxListAt(list, 1), 13); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
119 | EXPECT_EQ(*(int *) cxListAt(list, 2), 5); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
120 | EXPECT_EQ(*(int *) cxListAt(list, 3), 42); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
121 | } |
498
435c9965b2dd
reorder the list test functions
Mike Becker <universe@uap-core.de>
parents:
497
diff
changeset
|
122 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
123 | static void verifyInsertArray( |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
124 | CxList *list, |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
125 | bool pointers = false |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
126 | ) { |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
127 | int a[5] = {5, 47, 11, 13, 42}; |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
128 | int b[5] = {9, 18, 72, 50, 7}; |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
129 | int *aptr[5]; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
130 | int *bptr[5]; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
131 | cx_for_n(i, 5) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
132 | aptr[i] = &a[i]; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
133 | bptr[i] = &b[i]; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
134 | } |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
135 | |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
136 | size_t inserted; |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
137 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
138 | if (pointers) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
139 | inserted = cxListInsertArray(list, 0, aptr, 5); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
140 | } else { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
141 | inserted = cxListInsertArray(list, 0, a, 5); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
142 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
143 | CX_TEST_ASSERT(inserted == 5); |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
144 | EXPECT_EQ(*(int *) cxListAt(list, 0), 5); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
145 | EXPECT_EQ(*(int *) cxListAt(list, 1), 47); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
146 | EXPECT_EQ(*(int *) cxListAt(list, 2), 11); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
147 | EXPECT_EQ(*(int *) cxListAt(list, 3), 13); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
148 | EXPECT_EQ(*(int *) cxListAt(list, 4), 42); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
149 | if (pointers) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
150 | inserted = cxListInsertArray(list, 3, bptr, 5); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
151 | } else { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
152 | inserted = cxListInsertArray(list, 3, b, 5); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
153 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
154 | CX_TEST_ASSERT(inserted == 5); |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
155 | EXPECT_EQ(*(int *) cxListAt(list, 0), 5); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
156 | EXPECT_EQ(*(int *) cxListAt(list, 1), 47); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
157 | EXPECT_EQ(*(int *) cxListAt(list, 2), 11); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
158 | EXPECT_EQ(*(int *) cxListAt(list, 3), 9); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
159 | EXPECT_EQ(*(int *) cxListAt(list, 4), 18); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
160 | EXPECT_EQ(*(int *) cxListAt(list, 5), 72); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
161 | EXPECT_EQ(*(int *) cxListAt(list, 6), 50); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
162 | EXPECT_EQ(*(int *) cxListAt(list, 7), 7); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
163 | EXPECT_EQ(*(int *) cxListAt(list, 8), 13); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
164 | EXPECT_EQ(*(int *) cxListAt(list, 9), 42); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
165 | } |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
166 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
167 | void verifyRemove(CxList *list) const { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
168 | EXPECT_EQ(cxListRemove(list, 2), 0); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
169 | EXPECT_EQ(cxListRemove(list, 4), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
170 | EXPECT_EQ(cxListSize(list), testdata_len - 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
171 | EXPECT_EQ(*(int *) cxListAt(list, 0), testdata.data[0]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
172 | EXPECT_EQ(*(int *) cxListAt(list, 1), testdata.data[1]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
173 | EXPECT_EQ(*(int *) cxListAt(list, 2), testdata.data[3]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
174 | EXPECT_EQ(*(int *) cxListAt(list, 3), testdata.data[4]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
175 | EXPECT_EQ(*(int *) cxListAt(list, 4), testdata.data[6]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
176 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
177 | EXPECT_EQ(cxListRemove(list, 0), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
178 | EXPECT_EQ(cxListSize(list), testdata_len - 3); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
179 | EXPECT_EQ(*(int *) cxListAt(list, 0), testdata.data[1]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
180 | EXPECT_EQ(*(int *) cxListAt(list, 1), testdata.data[3]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
181 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
182 | EXPECT_NE(cxListRemove(list, testdata_len), 0); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
183 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
184 | |
764
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
185 | void verifyFindRemove(CxList *list) const { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
186 | size_t exp = rand() % testdata_len; // NOLINT(cert-msc50-cpp) |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
187 | int val = testdata.data[exp]; |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
188 | // randomly picked number could occur earlier in list - find first position |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
189 | cx_for_n (i, exp) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
190 | if (testdata.data[i] == val) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
191 | exp = i; |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
192 | break; |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
193 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
194 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
195 | EXPECT_EQ(cxListSize(list), testdata_len); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
196 | EXPECT_EQ(cxListFind(list, &val), exp); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
197 | EXPECT_EQ(cxListFindRemove(list, &val), exp); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
198 | EXPECT_EQ(cxListSize(list), testdata_len - 1); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
199 | EXPECT_NE(cxListFind(list, &val), exp); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
200 | |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
201 | int notinlist = -1; |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
202 | EXPECT_LT(cxListFindRemove(list, ¬inlist), 0); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
203 | EXPECT_EQ(cxListSize(list), testdata_len - 1); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
204 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
205 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
206 | static void verifyClear(CxList *list) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
207 | cxListClear(list); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
208 | EXPECT_EQ(0, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
209 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
210 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
211 | static unsigned destr_test_ctr; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
212 | static int destr_last_value; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
213 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
214 | static void simple_destr_test_fun(void *data) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
215 | auto ptr = (int *) data; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
216 | destr_last_value = *ptr; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
217 | *ptr = destr_last_value + 1; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
218 | destr_test_ctr++; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
219 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
220 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
221 | static void advanced_destr_test_fun( |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
222 | [[maybe_unused]] void *u, |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
223 | void *data |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
224 | ) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
225 | simple_destr_test_fun(data); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
226 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
227 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
228 | void verifyAnyDestructor(CxList *list) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
229 | int off = cxListIsStoringPointers(list) ? 1 : 0; |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
230 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
231 | cxListRemove(list, 15); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
232 | EXPECT_EQ(1, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
233 | EXPECT_EQ(testdata.data[15], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
234 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
235 | cxListRemove(list, 47); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
236 | EXPECT_EQ(2, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
237 | EXPECT_EQ(testdata.data[48], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
238 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
239 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
240 | auto iter = cxListMutIteratorAt(list, 7); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
241 | cxIteratorNext(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
242 | EXPECT_EQ(2, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
243 | EXPECT_EQ(testdata.data[48], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
244 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
245 | cxIteratorFlagRemoval(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
246 | cxIteratorNext(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
247 | EXPECT_EQ(3, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
248 | EXPECT_EQ(testdata.data[8], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
249 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
250 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
251 | iter = cxListMutBackwardsIteratorAt(list, 5); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
252 | cxIteratorNext(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
253 | EXPECT_EQ(3, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
254 | EXPECT_EQ(testdata.data[8], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
255 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
256 | cxIteratorFlagRemoval(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
257 | cxIteratorNext(iter); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
258 | EXPECT_EQ(4, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
259 | EXPECT_EQ(testdata.data[4], destr_last_value + off); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
260 | EXPECT_EQ(testdata_len - destr_test_ctr, cxListSize(list)); |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
261 | |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
262 | cxListClear(list); |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
263 | EXPECT_EQ(testdata_len, destr_test_ctr); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
264 | EXPECT_EQ(testdata.data[testdata_len - 1], destr_last_value + off); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
265 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
266 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
267 | void verifySimpleDestructor(CxList *list) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
268 | destr_test_ctr = 0; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
269 | list->simple_destructor = simple_destr_test_fun; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
270 | verifyAnyDestructor(list); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
271 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
272 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
273 | void verifyAdvancedDestructor(CxList *list) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
274 | destr_test_ctr = 0; |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
275 | list->advanced_destructor = advanced_destr_test_fun; |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
276 | verifyAnyDestructor(list); |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
277 | } |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
278 | |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
279 | static void verifySwap(CxList *list) { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
280 | CX_TEST_ASSERT(cxListSize(list) == 0); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
281 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
282 | int original[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
283 | int swapped[16] = {8, 4, 14, 3, 1, 5, 9, 12, 0, 6, 11, 10, 7, 15, 2, 13}; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
284 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
285 | // we have to add the items one by one, because it could be a pointer list |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
286 | cx_for_n(i, 16) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
287 | cxListAdd(list, &original[i]); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
288 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
289 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
290 | int result; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
291 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
292 | // execute the test two times with different item sizes |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
293 | result = cxListSwap(list, 1, 4); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
294 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
295 | result = cxListSwap(list, 2, 14); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
296 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
297 | result = cxListSwap(list, 9, 6); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
298 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
299 | result = cxListSwap(list, 3, 3); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
300 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
301 | result = cxListSwap(list, 10, 11); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
302 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
303 | result = cxListSwap(list, 8, 0); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
304 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
305 | result = cxListSwap(list, 7, 12); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
306 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
307 | result = cxListSwap(list, 13, 15); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
308 | EXPECT_EQ(0, result); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
309 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
310 | result = cxListSwap(list, 5, 16); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
311 | CX_TEST_ASSERT(0 != result); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
312 | result = cxListSwap(list, 16, 6); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
313 | CX_TEST_ASSERT(0 != result); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
314 | result = cxListSwap(list, 16, 17); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
315 | CX_TEST_ASSERT(0 != result); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
316 | |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
317 | auto iter = cxListIterator(list); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
318 | cx_foreach(int*, e, iter) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
319 | EXPECT_EQ(*e, swapped[iter.index]); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
320 | } |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
321 | iter = cxListBackwardsIterator(list); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
322 | cx_foreach(int*, e, iter) { |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
323 | EXPECT_EQ(*e, swapped[iter.index]); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
324 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
325 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
326 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
327 | void verifyAt(CxList *list) const { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
328 | auto len = testdata_len; |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
329 | EXPECT_EQ(cxListSize(list), len); |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
330 | cx_for_n (i, len) { |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
331 | EXPECT_EQ(*(int *) cxListAt(list, i), testdata.data[i]); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
332 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
333 | EXPECT_EQ(cxListAt(list, cxListSize(list)), NULL); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
334 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
335 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
336 | void verifyFind(CxList *list) const { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
337 | cx_for_n (attempt, 25) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
338 | size_t exp = rand() % testdata_len; // NOLINT(cert-msc50-cpp) |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
339 | int val = testdata.data[exp]; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
340 | // randomly picked number could occur earlier in list - find first position |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
341 | cx_for_n (i, exp) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
342 | if (testdata.data[i] == val) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
343 | exp = i; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
344 | break; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
345 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
346 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
347 | EXPECT_EQ(cxListFind(list, &val), exp); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
348 | } |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
349 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
350 | int notinlist = -1; |
699
35b2b99ee523
make list find return a negative value when elem not found
Mike Becker <universe@uap-core.de>
parents:
680
diff
changeset
|
351 | EXPECT_LT(cxListFind(list, ¬inlist), 0); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
352 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
353 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
354 | void verifySort(CxList *list) const { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
355 | std::array<int, testdata_len> expected{}; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
356 | std::partial_sort_copy(testdata.data.begin(), testdata.data.end(), expected.begin(), expected.end()); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
357 | cxListSort(list); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
358 | cx_for_n (i, testdata_len) CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
359 | } |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
360 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
361 | void verifyIterator(CxList *list) const { |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
362 | auto iter = cxListIterator(list); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
363 | size_t i = 0; |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
364 | cx_foreach(int*, x, iter) { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
365 | CX_TEST_ASSERT(i == iter.index); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
366 | EXPECT_EQ(*x, testdata.data[iter.index]); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
367 | i++; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
368 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
369 | CX_TEST_ASSERT(i == cxListSize(list)); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
370 | iter = cxListBackwardsIterator(list); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
371 | cx_foreach(int*, x, iter) { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
372 | CX_TEST_ASSERT(i - 1 == iter.index); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
373 | EXPECT_EQ(*x, testdata.data[iter.index]); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
374 | i--; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
375 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
376 | CX_TEST_ASSERT(i == 0); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
377 | auto len = testdata_len; |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
378 | i = len / 2; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
379 | auto mut_iter = cxListMutIteratorAt(list, i); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
380 | size_t j = 0; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
381 | cx_foreach(int*, x, mut_iter) { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
382 | CX_TEST_ASSERT(mut_iter.index == len / 2 + j / 2); |
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
383 | CX_TEST_ASSERT(*x == testdata.data[i]); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
384 | if (i % 2 == 1) cxIteratorFlagRemoval(mut_iter); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
385 | i++; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
386 | j++; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
387 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
388 | CX_TEST_ASSERT(i == len); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
389 | i = len / 2; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
390 | j = 0; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
391 | mut_iter = cxListMutBackwardsIteratorAt(list, i - 1); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
392 | cx_foreach(int*, x, mut_iter) { |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
393 | CX_TEST_ASSERT(mut_iter.index == len / 2 - 1 - j); |
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
394 | CX_TEST_ASSERT(*x == testdata.data[i - 1]); |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
395 | if (i % 2 == 0) cxIteratorFlagRemoval(mut_iter); |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
396 | i--; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
397 | j++; |
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
398 | } |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
399 | CX_TEST_ASSERT(i == 0); |
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
400 | CX_TEST_ASSERT(cxListSize(list) == len / 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
401 | cx_for_n(j, len / 2) ASSERT_EQ(*(int *) cxListAt(list, j), testdata.data[j * 2]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
402 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
403 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
404 | static void verifyInsertViaIterator(CxList *list) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
405 | int newdata[] = {10, 20, 30, 40, 50}; |
498
435c9965b2dd
reorder the list test functions
Mike Becker <universe@uap-core.de>
parents:
497
diff
changeset
|
406 | |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
407 | auto iter = cxListMutIteratorAt(list, 2); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
408 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
409 | EXPECT_EQ(iter.index, 2); |
630
ac5e7f789048
separate iterators and mutating iterators
Mike Becker <universe@uap-core.de>
parents:
629
diff
changeset
|
410 | EXPECT_EQ(*(int *) cxIteratorCurrent(iter), 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
411 | cxListInsertAfter(&iter, &newdata[0]); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
412 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
413 | EXPECT_EQ(iter.index, 2); |
630
ac5e7f789048
separate iterators and mutating iterators
Mike Becker <universe@uap-core.de>
parents:
629
diff
changeset
|
414 | EXPECT_EQ(*(int *) cxIteratorCurrent(iter), 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
415 | cxListInsertBefore(&iter, &newdata[1]); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
416 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
417 | EXPECT_EQ(iter.index, 3); |
630
ac5e7f789048
separate iterators and mutating iterators
Mike Becker <universe@uap-core.de>
parents:
629
diff
changeset
|
418 | EXPECT_EQ(*(int *) cxIteratorCurrent(iter), 2); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
419 | |
655
7340c4255f1f
implement backwards iterator - fixes #238
Mike Becker <universe@uap-core.de>
parents:
654
diff
changeset
|
420 | iter = cxListMutIterator(list); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
421 | cxListInsertBefore(&iter, &newdata[2]); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
422 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
423 | EXPECT_EQ(iter.index, 1); |
630
ac5e7f789048
separate iterators and mutating iterators
Mike Becker <universe@uap-core.de>
parents:
629
diff
changeset
|
424 | EXPECT_EQ(*(int *) cxIteratorCurrent(iter), 0); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
425 | iter = cxListMutIteratorAt(list, cxListSize(list)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
426 | cxListInsertBefore(&iter, &newdata[3]); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
427 | CX_TEST_ASSERT(!cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
428 | EXPECT_EQ(iter.index, 9); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
429 | iter = cxListMutIteratorAt(list, cxListSize(list)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
430 | cxListInsertAfter(&iter, &newdata[4]); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
431 | CX_TEST_ASSERT(!cxIteratorValid(iter)); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
432 | EXPECT_EQ(iter.index, 10); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
433 | |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
434 | int expdata[] = {30, 0, 1, 20, 2, 10, 3, 4, 40, 50}; |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
435 | cx_for_n (j, 10) EXPECT_EQ(*(int *) cxListAt(list, j), expdata[j]); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
436 | } |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
437 | |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
438 | void verifyReverse(CxList *list) const { |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
439 | cxListReverse(list); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
440 | cx_for_n(i, testdata_len) { |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
441 | ASSERT_EQ(*(int *) cxListAt(list, i), testdata.data[testdata_len - 1 - i]); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
442 | } |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
443 | } |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
444 | |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
445 | static void verifyCompare( |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
446 | CxList *left, |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
447 | CxList *right |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
448 | ) { |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
449 | EXPECT_EQ(cxListCompare(left, right), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
450 | int x = 42; |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
451 | cxListAdd(left, &x); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
452 | ASSERT_GT(cxListSize(left), cxListSize(right)); |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
453 | EXPECT_GT(cxListCompare(left, right), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
454 | EXPECT_LT(cxListCompare(right, left), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
455 | cxListAdd(right, &x); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
456 | CX_TEST_ASSERT(cxListSize(left) == cxListSize(right)); |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
457 | EXPECT_EQ(cxListCompare(left, right), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
458 | int a = 5, b = 10; |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
459 | cxListInsert(left, 15, &a); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
460 | cxListInsert(right, 15, &b); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
461 | CX_TEST_ASSERT(cxListSize(left) == cxListSize(right)); |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
462 | EXPECT_LT(cxListCompare(left, right), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
463 | EXPECT_GT(cxListCompare(right, left), 0); |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
521
diff
changeset
|
464 | *(int *) cxListAt(left, 15) = 10; |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
465 | EXPECT_EQ(cxListCompare(left, right), 0); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
466 | } |
509
0d3c6075f82c
#129 - remove test code duplication
Mike Becker <universe@uap-core.de>
parents:
507
diff
changeset
|
467 | }; |
498
435c9965b2dd
reorder the list test functions
Mike Becker <universe@uap-core.de>
parents:
497
diff
changeset
|
468 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
469 | unsigned HighLevelTest::destr_test_ctr = 0; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
470 | int HighLevelTest::destr_last_value = 0; |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
471 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
472 | class LinkedList : public HighLevelTest { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
473 | }; |
469
0458bff0b1cd
add high level list sort and inlines method invocation functions
Mike Becker <universe@uap-core.de>
parents:
468
diff
changeset
|
474 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
475 | class PointerLinkedList : public HighLevelTest { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
476 | }; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
477 | |
606 | 478 | class ArrayList : public HighLevelTest { |
479 | }; | |
480 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
481 | class PointerArrayList : public HighLevelTest { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
482 | }; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
483 | |
662
d0d95740071b
add simple functions for creating lists
Mike Becker <universe@uap-core.de>
parents:
655
diff
changeset
|
484 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
485 | TEST_F(LinkedList, cxListAdd) { |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
486 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
487 | verifyAdd(list, false); |
509
0d3c6075f82c
#129 - remove test code duplication
Mike Becker <universe@uap-core.de>
parents:
507
diff
changeset
|
488 | } |
499
3dc9075df822
add cxListInsertAfter() and cxListInsertBefore()
Mike Becker <universe@uap-core.de>
parents:
498
diff
changeset
|
489 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
490 | TEST_F(PointerLinkedList, cxListAdd) { |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
491 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
492 | verifyAdd(list, true); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
493 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
494 | |
606 | 495 | TEST_F(ArrayList, cxListAdd) { |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
496 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); |
606 | 497 | verifyAdd(list, false); |
498 | } | |
499 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
500 | TEST_F(PointerArrayList, cxListAdd) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
501 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 8)); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
502 | verifyAdd(list, true); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
503 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
504 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
505 | TEST_F(LinkedList, cxListInsert) { |
602
3b071ea0e9cf
use ucx compare function in list tests
Mike Becker <universe@uap-core.de>
parents:
552
diff
changeset
|
506 | verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
499
3dc9075df822
add cxListInsertAfter() and cxListInsertBefore()
Mike Becker <universe@uap-core.de>
parents:
498
diff
changeset
|
507 | } |
3dc9075df822
add cxListInsertAfter() and cxListInsertBefore()
Mike Becker <universe@uap-core.de>
parents:
498
diff
changeset
|
508 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
509 | TEST_F(PointerLinkedList, cxListInsert) { |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
510 | verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
511 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
512 | |
606 | 513 | TEST_F(ArrayList, cxListInsert) { |
514 | verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 2))); | |
515 | } | |
516 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
517 | TEST_F(PointerArrayList, cxListInsert) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
518 | verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 2))); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
519 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
520 | |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
521 | TEST_F(LinkedList, cxListInsertArray) { |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
522 | verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
523 | } |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
524 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
525 | TEST_F(PointerLinkedList, cxListInsertArray) { |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
526 | verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)), true); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
527 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
528 | |
638
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
529 | TEST_F(ArrayList, cxListInsertArray) { |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
530 | verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4))); |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
531 | } |
eafb45eefc51
add cxListInsertArray() - fixes #224
Mike Becker <universe@uap-core.de>
parents:
630
diff
changeset
|
532 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
533 | TEST_F(PointerArrayList, cxListInsertArray) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
534 | verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)), true); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
535 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
536 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
537 | TEST_F(LinkedList, cxListRemove) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
538 | verifyRemove(linkedListFromTestData()); |
506
18782bbe3607
add setup and teardown functions to test_list.c
Mike Becker <universe@uap-core.de>
parents:
503
diff
changeset
|
539 | } |
18782bbe3607
add setup and teardown functions to test_list.c
Mike Becker <universe@uap-core.de>
parents:
503
diff
changeset
|
540 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
541 | TEST_F(PointerLinkedList, cxListRemove) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
542 | verifyRemove(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
543 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
544 | |
606 | 545 | TEST_F(ArrayList, cxListRemove) { |
546 | verifyRemove(arrayListFromTestData()); | |
547 | } | |
548 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
549 | TEST_F(PointerArrayList, cxListRemove) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
550 | verifyRemove(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
551 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
552 | |
764
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
553 | TEST_F(LinkedList, cxListFindRemove) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
554 | verifyFindRemove(linkedListFromTestData()); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
555 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
556 | |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
557 | TEST_F(PointerLinkedList, cxListFindRemove) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
558 | verifyFindRemove(pointerLinkedListFromTestData()); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
559 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
560 | |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
561 | TEST_F(ArrayList, cxListFindRemove) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
562 | verifyFindRemove(arrayListFromTestData()); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
563 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
564 | |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
565 | TEST_F(PointerArrayList, cxListFindRemove) { |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
566 | verifyFindRemove(pointerArrayListFromTestData()); |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
567 | } |
ccbdbd088455
add cxListFindRemove and cx_linked_list_find_node
Mike Becker <universe@uap-core.de>
parents:
763
diff
changeset
|
568 | |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
569 | TEST_F(LinkedList, cxListClear) { |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
570 | verifyClear(linkedListFromTestData()); |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
571 | } |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
572 | |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
573 | TEST_F(PointerLinkedList, cxListClear) { |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
574 | verifyClear(pointerLinkedListFromTestData()); |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
575 | } |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
576 | |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
577 | TEST_F(ArrayList, cxListClear) { |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
578 | verifyClear(arrayListFromTestData()); |
666
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
579 | } |
b5dd654deb3b
add unit test for cxListClear + fix destructor functions not always invoked with the correct pointer
Mike Becker <universe@uap-core.de>
parents:
662
diff
changeset
|
580 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
581 | TEST_F(PointerArrayList, cxListClear) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
582 | verifyClear(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
583 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
584 | |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
585 | TEST_F(LinkedList, cxListSwap) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
586 | verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
587 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
588 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
589 | TEST_F(PointerLinkedList, cxListSwap) { |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
590 | verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
591 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
592 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
593 | TEST_F(ArrayList, cxListSwap) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
594 | verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 16))); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
595 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
596 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
597 | TEST_F(PointerArrayList, cxListSwap) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
598 | verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 16))); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
599 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
600 | |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
601 | TEST_F(LinkedList, cxListSwapNoSBO) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
602 | CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
603 | verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
604 | CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
605 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
606 | |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
607 | TEST_F(PointerLinkedList, cxListSwapNoSBO) { |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
608 | CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
609 | verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
647
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
610 | CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
611 | } |
2e6e9d9f2159
implement swap function for list elements - fixes #218
Mike Becker <universe@uap-core.de>
parents:
641
diff
changeset
|
612 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
613 | TEST_F(LinkedList, cxListAt) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
614 | verifyAt(linkedListFromTestData()); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
615 | } |
449 | 616 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
617 | TEST_F(PointerLinkedList, cxListAt) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
618 | verifyAt(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
619 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
620 | |
606 | 621 | TEST_F(ArrayList, cxListAt) { |
622 | verifyAt(arrayListFromTestData()); | |
623 | } | |
624 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
625 | TEST_F(PointerArrayList, cxListAt) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
626 | verifyAt(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
627 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
628 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
629 | TEST_F(LinkedList, cxListFind) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
630 | verifyFind(linkedListFromTestData()); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
631 | } |
455 | 632 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
633 | TEST_F(PointerLinkedList, cxListFind) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
634 | verifyFind(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
635 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
636 | |
606 | 637 | TEST_F(ArrayList, cxListFind) { |
638 | verifyFind(arrayListFromTestData()); | |
639 | } | |
640 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
641 | TEST_F(PointerArrayList, cxListFind) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
642 | verifyFind(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
643 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
644 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
645 | TEST_F(LinkedList, cxListSort) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
646 | verifySort(linkedListFromTestData()); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
647 | } |
455 | 648 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
649 | TEST_F(PointerLinkedList, cxListSort) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
650 | verifySort(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
651 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
652 | |
606 | 653 | TEST_F(ArrayList, cxListSort) { |
654 | verifySort(arrayListFromTestData()); | |
655 | } | |
656 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
657 | TEST_F(PointerArrayList, cxListSort) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
658 | verifySort(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
659 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
660 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
661 | TEST_F(LinkedList, Iterator) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
662 | verifyIterator(linkedListFromTestData()); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
663 | } |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
664 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
665 | TEST_F(PointerLinkedList, Iterator) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
666 | verifyIterator(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
667 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
668 | |
606 | 669 | TEST_F(ArrayList, Iterator) { |
670 | verifyIterator(arrayListFromTestData()); | |
671 | } | |
672 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
673 | TEST_F(PointerArrayList, Iterator) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
674 | verifyIterator(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
675 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
676 | |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
677 | TEST_F(LinkedList, InsertViaIterator) { |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
678 | int fivenums[] = {0, 1, 2, 3, 4, 5}; |
629
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
679 | CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
680 | cxListAddArray(list, fivenums, 5); |
517
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
681 | verifyInsertViaIterator(list); |
b3baaf9b7e3c
migrate list tests to gtest
Mike Becker <universe@uap-core.de>
parents:
509
diff
changeset
|
682 | } |
466
28bc3e10ac28
add special linked list implementation for storing pointers
Mike Becker <universe@uap-core.de>
parents:
460
diff
changeset
|
683 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
684 | TEST_F(PointerLinkedList, InsertViaIterator) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
685 | int fivenums[] = {0, 1, 2, 3, 4, 5}; |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
686 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
687 | // note: cannot use cxListAddArray() because we don't have a list of pointers |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
688 | cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
689 | verifyInsertViaIterator(list); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
690 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
691 | |
606 | 692 | TEST_F(ArrayList, InsertViaIterator) { |
693 | int fivenums[] = {0, 1, 2, 3, 4, 5}; | |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
694 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)); |
629
6c81ee4f11ad
#224 add cxListAddArray()
Mike Becker <universe@uap-core.de>
parents:
623
diff
changeset
|
695 | cxListAddArray(list, fivenums, 5); |
606 | 696 | verifyInsertViaIterator(list); |
697 | } | |
698 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
699 | TEST_F(PointerArrayList, InsertViaIterator) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
700 | int fivenums[] = {0, 1, 2, 3, 4, 5}; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
701 | auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
702 | // note: cannot use cxListAddArray() because we don't have a list of pointers |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
703 | cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
704 | verifyInsertViaIterator(list); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
705 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
706 | |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
707 | TEST_F(LinkedList, cxListReverse) { |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
708 | verifyReverse(linkedListFromTestData()); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
709 | } |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
710 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
711 | TEST_F(PointerLinkedList, cxListReverse) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
712 | verifyReverse(pointerLinkedListFromTestData()); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
713 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
714 | |
606 | 715 | TEST_F(ArrayList, cxListReverse) { |
716 | verifyReverse(arrayListFromTestData()); | |
717 | } | |
718 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
719 | TEST_F(PointerArrayList, cxListReverse) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
720 | verifyReverse(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
721 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
722 | |
521
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
723 | TEST_F(LinkedList, cxListCompare) { |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
724 | auto left = linkedListFromTestData(); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
725 | auto right = linkedListFromTestData(); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
726 | verifyCompare(left, right); |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
727 | } |
e5dc54131d55
add test for cxListCompare
Mike Becker <universe@uap-core.de>
parents:
520
diff
changeset
|
728 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
729 | TEST_F(LinkedList, cxListCompareWithPtrList) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
730 | auto left = linkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
731 | auto right = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
732 | verifyCompare(left, right); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
733 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
734 | |
606 | 735 | TEST_F(LinkedList, cxListCompareWithArrayList) { |
736 | auto left = linkedListFromTestData(); | |
737 | auto right = arrayListFromTestData(); | |
738 | verifyCompare(left, right); | |
739 | } | |
740 | ||
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
741 | TEST_F(LinkedList, cxListCompareWithPtrArrayList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
742 | auto left = linkedListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
743 | auto right = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
744 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
745 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
746 | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
747 | TEST_F(PointerLinkedList, cxListCompare) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
748 | auto left = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
749 | auto right = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
750 | verifyCompare(left, right); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
751 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
752 | |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
753 | TEST_F(PointerLinkedList, cxListCompareWithNormalList) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
754 | auto left = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
755 | auto right = linkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
756 | verifyCompare(left, right); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
757 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
758 | |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
759 | TEST_F(PointerLinkedList, cxListCompareWithArrayList) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
760 | auto left = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
761 | auto right = arrayListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
762 | verifyCompare(left, right); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
763 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
764 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
765 | TEST_F(PointerLinkedList, cxListCompareWithPtrArrayList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
766 | auto left = pointerLinkedListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
767 | auto right = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
768 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
769 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
770 | |
606 | 771 | TEST_F(ArrayList, cxListCompare) { |
772 | auto left = arrayListFromTestData(); | |
773 | auto right = arrayListFromTestData(); | |
774 | verifyCompare(left, right); | |
775 | } | |
776 | ||
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
777 | TEST_F(ArrayList, cxListCompareWithPtrList) { |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
778 | auto left = arrayListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
779 | auto right = pointerLinkedListFromTestData(); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
780 | verifyCompare(left, right); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
781 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
782 | |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
783 | TEST_F(ArrayList, cxListCompareWithNormalList) { |
606 | 784 | auto left = arrayListFromTestData(); |
785 | auto right = linkedListFromTestData(); | |
786 | verifyCompare(left, right); | |
787 | } | |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
788 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
789 | TEST_F(ArrayList, cxListCompareWithPtrArrayList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
790 | auto left = arrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
791 | auto right = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
792 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
793 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
794 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
795 | TEST_F(PointerArrayList, cxListCompare) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
796 | auto left = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
797 | auto right = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
798 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
799 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
800 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
801 | TEST_F(PointerArrayList, cxListCompareWithPtrList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
802 | auto left = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
803 | auto right = pointerLinkedListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
804 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
805 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
806 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
807 | TEST_F(PointerArrayList, cxListCompareWithNormalList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
808 | auto left = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
809 | auto right = linkedListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
810 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
811 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
812 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
813 | TEST_F(PointerArrayList, cxListCompareWithNormalArrayList) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
814 | auto left = pointerArrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
815 | auto right = arrayListFromTestData(); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
816 | verifyCompare(left, right); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
817 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
818 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
819 | TEST_F(LinkedList, SimpleDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
820 | verifySimpleDestructor(linkedListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
821 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
822 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
823 | TEST_F(PointerLinkedList, SimpleDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
824 | verifySimpleDestructor(pointerLinkedListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
825 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
826 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
827 | TEST_F(ArrayList, SimpleDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
828 | verifySimpleDestructor(arrayListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
829 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
830 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
831 | TEST_F(PointerArrayList, SimpleDestructor) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
832 | verifySimpleDestructor(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
833 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
834 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
835 | TEST_F(LinkedList, AdvancedDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
836 | verifyAdvancedDestructor(linkedListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
837 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
838 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
839 | TEST_F(PointerLinkedList, AdvancedDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
840 | verifyAdvancedDestructor(pointerLinkedListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
841 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
842 | |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
843 | TEST_F(ArrayList, AdvancedDestructor) { |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
844 | verifyAdvancedDestructor(arrayListFromTestData()); |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
845 | } |
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
846 | |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
847 | TEST_F(PointerArrayList, AdvancedDestructor) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
848 | verifyAdvancedDestructor(pointerArrayListFromTestData()); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
849 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
850 | |
800
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
851 | TEST_F(PointerLinkedList, cxListStorePointers) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
852 | auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, 47)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
853 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
854 | cxListStorePointers(list); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
855 | EXPECT_EQ(list->item_size, sizeof(void *)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
856 | CX_TEST_ASSERT(list->cl != NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
857 | CX_TEST_ASSERT(list->climpl != NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
858 | CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
859 | cxListStoreObjects(list); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
860 | CX_TEST_ASSERT(list->cl != NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
861 | EXPECT_EQ(list->climpl, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
862 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
863 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
864 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
865 | TEST_F(LinkedList, cxLinkedListCreate) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
866 | CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
867 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
868 | EXPECT_EQ(list->item_size, sizeof(int)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
869 | EXPECT_EQ(list->simple_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
870 | EXPECT_EQ(list->advanced_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
871 | EXPECT_EQ(list->destructor_data, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
872 | EXPECT_EQ(cxListSize(list), 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
873 | EXPECT_EQ(list->allocator, &testingAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
874 | EXPECT_EQ(list->cmpfunc, cx_cmp_int); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
875 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
876 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
877 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
878 | TEST_F(LinkedList, cxLinkedListCreateSimple) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
879 | CxList *list = autofree(cxLinkedListCreateSimple(sizeof(int))); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
880 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
881 | EXPECT_EQ(list->item_size, sizeof(int)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
882 | EXPECT_EQ(list->cmpfunc, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
883 | EXPECT_EQ(list->allocator, cxDefaultAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
884 | EXPECT_EQ(list->simple_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
885 | EXPECT_EQ(list->advanced_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
886 | EXPECT_EQ(list->destructor_data, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
887 | EXPECT_EQ(cxListSize(list), 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
888 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
889 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
890 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
891 | TEST_F(PointerLinkedList, cxLinkedListCreateSimpleForPointers) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
892 | CxList *list = autofree(cxLinkedListCreateSimple(CX_STORE_POINTERS)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
893 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
894 | EXPECT_EQ(list->item_size, sizeof(void *)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
895 | EXPECT_EQ(list->cmpfunc, cx_cmp_ptr); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
896 | EXPECT_EQ(list->allocator, cxDefaultAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
897 | EXPECT_EQ(list->simple_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
898 | EXPECT_EQ(list->advanced_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
899 | EXPECT_EQ(list->destructor_data, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
900 | EXPECT_EQ(cxListSize(list), 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
901 | CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
902 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
903 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
904 | TEST_F(ArrayList, cxArrayListCreate) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
905 | CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
906 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
907 | EXPECT_EQ(list->item_size, sizeof(int)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
908 | EXPECT_EQ(list->simple_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
909 | EXPECT_EQ(list->advanced_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
910 | EXPECT_EQ(list->destructor_data, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
911 | EXPECT_EQ(cxListSize(list), 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
912 | EXPECT_EQ(list->allocator, &testingAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
913 | EXPECT_EQ(list->cmpfunc, cx_cmp_int); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
914 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
915 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
916 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
917 | TEST_F(ArrayList, cxArrayListCreateSimple) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
918 | CxList *list = autofree(cxArrayListCreateSimple(sizeof(int), 8)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
919 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
920 | EXPECT_EQ(list->cmpfunc, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
921 | EXPECT_EQ(list->allocator, cxDefaultAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
922 | EXPECT_EQ(list->item_size, sizeof(int)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
923 | EXPECT_EQ(list->simple_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
924 | EXPECT_EQ(list->advanced_destructor, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
925 | EXPECT_EQ(list->destructor_data, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
926 | EXPECT_EQ(cxListSize(list), 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
927 | CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
928 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
929 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
930 | TEST_F(PointerArrayList, cxArrayListCreateSimpleForPointers) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
931 | CxList *list = autofree(cxArrayListCreateSimple(CX_STORE_POINTERS, 8)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
932 | ASSERT_NE(list, NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
933 | EXPECT_EQ(list->cmpfunc, cx_cmp_ptr); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
934 | EXPECT_EQ(list->allocator, cxDefaultAllocator); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
935 | EXPECT_EQ(list->item_size, sizeof(void *)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
936 | CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
937 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
798
diff
changeset
|
938 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
939 | TEST_F(PointerLinkedList, DestroyNoDestructor) { |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
940 | void *item = cxMalloc(&testingAllocator, sizeof(int)); |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
941 | auto list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
942 | cxListAdd(list, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
943 | CX_TEST_ASSERT(!testingAllocator.verify()); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
944 | cxListDestroy(list); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
945 | CX_TEST_ASSERT(!testingAllocator.verify()); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
946 | cxFree(&testingAllocator, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
947 | CX_TEST_ASSERT(testingAllocator.verify()); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
948 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
949 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
950 | TEST_F(PointerLinkedList, DestroySimpleDestructor) { |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
951 | int item = 0; |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
952 | auto list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
953 | list->simple_destructor = [](void *elem) { *(int *) elem = 42; }; |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
954 | cxListAdd(list, &item); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
955 | cxListDestroy(list); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
956 | EXPECT_EQ(item, 42); |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
957 | } |
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
958 | |
672
55d8fdd38ca4
increase test coverage - fixes #250
Mike Becker <universe@uap-core.de>
parents:
667
diff
changeset
|
959 | TEST_F(PointerLinkedList, DestroyAdvancedDestructor) { |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
960 | void *item = cxMalloc(&testingAllocator, sizeof(int)); |
667
2f88a7c13a28
add CX_STORE_POINTERS special "item size" for lists
Mike Becker <universe@uap-core.de>
parents:
666
diff
changeset
|
961 | auto list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); |
677
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
962 | list->destructor_data = &testingAllocator; |
b09aae58bba4
refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents:
672
diff
changeset
|
963 | list->advanced_destructor = (cx_destructor_func2) cxFree; |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
964 | cxListAdd(list, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
965 | CX_TEST_ASSERT(!testingAllocator.verify()); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
966 | cxListDestroy(list); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
967 | CX_TEST_ASSERT(testingAllocator.verify()); |
641
d402fead3386
add new pointer list wrapper - resolves #234
Mike Becker <universe@uap-core.de>
parents:
639
diff
changeset
|
968 | } |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
969 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
970 | TEST_F(PointerArrayList, DestroyNoDestructor) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
971 | void *item = cxMalloc(&testingAllocator, sizeof(int)); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
972 | auto list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
973 | cxListAdd(list, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
974 | CX_TEST_ASSERT(!testingAllocator.verify()); |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
975 | cxListDestroy(list); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
976 | CX_TEST_ASSERT(!testingAllocator.verify()); |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
977 | cxFree(&testingAllocator, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
978 | CX_TEST_ASSERT(testingAllocator.verify()); |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
979 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
980 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
981 | TEST_F(PointerArrayList, DestroySimpleDestructor) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
982 | int item = 0; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
983 | auto list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
984 | list->simple_destructor = [](void *elem) { *(int *) elem = 42; }; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
985 | cxListAdd(list, &item); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
986 | cxListDestroy(list); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
987 | EXPECT_EQ(item, 42); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
988 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
989 | |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
990 | TEST_F(PointerArrayList, DestroyAdvancedDestructor) { |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
991 | void *item = cxMalloc(&testingAllocator, sizeof(int)); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
992 | auto list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4); |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
993 | list->destructor_data = &testingAllocator; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
994 | list->advanced_destructor = (cx_destructor_func2) cxFree; |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
995 | cxListAdd(list, item); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
996 | CX_TEST_ASSERT(!testingAllocator.verify()); |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
997 | cxListDestroy(list); |
790
42877968260c
some text replacements to prepare migration of list tests
Mike Becker <universe@uap-core.de>
parents:
764
diff
changeset
|
998 | CX_TEST_ASSERT(testingAllocator.verify()); |
679
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
999 | } |
022fbd4bc057
add pointer array list tests
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
1000 |