mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 03:28:53 +08:00
27 lines
940 B
C++
27 lines
940 B
C++
#include "gtest/gtest.h"
|
|
#include "tkc/data_writer_factory.h"
|
|
#include "tkc/data_writer_file.h"
|
|
#include "tkc/data_writer_wbuffer.h"
|
|
|
|
TEST(DataWriterFactory, basic) {
|
|
data_writer_t* writer = NULL;
|
|
data_writer_factory_t* f = data_writer_factory_create();
|
|
writer = data_writer_factory_create_writer(f, "file://./tests/testdata/test.xml");
|
|
ASSERT_EQ(writer == NULL, true);
|
|
|
|
ASSERT_EQ(data_writer_factory_register(f, "file", data_writer_file_create), RET_OK);
|
|
|
|
writer = data_writer_factory_create_writer(f, "file://./tests/testdata/test.xml");
|
|
ASSERT_EQ(writer != NULL, true);
|
|
data_writer_destroy(writer);
|
|
|
|
writer = data_writer_factory_create_writer(f, "./tests/testdata/test.xml");
|
|
ASSERT_EQ(writer != NULL, true);
|
|
data_writer_write(writer, 0, "hello ", 6);
|
|
ASSERT_EQ(data_writer_flush(writer), RET_OK);
|
|
data_writer_write(writer, 7, "world", 5);
|
|
data_writer_destroy(writer);
|
|
|
|
data_writer_factory_destroy(f);
|
|
}
|