diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /share/extensions/tests/test_text_titlecase.py | |
parent | Initial commit. (diff) | |
download | inkscape-upstream/1.2.2.tar.xz inkscape-upstream/1.2.2.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | share/extensions/tests/test_text_titlecase.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/share/extensions/tests/test_text_titlecase.py b/share/extensions/tests/test_text_titlecase.py new file mode 100644 index 0000000..85fb655 --- /dev/null +++ b/share/extensions/tests/test_text_titlecase.py @@ -0,0 +1,70 @@ +# coding=utf-8 +""" +Test titlecase extension +""" + +import string + +from inkex.tester import ComparisonMixin, TestCase +from inkex.tester.word import sentencecase, word_generator +from text_titlecase import TitleCase + + +class TitleCaseTest(ComparisonMixin, TestCase): + effect_class = TitleCase + comparisons = [()] + + def test_lowercase(self): + var = word_generator(6) + var1 = word_generator(9) + var2 = word_generator(10) + words = var.lower() + " " + var1.lower() + " " + var2.lower() + titlecase = self.effect.process_chardata(words) + self.assertEqual(self.effect.process_chardata(words), titlecase) + + def test_uppercase(self): + var = word_generator(6) + var1 = word_generator(9) + var2 = word_generator(10) + words = var.upper() + " " + var1.upper() + " " + var2.upper() + titlecase = self.effect.process_chardata(words) + self.assertEqual(self.effect.process_chardata(words), titlecase) + + def test_sentencecase(self): + var = word_generator(5) + var1 = word_generator(8) + var2 = word_generator(7) + words = var + " " + var1 + " " + var2 + word_new = sentencecase(words) + titlecase = self.effect.process_chardata(word_new) + self.assertEqual(self.effect.process_chardata(word_new), titlecase) + + def test_numbers_before(self): + words = word_generator(15) + word_new = words.zfill(20) + titlecase = self.effect.process_chardata(word_new) + self.assertEqual(self.effect.process_chardata(word_new), titlecase) + + def test_punctuation_before(self): + words = word_generator(15) + word_new = string.punctuation + words + titlecase = self.effect.process_chardata(word_new) + self.assertEqual(self.effect.process_chardata(word_new), titlecase) + + def test_check_strings(self): + titlecase_strings = [ + ("i love inkscape", "I Love Inkscape"), + ("i LOVE inkscape", "I Love Inkscape"), + ("I love Inkscape", "I Love Inkscape"), + ("I LOVE INKSCAPE", "I Love Inkscape"), + ("ThIs Is VeRy AwEsOmE", "This Is Very Awesome"), + ("!$this is Very awesome.", "!$This Is Very Awesome."), + ("this *is @very ^awesome.", "This *Is @Very ^Awesome."), + ("there is a space.", "There Is A Space."), + ("9these 5are 7numbers", "9These 5Are 7Numbers"), + ("thisworddidnotend", "Thisworddidnotend"), + ("This Should Not Change", "This Should Not Change"), + ] + + for item in titlecase_strings: + self.assertEqual(self.effect.process_chardata(item[0]), item[1]) |