diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fe5b664 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Test + run: go test -v ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9ae95ad..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go - -go: - - "1.20.x" - - "1.19.x" - - "1.18.x" - - "1.16.x" - - -script: - - go test -v ./... \ No newline at end of file diff --git a/README.md b/README.md index 6b02106..ecdf160 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ +![Test](https://github.com/siyanew/num2fa/actions/workflows/test.yml/badge.svg) +[![Go Reference](https://pkg.go.dev/badge/github.com/siyanew/num2fa.svg)](https://pkg.go.dev/github.com/siyanew/num2fa) + # Num2Fa - Number to Farsi Words + This is a Golang library that helps you convert numbers to Farsi(Persian) words. ## Usage @@ -7,11 +11,11 @@ To use the library, simply import it into your project and call the Num2fa funct import "github.com/siyanew/num2fa" func main() { - // Prints "سیصد هفتاد و شش" - fmt.Println(num2fa.Num2fa(376)) +// Prints "سیصد هفتاد و شش" +fmt.Println(num2fa.Convert(376)) - // Prints "منفی یک میلیارد و دویست و سی و چهار میلیون و پانصد و شصت و هفت هزار و هشتصد و نود" - fmt.Println(num2fa.Num2fa(-1234567890)) +// Prints "منفی یک میلیارد و دویست و سی و چهار میلیون و پانصد و شصت و هفت هزار و هشتصد و نود" +fmt.Println(num2fa.Convert(-1234567890)) } ``` diff --git a/num2fa.go b/num2fa.go index 39bc2fa..4b61f41 100644 --- a/num2fa.go +++ b/num2fa.go @@ -1,4 +1,4 @@ -package main +package num2fa import ( "strings" @@ -101,7 +101,7 @@ func threeDigitToPersianWord(number int) string { return strings.Join(result, " و ") } -func Num2fa(number int) string { +func Convert(number int) string { if number == 0 { return "صفر" } diff --git a/num2fa_test.go b/num2fa_test.go index c4479f4..025427d 100644 --- a/num2fa_test.go +++ b/num2fa_test.go @@ -1,6 +1,9 @@ -package main +package num2fa_test -import "testing" +import ( + "github.com/siyanew/num2fa" + "testing" +) func TestNum2fa(t *testing.T) { testCases := []struct { @@ -35,16 +38,10 @@ func TestNum2fa(t *testing.T) { {100000000, "صد میلیون"}, {1000000000, "یک میلیارد"}, {-1234567890, "منفی یک میلیارد و دویست و سی و چهار میلیون و پانصد و شصت و هفت هزار و هشتصد و نود"}, - //{10000000000, "ده میلیارد"}, - //{100000000000, "صد میلیارد"}, - //{1000000000000, "یک تریلیون"}, - //{10000000000000, "ده تریلیون"}, - //{100000000000000, "صد تریلیون"}, - //{1000000000000000, "یک کوآدریلیون"}, } for _, tc := range testCases { - if actual := Num2fa(tc.input); actual != tc.expected { + if actual := num2fa.Convert(tc.input); actual != tc.expected { t.Errorf("Num2fa(%d) = %s; expected %s", tc.input, actual, tc.expected) } }