initial commit
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
bool feq(float a, float b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
bool flt(float a, float b)
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
|
||||
bool fle(float a, float b)
|
||||
{
|
||||
return a <= b;
|
||||
}
|
||||
|
||||
bool fgt(float a, float b)
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
|
||||
bool fge(float a, float b)
|
||||
{
|
||||
return a >= b;
|
||||
}
|
||||
|
||||
|
||||
volatile float f;
|
||||
|
||||
inline void cmpflt(float a, float b, bool eq, bool lt, bool gt)
|
||||
{
|
||||
bool le = eq || lt;
|
||||
bool ge = eq || gt;
|
||||
|
||||
assert(feq(a, b) == eq);
|
||||
assert(flt(a, b) == lt);
|
||||
assert(fgt(a, b) == gt);
|
||||
assert(fle(a, b) == le);
|
||||
assert(fge(a, b) == ge);
|
||||
|
||||
f = a;
|
||||
|
||||
assert(feq(f, b) == eq);
|
||||
assert(flt(f, b) == lt);
|
||||
assert(fgt(f, b) == gt);
|
||||
assert(fle(f, b) == le);
|
||||
assert(fge(f, b) == ge);
|
||||
|
||||
f = b;
|
||||
|
||||
assert(feq(a, f) == eq);
|
||||
assert(flt(a, f) == lt);
|
||||
assert(fgt(a, f) == gt);
|
||||
assert(fle(a, f) == le);
|
||||
assert(fge(a, f) == ge);
|
||||
}
|
||||
|
||||
__noinline void test1(void)
|
||||
{
|
||||
cmpflt( 0.0, 1.0, false, true, false);
|
||||
cmpflt( 0.0, -1.0, false, false, true);
|
||||
cmpflt( 1.0, 0.0, false, false, true);
|
||||
cmpflt(-1.0, 0.0, false, true, false);
|
||||
}
|
||||
|
||||
__noinline void test2(void)
|
||||
{
|
||||
cmpflt( 1.0, 1.0, true, false, false);
|
||||
cmpflt( 1.0, 2.0, false, true, false);
|
||||
cmpflt( 2.0, 1.0, false, false, true);
|
||||
}
|
||||
|
||||
__noinline void test3(void)
|
||||
{
|
||||
|
||||
cmpflt(-1.0, -1.0, true, false, false);
|
||||
cmpflt(-1.0, -2.0, false, false, true);
|
||||
cmpflt(-2.0, -1.0, false, true, false);
|
||||
}
|
||||
|
||||
__noinline void test4(void)
|
||||
{
|
||||
|
||||
cmpflt( 1.0, -1.0, false, false, true);
|
||||
cmpflt( 1.0, -2.0, false, false, true);
|
||||
cmpflt( 2.0, -1.0, false, false, true);
|
||||
}
|
||||
|
||||
__noinline void test5(void)
|
||||
{
|
||||
|
||||
cmpflt(-1.0, 1.0, false, true, false);
|
||||
cmpflt(-1.0, 2.0, false, true, false);
|
||||
cmpflt(-2.0, 1.0, false, true, false);
|
||||
}
|
||||
|
||||
__noinline void test6(void)
|
||||
{
|
||||
cmpflt( 0.0, 0.0, true, false, false);
|
||||
cmpflt(-0.0, 0.0, true, false, false);
|
||||
cmpflt( 0.0, -0.0, true, false, false);
|
||||
cmpflt(-0.0, -0.0, true, false, false);
|
||||
}
|
||||
|
||||
__noinline void test7(void)
|
||||
{
|
||||
cmpflt( 1.0, 1.000001, false, true, false);
|
||||
cmpflt( 1.000001, 1.0, false, false, true);
|
||||
cmpflt( 1.000001, 1.000001, true, false, false);
|
||||
}
|
||||
|
||||
__noinline void test8(void)
|
||||
{
|
||||
|
||||
cmpflt( -1.0, -1.000001, false, false, true);
|
||||
cmpflt( -1.000001, -1.0, false, true, false);
|
||||
cmpflt( -1.000001, -1.000001, true, false, false);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test7();
|
||||
test8();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user