Skip to content

Commit

Permalink
Rename {Negative,Positive}AmountSignOrZero -> {Negative,Positive}OrZe…
Browse files Browse the repository at this point in the history
…roAmountSign
  • Loading branch information
KNWR committed Mar 17, 2021
1 parent e4d6d47 commit 33b396c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions parser/match_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const (
PositiveAmountSign = 2

// PositiveOrZeroAmountSign is a positive or zero amount.
PositiveAmountSignOrZero = 3
PositiveOrZeroAmountSign = 3

// NegativeOrZeroAmountSign is a positive or zero amount.
NegativeAmountSignOrZero = 4
NegativeOrZeroAmountSign = 4

// oppositesLength is the only allowed number of
// operations to compare as opposites.
Expand All @@ -67,11 +67,11 @@ func (s AmountSign) Match(amount *types.Amount) bool {
return true
}

if s == PositiveAmountSignOrZero && (numeric.Sign() == 1 || amount.Value == "0") {
if s == PositiveOrZeroAmountSign && (numeric.Sign() == 1 || amount.Value == "0") {
return true
}

if s == NegativeAmountSignOrZero && (numeric.Sign() == -1 || amount.Value == "0") {
if s == NegativeOrZeroAmountSign && (numeric.Sign() == -1 || amount.Value == "0") {
return true
}

Expand All @@ -87,6 +87,10 @@ func (s AmountSign) String() string {
return "negative"
case PositiveAmountSign:
return "positive"
case PositiveOrZeroAmountSign:
return "positive or zero"
case NegativeOrZeroAmountSign:
return "negative or zero"
default:
return "invalid"
}
Expand Down
4 changes: 2 additions & 2 deletions parser/match_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestMatchOperations(t *testing.T) {
},
Amount: &AmountDescription{
Exists: true,
Sign: NegativeAmountSignOrZero,
Sign: NegativeOrZeroAmountSign,
},
},
{
Expand All @@ -143,7 +143,7 @@ func TestMatchOperations(t *testing.T) {
},
Amount: &AmountDescription{
Exists: true,
Sign: PositiveAmountSignOrZero,
Sign: PositiveOrZeroAmountSign,
},
},
},
Expand Down

0 comments on commit 33b396c

Please sign in to comment.