< prev index next >

test/native/runtime/test_arguments.cpp

Print this page
rev 13107 : imported patch jvm_h
   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 "runtime/arguments.hpp"
  26 #include "unittest.hpp"
  27 #include "utilities/globalDefinitions.hpp"
  28 
  29 TEST(arguments, atojulong) {
  30   char ullong_max[32];
  31   int ret = jio_snprintf(ullong_max, sizeof(ullong_max), JULONG_FORMAT, ULLONG_MAX);
  32   ASSERT_NE(-1, ret);
  33 
  34   julong value;
  35   const char* invalid_strings[] = {
  36     "", "-1", "-100", " 1", "2 ", "3 2", "1.0",
  37     "0x4.5", "0x", "0x0x1" "0.001", "4e10", "e"
  38     "K", "M", "G", "1MB", "1KM", "AA", "0B",
  39     "18446744073709551615K", "17179869184G",
  40     "999999999999999999999999999999"
  41   };
  42   for (uint i = 0; i < ARRAY_SIZE(invalid_strings); i++) {
  43     ASSERT_FALSE(Arguments::atojulong(invalid_strings[i], &value))
  44         << "Invalid string '" << invalid_strings[i] << "' parsed without error.";


   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 "prims/jvm.h"
  26 #include "runtime/arguments.hpp"
  27 #include "unittest.hpp"
  28 #include "utilities/globalDefinitions.hpp"
  29 
  30 TEST(arguments, atojulong) {
  31   char ullong_max[32];
  32   int ret = jio_snprintf(ullong_max, sizeof(ullong_max), JULONG_FORMAT, ULLONG_MAX);
  33   ASSERT_NE(-1, ret);
  34 
  35   julong value;
  36   const char* invalid_strings[] = {
  37     "", "-1", "-100", " 1", "2 ", "3 2", "1.0",
  38     "0x4.5", "0x", "0x0x1" "0.001", "4e10", "e"
  39     "K", "M", "G", "1MB", "1KM", "AA", "0B",
  40     "18446744073709551615K", "17179869184G",
  41     "999999999999999999999999999999"
  42   };
  43   for (uint i = 0; i < ARRAY_SIZE(invalid_strings); i++) {
  44     ASSERT_FALSE(Arguments::atojulong(invalid_strings[i], &value))
  45         << "Invalid string '" << invalid_strings[i] << "' parsed without error.";


< prev index next >