< prev index next >

test/native/utilities/test_align.cpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"

  25 #include "utilities/formatBuffer.hpp"
  26 #include "utilities/globalDefinitions.hpp"
  27 #include "unittest.hpp"
  28 
  29 #include <limits>
  30 
  31 // A few arbitrarily chosen values to test the align functions on.
  32 static uint64_t values[] = {1, 3, 10, 345, 1023, 1024, 1025, 23909034, INT_MAX, uint64_t(-1) / 2, uint64_t(-1) / 2 + 100, -1 };
  33 
  34 template <typename T>
  35 static T max_alignment() {
  36   T max = std::numeric_limits<T>::max();
  37   return max ^ (max >> 1);
  38 }
  39 
  40 #define log(...) SCOPED_TRACE(err_msg(__VA_ARGS__).buffer())
  41 
  42 template <typename T, typename A>
  43 static void test_alignments() {
  44   log("### Test: %c" SIZE_FORMAT " " UINT64_FORMAT " : %c" SIZE_FORMAT " " UINT64_FORMAT " ###\n",




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "utilities/align.hpp"
  26 #include "utilities/formatBuffer.hpp"
  27 #include "utilities/globalDefinitions.hpp"
  28 #include "unittest.hpp"
  29 
  30 #include <limits>
  31 
  32 // A few arbitrarily chosen values to test the align functions on.
  33 static uint64_t values[] = {1, 3, 10, 345, 1023, 1024, 1025, 23909034, INT_MAX, uint64_t(-1) / 2, uint64_t(-1) / 2 + 100, -1 };
  34 
  35 template <typename T>
  36 static T max_alignment() {
  37   T max = std::numeric_limits<T>::max();
  38   return max ^ (max >> 1);
  39 }
  40 
  41 #define log(...) SCOPED_TRACE(err_msg(__VA_ARGS__).buffer())
  42 
  43 template <typename T, typename A>
  44 static void test_alignments() {
  45   log("### Test: %c" SIZE_FORMAT " " UINT64_FORMAT " : %c" SIZE_FORMAT " " UINT64_FORMAT " ###\n",


< prev index next >