Line data Source code
1 : // Copyright 2024 Accenture. 2 : 3 : #include "estd/algorithm.h" 4 : 5 : #include "estd/array.h" 6 : #include "estd/deque.h" 7 : #include "estd/vector.h" 8 : 9 : #include <gtest/gtest.h> 10 : 11 : namespace 12 : { 13 1 : void Usage() 14 : { 15 : // EXAMPLE_START container 16 : // example to create container c from array 17 1 : ::estd::array<int32_t, 3> c = {{1, 2, 3}}; 18 : 19 : // example to create container c from vector 20 1 : ::estd::declare::vector<int32_t, 10U> c0; 21 : 22 : // example to create container c1 from deque 23 1 : ::estd::declare::deque<int32_t, 10U> c1; 24 : 25 : // Checks if all of the value in array c are equal to 1. 26 1 : ::estd::all_of(c.cbegin(), c.cend(), ::estd::equals<int32_t>(1)); 27 : 28 : // Checks if all of the value in vector c0 are equal to 1. 29 1 : ::estd::all_of(c0.cbegin(), c0.cend(), ::estd::equals<int32_t>(1)); 30 : 31 : // Checks if all of the value in deque c1 are equal to 1. 32 1 : ::estd::all_of(c1.cbegin(), c1.cend(), ::estd::equals<int32_t>(1)); 33 1 : c1.push_back(1); // appending value to the container c1 34 : 35 : // Returns the minimum value of two integers which is 10U. 36 1 : ::estd::min(15U, 10U); 37 : // Returns the maximum value of two integers which is 15U. 38 1 : ::estd::max(15U, 10U); 39 : // Swaps the values of two variables. 40 1 : uint16_t a = 1, b = 2; 41 1 : ::estd::swap(a, b); 42 : // Check all of the elements in container equals to 1. 43 1 : ::estd::all_of(c.cbegin(), c.cend(), ::estd::equals<int32_t>(1)); 44 : // Check if all of the elements in container not equals to 1. 45 : ::estd::all_of(c.cbegin(), c.cend(), ::estd::not_equals<int32_t>(1)); 46 : // Check if all of the elements in container are greater than a certain value(0). 47 : ::estd::all_of(c.cbegin(), c.cend(), ::estd::greater1<int32_t>(0)); 48 : // Check if all of the elements in container are less than a certain value(0). 49 : ::estd::all_of(c.cbegin(), c.cend(), ::estd::less1<int32_t>(10)); 50 : ::estd::any_of(c.cbegin(), c.cend(), ::estd::equals<int32_t>(1)); 51 1 : ::estd::none_of(c.cbegin(), c.cend(), ::estd::equals<int32_t>(-1)); 52 : // EXAMPLE_END container 53 1 : } 54 : } // namespace 55 : 56 3 : TEST(algorithm_test, run_examples) { Usage(); }