sheet-historical-data-conve.../utility/validate_test.go

51 lines
1.3 KiB
Go
Raw Permalink Normal View History

2024-11-05 19:59:23 +00:00
package utility
import (
"testing"
)
func TestValidXLXSDate(t *testing.T) {
const date = "40179.0"
dateValidator := &XLXSDateValidator{date}
expVal := true
actVal := ValidateData(dateValidator)
if actVal != expVal {
t.Errorf("Failed:%s with expected value:%t and actual value:%t\n", date, expVal, actVal)
}
}
func TestInvalidXLXSDate(t *testing.T) {
const date = "dsds"
dateValidator := &XLXSDateValidator{date}
expVal := false
actVal := ValidateData(dateValidator)
if actVal != expVal {
t.Errorf("Failed:%s with expected value:%t and actual value:%t\n", date, expVal, actVal)
}
}
func TestValidCurrencyAmount(t *testing.T) {
const currencyAmount = "1,728.30"
currencyAmountValidator := &CurrencyAmountValidator{currencyAmount}
expVal := true
actVal := ValidateData(currencyAmountValidator)
if actVal != expVal {
t.Errorf("Failed:%s with expected value:%t and actual value:%t\n", currencyAmount, expVal, actVal)
}
}
func TestInValidCurrencyAmount(t *testing.T) {
const currencyAmount = "ddd333"
currencyAmountValidator := &CurrencyAmountValidator{currencyAmount}
expVal := false
actVal := ValidateData(currencyAmountValidator)
if actVal != expVal {
t.Errorf("Failed:%s with expected value:%t and actual value:%t\n", currencyAmount, expVal, actVal)
}
}