Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger: remove multibyte characters #199

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ledger/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

const TestVersion = 1
const TestVersion = 2

type Entry struct {
Date string // "Y-m-d"
Expand Down Expand Up @@ -41,8 +41,8 @@ func FormatLedger(currency string, locale string, entries []Entry) (string, erro
return "", err
}
description := entry.Description
if len(description) > 27 {
description = description[:24] + "..."
if len(description) > 25 {
description = description[:22] + "..."
}
buf.WriteString(fmt.Sprintf("%-10s | %-25s | %13s\n",
locInfo.dateString(date),
Expand Down
6 changes: 3 additions & 3 deletions ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

const TestVersion = 1
const TestVersion = 2

type Entry struct {
Date string // "Y-m-d"
Expand Down Expand Up @@ -95,8 +95,8 @@ func FormatLedger(currency string, locale string, entries []Entry) (string, erro
}{e: errors.New("")}
}
de := entry.Description
if len(de) > 27 {
de = de[:24] + "..."
if len(de) > 25 {
de = de[:22] + "..."
} else {
de = de + strings.Repeat(" ", 25-len(de))
}
Expand Down
9 changes: 6 additions & 3 deletions ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"testing"
)

const testVersion = 1
const testVersion = 2

// Retired:
// 1 3bb3de28d30b6db66070440df9de0d8a1963f22f

var successTestCases = []struct {
name string
Expand Down Expand Up @@ -119,13 +122,13 @@ Date | Description | Change
entries: []Entry{
{
Date: "2015-01-01",
Description: "Freude schöner Götterfunken",
Description: "Freude schoner Gotterfunken",
Change: -123456,
},
},
expected: `
Date | Description | Change
01/01/2015 | Freude schöner Götterf... | ($1,234.56)
01/01/2015 | Freude schoner Gotterf... | ($1,234.56)
`,
},
{
Expand Down