From 278d78532b8fc57e4a1f3b7e9a3a39405b902c41 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 17 Aug 2019 14:00:21 -0500 Subject: [PATCH] Convert ReadabilityTest to Kotlin --- .../simplemarkdown/ReadabilityTest.java | 52 ------------------- .../simplemarkdown/ReadabilityTest.kt | 49 +++++++++++++++++ 2 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.java create mode 100644 app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.kt diff --git a/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.java b/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.java deleted file mode 100644 index 3f73e04..0000000 --- a/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.wbrawner.simplemarkdown; - -import com.wbrawner.simplemarkdown.model.Readability; -import com.wbrawner.simplemarkdown.model.Sentence; -import eu.crydee.syllablecounter.SyllableCounter; -import org.junit.Test; - -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class ReadabilityTest { - - @Test - public void break_content_into_sentances() { - SyllableCounter sc = new SyllableCounter(); - assertEquals(4, sc.count("facility")); - } - - @Test - public void can_break_text_into_sentences_with_indexes(){ - String content = "Hop on pop. I am a fish. This is a test."; - Readability readability = new Readability(content); - List sentenceList = readability.sentences(); - - assertEquals(3, sentenceList.size()); - - Sentence hopOnPop = sentenceList.get(0); - assertEquals(hopOnPop.toString(), "Hop on pop"); - assertEquals(0, hopOnPop.start()); - assertEquals(10, hopOnPop.end()); - - Sentence iAmAFish = sentenceList.get(1); - assertEquals(iAmAFish.toString(), "I am a fish"); - assertEquals(12, iAmAFish.start()); - assertEquals(23, iAmAFish.end()); - - Sentence thisIsATest = sentenceList.get(2); - assertEquals(thisIsATest.toString(), "This is a test"); - assertEquals(25, thisIsATest.start()); - assertEquals(39, thisIsATest.end()); - } - - - @Test - public void get_syllable_count_for_sentence(){ - assertEquals(8, new Sentence("This is the song that never ends").syllableCount()); - assertEquals(10, new Sentence("facility facility downing").syllableCount()); - } - - -} diff --git a/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.kt b/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.kt new file mode 100644 index 0000000..9602ddb --- /dev/null +++ b/app/src/test/java/com/wbrawner/simplemarkdown/ReadabilityTest.kt @@ -0,0 +1,49 @@ +package com.wbrawner.simplemarkdown + +import com.wbrawner.simplemarkdown.model.Readability +import com.wbrawner.simplemarkdown.model.Sentence +import eu.crydee.syllablecounter.SyllableCounter +import org.junit.Assert.assertEquals +import org.junit.Test + +class ReadabilityTest { + + @Test + fun break_content_into_sentances() { + val sc = SyllableCounter() + assertEquals(4, sc.count("facility").toLong()) + } + + @Test + fun can_break_text_into_sentences_with_indexes() { + val content = "Hop on pop. I am a fish. This is a test." + val readability = Readability(content) + val sentenceList = readability.sentences() + + assertEquals(3, sentenceList.size.toLong()) + + val hopOnPop = sentenceList[0] + assertEquals(hopOnPop.toString(), "Hop on pop") + assertEquals(0, hopOnPop.start().toLong()) + assertEquals(10, hopOnPop.end().toLong()) + + val iAmAFish = sentenceList[1] + assertEquals(iAmAFish.toString(), "I am a fish") + assertEquals(12, iAmAFish.start().toLong()) + assertEquals(23, iAmAFish.end().toLong()) + + val thisIsATest = sentenceList[2] + assertEquals(thisIsATest.toString(), "This is a test") + assertEquals(25, thisIsATest.start().toLong()) + assertEquals(39, thisIsATest.end().toLong()) + } + + + @Test + fun get_syllable_count_for_sentence() { + assertEquals(8, Sentence("This is the song that never ends").syllableCount().toLong()) + assertEquals(10, Sentence("facility facility downing").syllableCount().toLong()) + } + + +}