Run AtomTextTest with Robolectric (#4771)

This commit is contained in:
Herbert Reiter 2020-12-20 16:06:14 +01:00 committed by GitHub
parent c10d1a1d79
commit 72f4296150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 49 deletions

View File

@ -1,49 +0,0 @@
package de.danoeh.antennapod.core.syndication.namespace.atom;
import androidx.test.filters.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.runners.Parameterized.Parameter;
import static org.junit.runners.Parameterized.Parameters;
import static org.junit.Assert.assertEquals;
/**
* Unit test for {@link AtomText}.
*/
@SmallTest
@RunWith(Parameterized.class)
public class AtomTextTest {
@Parameter(value = 0)
public String input;
@Parameter(value = 1)
public String expectedOutput;
@Parameters
public static Collection<Object[]> initParameters() {
return Arrays.asList(new Object[][] {
{"&gt;", ">"},
{">", ">"},
{"&lt;Fran&ccedil;ais&gt;", "<Français>"},
{"ßÄÖÜ", "ßÄÖÜ"},
{"&quot;", "\""},
{"&szlig;", "ß"},
{"&#8217;", ""},
{"&#x2030;", ""},
{"&euro;", ""},
});
}
@Test
public void testProcessingHtml() {
final AtomText atomText = new AtomText("", new NSAtom(), AtomText.TYPE_HTML);
atomText.setContent(input);
assertEquals(expectedOutput, atomText.getProcessedContent());
}
}

View File

@ -0,0 +1,35 @@
package de.danoeh.antennapod.core.syndication.namespace.atom;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
/**
* Unit test for {@link AtomText}.
*/
@RunWith(RobolectricTestRunner.class)
public class AtomTextTest {
private static final String[][] TEST_DATA = {
{"&gt;", ">"},
{">", ">"},
{"&lt;Fran&ccedil;ais&gt;", "<Français>"},
{"ßÄÖÜ", "ßÄÖÜ"},
{"&quot;", "\""},
{"&szlig;", "ß"},
{"&#8217;", ""},
{"&#x2030;", ""},
{"&euro;", ""}
};
@Test
public void testProcessingHtml() {
for (String[] pair : TEST_DATA) {
final AtomText atomText = new AtomText("", new NSAtom(), AtomText.TYPE_HTML);
atomText.setContent(pair[0]);
assertEquals(pair[1], atomText.getProcessedContent());
}
}
}