-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader_test.go
104 lines (98 loc) · 2.8 KB
/
reader_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package goscon
import (
"testing"
"github.com/dslipak/pdf"
)
func TestIsLine(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 112, Y: -494, S: "Bag Purchase COCHIN"},
{X: 542, Y: -494, S: "2000.00"},
{X: 562.5, Y: -494, S: " "},
}
if !isLine(line) {
t.Fatalf("got %v, wanted %v", true, false)
}
}
func TestIsNotLine(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 562.5, Y: -494, S: " "},
}
if isLine(line) {
t.Fatalf("got %v, wanted %v", false, true)
}
var line2 pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 112, Y: -494, S: "84,152.64"},
{X: 542, Y: -494, S: "Transaction"},
{X: 562.5, Y: -494, S: " "},
}
if isLine(line2) {
t.Fatalf("got %v, wanted %v", false, true)
}
}
func TestIsCredit(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 112, Y: -494, S: "Bag Purchase COCHIN"},
{X: 542, Y: -494, S: "2000.00"},
{X: 562.5, Y: -494, S: "Cr"},
}
if !isCredit(line) {
t.Fatalf("got %v, wanted %v", true, false)
}
}
func TestIsNotCredit(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 112, Y: -494, S: "Bag Purchase COCHIN"},
{X: 542, Y: -494, S: "2000.00"},
{X: 562.5, Y: -494, S: " "},
}
if isCredit(line) {
t.Fatalf("got %v, wanted %v", false, true)
}
var line2 pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 562.5, Y: -494, S: " "},
}
if isCredit(line2) {
t.Fatalf("got %v, wanted %v", false, true)
}
}
func TestIsOpeningBalance(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 16, Y: -236, S: "(including fresh purchases, if any) on an average daily"},
{X: 264, Y: -236.62, S: "41,954.43"},
{X: 332.12, Y: -236.62, S: "41,954.00"},
{X: 402.12, Y: -236.62, S: "4,162.00"},
{X: 477.12, Y: -236.62, S: "8.00"},
{X: 538.12, Y: -236.62, S: "4,170.00"},
}
if !isOpeningBalance(line) {
t.Fatalf("got %v, wanted %v", true, false)
}
}
func TestIsNotOpeningBalance(t *testing.T) {
var line pdf.TextHorizontal = []pdf.Text{
{X: 13, Y: -494, S: "29/12/2022 02:14:05"},
{X: 112, Y: -494, S: "Bag Purchase COCHIN"},
{X: 542, Y: -494, S: "2000.00"},
{X: 562.5, Y: -494, S: " "},
}
if isOpeningBalance(line) {
t.Fatalf("got %v, wanted %v", false, true)
}
var line2 pdf.TextHorizontal = []pdf.Text{
{X: 16, Y: -236, S: "Welcome"},
{X: 264, Y: -236.62, S: "Hello"},
{X: 332.12, Y: -236.62, S: " "},
{X: 402.12, Y: -236.62, S: "123.00"},
{X: 477.12, Y: -236.62, S: " "},
{X: 538.12, Y: -236.62, S: "Thank you"},
}
if isOpeningBalance(line2) {
t.Fatalf("got %v, wanted %v", false, true)
}
}