removed the containing subdir
This commit is contained in:
43
t/Makefile.am
Normal file
43
t/Makefile.am
Normal file
@ -0,0 +1,43 @@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
|
||||
CPPFLAGS_COMMON = \
|
||||
-I$(abs_builddir) \
|
||||
-I$(abs_builddir)/../lib \
|
||||
-I$(abs_srcdir) \
|
||||
-I$(abs_srcdir)/../lib \
|
||||
-I$(includedir)
|
||||
CFLAGS_COMMON =
|
||||
LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
|
||||
LIBADD_COMMON = ../lib/libmoo.la
|
||||
|
||||
check_PROGRAMS = t-001 t-002 t-003 t-004 t-005
|
||||
|
||||
t_001_SOURCES = t-001.c t.h
|
||||
t_001_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
|
||||
t_002_SOURCES = t-002.c t.h
|
||||
t_002_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_002_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_002_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_002_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_003_SOURCES = t-003.c t.h
|
||||
t_003_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_003_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_003_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_003_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_004_SOURCES = t-004.c t.h
|
||||
t_004_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_004_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_004_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_004_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_005_SOURCES = t-005.c t.h
|
||||
t_005_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_005_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_005_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_005_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
1176
t/Makefile.in
Normal file
1176
t/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
2
t/m/b-001.txt
Normal file
2
t/m/b-001.txt
Normal file
@ -0,0 +1,2 @@
|
||||
[ X02: 20 ] value dump.
|
||||
[ X02: 20 ] value dump. // syntax error X02 is a duplicate label. a label must be uniquie method-wide.
|
2
t/m/b-002.txt
Normal file
2
t/m/b-002.txt
Normal file
@ -0,0 +1,2 @@
|
||||
[ goto X03. ] value dump. /* Unable to jump out of a block */
|
||||
[ goto X02. X01: 9. goto X03. X02: goto X01. X03: 20. ] value dump.
|
38
t/m/r.awk
Normal file
38
t/m/r.awk
Normal file
@ -0,0 +1,38 @@
|
||||
### THIS SCRIPT NEEDS MUCH MORE ENHANCEMENT.
|
||||
### THE CURRENT CODE IS JUST TEMPORARY.
|
||||
|
||||
BEGIN {
|
||||
@local pid, workfile, d, f, cmd;
|
||||
|
||||
pid = sys::getpid();
|
||||
workfile = "moo-test." pid;
|
||||
|
||||
d = dir::open (".", dir::SORT);
|
||||
while (dir::read(d, f) > 0)
|
||||
{
|
||||
if (f !~ /.txt$/) continue;
|
||||
|
||||
print "#include \"../../kernel/Moo.moo\"." > workfile;
|
||||
print "class MyObject(Object) {" >> workfile;
|
||||
print "\tmethod(#class) main" >> workfile;
|
||||
print "\t{" >> workfile;
|
||||
|
||||
while ((getline x < f) > 0)
|
||||
{
|
||||
print x >> workfile;
|
||||
}
|
||||
close (f);
|
||||
|
||||
print "\t}" >> workfile;
|
||||
print "\}" >> workfile;
|
||||
close (workfile);
|
||||
|
||||
cmd = "/home/hyung-hwan/xxx/bin/moo " workfile;
|
||||
print "<" f ">";
|
||||
##sys::system ("cat " workfile);
|
||||
sys::system (cmd);
|
||||
}
|
||||
|
||||
dir::close(d);
|
||||
sys::unlink (workfile);
|
||||
}
|
149
t/t-001.c
Normal file
149
t/t-001.c
Normal file
@ -0,0 +1,149 @@
|
||||
/* test endian conversion macros */
|
||||
|
||||
#include <moo-utl.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
{
|
||||
union {
|
||||
moo_uint16_t u16;
|
||||
moo_uint8_t arr[2];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
|
||||
printf("x.u16 = 0x%04x\n", x.u16);
|
||||
printf("htole16(x.u16) = 0x%04x\n", moo_htole16(x.u16));
|
||||
printf("htobe16(x.u16) = 0x%04x\n", moo_htobe16(x.u16));
|
||||
|
||||
T_ASSERT1 (x.u16 != moo_htole16(x.u16) || x.u16 != moo_htobe16(x.u16), "u16 endian conversion #0");
|
||||
T_ASSERT1 (x.u16 == moo_le16toh(moo_htole16(x.u16)), "u16 endian conversion #1");
|
||||
T_ASSERT1 (x.u16 == moo_be16toh(moo_htobe16(x.u16)), "u16 endian conversion #2");
|
||||
T_ASSERT1 (x.u16 == moo_ntoh16(moo_hton16(x.u16)), "u16 endian conversion #3");
|
||||
|
||||
#define X_CONST (0x1122)
|
||||
T_ASSERT1 (X_CONST != MOO_CONST_HTOLE16(X_CONST) || X_CONST != MOO_CONST_HTOBE16(X_CONST), "u16 constant endian conversion #0");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_LE16TOH(MOO_CONST_HTOLE16(X_CONST)), "u16 constant endian conversion #1");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_BE16TOH(MOO_CONST_HTOBE16(X_CONST)), "u16 constant endian conversion #2");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_NTOH16(MOO_CONST_HTON16(X_CONST)), "u16 constant endian conversion #3");
|
||||
#undef X_CONST
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
union {
|
||||
moo_uint32_t u32;
|
||||
moo_uint8_t arr[4];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
|
||||
printf("x.u32 = 0x%08x\n", x.u32);
|
||||
printf("htole32(x.u32) = 0x%08x\n", moo_htole32(x.u32));
|
||||
printf("htobe32(x.u32) = 0x%08x\n", moo_htobe32(x.u32));
|
||||
|
||||
T_ASSERT1 (x.u32 != moo_htole32(x.u32) || x.u32 != moo_htobe32(x.u32), "u32 endian conversion #0");
|
||||
T_ASSERT1 (x.u32 == moo_le32toh(moo_htole32(x.u32)), "u32 endian conversion #1");
|
||||
T_ASSERT1 (x.u32 == moo_be32toh(moo_htobe32(x.u32)), "u32 endian conversion #2");
|
||||
T_ASSERT1 (x.u32 == moo_ntoh32(moo_hton32(x.u32)), "u32 endian conversion #3");
|
||||
|
||||
#define X_CONST (0x11223344)
|
||||
T_ASSERT1 (X_CONST != MOO_CONST_HTOLE32(X_CONST) || X_CONST != MOO_CONST_HTOBE32(X_CONST), "u32 constant endian conversion #0");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_LE32TOH(MOO_CONST_HTOLE32(X_CONST)), "u32 constant endian conversion #1");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_BE32TOH(MOO_CONST_HTOBE32(X_CONST)), "u32 constant endian conversion #2");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_NTOH32(MOO_CONST_HTON32(X_CONST)), "u32 constant endian conversion #3");
|
||||
#undef X_CONST
|
||||
}
|
||||
|
||||
#if defined(MOO_HAVE_UINT64_T)
|
||||
{
|
||||
union {
|
||||
moo_uint64_t u64;
|
||||
moo_uint8_t arr[8];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
x.arr[4] = 0x55;
|
||||
x.arr[5] = 0x66;
|
||||
x.arr[6] = 0x77;
|
||||
x.arr[7] = 0x88;
|
||||
|
||||
printf("x.u64 = 0x%016llx\n", (unsigned long long)x.u64);
|
||||
printf("htole64(x.u64) = 0x%016llx\n", (unsigned long long)moo_htole64(x.u64));
|
||||
printf("htobe64(x.u64) = 0x%016llx\n", (unsigned long long)moo_htobe64(x.u64));
|
||||
|
||||
T_ASSERT1 (x.u64 != moo_htole64(x.u64) || x.u64 != moo_htobe64(x.u64), "u64 endian conversion #0");
|
||||
T_ASSERT1 (x.u64 == moo_le64toh(moo_htole64(x.u64)), "u64 endian conversion #1");
|
||||
T_ASSERT1 (x.u64 == moo_be64toh(moo_htobe64(x.u64)), "u64 endian conversion #2");
|
||||
T_ASSERT1 (x.u64 == moo_ntoh64(moo_hton64(x.u64)), "u64 endian conversion #3");
|
||||
|
||||
#define X_CONST (((moo_uint64_t)0x11223344 << 32) | (moo_uint64_t)0x55667788)
|
||||
T_ASSERT1 (X_CONST != MOO_CONST_HTOLE64(X_CONST) || X_CONST != MOO_CONST_HTOBE64(X_CONST), "u64 constant endian conversion #0");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_LE64TOH(MOO_CONST_HTOLE64(X_CONST)), "u64 constant endian conversion #1");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_BE64TOH(MOO_CONST_HTOBE64(X_CONST)), "u64 constant endian conversion #2");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_NTOH64(MOO_CONST_HTON64(X_CONST)), "u64 constant endian conversion #3");
|
||||
#undef X_CONST
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOO_HAVE_UINT128_T)
|
||||
{
|
||||
union {
|
||||
moo_uint128_t u128;
|
||||
moo_uint8_t arr[16];
|
||||
} x;
|
||||
moo_uint128_t tmp;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
x.arr[4] = 0x55;
|
||||
x.arr[5] = 0x66;
|
||||
x.arr[6] = 0x77;
|
||||
x.arr[7] = 0x88;
|
||||
x.arr[8] = 0x99;
|
||||
x.arr[9] = 0xaa;
|
||||
x.arr[10] = 0xbb;
|
||||
x.arr[11] = 0xcc;
|
||||
x.arr[12] = 0xdd;
|
||||
x.arr[13] = 0xee;
|
||||
x.arr[14] = 0xff;
|
||||
x.arr[15] = 0xfa;
|
||||
|
||||
printf("x.u128 = 0x%016llx%016llx\n", (unsigned long long)(moo_uint64_t)(x.u128 >> 64), (unsigned long long)(moo_uint64_t)(x.u128 >> 0));
|
||||
|
||||
tmp = moo_htole128(x.u128);
|
||||
printf("htole128(tmp) = 0x%016llx%016llx\n", (unsigned long long)(moo_uint64_t)(tmp >> 64), (unsigned long long)(moo_uint64_t)(tmp >> 0));
|
||||
|
||||
tmp = moo_htobe128(x.u128);
|
||||
printf("htobe128(tmp) = 0x%016llx%016llx\n", (unsigned long long)(moo_uint64_t)(tmp >> 64), (unsigned long long)(moo_uint64_t)(tmp >> 0));
|
||||
|
||||
T_ASSERT1 (x.u128 != moo_htole128(x.u128) || x.u128 != moo_htobe128(x.u128), "u128 endian conversion #0");
|
||||
T_ASSERT1 (x.u128 == moo_le128toh(moo_htole128(x.u128)), "u128 endian conversion #1");
|
||||
T_ASSERT1 (x.u128 == moo_be128toh(moo_htobe128(x.u128)), "u128 endian conversion #2");
|
||||
T_ASSERT1 (x.u128 == moo_ntoh128(moo_hton128(x.u128)), "u128 endian conversion #3");
|
||||
|
||||
#define X_CONST (((moo_uint128_t)0x11223344 << 96) | ((moo_uint128_t)0x55667788 << 64) | ((moo_uint128_t)0x99aabbcc << 32) | ((moo_uint128_t)0xddeefffa))
|
||||
T_ASSERT1 (X_CONST != MOO_CONST_HTOLE128(X_CONST) || X_CONST != MOO_CONST_HTOBE128(X_CONST), "u128 constant endian conversion #0");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_LE128TOH(MOO_CONST_HTOLE128(X_CONST)), "u128 constant endian conversion #1");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_BE128TOH(MOO_CONST_HTOBE128(X_CONST)), "u128 constant endian conversion #2");
|
||||
T_ASSERT1 (X_CONST == MOO_CONST_NTOH128(MOO_CONST_HTON128(X_CONST)), "u128 constant endian conversion #3");
|
||||
#undef X_CONST
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
35
t/t-002.c
Normal file
35
t/t-002.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* test bit position functions */
|
||||
|
||||
#include <moo-utl.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
int i, j;
|
||||
moo_oow_t v;
|
||||
|
||||
printf ("QSE_OOW_BITS => %d, sizeof(moo_oow_t)=%d\n", (int)MOO_OOW_BITS, (int)sizeof(moo_oow_t));
|
||||
for (i = 0; i < MOO_OOW_BITS; i++)
|
||||
{
|
||||
v = ((moo_oow_t)1 << i);
|
||||
j = moo_get_pos_of_msb_set_pow2(v);
|
||||
printf ("msb(pow2) %d %d ==> %llx\n", i, j, (long long int)v);
|
||||
T_ASSERT1 (i == j, "msb(pow2) position tester");
|
||||
}
|
||||
|
||||
for (i = 0; i < MOO_OOW_BITS; i++)
|
||||
{
|
||||
v = ((moo_oow_t)1 << i);
|
||||
v |= 1;
|
||||
j = moo_get_pos_of_msb_set(v);
|
||||
printf ("msb %d %d ==> %llx\n", i, j, (long long int)v);
|
||||
T_ASSERT1 (i == j, "msb position tester");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
79
t/t-003.c
Normal file
79
t/t-003.c
Normal file
@ -0,0 +1,79 @@
|
||||
#include <moo-fmt.h>
|
||||
#include <moo-utl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <locale.h>
|
||||
#include <stdarg.h>
|
||||
#include "t.h"
|
||||
|
||||
static int put_bcs (moo_fmtout_t* fmtout, const moo_bch_t* c, moo_oow_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
putchar (*c);
|
||||
c++;
|
||||
len--;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int put_ucs (moo_fmtout_t* fmtout, const moo_uch_t* c, moo_oow_t len)
|
||||
{
|
||||
moo_cmgr_t* cmgr = moo_get_utf8_cmgr();
|
||||
moo_bch_t bcs[MOO_BCSIZE_MAX];
|
||||
moo_oow_t bcslen, i;
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
bcslen = cmgr->uctobc(*c, bcs, MOO_COUNTOF(bcs));
|
||||
/*putwchar (*c);*/
|
||||
for (i = 0; i < bcslen; i++) putchar(bcs[i]);
|
||||
c++;
|
||||
len--;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static moo_ooi_t bfmt_out (const moo_bch_t* fmt, ...)
|
||||
{
|
||||
moo_fmtout_t fmtout;
|
||||
va_list ap;
|
||||
int n;
|
||||
|
||||
memset (&fmtout, 0, MOO_SIZEOF(fmtout));
|
||||
fmtout.putbchars = put_bcs;
|
||||
fmtout.putuchars = put_ucs;
|
||||
|
||||
va_start (ap, fmt);
|
||||
n = moo_bfmt_outv (&fmtout, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
return (n <= -1)? -1: fmtout.count;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
moo_uch_t x[] = { 'A', L'\uBB33', L'\uBB34', L'\uBB35', 'Q', '\0' };
|
||||
moo_ooi_t cnt;
|
||||
|
||||
setlocale (LC_ALL, NULL);
|
||||
cnt = bfmt_out ("[%s %d %020X %ls %s %w %.*lk]\n", "test", 10, 0x1232, x, "code", x, MOO_SIZEOF_UCH_T * 3, x);
|
||||
|
||||
/* this unit is the number of characters written. but some are written as bch and some other as uch.
|
||||
* if uch and bch data are mixed, the count returned doesn't really tell how many bytes or characters written */
|
||||
bfmt_out ("wrote [%ld] units\n", cnt);
|
||||
#if (MOO_SIZEOF_UCH_T == 2)
|
||||
# define EXPECTED_LEN 98
|
||||
#elif (MOO_SIZEOF_UCH_T == 4)
|
||||
# define EXPECTED_LEN 122
|
||||
#else
|
||||
# error UNSUPPORTED UCH SIZE
|
||||
#endif
|
||||
T_ASSERT1 (cnt == EXPECTED_LEN, "bfmt_out test #1");
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
37
t/t-004.c
Normal file
37
t/t-004.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include <moo-std.h>
|
||||
#include <moo-utl.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
moo_t* moo = MOO_NULL;
|
||||
moo_uch_t ufmt1[] = { '%', '0', '5', 'd', ' ', '%', '-', '9', 'h', 's', '\0' };
|
||||
moo_uch_t ufmt2[] = { '%', '0', '5', 'd', ' ', '%', '-', '9', 'h', 's', ' ', '%','O','\0' };
|
||||
|
||||
moo = moo_openstd(0, MOO_NULL, MOO_NULL);
|
||||
if (!moo)
|
||||
{
|
||||
fprintf (stderr, "Unable to open moo\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
moo_seterrbfmt (moo, MOO_EINVAL, "%d %ld %s %hs", 10, 20L, "moo", "moo");
|
||||
T_ASSERT1 (moo_comp_oocstr_bcstr(moo_geterrmsg(moo), "10 20 moo moo") == 0, "moo seterrbfmt #1");
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "[%js]\n", moo_geterrmsg(moo));
|
||||
|
||||
moo_seterrufmt (moo, MOO_EINVAL, ufmt1, 9923, "moo");
|
||||
T_ASSERT1 (moo_comp_oocstr_bcstr(moo_geterrmsg(moo), "09923 moo ") == 0, "moo seterrufmt #1");
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "[%js]\n", moo_geterrmsg(moo));
|
||||
|
||||
moo_seterrufmt (moo, MOO_EINVAL, ufmt2, 9923, "moo", MOO_SMPTR_TO_OOP(0x12345678));
|
||||
T_ASSERT1 (moo_comp_oocstr_bcstr(moo_geterrmsg(moo), "09923 moo #\\p12345678") == 0, "moo seterrufmt #1");
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "[%js]\n", moo_geterrmsg(moo));
|
||||
|
||||
moo_close (moo);
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
if (moo) moo_close (moo);
|
||||
return -1;
|
||||
}
|
59
t/t-005.c
Normal file
59
t/t-005.c
Normal file
@ -0,0 +1,59 @@
|
||||
#include <moo-xma.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "t.h"
|
||||
|
||||
static void* sys_alloc (moo_mmgr_t* mmgr, moo_oow_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void* sys_realloc (moo_mmgr_t* mmgr, void* ptr, moo_oow_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void sys_free (moo_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static moo_mmgr_t sys_mmgr =
|
||||
{
|
||||
sys_alloc,
|
||||
sys_realloc,
|
||||
sys_free,
|
||||
MOO_NULL
|
||||
};
|
||||
|
||||
void dumper (void* ctx, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
vprintf (fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
moo_xma_t* xma;
|
||||
void* ptr1, * ptr2, * ptr3;
|
||||
|
||||
|
||||
xma = moo_xma_open(&sys_mmgr, 0, MOO_NULL, 100000);
|
||||
|
||||
|
||||
ptr1 = moo_xma_alloc(xma, 1000);
|
||||
ptr2 = moo_xma_alloc(xma, 50);
|
||||
ptr3 = moo_xma_alloc(xma, 1);
|
||||
|
||||
moo_xma_free (xma, ptr2);
|
||||
moo_xma_free (xma, ptr1);
|
||||
|
||||
moo_xma_dump (xma, dumper, MOO_NULL);
|
||||
moo_xma_close (xma);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
18
t/t.h
Normal file
18
t/t.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _MOO_T_T_H_
|
||||
#define _MOO_T_T_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__>=199901L)
|
||||
# define T_ASSERT_FAIL1(msg1) printf("FAILURE in %s:%s[%d] - %s\n", __FILE__, __func__, (int)__LINE__, msg1)
|
||||
# define T_ASSERT_FAIL2(msg1,msg2) printf("FAILURE in %s:%s[%d] - %s - %s\n", __FILE__, __func__, (int)__LINE__, msg1, msg2)
|
||||
#else
|
||||
# define T_ASSERT_FAIL1(msg1) printf("FAILURE in %s[%d] - %s\n", __FILE__, (int)__LINE__, msg1)
|
||||
# define T_ASSERT_FAIL2(msg1,msg2) printf("FAILURE in %s[%d] - %s - %s\n", __FILE__, (int)__LINE__, msg1, msg2)
|
||||
#endif
|
||||
|
||||
#define T_ASSERT1(test,msg1) do { if (!(test)) { T_ASSERT_FAIL1(msg1); goto oops; } } while(0)
|
||||
#define T_ASSERT2(test,msg1,msg2) do { if (!(test)) { T_ASSERT_FAIL2(msg1,msg2); goto oops; } } while(0)
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user