-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnum2words_test.go
36 lines (32 loc) · 925 Bytes
/
num2words_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
package num2words
import (
"fmt"
"testing"
)
var (
TEST_CASES_TO_CURRENCY_EUR = []struct {
num float64
word string
}{
{num: 1.00, word: "un euro et zéro centimes"},
{num: 2.01, word: "deux euros et un centime"},
{num: 8.10, word: "huit euros et dix centimes"},
{num: 12.26, word: "douze euros et vingt-six centimes"},
{num: 21.29, word: "vingt et un euros et vingt-neuf centimes"},
{num: 81.25, word: "quatre-vingt-un euros et vingt-cinq centimes"},
{num: 77.2, word: "soixante-dix-sept euros et vingt centimes"},
{num: 100.00, word: "cent euros et zéro centimes"},
}
)
func TestBasic(t *testing.T) {
// fmt.Println(EurosToWords(265.45))
fmt.Println(EurosToWords(81.25))
fmt.Println(EurosToWords(77.2))
}
func TestCurrency(t *testing.T) {
for _, numWord := range TEST_CASES_TO_CURRENCY_EUR {
if EurosToWords(numWord.num) != numWord.word {
t.Fatalf(EurosToWords(numWord.num))
}
}
}