1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
void test_assert_cmpstr () {
// assume g_strcmp0() behaviour for nulls
assert_cmpstr (null, EQ, null);
assert_cmpstr ("", GT, null);
assert_cmpstr (null, LT, "");
assert_cmpstr (null, LT, "");
assert_cmpstr (null, NE, "some non-null, non-empty string");
assert_cmpstr (null, LT, "some non-null, non-empty string");
assert_cmpstr (null, LE, "some non-null, non-empty string");
assert_cmpstr ("some non-null, non-empty string", NE, null);
assert_cmpstr ("some non-null, non-empty string", GT, null);
assert_cmpstr ("some non-null, non-empty string", GE, null);
assert_cmpstr ("0", LT, "1");
assert_cmpstr ("0", LE, "1");
assert_cmpstr ("1", LE, "1");
assert_cmpstr ("2", EQ, "2");
assert_cmpstr ("3", GE, "3");
assert_cmpstr ("4", GE, "3");
assert_cmpstr ("4", GT, "3");
assert_cmpstr ("4", NE, "3");
}
void test_assert_cmpint () {
assert_cmpint (0, LT, 1);
assert_cmpint (0, NE, 1);
assert_cmpint (0, LE, 1);
assert_cmpint (1, LE, 1);
assert_cmpint (1, EQ, 1);
assert_cmpint (1, GE, 1);
assert_cmpint (2, GE, 1);
assert_cmpint (2, GT, 1);
assert_cmpint (-1, GT, -2);
assert_cmpint (-1, NE, -2);
assert_cmpint (-1, GE, -2);
assert_cmpint (-2, GE, -2);
assert_cmpint (-2, EQ, -2);
assert_cmpint (-2, LE, -2);
assert_cmpint (-3, LE, -2);
assert_cmpint (-3, LT, -2);
assert_cmpint (-100, LT, 101);
assert_cmpint (-100, NE, 101);
assert_cmpint (-100, LE, 101);
assert_cmpint (-101, LE, 101);
assert_cmpint (101, GE, -101);
assert_cmpint (102, GE, -101);
assert_cmpint (102, GT, -101);
}
void test_assert_cmpuint () {
assert_cmpuint (0U, LT, 1U);
assert_cmpuint (0U, NE, 1U);
assert_cmpuint (0U, LE, 1U);
assert_cmpuint (1U, LE, 1U);
assert_cmpuint (1U, EQ, 1U);
assert_cmpuint (1U, GE, 1U);
assert_cmpuint (2U, GE, 1U);
assert_cmpuint (2U, GT, 1U);
}
void test_assert_cmphex () {
assert_cmphex (0x0, LT, 0x1);
assert_cmphex (0x0, NE, 0x1);
assert_cmphex (0x0, LE, 0x1);
assert_cmphex (0x1, LE, 0x1);
assert_cmphex (0x1, EQ, 0x1);
assert_cmphex (0x1, GE, 0x1);
assert_cmphex (0x2, GE, 0x1);
assert_cmphex (0x2, GT, 0x1);
}
void test_assert_cmpfloat () {
assert_cmpfloat (0.0f, LT, 1.0f);
assert_cmpfloat (0.0f, NE, 1.0f);
assert_cmpfloat (0.0f, LE, 1.0f);
assert_cmpfloat (1.0f, LE, 1.0f);
assert_cmpfloat (1.0f, EQ, 1.0f);
assert_cmpfloat (1.0f, GE, 1.0f);
assert_cmpfloat (2.0f, GE, 1.0f);
assert_cmpfloat (2.0f, GT, 1.0f);
assert_cmpfloat (-1.0f, GT, -2.0f);
assert_cmpfloat (-1.0f, NE, -2.0f);
assert_cmpfloat (-1.0f, GE, -2.0f);
assert_cmpfloat (-2.0f, GE, -2.0f);
assert_cmpfloat (-2.0f, EQ, -2.0f);
assert_cmpfloat (-2.0f, LE, -2.0f);
assert_cmpfloat (-3.0f, LE, -2.0f);
assert_cmpfloat (-3.0f, LT, -2.0f);
assert_cmpfloat (-100.0f, LT, 101.0f);
assert_cmpfloat (-100.0f, NE, 101.0f);
assert_cmpfloat (-100.0f, LE, 101.0f);
assert_cmpfloat (-101.0f, LE, 101.0f);
assert_cmpfloat (101.0f, GE, -101.0f);
assert_cmpfloat (102.0f, GE, -101.0f);
assert_cmpfloat (102.0f, GT, -101.0f);
}
void main () {
test_assert_cmpstr ();
test_assert_cmpint ();
test_assert_cmpuint ();
test_assert_cmphex ();
test_assert_cmpfloat ();
}
|