//----------------------------------------------------------------------------// // // // ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation // // and distributed under the MIT License (MIT). // // // // Copyright (c) Guillaume Blanc // // // // Permission is hereby granted, free of charge, to any person obtaining a // // copy of this software and associated documentation files (the "Software"), // // to deal in the Software without restriction, including without limitation // // the rights to use, copy, modify, merge, publish, distribute, sublicense, // // and/or sell copies of the Software, and to permit persons to whom the // // Software is furnished to do so, subject to the following conditions: // // // // The above copyright notice and this permission notice shall be included in // // all copies or substantial portions of the Software. // // // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // // DEALINGS IN THE SOFTWARE. // // // //----------------------------------------------------------------------------// #include "ozz/base/containers/intrusive_list.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4127) // constant conditional expression #endif // _MSC_VER #include #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER #include #include #include "gtest/gtest.h" #include "ozz/base/gtest_helper.h" // using-declaration of IntrusiveList type and its options using ozz::containers::IntrusiveList; using ozz::containers::Option; // Test whether assertion compliance tests can be ran on the container specified // as template argument. // The default implementation allows to run all tests. template struct TestAssertCompliance { enum { kValue = 1 }; }; // Check compiler settings for std/crt debug level availability. #if defined(_MSC_VER) #define HAS_STD_ASSERTION 1 // Win32 std lib has debug option. #elif defined(__GNUC__) && defined(_GLIBCXX_DEBUG) #define HAS_STD_ASSERTION 1 // _GLIBCXX_DEBUG enables GCC Libc debug option. #else #define HAS_STD_ASSERTION 0 // Disabled by default. #endif // Specializes for std::list, according to compilation settings. template struct TestAssertCompliance> { enum { kValue = HAS_STD_ASSERTION }; }; // Defines a test object that inherits from IntrusiveList::Hook in order to be // listed by an IntrusiveList. // Every instance is assigned a value (obtained for a global instance counter) // used for instance sorting and comparison. template > class TestObj1 : public IntrusiveList, _Options0>::Hook { public: // Constructs a TestObj1 and increments global TestObj1 counter. TestObj1() : instance_(s_instance_counter_++) {} // Does not copy the Node itself, just maintains the assigned instance number. TestObj1( TestObj1 const& _r) // NOLINT cannot be explicit as used by std::list : IntrusiveList, _Options0>::Hook(), instance_(_r.instance_) {} // Implements comparison operators. bool operator==(TestObj1 const& _r) const { return instance_ == _r.instance_; } bool operator<(TestObj1 const& _r) const { return instance_ < _r.instance_; } bool operator>(TestObj1 const& _r) const { return instance_ > _r.instance_; } private: // Disallows assignment operator. void operator=(TestObj1 const& _r); // Assigned instance value. const int instance_; // TestObj1 instance counter. static int s_instance_counter_; }; template int TestObj1<_Options0>::s_instance_counter_ = 0; // Defines a test object that inherits from TestObj1 in order to be listed by // two IntrusiveList at a time. template class TestObj2 : public TestObj1<_Options1>, public IntrusiveList, _Options2>::Hook { public: // Constructs a default TestObj2. TestObj2() {} // Does not copy the Node itself, just maintains the assigned instance number. explicit TestObj2(TestObj2 const& _r) : TestObj1<_Options1>(_r), IntrusiveList, _Options2>::Hook() {} }; // Applies the _Test function to some std::list<> and Intrusive<> types. template