Beispiel #1
0
void
test_interesting_level (void)
{
    logger = cut_logger_new();
    gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS,
                            CUT_LOG_LEVEL_MESSAGE |
                            CUT_LOG_LEVEL_WARNING |
                            CUT_LOG_LEVEL_ERROR |
                            CUT_LOG_LEVEL_CRITICAL,
                            cut_logger_get_interesting_level(logger));

    cut_logger_set_target_level(logger,
                                CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_TRACE);
    gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS,
                            CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_TRACE,
                            cut_logger_get_interesting_level(logger));

    cut_logger_set_interesting_level(logger,
                                     "syslog",
                                     CUT_LOG_LEVEL_DEBUG);
    gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS,
                            CUT_LOG_LEVEL_INFO |
                            CUT_LOG_LEVEL_DEBUG |
                            CUT_LOG_LEVEL_TRACE,
                            cut_logger_get_interesting_level(logger));
}
static void
stub_equal_flags (void)
{
    gcut_assert_equal_flags(flags_type,
                            (1 << 0) | (1 << 2),
                            (1 << 0) | (1 << 2));
    MARK_FAIL(gcut_assert_equal_flags(flags_type,
                                      (1 << 1) | (1 << 2),
                                      (1 << 3)));
}
Beispiel #3
0
void
test_get_flags (gconstpointer data)
{
    const EnumTestData *test_data = data;
    GError *error = NULL;
    guint flags_value;

    g_key_file_load_from_data(key_file, test_data->data, strlen(test_data->data),
                              0, &error);
    gcut_assert_error(error);

    flags_value = gcut_key_file_get_flags(key_file,
                                          test_data->group_name,
                                          test_data->key_name,
                                          test_data->type,
                                          &error);
    if (test_data->expected_error) {
        actual_error = error;
        gcut_assert_equal_error(test_data->expected_error, actual_error);
    } else {
        gcut_assert_error(error);
    }

    gcut_assert_equal_flags(test_data->type,
                            test_data->expected_flags_value,
                            flags_value);
}
Beispiel #4
0
void
test_level_from_string (gconstpointer data)
{
    const gchar *level_string;
    CutLogLevelFlags expected, actual;
    GError *error = NULL;

    expected = gcut_data_get_flags(data, "/expected");
    level_string = gcut_data_get_string(data, "/level-string");
    actual = cut_log_level_flags_from_string(level_string,
                                             CUT_LOG_LEVEL_DEFAULT,
                                             &error);
    gcut_assert_error(error);
    gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS,
                            expected,
                            actual);
}