Skip to content

Conditional (ternary) operator support [C standard test] #324

Closed
@belous-dp

Description

@belous-dp

Description
Add conditional (ternary) operator ? : support.

Current behavior
Source code:

int ternary_positive(int n) {
    int res = n >= 0 ? 1 : 0;
    return res;
}

int ternary_sign(int n) {
    return (n > 0 ? 1 : (n < 0 ? -1 : 0));
}

Generated tests:

TEST(regression, ternary_positive_test_1)
{
    int actual = ternary_positive(-1);
    EXPECT_EQ(0, actual);
}

TEST(regression, ternary_sign_test_1)
{
    int actual = ternary_sign(0);
    EXPECT_EQ(0, actual);
}

TEST(regression, ternary_sign_test_2)
{
    int actual = ternary_sign(1);
    EXPECT_EQ(1, actual);
}

Expected behavior
More tests generated. The following tests should be generated:

TEST(regression, ternary_positive_test_2)
{
    int actual = ternary_positive(0);
    EXPECT_EQ(1, actual);
}

TEST(regression, ternary_sign_test_2)
{
    int actual = ternary_sign(-1);
    EXPECT_EQ(-1, actual);
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingc-syntaxRelated to generation tests for CkleeRelated to internal work of KLEE

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions