API
#testing/fstest
Xu 0.8.8 API
import: #testing/fstest
counts: 2 函数, 5 方法, 2 类型, 0 常量, 0 方法集
内存 MapFS 与一致性检查。
struct MapFile
pub struct MapFile {
pub name string
pub body string
pub dir bool
}
用途
`testing/fstest.MapFS` + `TestFS` 的最小面:内存路径表 + 一致性检查。 无 interface 值,检查函数吃本包 `MapFS`。
参数
name string- 名字
body string- 正文
dir bool- 目录
struct MapFS
pub struct MapFS {
pub files []MapFile
}
用途
公开结构体 `MapFS`。
参数
files []MapFile- 字段([]MapFile)
map_fs
用途
mapfs。
参数
无
返回
MapFS — 该类型的值
(&mut MapFS) add
pub fn (fs &mut MapFS) add(name string, body string)
用途
`&mut MapFS` 上的方法:相加。
参数
fs &mut MapFS- 接收者 &mut MapFS(可变借用)
name string- 名字(string)
body string- 正文(string)
(&mut MapFS) add_dir
pub fn (fs &mut MapFS) add_dir(name string)
用途
`&mut MapFS` 上的方法:增加目录部分。
参数
fs &mut MapFS- 接收者 &mut MapFS(可变借用)
name string- 名字(string)
(MapFS) read_file
pub fn (fs MapFS) read_file(name string) string
用途
`MapFS` 上的方法:读文件。失败时 throw。
参数
fs MapFS- 接收者 MapFS(值接收者)
name string- 名字(string)
返回
string — 结果字符串
(MapFS) stat_dir
pub fn (fs MapFS) stat_dir(name string) bool
用途
`MapFS` 上的方法:元信息目录部分。
参数
fs MapFS- 接收者 MapFS(值接收者)
name string- 名字(string)
返回
bool — 是否成立
(MapFS) has
pub fn (fs MapFS) has(name string) bool
用途
`MapFS` 上的方法:是否具有。
参数
fs MapFS- 接收者 MapFS(值接收者)
name string- 名字(string)
返回
bool — 是否成立
test
pub fn test(fs &MapFS) int
用途
test: 路径合法、文件可读、目录可 stat( TestFS 的常见失败点)。失败时 throw。
参数
fs &MapFS- fs(借用,调用方仍持有;类型 &MapFS)
返回
int — 该类型的值