Skip to content

Commit

Permalink
Anarak404 PR of Rewrite tests - but with resolved conflicts and adde…
Browse files Browse the repository at this point in the history
…d new languages (#173)

* #147 | feat(tests): separate integer and long values tests

* #147 | feat(tests): adjust bulgarian values tests

* #147 | feat(tests): adjust croatian values tests

* #147 | feat(tests): adjust czech values tests

* #147 | feat(tests): adjust dutch values tests

* #147 | feat(tests): adjust french values tests

* #147 | feat(tests): adjust german values tests

* #147 | feat(tests): adjust hindi values tests

* #147 | feat(tests): adjust italian values tests

* #147 | feat(tests): adjust kazakh values tests

* #147 | feat(tests): adjust latvian values tests

* #147 | feat(tests): adjust polish values tests

* #147 | feat(tests): adjust portuguese values tests

* #147 | feat(tests): adjust russian values tests

* #147 | feat(tests): adjust serbian values tests

* #147 | feat(tests): adjust slovak values tests

* #147 | feat(tests): adjust slovene values tests

* #147 | feat(tests): adjust spanish values tests

* #147 | feat(tests): adjust swedish values tests

* #147 | feat(tests): adjust turkish values tests

* #147 | feat(tests): adjust ukrainian values tests

* #147 | feat(tests): add missing translates

* merge tests by Anarak404

* resolve conflict in spanish tests, rewrite serbian + japanese

---------

Co-authored-by: Anarak404 <[email protected]>
  • Loading branch information
jglaszka and Anarak404 authored Jan 3, 2025
1 parent 369d1fc commit 8ee5ca4
Show file tree
Hide file tree
Showing 57 changed files with 3,077 additions and 3,260 deletions.
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

0 comments on commit 8ee5ca4

Please sign in to comment.