|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
* Regression test
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#include "triodef.h"
|
|
Packit Service |
8f0814 |
#if defined(TRIO_COMPILER_ANCIENT)
|
|
Packit Service |
8f0814 |
# include <varargs.h>
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
# include <stdarg.h>
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#include <math.h>
|
|
Packit Service |
8f0814 |
#include <limits.h>
|
|
Packit Service |
8f0814 |
#include <float.h>
|
|
Packit Service |
8f0814 |
#include <errno.h>
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#include "trio.h"
|
|
Packit Service |
8f0814 |
#include "triop.h"
|
|
Packit Service |
8f0814 |
#if defined(TRIO_EMBED_NAN)
|
|
Packit Service |
8f0814 |
# define TRIO_PUBLIC_NAN static
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_NINF
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_PINF
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_NAN
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_ISINF
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_ISNAN
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_NZERO
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#include "trionan.h"
|
|
Packit Service |
8f0814 |
#if defined(TRIO_EMBED_STRING)
|
|
Packit Service |
8f0814 |
# define TRIO_PUBLIC_STRING static
|
|
Packit Service |
8f0814 |
# define TRIO_FUNC_EQUAL_CASE
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#include "triostr.h"
|
|
Packit Service |
8f0814 |
#undef printf
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_WIDECHAR
|
|
Packit Service |
8f0814 |
# include <wchar.h>
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#define QUOTE(x) #x
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#define DOUBLE_EQUAL(x,y) (((x)>(y)-DBL_EPSILON) && ((x)<(y)+DBL_EPSILON))
|
|
Packit Service |
8f0814 |
#define FLOAT_EQUAL(x,y) (((x)>(y)-FLT_EPSILON) && ((x)<(y)+FLT_EPSILON))
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
static TRIO_CONST char rcsid[] = "@(#)$Id: regression.c,v 1.54 2005/12/25 11:06:57 breese Exp $";
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if defined(TRIO_EMBED_NAN)
|
|
Packit Service |
8f0814 |
# include "trionan.c"
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#if defined(TRIO_EMBED_STRING)
|
|
Packit Service |
8f0814 |
# include "triostr.c"
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
static void
|
|
Packit Service |
8f0814 |
Dump
|
|
Packit Service |
8f0814 |
TRIO_ARGS2((buffer, rc),
|
|
Packit Service |
8f0814 |
char *buffer,
|
|
Packit Service |
8f0814 |
int rc)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
if (rc < 0)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
printf("Err = %d (%s), Pos = %d\n",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
else if (buffer)
|
|
Packit Service |
8f0814 |
printf("buffer[% 3d] = \"%s\"\n", rc, buffer);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
static void
|
|
Packit Service |
8f0814 |
Report0
|
|
Packit Service |
8f0814 |
TRIO_ARGS2((file, line),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
printf("Verification failed in %s:%d.\n", file, line);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
static void
|
|
Packit Service |
8f0814 |
Report
|
|
Packit Service |
8f0814 |
TRIO_ARGS4((file, line, expected, got),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *expected,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *got)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
Report0(file, line);
|
|
Packit Service |
8f0814 |
printf(" Expected \"%s\"\n", expected);
|
|
Packit Service |
8f0814 |
printf(" Got \"%s\"\n", got);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
Verify
|
|
Packit Service |
8f0814 |
TRIO_VARGS5((file, line, result, fmt, va_alist),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *result,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *fmt,
|
|
Packit Service |
8f0814 |
TRIO_VA_DECL)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int rc;
|
|
Packit Service |
8f0814 |
va_list args;
|
|
Packit Service |
8f0814 |
char buffer[4096];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
TRIO_VA_START(args, fmt);
|
|
Packit Service |
8f0814 |
rc = trio_vsnprintf(buffer, sizeof(buffer), fmt, args);
|
|
Packit Service |
8f0814 |
if (rc < 0)
|
|
Packit Service |
8f0814 |
Dump(buffer, rc);
|
|
Packit Service |
8f0814 |
TRIO_VA_END(args);
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, buffer))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
Report(file, line, result, buffer);
|
|
Packit Service |
8f0814 |
return 1;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
return 0;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyReturnValues(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
int rc;
|
|
Packit Service |
8f0814 |
int count;
|
|
Packit Service |
8f0814 |
char *expected;
|
|
Packit Service |
8f0814 |
char buffer[4096];
|
|
Packit Service |
8f0814 |
char result[4096];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
rc = trio_sprintf(buffer, "%s%n", "0123456789", &count);
|
|
Packit Service |
8f0814 |
trio_sprintf(result, "%d %d %s", rc, count, buffer);
|
|
Packit Service |
8f0814 |
expected = "10 10 0123456789";
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, expected))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, expected, result);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "%s%n", "0123456789", &count);
|
|
Packit Service |
8f0814 |
trio_sprintf(result, "%d %d %s", rc, count, buffer);
|
|
Packit Service |
8f0814 |
expected = "10 10 0123456789";
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, expected))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, expected, result);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, 4, "%s%n", "0123456789", &count);
|
|
Packit Service |
8f0814 |
trio_sprintf(result, "%d %d %s", rc, count, buffer);
|
|
Packit Service |
8f0814 |
expected = "10 3 012";
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, expected))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, expected, result);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* The output buffer contains the empty string */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, 1, "%s%n", "0123456789", &count);
|
|
Packit Service |
8f0814 |
trio_sprintf(result, "%d %d %s", rc, count, buffer);
|
|
Packit Service |
8f0814 |
expected = "10 0 ";
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, expected))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, expected, result);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* The output buffer should be left untouched when max size is 0 */
|
|
Packit Service |
8f0814 |
trio_sprintf(buffer, "DO NOT TOUCH");
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, 0, "%s%n", "0123456789", &count);
|
|
Packit Service |
8f0814 |
trio_sprintf(result, "%d %d %s", rc, count, buffer);
|
|
Packit Service |
8f0814 |
expected = "10 0 DO NOT TOUCH";
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(result, expected))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, expected, result);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
#define TEST_STRING "0123456789"
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyAllocate(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_DYNAMICSTRING
|
|
Packit Service |
8f0814 |
int rc;
|
|
Packit Service |
8f0814 |
char *string;
|
|
Packit Service |
8f0814 |
int count;
|
|
Packit Service |
8f0814 |
int test_size = sizeof(TEST_STRING) - 1;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Allocate a string with the result */
|
|
Packit Service |
8f0814 |
rc = trio_asprintf(&string, "%s%n", TEST_STRING, &count);
|
|
Packit Service |
8f0814 |
if (rc < 0)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Dump(string, rc);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
else if (count != test_size)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
printf("Validation failed in %s:%d\n", __FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
printf(" Expected %%n = %d\n", test_size);
|
|
Packit Service |
8f0814 |
printf(" Got %%n = %d\n", count);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
else if (!trio_equal_case(string, TEST_STRING))
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report(__FILE__, __LINE__, TEST_STRING, string);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (string)
|
|
Packit Service |
8f0814 |
free(string);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyFormatting(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
char buffer[256];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Normal text */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Hello world",
|
|
Packit Service |
8f0814 |
"Hello world");
|
|
Packit Service |
8f0814 |
/* String */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Hello world",
|
|
Packit Service |
8f0814 |
"%s", "Hello world");
|
|
Packit Service |
8f0814 |
/* Pointer */
|
|
Packit Service |
8f0814 |
if (sizeof(void *) == 4)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Pointer 0x01234567",
|
|
Packit Service |
8f0814 |
"Pointer %p", 0x1234567);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
else if (sizeof(void *) == 8)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Pointer 0x0123456789012345",
|
|
Packit Service |
8f0814 |
"Pointer %p", 0x123456789012345);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
/* Nil pointer */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Pointer (nil)",
|
|
Packit Service |
8f0814 |
"Pointer %p", NULL);
|
|
Packit Service |
8f0814 |
/* Integer */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number 42",
|
|
Packit Service |
8f0814 |
"Number %d", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number -42",
|
|
Packit Service |
8f0814 |
"Number %d", -42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number 42",
|
|
Packit Service |
8f0814 |
"Number %ld", 42L);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number -42",
|
|
Packit Service |
8f0814 |
"Number %ld", -42L);
|
|
Packit Service |
8f0814 |
/* Integer width */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1234",
|
|
Packit Service |
8f0814 |
"%6d", 1234);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1234",
|
|
Packit Service |
8f0814 |
"%*d", 6, 1234);
|
|
Packit Service |
8f0814 |
/* Integer width overrun */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "123456",
|
|
Packit Service |
8f0814 |
"%4d", 123456);
|
|
Packit Service |
8f0814 |
/* Integer precision */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0012",
|
|
Packit Service |
8f0814 |
"%.4d", 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0012",
|
|
Packit Service |
8f0814 |
"%.*d", 4, 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0012",
|
|
Packit Service |
8f0814 |
"%6.*d", 4, 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0012",
|
|
Packit Service |
8f0814 |
"%*.*d", 6, 4, 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0012",
|
|
Packit Service |
8f0814 |
"%*.*.*d", 6, 4, 2, 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0012",
|
|
Packit Service |
8f0814 |
"%*.*.*i", 6, 4, 10, 12);
|
|
Packit Service |
8f0814 |
/* Integer sign, zero-padding, and width */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "+01234",
|
|
Packit Service |
8f0814 |
"%+06d", 1234);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 01234",
|
|
Packit Service |
8f0814 |
"% 06d", 1234);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "+01234",
|
|
Packit Service |
8f0814 |
"% +06d", 1234);
|
|
Packit Service |
8f0814 |
/* Integer adjust, zero-padding, and width */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "12 ",
|
|
Packit Service |
8f0814 |
"%-08d", 12);
|
|
Packit Service |
8f0814 |
/* Integer zero-padding, width, and precision */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 000012",
|
|
Packit Service |
8f0814 |
"%08.6d", 12);
|
|
Packit Service |
8f0814 |
/* Integer base */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%u", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-1",
|
|
Packit Service |
8f0814 |
"%d", -1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "52",
|
|
Packit Service |
8f0814 |
"%o", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "052",
|
|
Packit Service |
8f0814 |
"%#o", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0",
|
|
Packit Service |
8f0814 |
"%#o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2a",
|
|
Packit Service |
8f0814 |
"%x", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2A",
|
|
Packit Service |
8f0814 |
"%X", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0x2a",
|
|
Packit Service |
8f0814 |
"%#x", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0X2A",
|
|
Packit Service |
8f0814 |
"%#X", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0x00c ",
|
|
Packit Service |
8f0814 |
"%-#6.3x", 12);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "",
|
|
Packit Service |
8f0814 |
"%.d", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "",
|
|
Packit Service |
8f0814 |
"%#.d", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%.d", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "",
|
|
Packit Service |
8f0814 |
"%.o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0000",
|
|
Packit Service |
8f0814 |
"%8.4o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0",
|
|
Packit Service |
8f0814 |
"%8o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "00000000",
|
|
Packit Service |
8f0814 |
"%08o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0",
|
|
Packit Service |
8f0814 |
"%#.o", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "52",
|
|
Packit Service |
8f0814 |
"%.o", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "",
|
|
Packit Service |
8f0814 |
"%.x", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "",
|
|
Packit Service |
8f0814 |
"%#.x", 0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2a",
|
|
Packit Service |
8f0814 |
"%.x", 42);
|
|
Packit Service |
8f0814 |
sprintf(buffer, "%u", UINT_MAX);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, buffer,
|
|
Packit Service |
8f0814 |
"%u", -1);
|
|
Packit Service |
8f0814 |
sprintf(buffer, "%x", UINT_MAX);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, buffer,
|
|
Packit Service |
8f0814 |
"%x", -1);
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
/* Double */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.000000",
|
|
Packit Service |
8f0814 |
"%f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.500000",
|
|
Packit Service |
8f0814 |
"%f", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3.141000e+03",
|
|
Packit Service |
8f0814 |
"%e", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " -2.3420e-02",
|
|
Packit Service |
8f0814 |
"%16.4e", -2.342E-02);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " -2.3420e-22",
|
|
Packit Service |
8f0814 |
"%16.4e", -2.342E-22);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 2.3420e-02",
|
|
Packit Service |
8f0814 |
"% 16.4e", 2.342E-02);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 2.3420e-02",
|
|
Packit Service |
8f0814 |
"% 1.4e", 2.342E-02);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3.141000E-44",
|
|
Packit Service |
8f0814 |
"%E", 3.141e-44);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0",
|
|
Packit Service |
8f0814 |
"%g", 0.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-0",
|
|
Packit Service |
8f0814 |
"%g", trio_nzero());
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.5",
|
|
Packit Service |
8f0814 |
"%g", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3.1415E-06",
|
|
Packit Service |
8f0814 |
"%G", 3.1415e-6);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "+3141.000000",
|
|
Packit Service |
8f0814 |
"%+f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-3141.000000",
|
|
Packit Service |
8f0814 |
"%+f", -3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.333333",
|
|
Packit Service |
8f0814 |
"%f", 1.0/3.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.666667",
|
|
Packit Service |
8f0814 |
"%f", 2.0/3.0);
|
|
Packit Service |
8f0814 |
/* Beyond accuracy */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.000000",
|
|
Packit Service |
8f0814 |
"%f", 1.234567890123456789e-20);
|
|
Packit Service |
8f0814 |
# if defined(TRIO_BREESE)
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.3999999999999999111821580299875",
|
|
Packit Service |
8f0814 |
"%.32g", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.39999999999999991118215802998748",
|
|
Packit Service |
8f0814 |
"%.32f", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.3999999999999999111821580300",
|
|
Packit Service |
8f0814 |
"%.28f", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.399999999999999911182158",
|
|
Packit Service |
8f0814 |
"%.24f", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.39999999999999991",
|
|
Packit Service |
8f0814 |
"%.17f", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.40000000000000",
|
|
Packit Service |
8f0814 |
"%.14f", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "39413.800000000002910383045673370361",
|
|
Packit Service |
8f0814 |
"%.30f", 39413.80);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
/* 2^-1 + 2^-15 */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.500030517578125",
|
|
Packit Service |
8f0814 |
"%.*g", DBL_DIG + 10, 0.500030517578125);
|
|
Packit Service |
8f0814 |
/* Double decimal point */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141",
|
|
Packit Service |
8f0814 |
"%.0f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3142",
|
|
Packit Service |
8f0814 |
"%.0f", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141",
|
|
Packit Service |
8f0814 |
"%.f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "12",
|
|
Packit Service |
8f0814 |
"%.f", 12.34);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.000",
|
|
Packit Service |
8f0814 |
"%.3f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.000000",
|
|
Packit Service |
8f0814 |
"%#f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.0000",
|
|
Packit Service |
8f0814 |
"%#.4f", 0.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.000",
|
|
Packit Service |
8f0814 |
"%#.4g", 0.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.001000",
|
|
Packit Service |
8f0814 |
"%#.4g", 1e-3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.0000",
|
|
Packit Service |
8f0814 |
"%#.4f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.",
|
|
Packit Service |
8f0814 |
"%#.0f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3141.",
|
|
Packit Service |
8f0814 |
"%#.f", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "11.0000",
|
|
Packit Service |
8f0814 |
"%#.4f", 11.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "100.00",
|
|
Packit Service |
8f0814 |
"%.2f", 99.9999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3e+03",
|
|
Packit Service |
8f0814 |
"%.e", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3.e+03",
|
|
Packit Service |
8f0814 |
"%#.e", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.23457e+06",
|
|
Packit Service |
8f0814 |
"%g", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1e+02",
|
|
Packit Service |
8f0814 |
"%.2g", 99.9999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.0e+02",
|
|
Packit Service |
8f0814 |
"%#.2g", 99.9999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.123",
|
|
Packit Service |
8f0814 |
"%0g", 0.123);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.00e+00",
|
|
Packit Service |
8f0814 |
"%.2e", 0.9999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1",
|
|
Packit Service |
8f0814 |
"%.2g", 0.9999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2",
|
|
Packit Service |
8f0814 |
"%.0g", 1.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2",
|
|
Packit Service |
8f0814 |
"%.g", 1.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.01",
|
|
Packit Service |
8f0814 |
"%.2g", 0.01);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.010",
|
|
Packit Service |
8f0814 |
"%#.2g", 0.01);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1e-04",
|
|
Packit Service |
8f0814 |
"%5.g", 0.999999e-4);
|
|
Packit Service |
8f0814 |
/* Double width and precision */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1e-05",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e-5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.0001",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e-4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.001",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e-3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.01",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e-2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.1",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e-1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 10",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 100",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1000",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 10000",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1e+05",
|
|
Packit Service |
8f0814 |
"%11.5g", 1e5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e-05",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e-4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.00099",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e-3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.0099",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e-2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.099",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e-1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.99",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 99",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+02",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+03",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+04",
|
|
Packit Service |
8f0814 |
"%11.2g", 0.99e5);
|
|
Packit Service |
8f0814 |
/* Double width, precision, and alternative */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1.0000e-05",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e-5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.00010000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e-4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.0010000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e-3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.010000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e-2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.10000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e-1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1.0000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 10.000",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 100.00",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1000.0",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 10000.",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 1.0000e+05",
|
|
Packit Service |
8f0814 |
"%#11.5g", 1e5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e-05",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e-4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.00099",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e-3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.0099",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e-2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.099",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e-1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 0.99",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e1);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 99.",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+02",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e3);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+03",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 9.9e+04",
|
|
Packit Service |
8f0814 |
"%#11.2g", 0.99e5);
|
|
Packit Service |
8f0814 |
/* Double width, precision, and zero padding */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "00003.141500e+03",
|
|
Packit Service |
8f0814 |
"%016e", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 3.141500e+03",
|
|
Packit Service |
8f0814 |
"%16e", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "3.141500e+03 ",
|
|
Packit Service |
8f0814 |
"%-16e", 3141.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "03.142e+03",
|
|
Packit Service |
8f0814 |
"%010.3e", 3141.5);
|
|
Packit Service |
8f0814 |
#if !defined(TRIO_COMPILER_ANCIENT)
|
|
Packit Service |
8f0814 |
/* Long double */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.400000",
|
|
Packit Service |
8f0814 |
"%Lf", 1.4L);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Special cases */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.00",
|
|
Packit Service |
8f0814 |
"%.2f", 0.999);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "100",
|
|
Packit Service |
8f0814 |
"%.0f", 99.9);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "inf",
|
|
Packit Service |
8f0814 |
"%f", trio_pinf());
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-inf",
|
|
Packit Service |
8f0814 |
"%f", trio_ninf());
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "INF",
|
|
Packit Service |
8f0814 |
"%F", trio_pinf());
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-INF",
|
|
Packit Service |
8f0814 |
"%F", trio_ninf());
|
|
Packit Service |
8f0814 |
/* May fail if NaN is unsupported */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "nan",
|
|
Packit Service |
8f0814 |
"%f", trio_nan());
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "NAN",
|
|
Packit Service |
8f0814 |
"%F", trio_nan());
|
|
Packit Service |
8f0814 |
#endif /* TRIO_FEATURE_FLOAT */
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Char width alignment */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Char X .",
|
|
Packit Service |
8f0814 |
"Char %-4c.", 'X');
|
|
Packit Service |
8f0814 |
/* String width / precision */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " testing",
|
|
Packit Service |
8f0814 |
"%8s", "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "testing ",
|
|
Packit Service |
8f0814 |
"%-8s", "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " testing",
|
|
Packit Service |
8f0814 |
"%*s", 8, "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "testing ",
|
|
Packit Service |
8f0814 |
"%*s", -8, "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "test",
|
|
Packit Service |
8f0814 |
"%.4s", "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "test",
|
|
Packit Service |
8f0814 |
"%.*s", 4, "testing");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "testing",
|
|
Packit Service |
8f0814 |
"%.*s", -4, "testing");
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_POSITIONAL
|
|
Packit Service |
8f0814 |
/* Positional */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "222 111",
|
|
Packit Service |
8f0814 |
"%2$s %1$s", "111", "222");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "123456 12345 0001234 00123",
|
|
Packit Service |
8f0814 |
"%4$d %3$*8$d %2$.*7$d %1$*6$.*5$d",
|
|
Packit Service |
8f0814 |
123, 1234, 12345, 123456, 5, 6, 7, 8);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SIZE_T_UPPER
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "256",
|
|
Packit Service |
8f0814 |
"%Zd", sizeof(buffer));
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRNO
|
|
Packit Service |
8f0814 |
errno = EINTR;
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Interrupted system call",
|
|
Packit Service |
8f0814 |
"%m");
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_QUAD
|
|
Packit Service |
8f0814 |
# if defined(TRIO_COMPILER_SUPPORTS_LL)
|
|
Packit Service |
8f0814 |
/* This may fail if the preprocessor does not recognize LL */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%qd", 42LL);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_HEXFLOAT
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0x2.ap+4",
|
|
Packit Service |
8f0814 |
"%a", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-0x2.ap+4",
|
|
Packit Service |
8f0814 |
"%a", -42.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0x1.8p+0",
|
|
Packit Service |
8f0814 |
"%a", 1.5);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0x1.6666666666666p+0",
|
|
Packit Service |
8f0814 |
"%a", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0xc.45p+8",
|
|
Packit Service |
8f0814 |
"%a", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0XC.45P+8",
|
|
Packit Service |
8f0814 |
"%A", 3141.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0xb.351c434a98fa8p-148",
|
|
Packit Service |
8f0814 |
"%a", 3.141e-44);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SIZE_T
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "256",
|
|
Packit Service |
8f0814 |
"%zd", sizeof(buffer));
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_PTRDIFF_T
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%td", 42);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_INTMAX_T
|
|
Packit Service |
8f0814 |
# if defined(TRIO_COMPILER_SUPPORTS_LL)
|
|
Packit Service |
8f0814 |
/* Some compilers may not handle the LL suffix correctly */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%jd", 42LL);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_WIDECHAR
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Hello World",
|
|
Packit Service |
8f0814 |
"%ls", L"Hello World");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "\\aHello World",
|
|
Packit Service |
8f0814 |
"%#ls", L"\aHello World");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "A",
|
|
Packit Service |
8f0814 |
"%lc", L'A');
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "\\a",
|
|
Packit Service |
8f0814 |
"%#lc", L'\a');
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FIXED_SIZE
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%I8d", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "ffffffff",
|
|
Packit Service |
8f0814 |
"%I16x", -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_EXTENSION
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, " 42 86",
|
|
Packit Service |
8f0814 |
"%!4d %d", 42, 86);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0042 0086",
|
|
Packit Service |
8f0814 |
"%!04d %d", 42, 86);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%&d", sizeof(long), 42L);
|
|
Packit Service |
8f0814 |
/* Non-printable string */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "NonPrintable \\x01 \\a \\\\",
|
|
Packit Service |
8f0814 |
"NonPrintable %#s", "\01 \07 \\");
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "\\a \\b \\t \\n \\v \\f \\r",
|
|
Packit Service |
8f0814 |
"%#s", "\007 \010 \011 \012 \013 \014 \015");
|
|
Packit Service |
8f0814 |
/* Quote flag */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Another \"quoted\" string",
|
|
Packit Service |
8f0814 |
"Another %'s string", "quoted");
|
|
Packit Service |
8f0814 |
/* Integer base */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number 42 == 1120 (base 3)",
|
|
Packit Service |
8f0814 |
"Number %d == %..3i (base 3)", 42, 42);
|
|
Packit Service |
8f0814 |
/* Integer base (specifier base must be used instead of base modifier) */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%..3d", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "52",
|
|
Packit Service |
8f0814 |
"%..3o", 42);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "2a",
|
|
Packit Service |
8f0814 |
"%..3x", 42);
|
|
Packit Service |
8f0814 |
/* Integer thousand separator */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number 100",
|
|
Packit Service |
8f0814 |
"Number %'d", 100);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Number 1,000,000",
|
|
Packit Service |
8f0814 |
"Number %'d", 1000000);
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
/* Float thousand separator */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "31,415.200000",
|
|
Packit Service |
8f0814 |
"%'f", 31415.2);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1,000,000.000000",
|
|
Packit Service |
8f0814 |
"%'f", 1000000.0);
|
|
Packit Service |
8f0814 |
/* Rounding modifier */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.4",
|
|
Packit Service |
8f0814 |
"%.32Rf", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.4",
|
|
Packit Service |
8f0814 |
"%.17Rf", 1.4);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "39413.8",
|
|
Packit Service |
8f0814 |
"%.30Rf", 39413.80);
|
|
Packit Service |
8f0814 |
# if !defined(TRIO_COMPILER_ANCIENT)
|
|
Packit Service |
8f0814 |
/* Long double */
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.4",
|
|
Packit Service |
8f0814 |
"%RLf", 1.4L);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.4",
|
|
Packit Service |
8f0814 |
"%.30RLf", 1.4L);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if defined(TRIO_BREESE)
|
|
Packit Service |
8f0814 |
/*
|
|
Packit Service |
8f0814 |
* These results depends on issues beyond our control. For example,
|
|
Packit Service |
8f0814 |
* the accuracy of floating-point numbers depends on the underlying
|
|
Packit Service |
8f0814 |
* floating-point hardware (e.g. whether IEEE 754 double or extended-
|
|
Packit Service |
8f0814 |
* double format is used).
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
* These tests are therefore not part of the normal regression test,
|
|
Packit Service |
8f0814 |
* but we keep them here for development purposes.
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "123456789012345680868.000000",
|
|
Packit Service |
8f0814 |
"%f", 1.234567890123456789e20);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1.23456789012345677901e-20",
|
|
Packit Service |
8f0814 |
"%.20e", 1.2345678901234567e-20);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.666666666666666629659233",
|
|
Packit Service |
8f0814 |
"%.*g", DBL_DIG + 10, 2.0/3.0);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "123456789012345700000",
|
|
Packit Service |
8f0814 |
"%Rf", 1.234567890123456789e20);
|
|
Packit Service |
8f0814 |
# if !defined(TRIO_COMPILER_ANCIENT)
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.666666666666666667",
|
|
Packit Service |
8f0814 |
"%RLf", (2.0L/3.0L));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0.666666666666666667",
|
|
Packit Service |
8f0814 |
"%.30RLf", (2.0L/3.0L));
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyErrors(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
char buffer[512];
|
|
Packit Service |
8f0814 |
int rc;
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Error: Invalid argument 1 */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "%d %r", 42, "text");
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRORCODE
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_STRERR
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d (%s), Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2 (Invalid argument), Pos = 5",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d, Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2, Pos = 5",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
nerrors += (rc != -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Error: Invalid argument 2 */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "%#");
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRORCODE
|
|
Packit Service |
8f0814 |
# if TRIO_FEATRUE_STRERR
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d (%s), Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2 (Invalid argument), Pos = 3",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d, Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2, Pos = 3",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
nerrors += (rc != -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Error: Invalid argument 3 */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "%hhhd", 42);
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRORCODE
|
|
Packit Service |
8f0814 |
# if TRIO_FEATRUE_STRERR
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d (%s), Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2 (Invalid argument), Pos = 4",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d, Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2, Pos = 4",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
nerrors += (rc != -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Error: Double reference */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "hello %1$d %1$d", 31, 32);
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRORCODE
|
|
Packit Service |
8f0814 |
# if TRIO_FEATRUE_STRERR
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d (%s), Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
# if TRIO_UNIX98
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 4 (Double reference), Pos = 0",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2 (Invalid argument), Pos = 9",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d, Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
# if TRIO_UNIX98
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 4, Pos = 0",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2, Pos = 9",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
nerrors += (rc != -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Error: Reference gap */
|
|
Packit Service |
8f0814 |
rc = trio_snprintf(buffer, sizeof(buffer), "%3$d %1$d", 31, 32, 33);
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_ERRORCODE
|
|
Packit Service |
8f0814 |
# if TRIO_FEATRUE_STRERR
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d (%s), Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_NAME(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
# if TRIO_UNIX98
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 5 (Reference gap), Pos = 1",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2 (Invalid argument), Pos = 3",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
trio_snprintf(buffer, sizeof(buffer), "Err = %d, Pos = %d",
|
|
Packit Service |
8f0814 |
TRIO_ERROR_CODE(rc),
|
|
Packit Service |
8f0814 |
TRIO_ERROR_POSITION(rc));
|
|
Packit Service |
8f0814 |
# if TRIO_UNIX98
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 5, Pos = 1",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# else
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "Err = 2, Pos = 3",
|
|
Packit Service |
8f0814 |
"%s", buffer);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#else
|
|
Packit Service |
8f0814 |
nerrors += (rc != -1);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SCANF
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningOneInteger
|
|
Packit Service |
8f0814 |
TRIO_ARGS5((file, line, expected, format, original),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *expected,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *format,
|
|
Packit Service |
8f0814 |
int original)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int number;
|
|
Packit Service |
8f0814 |
char data[512];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
trio_snprintf(data, sizeof(data), format, original);
|
|
Packit Service |
8f0814 |
trio_sscanf(data, format, &number);
|
|
Packit Service |
8f0814 |
return Verify(file, line, expected, format, number);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningIntegers(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%i", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%d", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "-42",
|
|
Packit Service |
8f0814 |
"%d", -42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "2147483647",
|
|
Packit Service |
8f0814 |
"%d", 2147483647);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%u", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "2a",
|
|
Packit Service |
8f0814 |
"%x", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "52",
|
|
Packit Service |
8f0814 |
"%o", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "101010",
|
|
Packit Service |
8f0814 |
"%..2i", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "0x2a",
|
|
Packit Service |
8f0814 |
"%#x", 42);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneInteger(__FILE__, __LINE__, "052",
|
|
Packit Service |
8f0814 |
"%#o", 42);
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SCANF
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningOneFloat
|
|
Packit Service |
8f0814 |
TRIO_ARGS5((file, line, expected, format, original),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *expected,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *format,
|
|
Packit Service |
8f0814 |
double original)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
double number;
|
|
Packit Service |
8f0814 |
char data[512];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
trio_snprintf(data, sizeof(data), format, original);
|
|
Packit Service |
8f0814 |
trio_sscanf(data, format, &number);
|
|
Packit Service |
8f0814 |
return Verify(file, line, expected, format, number);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningFloats(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "42.000000",
|
|
Packit Service |
8f0814 |
"%f", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "-42.000000",
|
|
Packit Service |
8f0814 |
"%f", -42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "4.200000e+01",
|
|
Packit Service |
8f0814 |
"%e", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "4.200000E+01",
|
|
Packit Service |
8f0814 |
"%E", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "42",
|
|
Packit Service |
8f0814 |
"%g", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.23457e+06",
|
|
Packit Service |
8f0814 |
"%g", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.23457e-06",
|
|
Packit Service |
8f0814 |
"%g", 1.234567e-6);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.23457E+06",
|
|
Packit Service |
8f0814 |
"%G", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.234567e+06",
|
|
Packit Service |
8f0814 |
"%12e", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.234500e+00",
|
|
Packit Service |
8f0814 |
"%6e", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.234567e+06",
|
|
Packit Service |
8f0814 |
"%.6e", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.2345670000e+06",
|
|
Packit Service |
8f0814 |
"%.10e", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.23457e+06",
|
|
Packit Service |
8f0814 |
"%.6g", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1234567",
|
|
Packit Service |
8f0814 |
"%.10g", 1234567.0);
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_HEXFLOAT
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "0x2.ap+4",
|
|
Packit Service |
8f0814 |
"%a", 42.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "0x1.2d687p+20",
|
|
Packit Service |
8f0814 |
"%a", 1234567.0);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "0X1.2D687P+20",
|
|
Packit Service |
8f0814 |
"%A", 1234567.0);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "1.79769e+308",
|
|
Packit Service |
8f0814 |
"%g", 1.79769e+308);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "nan",
|
|
Packit Service |
8f0814 |
"%f", trio_nan());
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "NAN",
|
|
Packit Service |
8f0814 |
"%F", trio_nan());
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneFloat(__FILE__, __LINE__, "-inf",
|
|
Packit Service |
8f0814 |
"%f", trio_ninf());
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SCANF
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningOneString
|
|
Packit Service |
8f0814 |
TRIO_ARGS5((file, line, expected, format, original),
|
|
Packit Service |
8f0814 |
TRIO_CONST char *file,
|
|
Packit Service |
8f0814 |
int line,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *expected,
|
|
Packit Service |
8f0814 |
TRIO_CONST char *format,
|
|
Packit Service |
8f0814 |
char *original)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
char string[512];
|
|
Packit Service |
8f0814 |
char data[512];
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
trio_snprintf(data, sizeof(data), "%s", original);
|
|
Packit Service |
8f0814 |
trio_sscanf(data, format, string);
|
|
Packit Service |
8f0814 |
return Verify(file, line, expected, "%s", string);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningStrings(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "hello",
|
|
Packit Service |
8f0814 |
"%s", "hello");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "hello",
|
|
Packit Service |
8f0814 |
"%s", "hello world");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "hello world",
|
|
Packit Service |
8f0814 |
"%[^\n]", "hello world");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "(nil)",
|
|
Packit Service |
8f0814 |
"%s", NULL);
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "hello",
|
|
Packit Service |
8f0814 |
"%20s", "hello");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "he",
|
|
Packit Service |
8f0814 |
"%2s", "hello");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "ab",
|
|
Packit Service |
8f0814 |
"%[ab]", "abcba");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "abcba",
|
|
Packit Service |
8f0814 |
"%[abc]", "abcba");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "abcba",
|
|
Packit Service |
8f0814 |
"%[a-c]", "abcba");
|
|
Packit Service |
8f0814 |
#if TRIO_EXTENSION
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "abcba",
|
|
Packit Service |
8f0814 |
"%[[:alpha:]]", "abcba");
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningOneString(__FILE__, __LINE__, "ba",
|
|
Packit Service |
8f0814 |
"%*[ab]c%[^\n]", "abcba");
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SCANF
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanningRegression(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
int rc;
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
int index;
|
|
Packit Service |
8f0814 |
double dnumber;
|
|
Packit Service |
8f0814 |
# if defined(TRIO_BREESE)
|
|
Packit Service |
8f0814 |
trio_long_double_t ldnumber;
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
long lnumber;
|
|
Packit Service |
8f0814 |
int number;
|
|
Packit Service |
8f0814 |
char ch;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("1.5", "%lf%n", &dnumber, &index);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1 3 1.500000",
|
|
Packit Service |
8f0814 |
"%d %d %f", rc, index, dnumber);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("q 123", "%c%ld", &ch, &lnumber);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "q 123",
|
|
Packit Service |
8f0814 |
"%c %ld", ch, lnumber);
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("abc", "%*s%n", &number);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0 3",
|
|
Packit Service |
8f0814 |
"%d %d", rc, number);
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("abc def", "%*s%n", &number);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0 3",
|
|
Packit Service |
8f0814 |
"%d %d", rc, number);
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("0.141882295971771490", "%lf", &dnumber);
|
|
Packit Service |
8f0814 |
/* FIXME: Verify */
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
number = 33;
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("total 1", "total %d", &number);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1 1",
|
|
Packit Service |
8f0814 |
"%d %d", rc, number);
|
|
Packit Service |
8f0814 |
#if defined(TRIO_BREESE)
|
|
Packit Service |
8f0814 |
# if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1 0.141882295971771488",
|
|
Packit Service |
8f0814 |
"%d %.18f", rc, dnumber);
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("0.141882295971771490", "%Lf", &ldnumber);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1 0.141882295971771490",
|
|
Packit Service |
8f0814 |
"%d %.18Lf", rc, ldnumber);
|
|
Packit Service |
8f0814 |
# endif
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("1.e-6", "%g", &dnumber);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1e-06",
|
|
Packit Service |
8f0814 |
"%g", dnumber);
|
|
Packit Service |
8f0814 |
rc = trio_sscanf("1e-6", "%g", &dnumber);
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1e-06",
|
|
Packit Service |
8f0814 |
"%g", dnumber);
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyScanning(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_SCANF
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningIntegers();
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningFloats();
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningStrings();
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanningRegression();
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyStrings(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
#if !defined(TRIO_MINIMAL)
|
|
Packit Service |
8f0814 |
char buffer[512];
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
double dnumber;
|
|
Packit Service |
8f0814 |
float fnumber;
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
char *end;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Comparison */
|
|
Packit Service |
8f0814 |
trio_copy(buffer, "Find me now");
|
|
Packit Service |
8f0814 |
if (trio_length(buffer) != sizeof("Find me now") - 1) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_equal(buffer, "Find me now")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(buffer, "Find me now")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_equal_case(buffer, "FIND ME NOW")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_equal_max(buffer, sizeof("Find me") - 1, "Find ME")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_contains(buffer, "me")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_contains(buffer, "and me")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_substring(buffer, "me") == NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_substring_max(buffer, 4, "me") != NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_match(buffer, "* me *")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_match_case(buffer, "* ME *")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_index(buffer, 'n') == NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_index(buffer, '_') != NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_index_last(buffer, 'n') == NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Append */
|
|
Packit Service |
8f0814 |
trio_copy(buffer, "Find me now");
|
|
Packit Service |
8f0814 |
if (!trio_append(buffer, " and again")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_equal(buffer, "Find me now and again")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_append_max(buffer, 0, "should not appear")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_equal(buffer, "Find me now and again")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* To upper/lower */
|
|
Packit Service |
8f0814 |
trio_copy(buffer, "Find me now");
|
|
Packit Service |
8f0814 |
trio_upper(buffer);
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(buffer, "FIND ME NOW")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
trio_lower(buffer);
|
|
Packit Service |
8f0814 |
if (!trio_equal_case(buffer, "find me now")) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_FEATURE_FLOAT
|
|
Packit Service |
8f0814 |
/* Double conversion */
|
|
Packit Service |
8f0814 |
trio_copy(buffer, "3.1415");
|
|
Packit Service |
8f0814 |
dnumber = trio_to_double(buffer, NULL);
|
|
Packit Service |
8f0814 |
if (!DOUBLE_EQUAL(dnumber, 3.1415)) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
fnumber = trio_to_float(buffer, NULL);
|
|
Packit Service |
8f0814 |
if (!FLOAT_EQUAL(fnumber, 3.1415)) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/* Long conversion */
|
|
Packit Service |
8f0814 |
trio_copy(buffer, "3.1415");
|
|
Packit Service |
8f0814 |
if (trio_to_long(buffer, NULL, 10) != 3L) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (trio_to_long(buffer, NULL, 4) != 3L) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
trio_to_long(buffer, &end, 2);
|
|
Packit Service |
8f0814 |
if (end != buffer) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
Report0(__FILE__, __LINE__);
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#endif /* !defined(TRIO_MINIMAL) */
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyDynamicStrings(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
#if !defined(TRIO_MINIMAL)
|
|
Packit Service |
8f0814 |
trio_string_t *string;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
string = trio_xstring_duplicate("Find me now");
|
|
Packit Service |
8f0814 |
if (string == NULL) {
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
goto error;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
if (!trio_xstring_equal(string, "FIND ME NOW"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
if (!trio_xstring_append(string, " and again") ||
|
|
Packit Service |
8f0814 |
!trio_xstring_equal(string, "FIND ME NOW AND AGAIN"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
if (!trio_xstring_contains(string, "me"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
if (trio_xstring_contains(string, "ME"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
if (!trio_xstring_match(string, "* me *"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
if (trio_xstring_match_case(string, "* ME *"))
|
|
Packit Service |
8f0814 |
nerrors++;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
error:
|
|
Packit Service |
8f0814 |
if (string)
|
|
Packit Service |
8f0814 |
trio_string_destroy(string);
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#endif /* !defined(TRIO_MINIMAL) */
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
VerifyNaN(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
double ninf_number = trio_ninf();
|
|
Packit Service |
8f0814 |
double pinf_number = trio_pinf();
|
|
Packit Service |
8f0814 |
double nan_number = trio_nan();
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "-1",
|
|
Packit Service |
8f0814 |
"%d", trio_isinf(ninf_number));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0",
|
|
Packit Service |
8f0814 |
"%d", trio_isinf(42.0));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1",
|
|
Packit Service |
8f0814 |
"%d", trio_isinf(pinf_number));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "1",
|
|
Packit Service |
8f0814 |
"%d", trio_isnan(nan_number));
|
|
Packit Service |
8f0814 |
nerrors += Verify(__FILE__, __LINE__, "0",
|
|
Packit Service |
8f0814 |
"%d", trio_isnan(42.0));
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors;
|
|
Packit Service |
8f0814 |
}
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
/*************************************************************************
|
|
Packit Service |
8f0814 |
*
|
|
Packit Service |
8f0814 |
*/
|
|
Packit Service |
8f0814 |
int
|
|
Packit Service |
8f0814 |
main(TRIO_NOARGS)
|
|
Packit Service |
8f0814 |
{
|
|
Packit Service |
8f0814 |
int nerrors = 0;
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("%s\n", rcsid);
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
#if TRIO_EXTENSION
|
|
Packit Service |
8f0814 |
/* Override system locale settings */
|
|
Packit Service |
8f0814 |
trio_locale_set_decimal_point(".");
|
|
Packit Service |
8f0814 |
trio_locale_set_thousand_separator(",");
|
|
Packit Service |
8f0814 |
trio_locale_set_grouping("\3");
|
|
Packit Service |
8f0814 |
#endif
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying strings\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyStrings();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying dynamic strings\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyDynamicStrings();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying special quantities\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyNaN();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying formatting\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyFormatting();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying scanning\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyScanning();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying return values\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyErrors();
|
|
Packit Service |
8f0814 |
nerrors += VerifyReturnValues();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
printf("Verifying allocation\n");
|
|
Packit Service |
8f0814 |
nerrors += VerifyAllocate();
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
if (nerrors == 0)
|
|
Packit Service |
8f0814 |
printf("Regression test suceeded\n");
|
|
Packit Service |
8f0814 |
else
|
|
Packit Service |
8f0814 |
printf("Regression test failed in %d instance(s)\n", nerrors);
|
|
Packit Service |
8f0814 |
|
|
Packit Service |
8f0814 |
return nerrors ? 1 : 0;
|
|
Packit Service |
8f0814 |
}
|