Skip to content

Commit

Permalink
#710 add new string and plurals tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ExNDY committed May 17, 2024
1 parent 4cde7de commit 6308565
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.gradle.generator.pluralsGenerator

import dev.icerock.gradle.utils.convertXmlStringToAndroidLocalization
import dev.icerock.gradle.utils.convertXmlStringToApplePluralLocalization
import dev.icerock.gradle.utils.convertXmlStringToLocalization
import kotlin.test.Test
import kotlin.test.assertEquals

class XmlPluralsToPlatformRuTest {
@Test
fun simplePluralsAppleTest(){
assertEquals(
expected = """%d число "%s"""",
actual ="%d число \"%s\"".convertXmlStringToApplePluralLocalization(),
)
}

@Test
fun simplePluralsAndroidTest(){
assertEquals(
expected = """%d число \"%s\"""",
actual ="%d число \"%s\"".convertXmlStringToAndroidLocalization(),
)
}

@Test
fun simplePluralsOtherPlatformsTest() {
assertEquals(
expected = """%d число \"%s\"""",
actual ="%d число \"%s\"".convertXmlStringToLocalization(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.gradle.generator.pluralsGenerator

import dev.icerock.gradle.utils.convertXmlStringToAndroidLocalization
import dev.icerock.gradle.utils.convertXmlStringToApplePluralLocalization
import dev.icerock.gradle.utils.convertXmlStringToLocalization
import kotlin.test.Test
import kotlin.test.assertEquals

class XmlPluralsToPlatformTest {
@Test
fun simplePluralsAppleTest(){
assertEquals(
expected = """%d count of "%s"""",
actual ="%d count of \"%s\"".convertXmlStringToApplePluralLocalization(),
)
}

@Test
fun simplePluralsAndroidTest(){
assertEquals(
expected = """%d count of \"%s\"""",
actual ="%d count of \"%s\"".convertXmlStringToAndroidLocalization(),
)
}

@Test
fun simplePluralsOtherPlatformsTest() {
assertEquals(
expected = """%d count of \"%s\"""",
actual ="%d count of \"%s\"".convertXmlStringToLocalization(),
)
}

@Test
fun pluralWithNewLineAppleTest() {
assertEquals(
expected = """%d count
|of tests""".trimMargin(),
actual ="%d count\nof tests".convertXmlStringToApplePluralLocalization(),
)
}

@Test
fun pluralWithNewLineAndroidTest() {
assertEquals(
expected = """%d count\nof tests""",
actual ="%d count\nof tests".convertXmlStringToAndroidLocalization(),
)
}

@Test
fun pluralWithNewLineOtherPlatformTest() {
assertEquals(
expected = """%d count\nof tests""",
actual ="%d count\nof tests".convertXmlStringToLocalization(),
)
}

@Test
fun separateSymbolsApplePluralsTest() {
assertEquals(
expected = """" ' % @ * & {}""",
actual = "\" ' % @ * & {}".convertXmlStringToApplePluralLocalization()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class XmlStringsToPlatformRuTest {
@Test
fun textWithApostropheAndroid() {
assertEquals(
expected = """Я'ж купил новый 27 дюйм'ов монитор""",
expected = """Я\'ж купил новый 27 дюйм\'ов монитор""",
actual = "Я'ж купил новый 27 дюйм'ов монитор".convertXmlStringToAndroidLocalization()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package dev.icerock.gradle.generator.stringsGenerator

import dev.icerock.gradle.utils.convertXmlStringToAndroidLocalization
import dev.icerock.gradle.utils.convertXmlStringToApplePluralLocalization
import dev.icerock.gradle.utils.convertXmlStringToLocalization
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -29,7 +30,7 @@ class XmlStringsToPlatformTest {
@Test
fun separateSymbolsAndroid() {
assertEquals(
expected = """" ' % @ * & {}""",
expected = """\" \' % @ * & {}""",
actual = "\" ' % @ * & {}".convertXmlStringToAndroidLocalization()
)
}
Expand All @@ -45,7 +46,7 @@ class XmlStringsToPlatformTest {
@Test
fun textWithApostropheAndroid() {
assertEquals(
expected = """I'm bought new monitor with 27 inch's""",
expected = """I\'m bought new monitor with 27 inch\'s""",
actual = "I'm bought new monitor with 27 inch's".convertXmlStringToAndroidLocalization()
)
}
Expand Down Expand Up @@ -73,4 +74,52 @@ class XmlStringsToPlatformTest {
actual = "Text with <b>bold</b>, <i>italic</i>, <u>underline</u>".convertXmlStringToLocalization(),
)
}

@Test
fun textWithQuotesAndroid() {
assertEquals(
expected = """%d count \"%s\"""",
actual = "%d count \"%s\"".convertXmlStringToAndroidLocalization()
)
}

@Test
fun textWithQuotesOtherPlatforms() {
assertEquals(
expected = """%d count \"%s\"""",
actual = "%d count \"%s\"".convertXmlStringToAndroidLocalization()
)
}

@Test
fun unicodeEmojiAppleTest() {
assertEquals(
expected = """😈""",
actual = "\uD83D\uDE08".convertXmlStringToLocalization()
)
}

@Test
fun unicodeEmojiApplePluralTest() {
assertEquals(
expected = """😈""",
actual = "\uD83D\uDE08".convertXmlStringToApplePluralLocalization()
)
}

@Test
fun unicodeEmojiAndroidTest() {
assertEquals(
expected = """😈""",
actual = "\uD83D\uDE08".convertXmlStringToAndroidLocalization()
)
}

@Test
fun unicodeEmojiOtherPlatformTest() {
assertEquals(
expected = """😈""",
actual = "\uD83D\uDE08".convertXmlStringToLocalization()
)
}
}

0 comments on commit 6308565

Please sign in to comment.