Add long long tests for bitset, convert, multiply.

This commit is contained in:
George Koehler 2019-09-16 11:44:25 -04:00
parent 04427e65dc
commit 12457f6385
4 changed files with 247 additions and 1 deletions

View file

@ -4,7 +4,7 @@ definerule("plat_testsuite",
{ {
plat = { type="string" }, plat = { type="string" },
method = { type="string" }, method = { type="string" },
-- added long-long/llshift_e.c -- added long-long/llbitset_e.c
sets = { type="table", default={"core", "b", "bugs", "m2", "floats", "long-long"}}, sets = { type="table", default={"core", "b", "bugs", "m2", "floats", "long-long"}},
skipsets = { type="table", default={}}, skipsets = { type="table", default={}},
tests = { type="targets", default={} }, tests = { type="targets", default={} },

View file

@ -0,0 +1,40 @@
#include "test.h"
typedef unsigned long long set;
set a = 0xfaab001bd86b595aLL;
set b = 0x3abe6373562dec1cLL;
set not_a = 0x0554ffe42794a6a5LL;
set a_and_b = 0x3aaa001350294818LL;
set a_or_b = 0xfabf637bde6ffd5eLL;
set a_xor_b = 0xc01563688e46b546LL;
/* ACK C evaluates H(constant) at compile time. */
#define H(x) ((set)x << 32)
void _m_a_i_n(void) {
ASSERT((~a & 0xffffffffffffffffLL) == not_a);
ASSERT((a & b) == a_and_b);
ASSERT((a | b) == a_or_b);
ASSERT((a ^ b) == a_xor_b);
ASSERT((a & 1) == 0);
ASSERT((2 & a) == 2);
ASSERT((a & ~8) == 0xfaab001bd86b5952LL);
ASSERT((a & H(1)) == H(1));
ASSERT((H(4) & a) == 0);
ASSERT((a & ~H(2)) == 0xfaab0019d86b595aLL);
ASSERT((a | 1) == 0xfaab001bd86b595bLL);
ASSERT((2 | a) == a);
ASSERT((a | H(4)) == 0xfaab001fd86b595aLL);
ASSERT((H(8) | a) == a);
ASSERT((a ^ 1) == 0xfaab001bd86b595bLL);
ASSERT((2 ^ a) == 0xfaab001bd86b5958LL);
ASSERT((a ^ H(4)) == 0xfaab001fd86b595aLL);
ASSERT((H(8) ^ a) == 0xfaab0013d86b595aLL);
finished();
}

View file

@ -0,0 +1,183 @@
#include <unistd.h>
#include "test.h"
char coal = 12;
short stop = 3456;
int erest = 7890;
long way = 123456789L;
signed char ter = -1;
short sale = -9876;
int ern = -5432;
long itude = -1000000L;
unsigned char ming = 200;
unsigned short age = 40000U;
unsigned int othe = 50000U;
unsigned long shore = 3000000000UL;
long long ago;
unsigned long long ull;
/*
* BAR may modify global variables (though it really doesn't). The
* compiler should not assume that "ago" has the same value before and
* after BAR, but should generate code to read "ago" again.
*/
#define BAR write(1, "", 0)
void _m_a_i_n(void) {
ago = coal;
BAR;
ASSERT(ago == coal);
ASSERT(ago == 12LL);
ago = stop;
BAR;
ASSERT(ago == stop);
ASSERT(ago == 3456LL);
ago = erest;
BAR;
ASSERT(ago == erest);
ASSERT(ago == 7890LL);
ago = way;
BAR;
ASSERT(ago == way);
ASSERT(ago == 123456789LL);
ull = coal;
BAR;
ASSERT(ull == coal);
ASSERT(ull == 12ULL);
ull = stop;
BAR;
ASSERT(ull == stop);
ASSERT(ull == 3456ULL);
ull = erest;
BAR;
ASSERT(ull == erest);
ASSERT(ull == 7890ULL);
ull = way;
BAR;
ASSERT(ull == way);
ASSERT(ull == 123456789ULL);
ago = ter;
BAR;
ASSERT(ago == ter);
ASSERT(ago == -1LL);
ago = sale;
BAR;
ASSERT(ago == sale);
ASSERT(ago == -9876LL);
ago = ern;
BAR;
ASSERT(ago == ern);
ASSERT(ago == -5432LL);
ago = itude;
BAR;
ASSERT(ago == itude);
ASSERT(ago == -1000000LL);
ago = ming;
BAR;
ASSERT(ago == ming);
ASSERT(ago == 200LL);
ago = age;
BAR;
ASSERT(ago == age);
ASSERT(ago == 40000LL);
ago = othe;
BAR;
ASSERT(ago == othe);
ASSERT(ago == 50000LL);
ago = shore;
BAR;
ASSERT(ago == shore);
ASSERT(ago == 3000000000LL);
ull = ming;
BAR;
ASSERT(ull == ming);
ASSERT(ull == 200ULL);
ull = age;
BAR;
ASSERT(ull == age);
ASSERT(ull == 40000ULL);
ull = othe;
BAR;
ASSERT(ull == othe);
ASSERT(ull == 50000ULL);
ull = shore;
BAR;
ASSERT(ull == shore);
ASSERT(ull == 3000000000ULL);
ago = 95;
BAR;
ter = ago;
sale = ago;
ern = ago;
itude = ago;
ming = ago;
age = ago;
othe = ago;
shore = ago;
BAR;
ASSERT(ter == 95);
ASSERT(sale == 95);
ASSERT(ern == 95);
ASSERT(itude == 95L);
ASSERT(ming == 95);
ASSERT(age == 95U);
ASSERT(othe == 95U);
ASSERT(shore == 95UL);
ago = -59;
BAR;
ter = ago;
sale = ago;
ern = ago;
itude = ago;
BAR;
ASSERT(ter == -59);
ASSERT(sale == -59);
ASSERT(ern == -59);
ASSERT(itude == -59L);
ull = 42;
BAR;
ter = ull;
sale = ull;
ern = ull;
itude = ull;
ming = ull;
age = ull;
othe = ull;
shore = ull;
BAR;
ASSERT(ter == 42);
ASSERT(sale == 42);
ASSERT(ern == 42);
ASSERT(itude == 42L);
ASSERT(ming == 42);
ASSERT(age == 42U);
ASSERT(othe == 42U);
ASSERT(shore == 42UL);
finished();
}

View file

@ -0,0 +1,23 @@
#include "test.h"
long long a = 40000LL;
long long b = 3000000000LL;
long long c = 200000000000000LL;
unsigned long long d = 60000ULL;
/* products a * b, a * c, c * d */
long long ab = 120000000000000LL;
long long ac = 8000000000000000000LL;
unsigned long long cd = 12000000000000000000ULL;
void _m_a_i_n(void) {
ASSERT(a * b == ab);
ASSERT(-b * a == -ab);
ASSERT(b * -40000LL == -ab);
ASSERT(c * a == ac);
ASSERT(a * -c == -ac);
ASSERT(40000LL * -c == -ac);
ASSERT(c * d == cd);
ASSERT(d * c == cd);
finished();
}