Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anarak404 PR of Rewrite tests - but with resolved conflicts and added new languages #173

Merged
merged 25 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04c0c68
#147 | feat(tests): separate integer and long values tests
Anarak404 Dec 16, 2023
7cdafe5
#147 | feat(tests): adjust bulgarian values tests
Anarak404 Dec 16, 2023
b1ac101
#147 | feat(tests): adjust croatian values tests
Anarak404 Dec 16, 2023
a0fd63a
#147 | feat(tests): adjust czech values tests
Anarak404 Dec 16, 2023
1b7ee1f
#147 | feat(tests): adjust dutch values tests
Anarak404 Dec 16, 2023
fa83e78
#147 | feat(tests): adjust french values tests
Anarak404 Dec 16, 2023
69fa7f0
#147 | feat(tests): adjust german values tests
Anarak404 Dec 16, 2023
b969a8d
#147 | feat(tests): adjust hindi values tests
Anarak404 Dec 16, 2023
46bad60
#147 | feat(tests): adjust italian values tests
Anarak404 Dec 16, 2023
66ff03e
#147 | feat(tests): adjust kazakh values tests
Anarak404 Dec 16, 2023
aa03481
#147 | feat(tests): adjust latvian values tests
Anarak404 Dec 16, 2023
3c7cb9c
#147 | feat(tests): adjust polish values tests
Anarak404 Dec 16, 2023
a0d91fa
#147 | feat(tests): adjust portuguese values tests
Anarak404 Dec 16, 2023
0d9a4f4
#147 | feat(tests): adjust russian values tests
Anarak404 Dec 16, 2023
b89d4a3
#147 | feat(tests): adjust serbian values tests
Anarak404 Dec 16, 2023
81afa95
#147 | feat(tests): adjust slovak values tests
Anarak404 Dec 16, 2023
4dcf175
#147 | feat(tests): adjust slovene values tests
Anarak404 Dec 16, 2023
7aedecb
#147 | feat(tests): adjust spanish values tests
Anarak404 Dec 16, 2023
4f50377
#147 | feat(tests): adjust swedish values tests
Anarak404 Dec 16, 2023
6bd1d2c
#147 | feat(tests): adjust turkish values tests
Anarak404 Dec 16, 2023
6ad1099
#147 | feat(tests): adjust ukrainian values tests
Anarak404 Dec 16, 2023
bc153d4
#147 | feat(tests): add missing translates
Anarak404 Jan 24, 2024
9055284
merge tests by Anarak404
jglaszka Jan 3, 2025
4abc6ce
merge conflicts
jglaszka Jan 3, 2025
e8a3e6c
resolve conflict in spanish tests, rewrite serbian + japanese
jglaszka Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package pl.allegro.finance.tradukisto.internal.languages

import pl.allegro.finance.tradukisto.internal.IntegerToStringConverter
import pl.allegro.finance.tradukisto.internal.LongToStringConverter
import spock.lang.Specification
import spock.lang.Unroll

