diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-06-18 16:15:08 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-06-19 13:02:21 +0300 |
commit | b3b445979e6a7e6cd80f9e5240d1813a25b2f0c1 (patch) | |
tree | e02a584734181550e5843a17f2f8b0babf685e1b /tests/gtests/blenlib | |
parent | 8c3dd6d83df467f3b8e53b6c97545eabf07768be (diff) |
Tests: Use explicit signature constants
Are reported by MSVC 2019 after C++17 switch.
One might suggest lets just silence the warning, I will say why to have
specific signed/unsigned types in API just to then (usafely) ignore the
sign conversion.
Diffstat (limited to 'tests/gtests/blenlib')
-rw-r--r-- | tests/gtests/blenlib/BLI_array_test.cc | 30 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_index_range_test.cc | 70 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_linear_allocator_test.cc | 12 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_map_test.cc | 70 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_set_test.cc | 42 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_span_test.cc | 60 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_stack_cxx_test.cc | 40 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_string_ref_test.cc | 32 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_vector_set_test.cc | 56 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_vector_test.cc | 118 |
10 files changed, 265 insertions, 265 deletions
diff --git a/tests/gtests/blenlib/BLI_array_test.cc b/tests/gtests/blenlib/BLI_array_test.cc index fc3c15fe813..9ff4dc9a371 100644 --- a/tests/gtests/blenlib/BLI_array_test.cc +++ b/tests/gtests/blenlib/BLI_array_test.cc @@ -7,21 +7,21 @@ using namespace blender; TEST(array, DefaultConstructor) { Array<int> array; - EXPECT_EQ(array.size(), 0); + EXPECT_EQ(array.size(), 0u); EXPECT_TRUE(array.is_empty()); } TEST(array, SizeConstructor) { Array<int> array(5); - EXPECT_EQ(array.size(), 5); + EXPECT_EQ(array.size(), 5u); EXPECT_FALSE(array.is_empty()); } TEST(array, FillConstructor) { Array<int> array(5, 8); - EXPECT_EQ(array.size(), 5); + EXPECT_EQ(array.size(), 5u); EXPECT_EQ(array[0], 8); EXPECT_EQ(array[1], 8); EXPECT_EQ(array[2], 8); @@ -32,7 +32,7 @@ TEST(array, FillConstructor) TEST(array, InitializerListConstructor) { Array<int> array = {4, 5, 6, 7}; - EXPECT_EQ(array.size(), 4); + EXPECT_EQ(array.size(), 4u); EXPECT_EQ(array[0], 4); EXPECT_EQ(array[1], 5); EXPECT_EQ(array[2], 6); @@ -44,7 +44,7 @@ TEST(array, SpanConstructor) int stackarray[4] = {6, 7, 8, 9}; Span<int> span(stackarray, ARRAY_SIZE(stackarray)); Array<int> array(span); - EXPECT_EQ(array.size(), 4); + EXPECT_EQ(array.size(), 4u); EXPECT_EQ(array[0], 6); EXPECT_EQ(array[1], 7); EXPECT_EQ(array[2], 8); @@ -56,8 +56,8 @@ TEST(array, CopyConstructor) Array<int> array = {5, 6, 7, 8}; Array<int> new_array(array); - EXPECT_EQ(array.size(), 4); - EXPECT_EQ(new_array.size(), 4); + EXPECT_EQ(array.size(), 4u); + EXPECT_EQ(new_array.size(), 4u); EXPECT_NE(array.data(), new_array.data()); EXPECT_EQ(new_array[0], 5); EXPECT_EQ(new_array[1], 6); @@ -70,8 +70,8 @@ TEST(array, MoveConstructor) Array<int> array = {5, 6, 7, 8}; Array<int> new_array(std::move(array)); - EXPECT_EQ(array.size(), 0); - EXPECT_EQ(new_array.size(), 4); + EXPECT_EQ(array.size(), 0u); + EXPECT_EQ(new_array.size(), 4u); EXPECT_EQ(new_array[0], 5); EXPECT_EQ(new_array[1], 6); EXPECT_EQ(new_array[2], 7); @@ -82,10 +82,10 @@ TEST(array, CopyAssignment) { Array<int> array = {1, 2, 3}; Array<int> new_array = {4}; - EXPECT_EQ(new_array.size(), 1); + EXPECT_EQ(new_array.size(), 1u); new_array = array; - EXPECT_EQ(new_array.size(), 3); - EXPECT_EQ(array.size(), 3); + EXPECT_EQ(new_array.size(), 3u); + EXPECT_EQ(array.size(), 3u); EXPECT_NE(array.data(), new_array.data()); EXPECT_EQ(new_array[0], 1); EXPECT_EQ(new_array[1], 2); @@ -96,10 +96,10 @@ TEST(array, MoveAssignment) { Array<int> array = {1, 2, 3}; Array<int> new_array = {4}; - EXPECT_EQ(new_array.size(), 1); + EXPECT_EQ(new_array.size(), 1u); new_array = std::move(array); - EXPECT_EQ(new_array.size(), 3); - EXPECT_EQ(array.size(), 0); + EXPECT_EQ(new_array.size(), 3u); + EXPECT_EQ(array.size(), 0u); EXPECT_EQ(new_array[0], 1); EXPECT_EQ(new_array[1], 2); EXPECT_EQ(new_array[2], 3); diff --git a/tests/gtests/blenlib/BLI_index_range_test.cc b/tests/gtests/blenlib/BLI_index_range_test.cc index da51b7a66c0..6b628909f18 100644 --- a/tests/gtests/blenlib/BLI_index_range_test.cc +++ b/tests/gtests/blenlib/BLI_index_range_test.cc @@ -8,41 +8,41 @@ using namespace blender; TEST(index_range, DefaultConstructor) { IndexRange range; - EXPECT_EQ(range.size(), 0); + EXPECT_EQ(range.size(), 0u); Vector<uint> vector; for (uint value : range) { vector.append(value); } - EXPECT_EQ(vector.size(), 0); + EXPECT_EQ(vector.size(), 0u); } TEST(index_range, SingleElementRange) { IndexRange range(4, 1); - EXPECT_EQ(range.size(), 1); - EXPECT_EQ(*range.begin(), 4); + EXPECT_EQ(range.size(), 1u); + EXPECT_EQ(*range.begin(), 4u); Vector<uint> vector; for (uint value : range) { vector.append(value); } - EXPECT_EQ(vector.size(), 1); - EXPECT_EQ(vector[0], 4); + EXPECT_EQ(vector.size(), 1u); + EXPECT_EQ(vector[0], 4u); } TEST(index_range, MultipleElementRange) { IndexRange range(6, 4); - EXPECT_EQ(range.size(), 4); + EXPECT_EQ(range.size(), 4u); Vector<uint> vector; for (uint value : range) { vector.append(value); } - EXPECT_EQ(vector.size(), 4); + EXPECT_EQ(vector.size(), 4u); for (uint i = 0; i < 4; i++) { EXPECT_EQ(vector[i], i + 6); } @@ -51,28 +51,28 @@ TEST(index_range, MultipleElementRange) TEST(index_range, SubscriptOperator) { IndexRange range(5, 5); - EXPECT_EQ(range[0], 5); - EXPECT_EQ(range[1], 6); - EXPECT_EQ(range[2], 7); + EXPECT_EQ(range[0], 5u); + EXPECT_EQ(range[1], 6u); + EXPECT_EQ(range[2], 7u); } TEST(index_range, Before) { IndexRange range = IndexRange(5, 5).before(3); - EXPECT_EQ(range[0], 2); - EXPECT_EQ(range[1], 3); - EXPECT_EQ(range[2], 4); - EXPECT_EQ(range.size(), 3); + EXPECT_EQ(range[0], 2u); + EXPECT_EQ(range[1], 3u); + EXPECT_EQ(range[2], 4u); + EXPECT_EQ(range.size(), 3u); } TEST(index_range, After) { IndexRange range = IndexRange(5, 5).after(4); - EXPECT_EQ(range[0], 10); - EXPECT_EQ(range[1], 11); - EXPECT_EQ(range[2], 12); - EXPECT_EQ(range[3], 13); - EXPECT_EQ(range.size(), 4); + EXPECT_EQ(range[0], 10u); + EXPECT_EQ(range[1], 11u); + EXPECT_EQ(range[2], 12u); + EXPECT_EQ(range[3], 13u); + EXPECT_EQ(range.size(), 4u); } TEST(index_range, Contains) @@ -88,52 +88,52 @@ TEST(index_range, Contains) TEST(index_range, First) { IndexRange range = IndexRange(5, 3); - EXPECT_EQ(range.first(), 5); + EXPECT_EQ(range.first(), 5u); } TEST(index_range, Last) { IndexRange range = IndexRange(5, 3); - EXPECT_EQ(range.last(), 7); + EXPECT_EQ(range.last(), 7u); } TEST(index_range, OneAfterEnd) { IndexRange range = IndexRange(5, 3); - EXPECT_EQ(range.one_after_last(), 8); + EXPECT_EQ(range.one_after_last(), 8u); } TEST(index_range, Start) { IndexRange range = IndexRange(6, 2); - EXPECT_EQ(range.start(), 6); + EXPECT_EQ(range.start(), 6u); } TEST(index_range, Slice) { IndexRange range = IndexRange(5, 15); IndexRange slice = range.slice(2, 6); - EXPECT_EQ(slice.size(), 6); - EXPECT_EQ(slice.first(), 7); - EXPECT_EQ(slice.last(), 12); + EXPECT_EQ(slice.size(), 6u); + EXPECT_EQ(slice.first(), 7u); + EXPECT_EQ(slice.last(), 12u); } TEST(index_range, SliceRange) { IndexRange range = IndexRange(5, 15); IndexRange slice = range.slice(IndexRange(3, 5)); - EXPECT_EQ(slice.size(), 5); - EXPECT_EQ(slice.first(), 8); - EXPECT_EQ(slice.last(), 12); + EXPECT_EQ(slice.size(), 5u); + EXPECT_EQ(slice.first(), 8u); + EXPECT_EQ(slice.last(), 12u); } TEST(index_range, AsSpan) { IndexRange range = IndexRange(4, 6); Span<uint> span = range.as_span(); - EXPECT_EQ(span.size(), 6); - EXPECT_EQ(span[0], 4); - EXPECT_EQ(span[1], 5); - EXPECT_EQ(span[2], 6); - EXPECT_EQ(span[3], 7); + EXPECT_EQ(span.size(), 6u); + EXPECT_EQ(span[0], 4u); + EXPECT_EQ(span[1], 5u); + EXPECT_EQ(span[2], 6u); + EXPECT_EQ(span[3], 7u); } diff --git a/tests/gtests/blenlib/BLI_linear_allocator_test.cc b/tests/gtests/blenlib/BLI_linear_allocator_test.cc index 0d926ca7931..9c230d404f2 100644 --- a/tests/gtests/blenlib/BLI_linear_allocator_test.cc +++ b/tests/gtests/blenlib/BLI_linear_allocator_test.cc @@ -68,7 +68,7 @@ TEST(linear_allocator, AllocateArray) LinearAllocator<> allocator; MutableSpan<int> span = allocator.allocate_array<int>(5); - EXPECT_EQ(span.size(), 5); + EXPECT_EQ(span.size(), 5u); } TEST(linear_allocator, Construct) @@ -77,7 +77,7 @@ TEST(linear_allocator, Construct) std::array<int, 5> values = {1, 2, 3, 4, 5}; Vector<int> *vector = allocator.construct<Vector<int>>(values); - EXPECT_EQ(vector->size(), 5); + EXPECT_EQ(vector->size(), 5u); EXPECT_EQ((*vector)[3], 4); vector->~Vector(); } @@ -90,8 +90,8 @@ TEST(linear_allocator, ConstructElementsAndPointerArray) Span<Vector<int> *> vectors = allocator.construct_elements_and_pointer_array<Vector<int>>( 5, values); - EXPECT_EQ(vectors.size(), 5); - EXPECT_EQ(vectors[3]->size(), 7); + EXPECT_EQ(vectors.size(), 5u); + EXPECT_EQ(vectors[3]->size(), 7u); EXPECT_EQ((*vectors[2])[5], 6); for (Vector<int> *vector : vectors) { @@ -107,8 +107,8 @@ TEST(linear_allocator, ConstructArrayCopy) MutableSpan<int> span1 = allocator.construct_array_copy(values.as_span()); MutableSpan<int> span2 = allocator.construct_array_copy(values.as_span()); EXPECT_NE(span1.data(), span2.data()); - EXPECT_EQ(span1.size(), 3); - EXPECT_EQ(span2.size(), 3); + EXPECT_EQ(span1.size(), 3u); + EXPECT_EQ(span2.size(), 3u); EXPECT_EQ(span1[1], 2); EXPECT_EQ(span2[2], 3); } diff --git a/tests/gtests/blenlib/BLI_map_test.cc b/tests/gtests/blenlib/BLI_map_test.cc index 85b2f642654..79a8786def9 100644 --- a/tests/gtests/blenlib/BLI_map_test.cc +++ b/tests/gtests/blenlib/BLI_map_test.cc @@ -11,20 +11,20 @@ using namespace blender; TEST(map, DefaultConstructor) { Map<int, float> map; - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); EXPECT_TRUE(map.is_empty()); } TEST(map, AddIncreasesSize) { Map<int, float> map; - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); EXPECT_TRUE(map.is_empty()); map.add(2, 5.0f); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_FALSE(map.is_empty()); map.add(6, 2.0f); - EXPECT_EQ(map.size(), 2); + EXPECT_EQ(map.size(), 2u); EXPECT_FALSE(map.is_empty()); } @@ -87,16 +87,16 @@ TEST(map, PopTry) Map<int, int> map; map.add(1, 5); map.add(2, 7); - EXPECT_EQ(map.size(), 2); + EXPECT_EQ(map.size(), 2u); Optional<int> value = map.pop_try(4); - EXPECT_EQ(map.size(), 2); + EXPECT_EQ(map.size(), 2u); EXPECT_FALSE(value.has_value()); value = map.pop_try(2); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_TRUE(value.has_value()); EXPECT_EQ(value.value(), 7); EXPECT_EQ(*map.pop_try(1), 5); - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); } TEST(map, PopDefault) @@ -105,17 +105,17 @@ TEST(map, PopDefault) map.add(1, 4); map.add(2, 7); map.add(3, 8); - EXPECT_EQ(map.size(), 3); + EXPECT_EQ(map.size(), 3u); EXPECT_EQ(map.pop_default(4, 10), 10); - EXPECT_EQ(map.size(), 3); + EXPECT_EQ(map.size(), 3u); EXPECT_EQ(map.pop_default(1, 10), 4); - EXPECT_EQ(map.size(), 2); + EXPECT_EQ(map.size(), 2u); EXPECT_EQ(map.pop_default(2, 20), 7); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_EQ(map.pop_default(2, 20), 20); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_EQ(map.pop_default(3, 0), 8); - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); } TEST(map, PopItemMany) @@ -147,7 +147,7 @@ TEST(map, ValueIterator) iterations++; } - EXPECT_EQ(iterations, 3); + EXPECT_EQ(iterations, 3u); EXPECT_TRUE(values.contains(5.0f)); EXPECT_TRUE(values.contains(-2.0f)); EXPECT_TRUE(values.contains(2.0f)); @@ -168,7 +168,7 @@ TEST(map, KeyIterator) iterations++; } - EXPECT_EQ(iterations, 3); + EXPECT_EQ(iterations, 3u); EXPECT_TRUE(keys.contains(1)); EXPECT_TRUE(keys.contains(2)); EXPECT_TRUE(keys.contains(6)); @@ -192,7 +192,7 @@ TEST(map, ItemIterator) iterations++; } - EXPECT_EQ(iterations, 3); + EXPECT_EQ(iterations, 3u); EXPECT_TRUE(keys.contains(5)); EXPECT_TRUE(keys.contains(2)); EXPECT_TRUE(keys.contains(1)); @@ -241,8 +241,8 @@ TEST(map, MutableItemToItemConversion) values.append(item.value); } - EXPECT_EQ(keys.size(), 2); - EXPECT_EQ(values.size(), 2); + EXPECT_EQ(keys.size(), 2u); + EXPECT_EQ(values.size(), 2u); EXPECT_TRUE(keys.contains(3)); EXPECT_TRUE(keys.contains(2)); EXPECT_TRUE(values.contains(6)); @@ -330,10 +330,10 @@ TEST(map, MoveConstructorSmall) map1.add(1, 2.0f); map1.add(4, 1.0f); Map<int, float> map2(std::move(map1)); - EXPECT_EQ(map2.size(), 2); + EXPECT_EQ(map2.size(), 2u); EXPECT_EQ(map2.lookup(1), 2.0f); EXPECT_EQ(map2.lookup(4), 1.0f); - EXPECT_EQ(map1.size(), 0); + EXPECT_EQ(map1.size(), 0u); EXPECT_EQ(map1.lookup_ptr(4), nullptr); } @@ -344,10 +344,10 @@ TEST(map, MoveConstructorLarge) map1.add_new(i, i); } Map<int, int> map2(std::move(map1)); - EXPECT_EQ(map2.size(), 100); + EXPECT_EQ(map2.size(), 100u); EXPECT_EQ(map2.lookup(1), 1); EXPECT_EQ(map2.lookup(4), 4); - EXPECT_EQ(map1.size(), 0); + EXPECT_EQ(map1.size(), 0u); EXPECT_EQ(map1.lookup_ptr(4), nullptr); } @@ -358,10 +358,10 @@ TEST(map, MoveAssignment) map1.add(4, 1.0f); Map<int, float> map2; map2 = std::move(map1); - EXPECT_EQ(map2.size(), 2); + EXPECT_EQ(map2.size(), 2u); EXPECT_EQ(map2.lookup(1), 2.0f); EXPECT_EQ(map2.lookup(4), 1.0f); - EXPECT_EQ(map1.size(), 0); + EXPECT_EQ(map1.size(), 0u); EXPECT_EQ(map1.lookup_ptr(4), nullptr); } @@ -372,10 +372,10 @@ TEST(map, CopyAssignment) map1.add(4, 1.0f); Map<int, float> map2; map2 = map1; - EXPECT_EQ(map2.size(), 2); + EXPECT_EQ(map2.size(), 2u); EXPECT_EQ(map2.lookup(1), 2.0f); EXPECT_EQ(map2.lookup(4), 1.0f); - EXPECT_EQ(map1.size(), 2); + EXPECT_EQ(map1.size(), 2u); EXPECT_EQ(*map1.lookup_ptr(4), 1.0f); } @@ -385,13 +385,13 @@ TEST(map, Clear) map.add(1, 1.0f); map.add(2, 5.0f); - EXPECT_EQ(map.size(), 2); + EXPECT_EQ(map.size(), 2u); EXPECT_TRUE(map.contains(1)); EXPECT_TRUE(map.contains(2)); map.clear(); - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); EXPECT_FALSE(map.contains(1)); EXPECT_FALSE(map.contains(2)); } @@ -423,11 +423,11 @@ TEST(map, Remove) { Map<int, int> map; map.add(2, 4); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_FALSE(map.remove(3)); - EXPECT_EQ(map.size(), 1); + EXPECT_EQ(map.size(), 1u); EXPECT_TRUE(map.remove(2)); - EXPECT_EQ(map.size(), 0); + EXPECT_EQ(map.size(), 0u); } TEST(map, PointerKeys) @@ -439,7 +439,7 @@ TEST(map, PointerKeys) EXPECT_FALSE(map.add(&a, 4)); map.add_new(&b, 1); map.add_new(&c, 1); - EXPECT_EQ(map.size(), 3); + EXPECT_EQ(map.size(), 3u); EXPECT_TRUE(map.remove(&b)); EXPECT_TRUE(map.add(&b, 8)); EXPECT_FALSE(map.remove(&d)); @@ -471,8 +471,8 @@ TEST(map, ForeachItem) values.append(value); }); - EXPECT_EQ(keys.size(), 2); - EXPECT_EQ(values.size(), 2); + EXPECT_EQ(keys.size(), 2u); + EXPECT_EQ(values.size(), 2u); EXPECT_EQ(keys.first_index_of(3), values.first_index_of(4)); EXPECT_EQ(keys.first_index_of(1), values.first_index_of(8)); } diff --git a/tests/gtests/blenlib/BLI_set_test.cc b/tests/gtests/blenlib/BLI_set_test.cc index 2387242c94b..ac78eb786df 100644 --- a/tests/gtests/blenlib/BLI_set_test.cc +++ b/tests/gtests/blenlib/BLI_set_test.cc @@ -14,7 +14,7 @@ namespace blender { TEST(set, DefaultConstructor) { Set<int> set; - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); EXPECT_TRUE(set.is_empty()); } @@ -52,7 +52,7 @@ TEST(set, AddMany) TEST(set, InitializerListConstructor) { Set<int> set = {4, 5, 6}; - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); EXPECT_TRUE(set.contains(4)); EXPECT_TRUE(set.contains(5)); EXPECT_TRUE(set.contains(6)); @@ -77,10 +77,10 @@ TEST(set, CopyConstructor) TEST(set, MoveConstructor) { Set<int> set = {1, 2, 3}; - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); Set<int> set2(std::move(set)); - EXPECT_EQ(set.size(), 0); - EXPECT_EQ(set2.size(), 3); + EXPECT_EQ(set.size(), 0u); + EXPECT_EQ(set2.size(), 3u); } TEST(set, CopyAssignment) @@ -101,11 +101,11 @@ TEST(set, CopyAssignment) TEST(set, MoveAssignment) { Set<int> set = {1, 2, 3}; - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); Set<int> set2; set2 = std::move(set); - EXPECT_EQ(set.size(), 0); - EXPECT_EQ(set2.size(), 3); + EXPECT_EQ(set.size(), 0u); + EXPECT_EQ(set2.size(), 3u); } TEST(set, RemoveContained) @@ -177,7 +177,7 @@ TEST(set, AddMultiple) a.add_multiple({2, 4, 7}); EXPECT_TRUE(a.contains(4)); EXPECT_TRUE(a.contains(2)); - EXPECT_EQ(a.size(), 4); + EXPECT_EQ(a.size(), 4u); } TEST(set, AddMultipleNew) @@ -195,7 +195,7 @@ TEST(set, Iterator) for (int value : set) { vec.append(value); } - EXPECT_EQ(vec.size(), 5); + EXPECT_EQ(vec.size(), 5u); EXPECT_TRUE(vec.contains(1)); EXPECT_TRUE(vec.contains(3)); EXPECT_TRUE(vec.contains(2)); @@ -208,9 +208,9 @@ TEST(set, OftenAddRemoveContained) Set<int> set; for (int i = 0; i < 100; i++) { set.add(42); - EXPECT_EQ(set.size(), 1); + EXPECT_EQ(set.size(), 1u); set.remove_contained(42); - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); } } @@ -222,15 +222,15 @@ TEST(set, UniquePtrValues) set.add_new(std::move(value1)); set.add(std::unique_ptr<int>(new int())); - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); } TEST(set, Clear) { Set<int> set = {3, 4, 6, 7}; - EXPECT_EQ(set.size(), 4); + EXPECT_EQ(set.size(), 4u); set.clear(); - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); } TEST(set, StringSet) @@ -238,7 +238,7 @@ TEST(set, StringSet) Set<std::string> set; set.add("hello"); set.add("world"); - EXPECT_EQ(set.size(), 2); + EXPECT_EQ(set.size(), 2u); EXPECT_TRUE(set.contains("hello")); EXPECT_TRUE(set.contains("world")); EXPECT_FALSE(set.contains("world2")); @@ -250,7 +250,7 @@ TEST(set, PointerSet) Set<int *> set; set.add(&a); set.add(&b); - EXPECT_EQ(set.size(), 2); + EXPECT_EQ(set.size(), 2u); EXPECT_TRUE(set.contains(&a)); EXPECT_TRUE(set.contains(&b)); EXPECT_FALSE(set.contains(&c)); @@ -259,14 +259,14 @@ TEST(set, PointerSet) TEST(set, Remove) { Set<int> set = {1, 2, 3, 4, 5, 6}; - EXPECT_EQ(set.size(), 6); + EXPECT_EQ(set.size(), 6u); EXPECT_TRUE(set.remove(2)); - EXPECT_EQ(set.size(), 5); + EXPECT_EQ(set.size(), 5u); EXPECT_FALSE(set.contains(2)); EXPECT_FALSE(set.remove(2)); - EXPECT_EQ(set.size(), 5); + EXPECT_EQ(set.size(), 5u); EXPECT_TRUE(set.remove(5)); - EXPECT_EQ(set.size(), 4); + EXPECT_EQ(set.size(), 4u); } struct Type1 { diff --git a/tests/gtests/blenlib/BLI_span_test.cc b/tests/gtests/blenlib/BLI_span_test.cc index b122e8efdb4..2662ab55584 100644 --- a/tests/gtests/blenlib/BLI_span_test.cc +++ b/tests/gtests/blenlib/BLI_span_test.cc @@ -9,7 +9,7 @@ TEST(span, FromSmallVector) { Vector<int> a = {1, 2, 3}; Span<int> a_span = a; - EXPECT_EQ(a_span.size(), 3); + EXPECT_EQ(a_span.size(), 3u); EXPECT_EQ(a_span[0], 1); EXPECT_EQ(a_span[1], 2); EXPECT_EQ(a_span[2], 3); @@ -21,14 +21,14 @@ TEST(span, AddConstToPointer) std::vector<int *> vec = {&a}; Span<int *> span = vec; Span<const int *> const_span = span; - EXPECT_EQ(const_span.size(), 1); + EXPECT_EQ(const_span.size(), 1u); } TEST(span, IsReferencing) { int array[] = {3, 5, 8}; MutableSpan<int> span(array, ARRAY_SIZE(array)); - EXPECT_EQ(span.size(), 3); + EXPECT_EQ(span.size(), 3u); EXPECT_EQ(span[1], 5); array[1] = 10; EXPECT_EQ(span[1], 10); @@ -38,7 +38,7 @@ TEST(span, DropBack) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).drop_back(2); - EXPECT_EQ(slice.size(), 2); + EXPECT_EQ(slice.size(), 2u); EXPECT_EQ(slice[0], 4); EXPECT_EQ(slice[1], 5); } @@ -47,14 +47,14 @@ TEST(span, DropBackAll) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).drop_back(a.size()); - EXPECT_EQ(slice.size(), 0); + EXPECT_EQ(slice.size(), 0u); } TEST(span, DropFront) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).drop_front(1); - EXPECT_EQ(slice.size(), 3); + EXPECT_EQ(slice.size(), 3u); EXPECT_EQ(slice[0], 5); EXPECT_EQ(slice[1], 6); EXPECT_EQ(slice[2], 7); @@ -64,14 +64,14 @@ TEST(span, DropFrontAll) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).drop_front(a.size()); - EXPECT_EQ(slice.size(), 0); + EXPECT_EQ(slice.size(), 0u); } TEST(span, TakeFront) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).take_front(2); - EXPECT_EQ(slice.size(), 2); + EXPECT_EQ(slice.size(), 2u); EXPECT_EQ(slice[0], 4); EXPECT_EQ(slice[1], 5); } @@ -80,7 +80,7 @@ TEST(span, TakeBack) { Vector<int> a = {5, 6, 7, 8}; auto slice = Span<int>(a).take_back(2); - EXPECT_EQ(slice.size(), 2); + EXPECT_EQ(slice.size(), 2u); EXPECT_EQ(slice[0], 7); EXPECT_EQ(slice[1], 8); } @@ -89,7 +89,7 @@ TEST(span, Slice) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).slice(1, 2); - EXPECT_EQ(slice.size(), 2); + EXPECT_EQ(slice.size(), 2u); EXPECT_EQ(slice[0], 5); EXPECT_EQ(slice[1], 6); } @@ -98,14 +98,14 @@ TEST(span, SliceEmpty) { Vector<int> a = {4, 5, 6, 7}; auto slice = Span<int>(a).slice(2, 0); - EXPECT_EQ(slice.size(), 0); + EXPECT_EQ(slice.size(), 0u); } TEST(span, SliceRange) { Vector<int> a = {1, 2, 3, 4, 5}; auto slice = Span<int>(a).slice(IndexRange(2, 2)); - EXPECT_EQ(slice.size(), 2); + EXPECT_EQ(slice.size(), 2u); EXPECT_EQ(slice[0], 3); EXPECT_EQ(slice[1], 4); } @@ -126,16 +126,16 @@ TEST(span, Count) { Vector<int> a = {2, 3, 4, 3, 3, 2, 2, 2, 2}; Span<int> a_span = a; - EXPECT_EQ(a_span.count(1), 0); - EXPECT_EQ(a_span.count(2), 5); - EXPECT_EQ(a_span.count(3), 3); - EXPECT_EQ(a_span.count(4), 1); - EXPECT_EQ(a_span.count(5), 0); + EXPECT_EQ(a_span.count(1), 0u); + EXPECT_EQ(a_span.count(2), 5u); + EXPECT_EQ(a_span.count(3), 3u); + EXPECT_EQ(a_span.count(4), 1u); + EXPECT_EQ(a_span.count(5), 0u); } static void test_ref_from_initializer_list(Span<int> span) { - EXPECT_EQ(span.size(), 4); + EXPECT_EQ(span.size(), 4u); EXPECT_EQ(span[0], 3); EXPECT_EQ(span[1], 6); EXPECT_EQ(span[2], 8); @@ -151,7 +151,7 @@ TEST(span, FromVector) { std::vector<int> a = {1, 2, 3, 4}; Span<int> a_span(a); - EXPECT_EQ(a_span.size(), 4); + EXPECT_EQ(a_span.size(), 4u); EXPECT_EQ(a_span[0], 1); EXPECT_EQ(a_span[1], 2); EXPECT_EQ(a_span[2], 3); @@ -162,7 +162,7 @@ TEST(span, FromArray) { std::array<int, 2> a = {5, 6}; Span<int> a_span(a); - EXPECT_EQ(a_span.size(), 2); + EXPECT_EQ(a_span.size(), 2u); EXPECT_EQ(a_span[0], 5); EXPECT_EQ(a_span[1], 6); } @@ -196,7 +196,7 @@ TEST(span, SizeInBytes) std::array<int, 10> a; Span<int> a_span(a); EXPECT_EQ(a_span.size_in_bytes(), sizeof(a)); - EXPECT_EQ(a_span.size_in_bytes(), 40); + EXPECT_EQ(a_span.size_in_bytes(), 40u); } TEST(span, FirstLast) @@ -244,9 +244,9 @@ TEST(span, FirstIndex) std::array<int, 5> a = {4, 5, 4, 2, 5}; Span<int> a_span(a); - EXPECT_EQ(a_span.first_index(4), 0); - EXPECT_EQ(a_span.first_index(5), 1); - EXPECT_EQ(a_span.first_index(2), 3); + EXPECT_EQ(a_span.first_index(4), 0u); + EXPECT_EQ(a_span.first_index(5), 1u); + EXPECT_EQ(a_span.first_index(2), 3u); } TEST(span, CastSameSize) @@ -256,8 +256,8 @@ TEST(span, CastSameSize) Span<int *> a_span = a; Span<float *> new_a_span = a_span.cast<float *>(); - EXPECT_EQ(a_span.size(), 4); - EXPECT_EQ(new_a_span.size(), 4); + EXPECT_EQ(a_span.size(), 4u); + EXPECT_EQ(new_a_span.size(), 4u); EXPECT_EQ(a_span[0], &value); EXPECT_EQ(new_a_span[0], (float *)&value); @@ -269,8 +269,8 @@ TEST(span, CastSmallerSize) Span<uint32_t> a_span = a; Span<uint16_t> new_a_span = a_span.cast<uint16_t>(); - EXPECT_EQ(a_span.size(), 4); - EXPECT_EQ(new_a_span.size(), 8); + EXPECT_EQ(a_span.size(), 4u); + EXPECT_EQ(new_a_span.size(), 8u); } TEST(span, CastLargerSize) @@ -279,6 +279,6 @@ TEST(span, CastLargerSize) Span<uint16_t> a_span = a; Span<uint32_t> new_a_span = a_span.cast<uint32_t>(); - EXPECT_EQ(a_span.size(), 4); - EXPECT_EQ(new_a_span.size(), 2); + EXPECT_EQ(a_span.size(), 4u); + EXPECT_EQ(new_a_span.size(), 2u); } diff --git a/tests/gtests/blenlib/BLI_stack_cxx_test.cc b/tests/gtests/blenlib/BLI_stack_cxx_test.cc index 2fb4c11ca83..c078c3e8991 100644 --- a/tests/gtests/blenlib/BLI_stack_cxx_test.cc +++ b/tests/gtests/blenlib/BLI_stack_cxx_test.cc @@ -8,7 +8,7 @@ using namespace blender; TEST(stack, DefaultConstructor) { Stack<int> stack; - EXPECT_EQ(stack.size(), 0); + EXPECT_EQ(stack.size(), 0u); EXPECT_TRUE(stack.is_empty()); } @@ -16,7 +16,7 @@ TEST(stack, SpanConstructor) { std::array<int, 3> array = {4, 7, 2}; Stack<int> stack(array); - EXPECT_EQ(stack.size(), 3); + EXPECT_EQ(stack.size(), 3u); EXPECT_EQ(stack.pop(), 2); EXPECT_EQ(stack.pop(), 7); EXPECT_EQ(stack.pop(), 4); @@ -27,8 +27,8 @@ TEST(stack, CopyConstructor) { Stack<int> stack1 = {1, 2, 3, 4, 5, 6, 7}; Stack<int> stack2 = stack1; - EXPECT_EQ(stack1.size(), 7); - EXPECT_EQ(stack2.size(), 7); + EXPECT_EQ(stack1.size(), 7u); + EXPECT_EQ(stack2.size(), 7u); for (int i = 7; i >= 1; i--) { EXPECT_FALSE(stack1.is_empty()); EXPECT_FALSE(stack2.is_empty()); @@ -43,8 +43,8 @@ TEST(stack, MoveConstructor) { Stack<int> stack1 = {1, 2, 3, 4, 5, 6, 7}; Stack<int> stack2 = std::move(stack1); - EXPECT_EQ(stack1.size(), 0); - EXPECT_EQ(stack2.size(), 7); + EXPECT_EQ(stack1.size(), 0u); + EXPECT_EQ(stack2.size(), 7u); for (int i = 7; i >= 1; i--) { EXPECT_EQ(stack2.pop(), i); } @@ -56,8 +56,8 @@ TEST(stack, CopyAssignment) Stack<int> stack2 = {2, 3, 4, 5, 6, 7}; stack2 = stack1; - EXPECT_EQ(stack1.size(), 7); - EXPECT_EQ(stack2.size(), 7); + EXPECT_EQ(stack1.size(), 7u); + EXPECT_EQ(stack2.size(), 7u); for (int i = 7; i >= 1; i--) { EXPECT_FALSE(stack1.is_empty()); EXPECT_FALSE(stack2.is_empty()); @@ -73,8 +73,8 @@ TEST(stack, MoveAssignment) Stack<int> stack1 = {1, 2, 3, 4, 5, 6, 7}; Stack<int> stack2 = {5, 3, 7, 2, 2}; stack2 = std::move(stack1); - EXPECT_EQ(stack1.size(), 0); - EXPECT_EQ(stack2.size(), 7); + EXPECT_EQ(stack1.size(), 0u); + EXPECT_EQ(stack2.size(), 7u); for (int i = 7; i >= 1; i--) { EXPECT_EQ(stack2.pop(), i); } @@ -83,19 +83,19 @@ TEST(stack, MoveAssignment) TEST(stack, Push) { Stack<int> stack; - EXPECT_EQ(stack.size(), 0); + EXPECT_EQ(stack.size(), 0u); stack.push(3); - EXPECT_EQ(stack.size(), 1); + EXPECT_EQ(stack.size(), 1u); stack.push(5); - EXPECT_EQ(stack.size(), 2); + EXPECT_EQ(stack.size(), 2u); } TEST(stack, PushMultiple) { Stack<int> stack; - EXPECT_EQ(stack.size(), 0); + EXPECT_EQ(stack.size(), 0u); stack.push_multiple({1, 2, 3}); - EXPECT_EQ(stack.size(), 3); + EXPECT_EQ(stack.size(), 3u); EXPECT_EQ(stack.pop(), 3); EXPECT_EQ(stack.pop(), 2); EXPECT_EQ(stack.pop(), 1); @@ -106,19 +106,19 @@ TEST(stack, PushPopMany) Stack<int> stack; for (int i = 0; i < 1000; i++) { stack.push(i); - EXPECT_EQ(stack.size(), i + 1); + EXPECT_EQ(stack.size(), static_cast<unsigned int>(i + 1)); } for (int i = 999; i > 50; i--) { EXPECT_EQ(stack.pop(), i); - EXPECT_EQ(stack.size(), i); + EXPECT_EQ(stack.size(), static_cast<unsigned int>(i)); } for (int i = 51; i < 5000; i++) { stack.push(i); - EXPECT_EQ(stack.size(), i + 1); + EXPECT_EQ(stack.size(), static_cast<unsigned int>(i + 1)); } for (int i = 4999; i >= 0; i--) { EXPECT_EQ(stack.pop(), i); - EXPECT_EQ(stack.size(), i); + EXPECT_EQ(stack.size(), static_cast<unsigned int>(i)); } } @@ -137,7 +137,7 @@ TEST(stack, PushMultipleAfterPop) values.append(i); } stack.push_multiple(values); - EXPECT_EQ(stack.size(), 5000); + EXPECT_EQ(stack.size(), 5000u); for (int i = 4999; i >= 0; i--) { EXPECT_EQ(stack.pop(), i); diff --git a/tests/gtests/blenlib/BLI_string_ref_test.cc b/tests/gtests/blenlib/BLI_string_ref_test.cc index 5bb0c396288..5a2d2463375 100644 --- a/tests/gtests/blenlib/BLI_string_ref_test.cc +++ b/tests/gtests/blenlib/BLI_string_ref_test.cc @@ -10,7 +10,7 @@ using blender::Vector; TEST(string_ref_null, DefaultConstructor) { StringRefNull ref; - EXPECT_EQ(ref.size(), 0); + EXPECT_EQ(ref.size(), 0u); EXPECT_EQ(ref[0], '\0'); } @@ -18,7 +18,7 @@ TEST(string_ref_null, CStringConstructor) { const char *str = "Hello"; StringRefNull ref(str); - EXPECT_EQ(ref.size(), 5); + EXPECT_EQ(ref.size(), 5u); EXPECT_EQ(ref.data(), str); } @@ -26,21 +26,21 @@ TEST(string_ref_null, CStringLengthConstructor) { const char *str = "Hello"; StringRefNull ref(str, 5); - EXPECT_EQ(ref.size(), 5); + EXPECT_EQ(ref.size(), 5u); EXPECT_EQ(ref.data(), str); } TEST(string_ref, DefaultConstructor) { StringRef ref; - EXPECT_EQ(ref.size(), 0); + EXPECT_EQ(ref.size(), 0u); } TEST(string_ref, StartEndConstructor) { const char *text = "hello world"; StringRef ref(text, text + 5); - EXPECT_EQ(ref.size(), 5); + EXPECT_EQ(ref.size(), 5u); EXPECT_TRUE(ref == "hello"); EXPECT_FALSE(ref == "hello "); } @@ -48,7 +48,7 @@ TEST(string_ref, StartEndConstructor) TEST(string_ref, StartEndConstructorNullptr) { StringRef ref(nullptr, nullptr); - EXPECT_EQ(ref.size(), 0); + EXPECT_EQ(ref.size(), 0u); EXPECT_TRUE(ref == ""); } @@ -56,7 +56,7 @@ TEST(string_ref, StartEndConstructorSame) { const char *text = "hello world"; StringRef ref(text, text); - EXPECT_EQ(ref.size(), 0); + EXPECT_EQ(ref.size(), 0u); EXPECT_TRUE(ref == ""); } @@ -64,7 +64,7 @@ TEST(string_ref, CStringConstructor) { const char *str = "Test"; StringRef ref(str); - EXPECT_EQ(ref.size(), 4); + EXPECT_EQ(ref.size(), 4u); EXPECT_EQ(ref.data(), str); } @@ -72,7 +72,7 @@ TEST(string_ref, PointerWithLengthConstructor) { const char *str = "Test"; StringRef ref(str, 2); - EXPECT_EQ(ref.size(), 2); + EXPECT_EQ(ref.size(), 2u); EXPECT_EQ(ref.data(), str); } @@ -80,14 +80,14 @@ TEST(string_ref, StdStringConstructor) { std::string str = "Test"; StringRef ref(str); - EXPECT_EQ(ref.size(), 4); + EXPECT_EQ(ref.size(), 4u); EXPECT_EQ(ref.data(), str.data()); } TEST(string_ref, SubscriptOperator) { StringRef ref("hello"); - EXPECT_EQ(ref.size(), 5); + EXPECT_EQ(ref.size(), 5u); EXPECT_EQ(ref[0], 'h'); EXPECT_EQ(ref[1], 'e'); EXPECT_EQ(ref[2], 'l'); @@ -99,7 +99,7 @@ TEST(string_ref, ToStdString) { StringRef ref("test"); std::string str = ref; - EXPECT_EQ(str.size(), 4); + EXPECT_EQ(str.size(), 4u); EXPECT_EQ(str, "test"); } @@ -204,7 +204,7 @@ TEST(string_ref, Iterate) for (char c : ref) { chars.append(c); } - EXPECT_EQ(chars.size(), 4); + EXPECT_EQ(chars.size(), 4u); EXPECT_EQ(chars[0], 't'); EXPECT_EQ(chars[1], 'e'); EXPECT_EQ(chars[2], 's'); @@ -240,8 +240,8 @@ TEST(string_ref, DropPrefixN) StringRef ref("test"); StringRef ref2 = ref.drop_prefix(2); StringRef ref3 = ref2.drop_prefix(2); - EXPECT_EQ(ref2.size(), 2); - EXPECT_EQ(ref3.size(), 0); + EXPECT_EQ(ref2.size(), 2u); + EXPECT_EQ(ref3.size(), 0u); EXPECT_EQ(ref2, "st"); EXPECT_EQ(ref3, ""); } @@ -250,7 +250,7 @@ TEST(string_ref, DropPrefix) { StringRef ref("test"); StringRef ref2 = ref.drop_prefix("tes"); - EXPECT_EQ(ref2.size(), 1); + EXPECT_EQ(ref2.size(), 1u); EXPECT_EQ(ref2, "t"); } diff --git a/tests/gtests/blenlib/BLI_vector_set_test.cc b/tests/gtests/blenlib/BLI_vector_set_test.cc index 1f8a830d134..c0374e87cd6 100644 --- a/tests/gtests/blenlib/BLI_vector_set_test.cc +++ b/tests/gtests/blenlib/BLI_vector_set_test.cc @@ -7,14 +7,14 @@ using blender::VectorSet; TEST(vector_set, DefaultConstructor) { VectorSet<int> set; - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); EXPECT_TRUE(set.is_empty()); } TEST(vector_set, InitializerListConstructor_WithoutDuplicates) { VectorSet<int> set = {1, 4, 5}; - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); EXPECT_EQ(set[0], 1); EXPECT_EQ(set[1], 4); EXPECT_EQ(set[2], 5); @@ -23,7 +23,7 @@ TEST(vector_set, InitializerListConstructor_WithoutDuplicates) TEST(vector_set, InitializerListConstructor_WithDuplicates) { VectorSet<int> set = {1, 3, 3, 2, 1, 5}; - EXPECT_EQ(set.size(), 4); + EXPECT_EQ(set.size(), 4u); EXPECT_EQ(set[0], 1); EXPECT_EQ(set[1], 3); EXPECT_EQ(set[2], 2); @@ -34,10 +34,10 @@ TEST(vector_set, Copy) { VectorSet<int> set1 = {1, 2, 3}; VectorSet<int> set2 = set1; - EXPECT_EQ(set1.size(), 3); - EXPECT_EQ(set2.size(), 3); - EXPECT_EQ(set1.index_of(2), 1); - EXPECT_EQ(set2.index_of(2), 1); + EXPECT_EQ(set1.size(), 3u); + EXPECT_EQ(set2.size(), 3u); + EXPECT_EQ(set1.index_of(2), 1u); + EXPECT_EQ(set2.index_of(2), 1u); } TEST(vector_set, CopyAssignment) @@ -45,18 +45,18 @@ TEST(vector_set, CopyAssignment) VectorSet<int> set1 = {1, 2, 3}; VectorSet<int> set2 = {}; set2 = set1; - EXPECT_EQ(set1.size(), 3); - EXPECT_EQ(set2.size(), 3); - EXPECT_EQ(set1.index_of(2), 1); - EXPECT_EQ(set2.index_of(2), 1); + EXPECT_EQ(set1.size(), 3u); + EXPECT_EQ(set2.size(), 3u); + EXPECT_EQ(set1.index_of(2), 1u); + EXPECT_EQ(set2.index_of(2), 1u); } TEST(vector_set, Move) { VectorSet<int> set1 = {1, 2, 3}; VectorSet<int> set2 = std::move(set1); - EXPECT_EQ(set1.size(), 0); - EXPECT_EQ(set2.size(), 3); + EXPECT_EQ(set1.size(), 0u); + EXPECT_EQ(set2.size(), 3u); } TEST(vector_set, MoveAssignment) @@ -64,36 +64,36 @@ TEST(vector_set, MoveAssignment) VectorSet<int> set1 = {1, 2, 3}; VectorSet<int> set2 = {}; set2 = std::move(set1); - EXPECT_EQ(set1.size(), 0); - EXPECT_EQ(set2.size(), 3); + EXPECT_EQ(set1.size(), 0u); + EXPECT_EQ(set2.size(), 3u); } TEST(vector_set, AddNewIncreasesSize) { VectorSet<int> set; EXPECT_TRUE(set.is_empty()); - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); set.add(5); EXPECT_FALSE(set.is_empty()); - EXPECT_EQ(set.size(), 1); + EXPECT_EQ(set.size(), 1u); } TEST(vector_set, AddExistingDoesNotIncreaseSize) { VectorSet<int> set; - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); EXPECT_TRUE(set.add(5)); - EXPECT_EQ(set.size(), 1); + EXPECT_EQ(set.size(), 1u); EXPECT_FALSE(set.add(5)); - EXPECT_EQ(set.size(), 1); + EXPECT_EQ(set.size(), 1u); } TEST(vector_set, Index) { VectorSet<int> set = {3, 6, 4}; - EXPECT_EQ(set.index_of(6), 1); - EXPECT_EQ(set.index_of(3), 0); - EXPECT_EQ(set.index_of(4), 2); + EXPECT_EQ(set.index_of(6), 1u); + EXPECT_EQ(set.index_of(3), 0u); + EXPECT_EQ(set.index_of(4), 2u); } TEST(vector_set, IndexTry) @@ -108,21 +108,21 @@ TEST(vector_set, IndexTry) TEST(vector_set, RemoveContained) { VectorSet<int> set = {4, 5, 6, 7}; - EXPECT_EQ(set.size(), 4); + EXPECT_EQ(set.size(), 4u); set.remove_contained(5); - EXPECT_EQ(set.size(), 3); + EXPECT_EQ(set.size(), 3u); EXPECT_EQ(set[0], 4); EXPECT_EQ(set[1], 7); EXPECT_EQ(set[2], 6); set.remove_contained(6); - EXPECT_EQ(set.size(), 2); + EXPECT_EQ(set.size(), 2u); EXPECT_EQ(set[0], 4); EXPECT_EQ(set[1], 7); set.remove_contained(4); - EXPECT_EQ(set.size(), 1); + EXPECT_EQ(set.size(), 1u); EXPECT_EQ(set[0], 7); set.remove_contained(7); - EXPECT_EQ(set.size(), 0); + EXPECT_EQ(set.size(), 0u); } TEST(vector_set, AddMultipleTimes) diff --git a/tests/gtests/blenlib/BLI_vector_test.cc b/tests/gtests/blenlib/BLI_vector_test.cc index 4a04d002580..4b42cc1b4af 100644 --- a/tests/gtests/blenlib/BLI_vector_test.cc +++ b/tests/gtests/blenlib/BLI_vector_test.cc @@ -8,13 +8,13 @@ using namespace blender; TEST(vector, DefaultConstructor) { Vector<int> vec; - EXPECT_EQ(vec.size(), 0); + EXPECT_EQ(vec.size(), 0u); } TEST(vector, SizeConstructor) { Vector<int> vec(3); - EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec.size(), 3u); } /** @@ -40,7 +40,7 @@ TEST(vector, TrivialTypeSizeConstructor) TEST(vector, SizeValueConstructor) { Vector<int> vec(4, 10); - EXPECT_EQ(vec.size(), 4); + EXPECT_EQ(vec.size(), 4u); EXPECT_EQ(vec[0], 10); EXPECT_EQ(vec[1], 10); EXPECT_EQ(vec[2], 10); @@ -50,7 +50,7 @@ TEST(vector, SizeValueConstructor) TEST(vector, InitializerListConstructor) { Vector<int> vec = {1, 3, 4, 6}; - EXPECT_EQ(vec.size(), 4); + EXPECT_EQ(vec.size(), 4u); EXPECT_EQ(vec[0], 1); EXPECT_EQ(vec[1], 3); EXPECT_EQ(vec[2], 4); @@ -74,7 +74,7 @@ TEST(vector, ListBaseConstructor) BLI_addtail(&list, value3); Vector<TestListValue *> vec(list); - EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec.size(), 3u); EXPECT_EQ(vec[0]->value, 4); EXPECT_EQ(vec[1]->value, 5); EXPECT_EQ(vec[2]->value, 6); @@ -92,7 +92,7 @@ TEST(vector, ContainerConstructor) list.push_front(5); Vector<int> vec = Vector<int>::FromContainer(list); - EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec.size(), 3u); EXPECT_EQ(vec[0], 5); EXPECT_EQ(vec[1], 1); EXPECT_EQ(vec[2], 3); @@ -102,7 +102,7 @@ TEST(vector, CopyConstructor) { Vector<int> vec1 = {1, 2, 3}; Vector<int> vec2(vec1); - EXPECT_EQ(vec2.size(), 3); + EXPECT_EQ(vec2.size(), 3u); EXPECT_EQ(vec2[0], 1); EXPECT_EQ(vec2[1], 2); EXPECT_EQ(vec2[2], 3); @@ -117,8 +117,8 @@ TEST(vector, CopyConstructor2) Vector<int, 2> vec1 = {1, 2, 3, 4}; Vector<int, 3> vec2(vec1); - EXPECT_EQ(vec1.size(), 4); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 4u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_NE(vec1.data(), vec2.data()); EXPECT_EQ(vec2[0], 1); EXPECT_EQ(vec2[1], 2); @@ -131,8 +131,8 @@ TEST(vector, CopyConstructor3) Vector<int, 20> vec1 = {1, 2, 3, 4}; Vector<int, 1> vec2(vec1); - EXPECT_EQ(vec1.size(), 4); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 4u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_NE(vec1.data(), vec2.data()); EXPECT_EQ(vec2[2], 3); } @@ -142,8 +142,8 @@ TEST(vector, CopyConstructor4) Vector<int, 5> vec1 = {1, 2, 3, 4}; Vector<int, 6> vec2(vec1); - EXPECT_EQ(vec1.size(), 4); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 4u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_NE(vec1.data(), vec2.data()); EXPECT_EQ(vec2[3], 4); } @@ -153,8 +153,8 @@ TEST(vector, MoveConstructor) Vector<int> vec1 = {1, 2, 3, 4}; Vector<int> vec2(std::move(vec1)); - EXPECT_EQ(vec1.size(), 0); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 0u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_EQ(vec2[0], 1); EXPECT_EQ(vec2[1], 2); EXPECT_EQ(vec2[2], 3); @@ -166,8 +166,8 @@ TEST(vector, MoveConstructor2) Vector<int, 2> vec1 = {1, 2, 3, 4}; Vector<int, 3> vec2(std::move(vec1)); - EXPECT_EQ(vec1.size(), 0); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 0u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_EQ(vec2[0], 1); EXPECT_EQ(vec2[1], 2); EXPECT_EQ(vec2[2], 3); @@ -179,8 +179,8 @@ TEST(vector, MoveConstructor3) Vector<int, 20> vec1 = {1, 2, 3, 4}; Vector<int, 1> vec2(std::move(vec1)); - EXPECT_EQ(vec1.size(), 0); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 0u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_EQ(vec2[2], 3); } @@ -189,20 +189,20 @@ TEST(vector, MoveConstructor4) Vector<int, 5> vec1 = {1, 2, 3, 4}; Vector<int, 6> vec2(std::move(vec1)); - EXPECT_EQ(vec1.size(), 0); - EXPECT_EQ(vec2.size(), 4); + EXPECT_EQ(vec1.size(), 0u); + EXPECT_EQ(vec2.size(), 4u); EXPECT_EQ(vec2[3], 4); } TEST(vector, MoveAssignment) { Vector<int> vec = {1, 2}; - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); EXPECT_EQ(vec[0], 1); EXPECT_EQ(vec[1], 2); vec = Vector<int>({5}); - EXPECT_EQ(vec.size(), 1); + EXPECT_EQ(vec.size(), 1u); EXPECT_EQ(vec[0], 5); } @@ -210,11 +210,11 @@ TEST(vector, CopyAssignment) { Vector<int> vec1 = {1, 2, 3}; Vector<int> vec2 = {4, 5}; - EXPECT_EQ(vec1.size(), 3); - EXPECT_EQ(vec2.size(), 2); + EXPECT_EQ(vec1.size(), 3u); + EXPECT_EQ(vec2.size(), 2u); vec2 = vec1; - EXPECT_EQ(vec2.size(), 3); + EXPECT_EQ(vec2.size(), 3u); vec1[0] = 7; EXPECT_EQ(vec1[0], 7); @@ -227,7 +227,7 @@ TEST(vector, Append) vec.append(3); vec.append(6); vec.append(7); - EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec.size(), 3u); EXPECT_EQ(vec[0], 3); EXPECT_EQ(vec[1], 6); EXPECT_EQ(vec[2], 7); @@ -236,40 +236,40 @@ TEST(vector, Append) TEST(vector, AppendAndGetIndex) { Vector<int> vec; - EXPECT_EQ(vec.append_and_get_index(10), 0); - EXPECT_EQ(vec.append_and_get_index(10), 1); - EXPECT_EQ(vec.append_and_get_index(10), 2); + EXPECT_EQ(vec.append_and_get_index(10), 0u); + EXPECT_EQ(vec.append_and_get_index(10), 1u); + EXPECT_EQ(vec.append_and_get_index(10), 2u); vec.append(10); - EXPECT_EQ(vec.append_and_get_index(10), 4); + EXPECT_EQ(vec.append_and_get_index(10), 4u); } TEST(vector, AppendNonDuplicates) { Vector<int> vec; vec.append_non_duplicates(4); - EXPECT_EQ(vec.size(), 1); + EXPECT_EQ(vec.size(), 1u); vec.append_non_duplicates(5); - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); vec.append_non_duplicates(4); - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); } TEST(vector, ExtendNonDuplicates) { Vector<int> vec; vec.extend_non_duplicates({1, 2}); - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); vec.extend_non_duplicates({3, 4}); - EXPECT_EQ(vec.size(), 4); + EXPECT_EQ(vec.size(), 4u); vec.extend_non_duplicates({0, 1, 2, 3}); - EXPECT_EQ(vec.size(), 5); + EXPECT_EQ(vec.size(), 5u); } TEST(vector, Fill) { Vector<int> vec(5); vec.fill(3); - EXPECT_EQ(vec.size(), 5); + EXPECT_EQ(vec.size(), 5u); EXPECT_EQ(vec[0], 3); EXPECT_EQ(vec[1], 3); EXPECT_EQ(vec[2], 3); @@ -304,9 +304,9 @@ TEST(vector, BecomeLarge) for (int i = 0; i < 100; i++) { vec.append(i * 5); } - EXPECT_EQ(vec.size(), 100); + EXPECT_EQ(vec.size(), 100u); for (uint i = 0; i < 100; i++) { - EXPECT_EQ(vec[i], i * 5); + EXPECT_EQ(vec[i], static_cast<int>(i * 5)); } } @@ -318,7 +318,7 @@ static Vector<int> return_by_value_helper() TEST(vector, ReturnByValue) { Vector<int> vec = return_by_value_helper(); - EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(vec.size(), 3u); EXPECT_EQ(vec[0], 3); EXPECT_EQ(vec[1], 5); EXPECT_EQ(vec[2], 1); @@ -327,12 +327,12 @@ TEST(vector, ReturnByValue) TEST(vector, VectorOfVectors_Append) { Vector<Vector<int>> vec; - EXPECT_EQ(vec.size(), 0); + EXPECT_EQ(vec.size(), 0u); Vector<int> v({1, 2}); vec.append(v); vec.append({7, 8}); - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); EXPECT_EQ(vec[0][0], 1); EXPECT_EQ(vec[0][1], 2); EXPECT_EQ(vec[1][0], 7); @@ -355,11 +355,11 @@ TEST(vector, VectorOfVectors_Fill) TEST(vector, RemoveLast) { Vector<int> vec = {5, 6}; - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); vec.remove_last(); - EXPECT_EQ(vec.size(), 1); + EXPECT_EQ(vec.size(), 1u); vec.remove_last(); - EXPECT_EQ(vec.size(), 0); + EXPECT_EQ(vec.size(), 0u); } TEST(vector, IsEmpty) @@ -401,7 +401,7 @@ TEST(vector, RemoveFirstOccurrenceAndReorder) vec.remove_first_occurrence_and_reorder(4); EXPECT_EQ(vec[0], 7); vec.remove_first_occurrence_and_reorder(7); - EXPECT_EQ(vec.size(), 0); + EXPECT_EQ(vec.size(), 0u); } TEST(vector, Remove) @@ -426,7 +426,7 @@ TEST(vector, ExtendSmallVector) Vector<int> a = {2, 3, 4}; Vector<int> b = {11, 12}; b.extend(a); - EXPECT_EQ(b.size(), 5); + EXPECT_EQ(b.size(), 5u); EXPECT_EQ(b[0], 11); EXPECT_EQ(b[1], 12); EXPECT_EQ(b[2], 2); @@ -441,7 +441,7 @@ TEST(vector, ExtendArray) Vector<int> a; a.extend(array, 2); - EXPECT_EQ(a.size(), 2); + EXPECT_EQ(a.size(), 2u); EXPECT_EQ(a[0], 3); EXPECT_EQ(a[1], 4); } @@ -457,7 +457,7 @@ TEST(vector, AppendNTimes) Vector<int> a; a.append_n_times(5, 3); a.append_n_times(2, 2); - EXPECT_EQ(a.size(), 5); + EXPECT_EQ(a.size(), 5u); EXPECT_EQ(a[0], 5); EXPECT_EQ(a[1], 5); EXPECT_EQ(a[2], 5); @@ -472,13 +472,13 @@ TEST(vector, UniquePtrValue) vec.append(std::unique_ptr<int>(new int())); vec.append(std::unique_ptr<int>(new int())); vec.append(std::unique_ptr<int>(new int())); - EXPECT_EQ(vec.size(), 4); + EXPECT_EQ(vec.size(), 4u); std::unique_ptr<int> &a = vec.last(); std::unique_ptr<int> b = vec.pop_last(); vec.remove_and_reorder(0); vec.remove(0); - EXPECT_EQ(vec.size(), 1); + EXPECT_EQ(vec.size(), 1u); UNUSED_VARS(a, b); } @@ -593,29 +593,29 @@ TEST(vector, Resize) { std::string long_string = "012345678901234567890123456789"; Vector<std::string> vec; - EXPECT_EQ(vec.size(), 0); + EXPECT_EQ(vec.size(), 0u); vec.resize(2); - EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec.size(), 2u); EXPECT_EQ(vec[0], ""); EXPECT_EQ(vec[1], ""); vec.resize(5, long_string); - EXPECT_EQ(vec.size(), 5); + EXPECT_EQ(vec.size(), 5u); EXPECT_EQ(vec[0], ""); EXPECT_EQ(vec[1], ""); EXPECT_EQ(vec[2], long_string); EXPECT_EQ(vec[3], long_string); EXPECT_EQ(vec[4], long_string); vec.resize(1); - EXPECT_EQ(vec.size(), 1); + EXPECT_EQ(vec.size(), 1u); EXPECT_EQ(vec[0], ""); } TEST(vector, FirstIndexOf) { Vector<int> vec = {2, 3, 5, 7, 5, 9}; - EXPECT_EQ(vec.first_index_of(2), 0); - EXPECT_EQ(vec.first_index_of(5), 2); - EXPECT_EQ(vec.first_index_of(9), 5); + EXPECT_EQ(vec.first_index_of(2), 0u); + EXPECT_EQ(vec.first_index_of(5), 2u); + EXPECT_EQ(vec.first_index_of(9), 5u); } TEST(vector, FirstIndexTryOf) |