-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.blinkfox.minitable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
|
@@ -31,14 +34,22 @@ public class MiniTableTest { | |
*/ | ||
@Test | ||
public void render() { | ||
// 构造一行List集合类型的普通数据,用于测试List集合数据的添加. | ||
List<Object> rowDatas = new ArrayList<Object>(); | ||
rowDatas.add("WangWu"); | ||
rowDatas.add("male"); | ||
rowDatas.add(48); | ||
rowDatas.add("[email protected]"); | ||
rowDatas.add("15809876236"); | ||
|
||
String table = new MiniTable("The Title") | ||
.addHeaders("Name", "Sex", "Age", "Email", "Phone") | ||
.addDatas("LiLei", "male", 25, "[email protected]", "13809345219") | ||
.addDatas("hanMeiMei", "female", 23, "[email protected]", "13515343853") | ||
.addHeaders("Name", "Sex", "Age", "Email", "Phone") | ||
.addDatas("ZhangSan", "female", 32, "[email protected]", "13920199836") | ||
.addDatas("Lisi", "male", 28, "[email protected]", "13635781534") | ||
.addDatas("WangWu", "male", 48, "[email protected]", "15809876236") | ||
.addDatas(rowDatas) | ||
.render(); | ||
Assert.assertEquals(TABLE, table); | ||
} | ||
|
@@ -58,14 +69,18 @@ public void renderWithException() { | |
*/ | ||
@Test | ||
public void renderWithLongTitle() { | ||
List<Object> headers = new ArrayList<Object>(); | ||
headers.add(12345); | ||
headers.add("abcde"); | ||
|
||
String table = new MiniTable("This is a too long title.") | ||
.addHeaders("col11", "col12") | ||
.addHeaders(headers) | ||
.render(); | ||
Assert.assertEquals("" | ||
+ "+---------------+\n" | ||
+ "| This is a too |\n" | ||
+ "+-------+-------+\n" | ||
+ "| col11 | col12 |\n" | ||
+ "| 12345 | abcde |\n" | ||
+ "+-------+-------+\n", table); | ||
} | ||
|
||
|