예제 #1
0
TEST_F(PropTest, shouldParseValidQualifiedNumber)
{
    uint64_t value = 0;

    EXPECT_EQ(aeron_parse_size64("0k", &value), 0);
    EXPECT_EQ(value, (uint64_t)0);

    EXPECT_EQ(aeron_parse_size64("1k", &value), 0);
    EXPECT_EQ(value, (uint64_t)1024);

    EXPECT_EQ(aeron_parse_size64("64k", &value), 0);
    EXPECT_EQ(value, (uint64_t)64 * 1024);

    EXPECT_EQ(aeron_parse_size64("0m", &value), 0);
    EXPECT_EQ(value, (uint64_t)0);

    EXPECT_EQ(aeron_parse_size64("1m", &value), 0);
    EXPECT_EQ(value, (uint64_t)1024 * 1024);

    EXPECT_EQ(aeron_parse_size64("64m", &value), 0);
    EXPECT_EQ(value, (uint64_t)64 * 1024 * 1024);

    EXPECT_EQ(aeron_parse_size64("0g", &value), 0);
    EXPECT_EQ(value, (uint64_t)0);

    EXPECT_EQ(aeron_parse_size64("1g", &value), 0);
    EXPECT_EQ(value, (uint64_t)1024 * 1024 * 1024);

    EXPECT_EQ(aeron_parse_size64("64g", &value), 0);
    EXPECT_EQ(value, (uint64_t)64 * 1024 * 1024 * 1024);
}
예제 #2
0
TEST_F(PropTest, shouldParseValidNumber)
{
    uint64_t value = 0;

    EXPECT_EQ(aeron_parse_size64("0", &value), 0);
    EXPECT_EQ(value, (uint64_t)0);

    EXPECT_EQ(aeron_parse_size64("1", &value), 0);
    EXPECT_EQ(value, (uint64_t)1);

    EXPECT_EQ(aeron_parse_size64("77777777", &value), 0);
    EXPECT_EQ(value, (uint64_t)77777777);
}
예제 #3
0
TEST_F(PropTest, shouldNotParseInvalidNumber)
{
    uint64_t value = 0;

    EXPECT_EQ(aeron_parse_size64(nullptr, &value), -1);
    EXPECT_EQ(aeron_parse_size64("", &value), -1);
    EXPECT_EQ(aeron_parse_size64("rubbish", &value), -1);
    EXPECT_EQ(aeron_parse_size64("-8", &value), -1);
    EXPECT_EQ(aeron_parse_size64("123Z", &value), -1);
    EXPECT_EQ(aeron_parse_size64("k", &value), -1);
}
예제 #4
0
int aeron_uri_get_mtu_length_param(aeron_uri_params_t *uri_params, aeron_uri_publication_params_t *params)
{
    const char *value_str;

    if ((value_str = aeron_uri_find_param_value(uri_params, AERON_URI_MTU_LENGTH_KEY)) != NULL)
    {
        uint64_t value;

        if (-1 == aeron_parse_size64(value_str, &value))
        {
            aeron_set_err(EINVAL, "could not parse %s in URI", AERON_URI_MTU_LENGTH_KEY);
            return -1;
        }

        if (aeron_driver_context_validate_mtu_length(value) < 0)
        {
            return -1;
        }

        params->mtu_length = value;
    }

    return 0;
}
예제 #5
0
int aeron_uri_get_term_length_param(aeron_uri_params_t *uri_params, aeron_uri_publication_params_t *params)
{
    const char *value_str;

    if ((value_str = aeron_uri_find_param_value(uri_params, AERON_URI_TERM_LENGTH_KEY)) != NULL)
    {
        uint64_t value;

        if (-1 == aeron_parse_size64(value_str, &value))
        {
            aeron_set_err(EINVAL, "could not parse %s in URI", AERON_URI_TERM_LENGTH_KEY);
            return -1;
        }

        if (aeron_logbuffer_check_term_length(value) < 0)
        {
            return -1;
        }

        params->term_length = value;
    }

    return 0;
}