-
Notifications
You must be signed in to change notification settings - Fork 257
/
AtxMarkdownTocFileTest.java
100 lines (84 loc) · 2.28 KB
/
AtxMarkdownTocFileTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.github.houbb.markdown.toc.core.impl;
import com.github.houbb.markdown.toc.core.MarkdownToc;
import com.github.houbb.markdown.toc.util.TestPathUtil;
import com.github.houbb.markdown.toc.vo.TocGen;
import org.junit.Test;
/**
* AtxMarkdownToc 单个文件测试
*
* @author author
* @version 1.0
* @since 2018-01-30 15:11:47.256
*/
public class AtxMarkdownTocFileTest {
/**
* 普通-fluent 写法
*/
@Test
public void commonFluentTest() {
String path = TestPathUtil.getAppRootPath("common.md");
TocGen tocGen = AtxMarkdownToc.newInstance()
.genTocFile(path);
System.out.println(tocGen);
}
/**
* 普通-新建接口的方式
*/
@Test
public void commonInterfaceTest() {
String path = TestPathUtil.getAppRootPath("common.md");
MarkdownToc markdownToc = new AtxMarkdownToc();
TocGen tocGen = markdownToc.genTocFile(path);
System.out.println(tocGen);
}
/**
* 中文名称测试
*/
@Test
public void chineseFileNameTest() {
String path = TestPathUtil.getAppRootPath("中文名称.md");
AtxMarkdownToc.newInstance()
.genTocFile(path);
}
/**
* 特殊文件编码测试
*/
@Test
public void charsetGbkTest() {
String path = TestPathUtil.getAppRootPath("README-GBK.md");
AtxMarkdownToc.newInstance()
.charset("GBK")
.genTocFile(path);
}
/**
* 不写入文件测试
*/
@Test
public void notWriteTest() {
String path = TestPathUtil.getAppRootPath("common.md");
TocGen tocGen = AtxMarkdownToc.newInstance()
.subTree(false)
.genTocFile(path);
System.out.println(tocGen);
}
/**
* 多层目录测试
*/
@Test
public void nLevelTest() {
String path = TestPathUtil.getAppRootPath("N-LEVEL.md");
TocGen tocGen = AtxMarkdownToc.newInstance()
.genTocFile(path);
System.out.println(tocGen);
}
/**
* 演示配置测试
*/
@Test
public void justConfigTest() {
AtxMarkdownToc.newInstance()
.charset("UTF-8")
.write(true)
.subTree(true);
}
}