1 package sg_CF
2
3 import (
4 "testing"
5 "time"
6
7 "github.com/go-playground/locales"
8 "github.com/go-playground/locales/currency"
9 )
10
11 func TestLocale(t *testing.T) {
12
13 trans := New()
14 expected := "sg_CF"
15
16 if trans.Locale() != expected {
17 t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale())
18 }
19 }
20
21 func TestPluralsRange(t *testing.T) {
22
23 trans := New()
24
25 tests := []struct {
26 expected locales.PluralRule
27 }{
28
29
30
31 }
32
33 rules := trans.PluralsRange()
34
35
36
37
38
39 for _, tt := range tests {
40
41 r := locales.PluralRuleUnknown
42
43 for i := 0; i < len(rules); i++ {
44 if rules[i] == tt.expected {
45 r = rules[i]
46 break
47 }
48 }
49 if r == locales.PluralRuleUnknown {
50 t.Errorf("Expected '%s' Got '%s'", tt.expected, r)
51 }
52 }
53 }
54
55 func TestPluralsOrdinal(t *testing.T) {
56
57 trans := New()
58
59 tests := []struct {
60 expected locales.PluralRule
61 }{
62
63
64
65
66
67
68
69
70
71
72
73
74 }
75
76 rules := trans.PluralsOrdinal()
77
78
79
80
81
82 for _, tt := range tests {
83
84 r := locales.PluralRuleUnknown
85
86 for i := 0; i < len(rules); i++ {
87 if rules[i] == tt.expected {
88 r = rules[i]
89 break
90 }
91 }
92 if r == locales.PluralRuleUnknown {
93 t.Errorf("Expected '%s' Got '%s'", tt.expected, r)
94 }
95 }
96 }
97
98 func TestPluralsCardinal(t *testing.T) {
99
100 trans := New()
101
102 tests := []struct {
103 expected locales.PluralRule
104 }{
105
106
107
108
109
110
111 }
112
113 rules := trans.PluralsCardinal()
114
115
116
117
118
119 for _, tt := range tests {
120
121 r := locales.PluralRuleUnknown
122
123 for i := 0; i < len(rules); i++ {
124 if rules[i] == tt.expected {
125 r = rules[i]
126 break
127 }
128 }
129 if r == locales.PluralRuleUnknown {
130 t.Errorf("Expected '%s' Got '%s'", tt.expected, r)
131 }
132 }
133 }
134
135 func TestRangePlurals(t *testing.T) {
136
137 trans := New()
138
139 tests := []struct {
140 num1 float64
141 v1 uint64
142 num2 float64
143 v2 uint64
144 expected locales.PluralRule
145 }{
146
147
148
149
150
151
152
153 }
154
155 for _, tt := range tests {
156 rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2)
157 if rule != tt.expected {
158 t.Errorf("Expected '%s' Got '%s'", tt.expected, rule)
159 }
160 }
161 }
162
163 func TestOrdinalPlurals(t *testing.T) {
164
165 trans := New()
166
167 tests := []struct {
168 num float64
169 v uint64
170 expected locales.PluralRule
171 }{
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192 }
193
194 for _, tt := range tests {
195 rule := trans.OrdinalPluralRule(tt.num, tt.v)
196 if rule != tt.expected {
197 t.Errorf("Expected '%s' Got '%s'", tt.expected, rule)
198 }
199 }
200 }
201
202 func TestCardinalPlurals(t *testing.T) {
203
204 trans := New()
205
206 tests := []struct {
207 num float64
208 v uint64
209 expected locales.PluralRule
210 }{
211
212
213
214
215
216
217
218
219
220
221 }
222
223 for _, tt := range tests {
224 rule := trans.CardinalPluralRule(tt.num, tt.v)
225 if rule != tt.expected {
226 t.Errorf("Expected '%s' Got '%s'", tt.expected, rule)
227 }
228 }
229 }
230
231 func TestDaysAbbreviated(t *testing.T) {
232
233 trans := New()
234 days := trans.WeekdaysAbbreviated()
235
236 for i, day := range days {
237 s := trans.WeekdayAbbreviated(time.Weekday(i))
238 if s != day {
239 t.Errorf("Expected '%s' Got '%s'", day, s)
240 }
241 }
242
243 tests := []struct {
244 idx int
245 expected string
246 }{
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 }
276
277 for _, tt := range tests {
278 s := trans.WeekdayAbbreviated(time.Weekday(tt.idx))
279 if s != tt.expected {
280 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
281 }
282 }
283 }
284
285 func TestDaysNarrow(t *testing.T) {
286
287 trans := New()
288 days := trans.WeekdaysNarrow()
289
290 for i, day := range days {
291 s := trans.WeekdayNarrow(time.Weekday(i))
292 if s != day {
293 t.Errorf("Expected '%s' Got '%s'", string(day), s)
294 }
295 }
296
297 tests := []struct {
298 idx int
299 expected string
300 }{
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329 }
330
331 for _, tt := range tests {
332 s := trans.WeekdayNarrow(time.Weekday(tt.idx))
333 if s != tt.expected {
334 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
335 }
336 }
337 }
338
339 func TestDaysShort(t *testing.T) {
340
341 trans := New()
342 days := trans.WeekdaysShort()
343
344 for i, day := range days {
345 s := trans.WeekdayShort(time.Weekday(i))
346 if s != day {
347 t.Errorf("Expected '%s' Got '%s'", day, s)
348 }
349 }
350
351 tests := []struct {
352 idx int
353 expected string
354 }{
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383 }
384
385 for _, tt := range tests {
386 s := trans.WeekdayShort(time.Weekday(tt.idx))
387 if s != tt.expected {
388 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
389 }
390 }
391 }
392
393 func TestDaysWide(t *testing.T) {
394
395 trans := New()
396 days := trans.WeekdaysWide()
397
398 for i, day := range days {
399 s := trans.WeekdayWide(time.Weekday(i))
400 if s != day {
401 t.Errorf("Expected '%s' Got '%s'", day, s)
402 }
403 }
404
405 tests := []struct {
406 idx int
407 expected string
408 }{
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437 }
438
439 for _, tt := range tests {
440 s := trans.WeekdayWide(time.Weekday(tt.idx))
441 if s != tt.expected {
442 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
443 }
444 }
445 }
446
447 func TestMonthsAbbreviated(t *testing.T) {
448
449 trans := New()
450 months := trans.MonthsAbbreviated()
451
452 for i, month := range months {
453 s := trans.MonthAbbreviated(time.Month(i + 1))
454 if s != month {
455 t.Errorf("Expected '%s' Got '%s'", month, s)
456 }
457 }
458
459 tests := []struct {
460 idx int
461 expected string
462 }{
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511 }
512
513 for _, tt := range tests {
514 s := trans.MonthAbbreviated(time.Month(tt.idx))
515 if s != tt.expected {
516 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
517 }
518 }
519 }
520
521 func TestMonthsNarrow(t *testing.T) {
522
523 trans := New()
524 months := trans.MonthsNarrow()
525
526 for i, month := range months {
527 s := trans.MonthNarrow(time.Month(i + 1))
528 if s != month {
529 t.Errorf("Expected '%s' Got '%s'", month, s)
530 }
531 }
532
533 tests := []struct {
534 idx int
535 expected string
536 }{
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585 }
586
587 for _, tt := range tests {
588 s := trans.MonthNarrow(time.Month(tt.idx))
589 if s != tt.expected {
590 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
591 }
592 }
593 }
594
595 func TestMonthsWide(t *testing.T) {
596
597 trans := New()
598 months := trans.MonthsWide()
599
600 for i, month := range months {
601 s := trans.MonthWide(time.Month(i + 1))
602 if s != month {
603 t.Errorf("Expected '%s' Got '%s'", month, s)
604 }
605 }
606
607 tests := []struct {
608 idx int
609 expected string
610 }{
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659 }
660
661 for _, tt := range tests {
662 s := string(trans.MonthWide(time.Month(tt.idx)))
663 if s != tt.expected {
664 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
665 }
666 }
667 }
668
669 func TestFmtTimeFull(t *testing.T) {
670
671
672
673
674
675
676
677
678 tests := []struct {
679 t time.Time
680 expected string
681 }{
682
683
684
685
686
687
688
689
690 }
691
692 trans := New()
693
694 for _, tt := range tests {
695 s := trans.FmtTimeFull(tt.t)
696 if s != tt.expected {
697 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
698 }
699 }
700 }
701
702 func TestFmtTimeLong(t *testing.T) {
703
704
705
706
707
708
709 tests := []struct {
710 t time.Time
711 expected string
712 }{
713
714
715
716
717
718
719
720
721 }
722
723 trans := New()
724
725 for _, tt := range tests {
726 s := trans.FmtTimeLong(tt.t)
727 if s != tt.expected {
728 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
729 }
730 }
731 }
732
733 func TestFmtTimeMedium(t *testing.T) {
734
735 tests := []struct {
736 t time.Time
737 expected string
738 }{
739
740
741
742
743
744
745
746
747 }
748
749 trans := New()
750
751 for _, tt := range tests {
752 s := trans.FmtTimeMedium(tt.t)
753 if s != tt.expected {
754 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
755 }
756 }
757 }
758
759 func TestFmtTimeShort(t *testing.T) {
760
761 tests := []struct {
762 t time.Time
763 expected string
764 }{
765
766
767
768
769
770
771
772
773 }
774
775 trans := New()
776
777 for _, tt := range tests {
778 s := trans.FmtTimeShort(tt.t)
779 if s != tt.expected {
780 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
781 }
782 }
783 }
784
785 func TestFmtDateFull(t *testing.T) {
786
787 tests := []struct {
788 t time.Time
789 expected string
790 }{
791
792
793
794
795 }
796
797 trans := New()
798
799 for _, tt := range tests {
800 s := trans.FmtDateFull(tt.t)
801 if s != tt.expected {
802 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
803 }
804 }
805 }
806
807 func TestFmtDateLong(t *testing.T) {
808
809 tests := []struct {
810 t time.Time
811 expected string
812 }{
813
814
815
816
817 }
818
819 trans := New()
820
821 for _, tt := range tests {
822 s := trans.FmtDateLong(tt.t)
823 if s != tt.expected {
824 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
825 }
826 }
827 }
828
829 func TestFmtDateMedium(t *testing.T) {
830
831 tests := []struct {
832 t time.Time
833 expected string
834 }{
835
836
837
838
839 }
840
841 trans := New()
842
843 for _, tt := range tests {
844 s := trans.FmtDateMedium(tt.t)
845 if s != tt.expected {
846 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
847 }
848 }
849 }
850
851 func TestFmtDateShort(t *testing.T) {
852
853 tests := []struct {
854 t time.Time
855 expected string
856 }{
857
858
859
860
861
862
863
864
865 }
866
867 trans := New()
868
869 for _, tt := range tests {
870 s := trans.FmtDateShort(tt.t)
871 if s != tt.expected {
872 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
873 }
874 }
875 }
876
877 func TestFmtNumber(t *testing.T) {
878
879 tests := []struct {
880 num float64
881 v uint64
882 expected string
883 }{
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924 }
925
926 trans := New()
927
928 for _, tt := range tests {
929 s := trans.FmtNumber(tt.num, tt.v)
930 if s != tt.expected {
931 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
932 }
933 }
934 }
935
936 func TestFmtCurrency(t *testing.T) {
937
938 tests := []struct {
939 num float64
940 v uint64
941 currency currency.Type
942 expected string
943 }{
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998 }
999
1000 trans := New()
1001
1002 for _, tt := range tests {
1003 s := trans.FmtCurrency(tt.num, tt.v, tt.currency)
1004 if s != tt.expected {
1005 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
1006 }
1007 }
1008 }
1009
1010 func TestFmtAccounting(t *testing.T) {
1011
1012 tests := []struct {
1013 num float64
1014 v uint64
1015 currency currency.Type
1016 expected string
1017 }{
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066 }
1067
1068 trans := New()
1069
1070 for _, tt := range tests {
1071 s := trans.FmtAccounting(tt.num, tt.v, tt.currency)
1072 if s != tt.expected {
1073 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
1074 }
1075 }
1076 }
1077
1078 func TestFmtPercent(t *testing.T) {
1079
1080 tests := []struct {
1081 num float64
1082 v uint64
1083 expected string
1084 }{
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110 }
1111
1112 trans := New()
1113
1114 for _, tt := range tests {
1115 s := trans.FmtPercent(tt.num, tt.v)
1116 if s != tt.expected {
1117 t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
1118 }
1119 }
1120 }
1121
View as plain text