(root)/
diffutils-3.10/
gnulib-tests/
test-year2038.c
       1  /* Test of year2038 module.
       2     Copyright (C) 2023 Free Software Foundation, Inc.
       3  
       4     This program is free software: you can redistribute it and/or modify
       5     it under the terms of the GNU General Public License as published by
       6     the Free Software Foundation, either version 3 of the License, or
       7     (at your option) any later version.
       8  
       9     This program is distributed in the hope that it will be useful,
      10     but WITHOUT ANY WARRANTY; without even the implied warranty of
      11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12     GNU General Public License for more details.
      13  
      14     You should have received a copy of the GNU General Public License
      15     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      16  
      17  /* Written by Bruno Haible <bruno@clisp.org>, 2023.  */
      18  
      19  /* This test fails if AC_SYS_YEAR2038 could not arrange for a time_t
      20     that supports values > 2147483647.
      21     This can happen
      22       - on systems that are not year 2038 safe, or
      23       - if the user specified --disable-year2038 at configure time.
      24     It is intended that this test fails in these circumstances.  */
      25  
      26  #include <config.h>
      27  
      28  #include <sys/types.h>
      29  #include "intprops.h"
      30  
      31  /* Although this test could be done with static_assert, the test
      32     harness prefers dynamic checking.  */
      33  
      34  int
      35  main (void)
      36  {
      37    /* Check the range of time_t.  */
      38    return TYPE_MAXIMUM (time_t) >> 31 == 0;
      39  }