[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
math.h test
From: |
Matti Ilgmann |
Subject: |
math.h test |
Date: |
Sun, 24 Apr 2005 15:06:07 +0200 |
Hi,
I have written a few lines to test math.h. I am not a programmer, so
please tell me
wether these lines are OK. I will then complete the test. On my
system a "make check"
has this output:
make check-TESTS
make[1]: Entering directory `/home/matti/hurd-l4/libl4/tests'
PASS: t-l4-kip
PASS: t-l4-message
PASS: t-l4-math
==================
All 3 tests passed
==================
make[1]: Leaving directory `/home/matti/hurd-l4/libl4/tests'
Thanks,
Matti
Here is the code:
/* t-l4-math.c -
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU L4 library.
The GNU L4 library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
The GNU L4 library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU L4 library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <limits.h>
/* This must be included before any libl4 header. */
#include "environment.h"
#include <l4/math.h>
void
test_msb_const ()
{
#ifdef _L4_INTERFACE_INTERN
check_nr ("[intern]", "test_msb_const", _L4_msb (0), 0);
check_nr ("[intern]", "test_msb_const", _L4_msb (1), 1);
check_nr ("[intern]", "test_msb_const", _L4_msb (2), 2);
check_nr ("[intern]", "test_msb_const", _L4_msb (3), 2);
check_nr ("[intern]", "test_msb_const", _L4_msb (65535), 16);
check_nr ("[intern]", "test_msb_const", _L4_msb (65536), 17);
check_nr ("[intern]", "test_msb_const", _L4_msb (LONG_MAX),
_L4_WORDSIZE-1);
#endif
#ifdef _L4_INTERFACE_GNU
check_nr ("[gnu]", "test_msb_const", l4_msb (0), 0);
check_nr ("[gnu]", "test_msb_const", l4_msb (1), 1);
check_nr ("[gnu]", "test_msb_const", _L4_msb (LONG_MAX),
_L4_WORDSIZE-1);
#endif
#ifdef _L4_INTERFACE_L4
#endif
}
void
test_msb (_L4_word_t data, _L4_word_t exp)
{
#ifdef _L4_INTERFACE_INTERN
check_nr ("[intern]", "test_msb", _L4_msb (data), exp);
#endif
#ifdef _L4_INTERFACE_GNU
#endif
#ifdef _L4_INTERFACE_L4
#endif
}
void
test (void)
{
_L4_word_t data = 0, k = 0;
test_msb_const ();
test_msb (data, k);
for (data=1,k=1;k<_L4_WORDSIZE;data*=2,k++)
{
test_msb (data, k);
}
}
- math.h test,
Matti Ilgmann <=