2018-06-27 13:46:42 +08:00
|
|
|
|
#include "base/fs.h"
|
2018-04-27 18:12:12 +08:00
|
|
|
|
#include "base/mem.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
TEST(Fs, basic) {
|
|
|
|
|
char buff[128];
|
|
|
|
|
uint32_t size = 0;
|
|
|
|
|
const char* str = "hello world";
|
|
|
|
|
const char* filename = "test.bin";
|
|
|
|
|
|
2018-08-26 07:14:32 +08:00
|
|
|
|
file_write(filename, str, strlen(str));
|
|
|
|
|
char* ret = (char*)file_read(filename, &size);
|
|
|
|
|
ASSERT_EQ(file_read_part(filename, buff, sizeof(buff), 0), strlen(str));
|
2018-04-27 18:12:12 +08:00
|
|
|
|
ASSERT_EQ(strcmp(ret, str), 0);
|
|
|
|
|
ASSERT_EQ(size, strlen(str));
|
2018-08-26 07:14:32 +08:00
|
|
|
|
file_remove(filename);
|
2018-04-29 16:51:54 +08:00
|
|
|
|
TKMEM_FREE(ret);
|
2018-04-27 18:12:12 +08:00
|
|
|
|
}
|