~elementary-os/elementaryos/os-patch-aptly-xenial

« back to all changes in this revision

Viewing changes to src/github.com/smira/aptly/_vendor/src/github.com/cheggaaa/pb/format_test.go

  • Committer: RabbitBot
  • Date: 2016-07-19 12:29:41 UTC
  • Revision ID: rabbitbot@elementary.io-20160719122941-z6gaxs7nzgmratry
Initial import, version 0.9.6-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package pb
 
2
 
 
3
import (
 
4
        "fmt"
 
5
        "strconv"
 
6
        "testing"
 
7
)
 
8
 
 
9
func Test_DefaultsToInteger(t *testing.T) {
 
10
        value := int64(1000)
 
11
        expected := strconv.Itoa(int(value))
 
12
        actual := Format(value, -1)
 
13
 
 
14
        if actual != expected {
 
15
                t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
 
16
        }
 
17
}
 
18
 
 
19
func Test_CanFormatAsInteger(t *testing.T) {
 
20
        value := int64(1000)
 
21
        expected := strconv.Itoa(int(value))
 
22
        actual := Format(value, U_NO)
 
23
 
 
24
        if actual != expected {
 
25
                t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
 
26
        }
 
27
}
 
28
 
 
29
func Test_CanFormatAsBytes(t *testing.T) {
 
30
        value := int64(1000)
 
31
        expected := "1000 B"
 
32
        actual := Format(value, U_BYTES)
 
33
 
 
34
        if actual != expected {
 
35
                t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
 
36
        }
 
37
}