mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 01:00:31 +00:00
table_line => table_divider
This commit is contained in:
1 parent
5cd2821266
commit
8c05fd030d
2 files changed
+36
-20
No files matched your search
+19
-12
@@ -1,15 +1,26 @@
|
||||
use crate::export::markup::MarkupExporter;
|
||||
|
||||
use super::markup::Alignment;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MarkdownExporter {}
|
||||
|
||||
impl MarkupExporter for MarkdownExporter {
|
||||
fn table_row(&self, data: &[&str]) -> String {
|
||||
format!("| {} |\n", data.join(" | "))
|
||||
fn table_row(&self, cells: &[&str]) -> String {
|
||||
format!("| {} |\n", cells.join(" | "))
|
||||
}
|
||||
|
||||
fn table_line(&self, size: usize) -> String {
|
||||
format!("|:---|{}\n", "---:|".repeat(size - 1))
|
||||
fn table_divider(&self, cell_aligmnents: &[Alignment]) -> String {
|
||||
format!(
|
||||
"|{}\n",
|
||||
cell_aligmnents
|
||||
.iter()
|
||||
.map(|a| match a {
|
||||
Alignment::Left => ":---|",
|
||||
Alignment::Right => "---:|",
|
||||
})
|
||||
.collect::<String>()
|
||||
)
|
||||
}
|
||||
|
||||
fn command(&self, cmd: &str) -> String {
|
||||
@@ -22,20 +33,16 @@ impl MarkupExporter for MarkdownExporter {
|
||||
fn test_markdown_formatter_table_data() {
|
||||
let formatter = MarkdownExporter::default();
|
||||
|
||||
let actual = formatter.table_row(&["a", "b", "c"]);
|
||||
let expect = "| a | b | c |\n";
|
||||
|
||||
assert_eq!(expect, actual);
|
||||
assert_eq!(formatter.table_row(&["a", "b", "c"]), "| a | b | c |\n");
|
||||
}
|
||||
|
||||
/// Check Markdown-based horizontal line formatting
|
||||
#[test]
|
||||
fn test_markdown_formatter_table_line() {
|
||||
fn test_markdown_formatter_table_divider() {
|
||||
let formatter = MarkdownExporter::default();
|
||||
let size = 5;
|
||||
|
||||
let actual = formatter.table_line(size);
|
||||
let expect = "|:---|---:|---:|---:|---:|\n";
|
||||
let actual = formatter.table_divider(&[Alignment::Left, Alignment::Right, Alignment::Left]);
|
||||
let expect = "|:---|---:|:---|\n";
|
||||
|
||||
assert_eq!(expect, actual);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user