示例#1
0
// Tests that the different score comparison functions give the expected
// results on the given score values.
static void test_score_compare(score_category_t cat_a, uint32_t sub_a,
    unsigned rel, score_category_t cat_b, uint32_t sub_b) {
  // Run the values through the new score test for good measure.
  value_t a = test_new_score(cat_a, sub_a);
  value_t b = test_new_score(cat_b, sub_b);
  ASSERT_TRUE(test_relation(value_ordering_compare(a, b), rel));
  int compared = compare_tagged_scores(a, b);
  ASSERT_TRUE(test_relation(integer_to_relation(compared), rel));
}
示例#2
0
int
gtk_module_init (gint  argc,
                 char* argv[])
{
    gboolean b_ret;

    g_print("Relation test module loaded\n");

    b_ret = test_relation ();
    if (b_ret)
        g_print ("Relation tests succeeded\n");
    else
        g_print ("Relation tests failed\n");
    b_ret = test_role ();
    if (b_ret)
        g_print ("Role tests succeeded\n");
    else
        g_print ("Role tests failed\n");
    b_ret = test_text_attr ();
    if (b_ret)
        g_print ("Text Attribute tests succeeded\n");
    else
        g_print ("Text Attribute tests failed\n");
    return 0;
}
示例#3
0
struct Symbol* relational_expression(struct RelationalExpression* node)
{
    if (node->type == 0)
        return shift_expression(node->shiftExpression);
    struct Symbol* symbol1 = load_symbol(relational_expression(node->relationalExpression));
    struct Symbol* symbol2 = load_symbol(shift_expression(node->shiftExpression));
    test_relation(&symbol1, &symbol2);
    struct Symbol* symbol3;
    if (node->type == 1)
        symbol3 = test_calculable2(&symbol1, &symbol2, '<');
    else
        symbol3 = test_calculable2(&symbol1, &symbol2, '>');
    if (symbol3)
        return symbol3;
    symbol3 = new_symbol("", 0, 2, 1, 0, 0, 0);
    char c = 's';
    if ((symbol1->specifier & (1 << 9)) > 0 || symbol1->stars)
        c = 'u';
    ADDSTRING("  ");
    code_gen_symbol('%', symbol3);
    if (symbol2->stars == 0 && (symbol2->specifier & (3 << 6)) != 0)
    {
        ADDSTRING(" = fcmp ");
        if (node->type == 1 || node->type == 3)
        {
            ADDSTRING("olt ");
        }
        else
        {
            ADDSTRING("ogt ");
        }
    }
    else
    {
        ADDSTRING(" = icmp ");
        *g_ptr++ = c;
        if (node->type == 1 || node->type == 3)
        {
            ADDSTRING("lt ");
        }
        else
        {
            ADDSTRING("gt ");
        }
    }
    code_gen_type_specifier(symbol1->specifier,0, symbol1->length, symbol1->stars);
    ADDSTRING(" ");
    code_gen_symbol('%', symbol1);
    ADDSTRING(", ");
    code_gen_symbol('%', symbol2);
    ADDSTRING("\n");
    return symbol3;
}
示例#4
0
TEST(tagged, relation) {
  ASSERT_TRUE(test_relation(less_than(), reLessThan));
  ASSERT_TRUE(test_relation(less_than(), reLessThan | reEqual));
  ASSERT_FALSE(test_relation(less_than(), reEqual));
  ASSERT_FALSE(test_relation(less_than(), reGreaterThan));
  ASSERT_FALSE(test_relation(less_than(), reGreaterThan | reEqual));
  ASSERT_FALSE(test_relation(less_than(), reUnordered));

  ASSERT_FALSE(test_relation(equal(), reLessThan));
  ASSERT_TRUE(test_relation(equal(), reLessThan | reEqual));
  ASSERT_TRUE(test_relation(equal(), reEqual));
  ASSERT_FALSE(test_relation(equal(), reGreaterThan));
  ASSERT_TRUE(test_relation(equal(), reGreaterThan | reEqual));
  ASSERT_FALSE(test_relation(equal(), reUnordered));

  ASSERT_FALSE(test_relation(greater_than(), reLessThan));
  ASSERT_FALSE(test_relation(greater_than(), reLessThan | reEqual));
  ASSERT_FALSE(test_relation(greater_than(), reEqual));
  ASSERT_TRUE(test_relation(greater_than(), reGreaterThan));
  ASSERT_TRUE(test_relation(greater_than(), reGreaterThan | reEqual));
  ASSERT_FALSE(test_relation(greater_than(), reUnordered));

  ASSERT_FALSE(test_relation(unordered(), reLessThan));
  ASSERT_FALSE(test_relation(unordered(), reLessThan | reEqual));
  ASSERT_FALSE(test_relation(unordered(), reEqual));
  ASSERT_FALSE(test_relation(unordered(), reGreaterThan));
  ASSERT_FALSE(test_relation(unordered(), reGreaterThan | reEqual));
  ASSERT_TRUE(test_relation(unordered(), reUnordered));
}
示例#5
0
TEST(tagged, integer_comparison) {
  ASSERT_TRUE(test_relation(compare_signed_integers(-1, 1), reLessThan));
  ASSERT_TRUE(test_relation(compare_signed_integers(0, 1), reLessThan));
  ASSERT_TRUE(test_relation(compare_signed_integers(0, 0), reEqual));
  ASSERT_TRUE(test_relation(compare_signed_integers(0, -1), reGreaterThan));
}