abstract class AbstractValuesTest extends Specification {
abstract ValuesTestData testData
abstract class AbstractIntegerValuesTest extends Specification {
abstract IntegerValuesTestData testData
abstract IntegerToStringConverter intConverter
abstract LongToStringConverter longConverter

private static final OBLIGATORY_INT_VALUES = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
Expand All @@ -24,19 +22,6 @@ abstract class AbstractValuesTest extends Specification {
1_000_000_000, 2_147_483_647,
]

private static final OBLIGATORY_LONG_VALUES = [
5_000_000_000,
1_000_000_000_000,
2_000_000_000_000,
5_000_000_000_000,
1_000_000_000_000_000,
2_000_000_000_000_000,
5_000_000_000_000_000,
1_000_000_000_000_000_000,
2_000_000_000_000_000_000,
Long.MAX_VALUE
]

@Unroll
def "should convert integer #input to #output"() {
expect:
Expand All @@ -47,47 +32,23 @@ abstract class AbstractValuesTest extends Specification {
output << getTestData().getIntegerTranslations().values()
}

@Unroll
def "should convert long #input to #output"() {
expect:
longConverter.asWords(input) == output

where:
input << getTestData().getLongTranslations().keySet()
output << getTestData().getLongTranslations().values()
}

static class ValuesTestData {
static class IntegerValuesTestData {
private final Map<Integer, String> integerTranslations
private final Map<Long, String> longTranslations

ValuesTestData(Map<Integer, String> integerTranslations, Map<Long, String> longTranslations) {
IntegerValuesTestData(Map<Integer, String> integerTranslations) {
this.integerTranslations = prepareIntegerInput(integerTranslations)
this.longTranslations = prepareLongInput(longTranslations)
}

Map<Integer, String> getIntegerTranslations() {
return integerTranslations
}

Map<Long, String> getLongTranslations() {
return longTranslations
}

private static prepareIntegerInput(Map<Integer, String> intWords) {
OBLIGATORY_INT_VALUES.stream()
.forEach {
intWords.putIfAbsent(it, "⚠️Please specify expected output")
}
return intWords.sort { it.key }
}

private static prepareLongInput(Map<Long, String> longWords) {
OBLIGATORY_LONG_VALUES.stream()
.forEach {
longWords.putIfAbsent(it, "⚠️Please specify expected output")
}
return longWords.sort { it.key }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package pl.allegro.finance.tradukisto.internal.languages

import pl.allegro.finance.tradukisto.internal.LongToStringConverter
import spock.lang.Specification
import spock.lang.Unroll

abstract class AbstractLongValuesTest extends Specification {
abstract LongValuesTestData testData
abstract LongToStringConverter longConverter

private static final OBLIGATORY_LONG_VALUES = [
5_000_000_000,
1_000_000_000_000,
2_000_000_000_000,
5_000_000_000_000,
1_000_000_000_000_000,
2_000_000_000_000_000,
5_000_000_000_000_000,
1_000_000_000_000_000_000,
2_000_000_000_000_000_000,
Long.MAX_VALUE
]

@Unroll
def "should convert long #input to #output"() {
expect:
longConverter.asWords(input) == output

where:
input << getTestData().getLongTranslations().keySet()
output << getTestData().getLongTranslations().values()
}

static class LongValuesTestData {
private final Map<Long, String> longTranslations

LongValuesTestData(Map<Long, String> longTranslations) {
this.longTranslations = prepareLongInput(longTranslations)
}

Map<Long, String> getLongTranslations() {
return longTranslations
}

private static prepareLongInput(Map<Long, String> longWords) {
OBLIGATORY_LONG_VALUES.stream()
.forEach {
longWords.putIfAbsent(it, "⚠️Please specify expected output")
}
return longWords.sort { it.key }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package pl.allegro.finance.tradukisto.internal.languages.bulgarian

import pl.allegro.finance.tradukisto.internal.languages.AbstractIntegerValuesTest

import static pl.allegro.finance.tradukisto.internal.Container.bulgarianContainer

class BulgarianIntegerValuesTest extends AbstractIntegerValuesTest {

def setup() {
intConverter = bulgarianContainer().getIntegerConverter()
}

@Override
IntegerValuesTestData getTestData() {
testData = new IntegerValuesTestData(integerTranslations)
}

private static integerTranslations = [
0 : "нула",
1 : "един",
2 : "два",
3 : "три",
4 : "четири",
5 : "пет",
6 : "шест",
7 : "седем",
8 : "осем",
9 : "девет",

11 : "единадесет",
12 : "дванадесет",
13 : "тринадесет",
14 : "четиринадесет",
15 : "петнадесет",
16 : "шестнадесет",
17 : "седемнадесет",
18 : "осемнадесет",
19 : "деветнадесет",

10 : "десет",
20 : "двадесет",
30 : "тридесет",
40 : "четиридесет",
50 : "петдесет",
60 : "шестдесет",
70 : "седемдесет",
80 : "осемдесет",
90 : "деветдесет",

21 : "двадесет един",
37 : "тридесет седем",
43 : "четиридесет три",
58 : "петдесет осем",
69 : "шестдесет девет",
76 : "седемдесет шест",
82 : "осемдесет два",
95 : "деветдесет пет",

100 : "сто",
200 : "двеста",
300 : "триста",
400 : "четиристотин",
500 : "петстотин",
600 : "шестстотин",
700 : "седемстотин",
800 : "осемстотин",
900 : "деветстотин",

111 : "сто единадесет",
272 : "двеста седемдесет два",
387 : "триста осемдесет седем",
448 : "четиристотин четиридесет осем",
569 : "петстотин шестдесет девет",
625 : "шестстотин двадесет пет",
782 : "седемстотин осемдесет два",
895 : "осемстотин деветдесет пет",
999 : "деветстотин деветдесет девет",

1_000 : "хиляда",
2_000 : "две хиляди",
3_000 : "три хиляди",
4_000 : "четири хиляди",
5_000 : "пет хиляди",
7_634 : "седем хиляди шестстотин тридесет четири",
11_000 : "единадесет хиляди",
15_000 : "петнадесет хиляди",
21_000 : "двадесет една хиляди",
24_190 : "двадесет четири хиляди сто деветдесет",
653_000 : "шестстотин петдесет три хиляди",
123_454 : "сто двадесет три хиляди четиристотин петдесет четири",
700_000 : "седемстотин хиляди",
999_999 : "деветстотин деветдесет девет хиляди деветстотин деветдесет девет",

1_000_000 : "един милион",
2_000_000 : "два милиона",
5_000_000 : "пет милиона",
23_437_219 : "двадесет три милиона четиристотин тридесет седем хиляди двеста деветнадесет",
100_000_000 : "сто милиона",
121_000_000 : "сто двадесет един милион",
123_456_789 : "сто двадесет три милиона четиристотин петдесет шест хиляди седемстотин осемдесет девет",
322_089_890 : "триста двадесет два милиона осемдесет девет хиляди осемстотин деветдесет",

1_000_000_000: "един милиард",
2_147_483_647: "два милиарда сто четиридесет седем милиона четиристотин осемдесет три хиляди шестстотин четиридесет седем"
]
}

This file was deleted.

Loading
Loading