J.Pabrieža noted: dual only on 2
This commit is contained in:
parent
347d1d10ad
commit
ee628379d7
3 changed files with 29 additions and 8 deletions
12
README.md
12
README.md
|
@ -22,6 +22,18 @@ https://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms
|
||||||
* 2 - other plural. Ex. 25 lapā
|
* 2 - other plural. Ex. 25 lapā
|
||||||
* 3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu
|
* 3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu
|
||||||
|
|
||||||
|
## Build and run
|
||||||
|
|
||||||
|
Code should be compilled:
|
||||||
|
```
|
||||||
|
$ gcc -o plural plural.c
|
||||||
|
```
|
||||||
|
|
||||||
|
Then it can be run to see testing results.
|
||||||
|
```
|
||||||
|
$ ./plural
|
||||||
|
```
|
||||||
|
|
||||||
## Result
|
## Result
|
||||||
|
|
||||||
See result.txt
|
See result.txt
|
||||||
|
|
17
plural.c
17
plural.c
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
main() {
|
int main() {
|
||||||
int i;
|
int i;
|
||||||
int n;
|
int n;
|
||||||
int plural;
|
int plural;
|
||||||
|
@ -21,25 +21,32 @@ main() {
|
||||||
printf("This is test of plural forms for Samogitian languages\n");
|
printf("This is test of plural forms for Samogitian languages\n");
|
||||||
printf("Written by Arns Udovič in 2021 <a@arns.lt>\n\n");
|
printf("Written by Arns Udovič in 2021 <a@arns.lt>\n\n");
|
||||||
printf("0 - singular or ending in 1 with exception for 11. Ex., 1 laps\n");
|
printf("0 - singular or ending in 1 with exception for 11. Ex., 1 laps\n");
|
||||||
printf("1 - dual or ending in 2 with exception for 12. Ex. 2 lapo\n");
|
printf("1 - dual. Ex. 2 lapo\n");
|
||||||
printf("2 - other plural. Ex. 25 lapā\n");
|
printf("2 - other plural. Ex. 25 lapā\n");
|
||||||
printf("3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu\n\n");
|
printf("3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu\n\n");
|
||||||
|
|
||||||
int data[] = {0, 1, 2, 3, 10, 11, 15, 20, 21, 22, 25, 100, 101, 102, 115, 200, 1000, 100000};
|
int data[] = {0, 1, 2, 3, 10, 11, 15, 20, 21, 22, 25, 100, 101, 102, 115, 200, 1000, 100000};
|
||||||
int result[] = {3, 0, 1, 2, 3, 3, 3, 3, 0, 1, 2, 3, 0, 1, 3, 3, 3, 3};
|
int result[] = {3, 0, 1, 2, 3, 3, 3, 3, 0, 2, 2, 3, 0, 2, 3, 3, 3, 3};
|
||||||
|
|
||||||
for (i = 0; i < sizeof(data)/sizeof(int); ++i) {
|
for (i = 0; i < sizeof(data)/sizeof(int); ++i) {
|
||||||
n = data[i];
|
n = data[i];
|
||||||
|
|
||||||
plural=(n % 10 == 1 && n % 100 != 11) ? 0
|
plural=(n % 10 == 1 && n % 100 != 11) ? 0
|
||||||
: ((n % 10 == 2 && n % 100 != 12) ? 1
|
: ((n == 2) ? 1
|
||||||
: ((n % 10 >= 3 && n % 10 <= 9 && (n % 100 < 11 || n % 100 > 19)) ? 2
|
: ((n != 2 && n % 10 >= 2 && n % 10 <= 9 && (n % 100 < 11 || n % 100 > 19)) ? 2
|
||||||
: 3));
|
: 3));
|
||||||
|
|
||||||
|
|
||||||
printf("Testing %i, should be: %i, got %i\n", n, result[i], plural);
|
printf("Testing %i, should be: %i, got %i\n", n, result[i], plural);
|
||||||
|
|
||||||
|
if (result[i] != plural) {
|
||||||
|
printf("ERR!\n");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\nPASS\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ This is test of plural forms for Samogitian languages
|
||||||
Written by Arns Udovič in 2021 <a@arns.lt>
|
Written by Arns Udovič in 2021 <a@arns.lt>
|
||||||
|
|
||||||
0 - singular or ending in 1 with exception for 11. Ex., 1 laps
|
0 - singular or ending in 1 with exception for 11. Ex., 1 laps
|
||||||
1 - dual or ending in 2 with exception for 12. Ex. 2 lapo
|
1 - dual. Ex. 2 lapo
|
||||||
2 - other plural. Ex. 25 lapā
|
2 - other plural. Ex. 25 lapā
|
||||||
3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu
|
3 - plural for 11-19, 10, 20, 100... Ex. 12 lapu
|
||||||
|
|
||||||
|
@ -15,12 +15,14 @@ Testing 11, should be: 3, got 3
|
||||||
Testing 15, should be: 3, got 3
|
Testing 15, should be: 3, got 3
|
||||||
Testing 20, should be: 3, got 3
|
Testing 20, should be: 3, got 3
|
||||||
Testing 21, should be: 0, got 0
|
Testing 21, should be: 0, got 0
|
||||||
Testing 22, should be: 1, got 1
|
Testing 22, should be: 2, got 2
|
||||||
Testing 25, should be: 2, got 2
|
Testing 25, should be: 2, got 2
|
||||||
Testing 100, should be: 3, got 3
|
Testing 100, should be: 3, got 3
|
||||||
Testing 101, should be: 0, got 0
|
Testing 101, should be: 0, got 0
|
||||||
Testing 102, should be: 1, got 1
|
Testing 102, should be: 2, got 2
|
||||||
Testing 115, should be: 3, got 3
|
Testing 115, should be: 3, got 3
|
||||||
Testing 200, should be: 3, got 3
|
Testing 200, should be: 3, got 3
|
||||||
Testing 1000, should be: 3, got 3
|
Testing 1000, should be: 3, got 3
|
||||||
Testing 100000, should be: 3, got 3
|
Testing 100000, should be: 3, got 3
|
||||||
|
|
||||||
|
PASS
|
||||||
|
|
Loading…
Reference in a new issue