forked from moov-io/ach
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconverters_test.go
52 lines (45 loc) · 1.42 KB
/
converters_test.go
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
// Copyright 2017 The ACH Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package ach
import "testing"
//testAlphaField ensire that padding and two long of strings get properly made
func TestAlphaFieldShort(t *testing.T) {
c := converters{}
result := c.alphaField("ABC123", 10)
if result != "ABC123 " {
t.Errorf("Left justified space filled got:'%v'", result)
}
}
// TestAlphaFieldLong ensure that string is left justified and sliced to max
func TestAlphaFieldLong(t *testing.T) {
c := converters{}
result := c.alphaField("abcdEFGH123", 10)
if result != "abcdEFGH12" {
t.Errorf("Left justified space filled got:'%v'", result)
}
}
// TestNumericFieldShort ensures zero padding and right justified
func TestNumericFieldShort(t *testing.T) {
c := converters{}
result := c.numericField(12345, 10)
if result != "0000012345" {
t.Errorf("Right justified zero got: '%v'", result)
}
}
// TestNumericFieldLong right justified and sliced to max length
func TestNumericFieldLong(t *testing.T) {
c := converters{}
result := c.numericField(123456, 5)
if result != "23456" {
t.Errorf("Right justified zero got: '%v'", result)
}
}
//TestParseNumField handle zero and spaces in number conversion
func TestParseNumField(t *testing.T) {
c := converters{}
result := c.parseNumField(" 012345")
if result != 12345 {
t.Errorf("Right justified zero got: '%v'", result)
}
}