예제 #1
0
TEST_F(BuilderBasicTest, it_basic) {
    dr_metalib_source_t source_a = dr_metalib_builder_add_file(m_builder, NULL, "a.xml");
    dr_metalib_source_t source_b = dr_metalib_builder_add_file(m_builder, NULL, "b.xml");

    struct dr_metalib_source_it it;
    dr_metalib_builder_sources(&it, m_builder);

    EXPECT_TRUE(source_a == dr_metalib_source_next(&it));
    EXPECT_TRUE(source_b == dr_metalib_source_next(&it));
    EXPECT_TRUE(NULL == dr_metalib_source_next(&it));
}
예제 #2
0
dir_visit_next_op_t
accept_input_file(const char * full, const char * base, void * ctx) {
    if (strcmp(file_name_suffix(base), "xml") == 0) {
        dr_metalib_builder_add_file((dr_metalib_builder_t)ctx, NULL, full);
    }
    return dir_visit_next_go;
}
예제 #3
0
TEST_F(BuilderBasicTest, add_file_basic) {
    dr_metalib_source_t source = dr_metalib_builder_add_file(m_builder, NULL, "b/a.xml");
    ASSERT_TRUE(source);

    EXPECT_EQ(dr_metalib_source_type_file, dr_metalib_source_type(source));
    EXPECT_EQ(dr_metalib_source_format_xml, dr_metalib_source_format(source));
    EXPECT_EQ(dr_metalib_source_from_user, dr_metalib_source_from(source));
    EXPECT_EQ(dr_metalib_source_state_not_analize, dr_metalib_source_state(source));

    EXPECT_STREQ("a", dr_metalib_source_name(source));
    EXPECT_STREQ("b/a.xml", dr_metalib_source_file(source));
    EXPECT_TRUE(NULL == dr_metalib_source_buf(source));
    EXPECT_EQ((size_t)0, dr_metalib_source_buf_capacity(source));
}
예제 #4
0
void prepare_input(dr_metalib_builder_t builder, error_monitor_t em) {
    int i;
    for(i = 0; i < input->count; ++i) {
        const char * filename;
        size_t filename_len;

        filename = input->filename[i];
        filename_len = strlen(filename);
        if (filename[filename_len - 1] == '\\' || filename[filename_len - 1] == '/') {
            ((char *)filename)[filename_len - 1] = 0;
        }

        if (dir_exist(filename, em)) {
            dir_search(&g_input_search_visitor, builder, filename, 5, em, NULL);
        }
        else if (file_exist(input->filename[i], em)) {
            dr_metalib_builder_add_file(builder, NULL, filename);
        }
        else {
            CPE_ERROR(em, "input %s not exist!", filename);
        }
    }
}
예제 #5
0
TEST_F(BuilderBasicTest, source_find_basic) {
    dr_metalib_source_t source = dr_metalib_builder_add_file(m_builder, NULL, "b/a.xml");
    ASSERT_TRUE(source == dr_metalib_source_find(m_builder, "a"));
}
예제 #6
0
TEST_F(BuilderBasicTest, add_file_prefix_unknown) {
    dr_metalib_source_t source = dr_metalib_builder_add_file(m_builder, NULL, "b/a.aa");
    ASSERT_TRUE(source == NULL);
}
예제 #7
0
TEST_F(BuilderBasicTest, add_file_with_name) {
    dr_metalib_source_t source = dr_metalib_builder_add_file(m_builder, "c", "b/a.xml");
    ASSERT_TRUE(source);

    EXPECT_STREQ("c", dr_metalib_source_name(source));
}