diff --git a/test/net/sourceforge/plantuml/UrlBuilderTest.java b/test/net/sourceforge/plantuml/UrlBuilderTest.java deleted file mode 100644 index fd2c076da..000000000 --- a/test/net/sourceforge/plantuml/UrlBuilderTest.java +++ /dev/null @@ -1,155 +0,0 @@ -package net.sourceforge.plantuml; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -import net.sourceforge.plantuml.url.Url; -import net.sourceforge.plantuml.url.UrlBuilder; -import net.sourceforge.plantuml.url.UrlMode; - -class UrlBuilderTest { - - @Test - public void testGetUrl10() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "http://foo", "http://foo", b.getUrl("[[http://foo]]")); - } - - @Test - public void testGetUrl11() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "tooltip", "text", b.getUrl("[[http://foo{tooltip} text]]")); - } - - @Test - public void testGetUrl12() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "tooltip", "text", b.getUrl("[[http://foo {tooltip} text]]")); - } - - @Test - public void testGetUrl13() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "tooltip", "http://foo", b.getUrl("[[http://foo {tooltip}]]")); - } - - @Test - public void testGetUrl15() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "http://foo", "text", b.getUrl("[[http://foo text]]")); - } - - @Test - public void testGetUrl18() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo", "http://foo", "http://foo", b.getUrl("[[ http://foo ]]")); - } - - @Test - public void testGetUrl20() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo test", "http://foo test", "http://foo test", b.getUrl("[[\"http://foo test\"]]")); - } - - @Test - public void testGetUrl30() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.ANYWHERE); - assertUrl("http://foo test", "http://foo test", "http://foo test", - b.getUrl("start [[\"http://foo test\"]] end")); - } - - @Test - public void testGetUrl40() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://google.com", "a nice toolip", "", - b.getUrl("[[http://google.com{a nice toolip} ]]")); - } - - @Test - public void testGetUrl41() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://google.com", "a nice toolip", "", - b.getUrl("[[http://google.com {a nice toolip} ]]")); - } - - @Test - public void testGetUrl42() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://google.com", "http://google.com", "", - b.getUrl("[[http://google.com ]]")); - } - - @Test - public void testGetUrl50() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://google.com", "http://google.com", "", - b.getUrl("[[http://google.com ]]")); - } - - @Test - public void testGetUrl60() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo?dummy={123}&action=edit", "http://foo?dummy={123}&action=edit", - "http://foo?dummy={123}&action=edit", b.getUrl("[[http://foo?dummy={123}&action=edit]]")); - } - - @Test - public void testGetUrl70() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://www.plantuml.com", "Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}", - "http://www.plantuml.com", - b.getUrl("[[http://www.plantuml.com{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]")); - } - - @Test - public void testGetUrl80() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo?dummy=", "123}z{", "http://foo?dummy=", b.getUrl("[[http://foo?dummy={123}z{}]]")); - } - - @Test - public void testGetUrl90() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("", "tooltip", "some text", b.getUrl("[[{tooltip} some text]]")); - } - - @Test - public void testGetUrl100() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.ANYWHERE); - assertUrl("www.google.com", "www.google.com", "POST /session/csrStart", - b.getUrl("fromor [[www.google.com POST /session/csrStart]] end")); - } - - @Test - public void testGetUrl110() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("blaha(xyz,12)", " tooltip ", "blaha(xyz,12)", b.getUrl("[[ blaha(xyz,12){ tooltip } ]]")); - } - - @Test - public void testGetUrl120() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("", "Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}", "", - b.getUrl("[[{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]")); - } - - @Test - public void testGetUrl130() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo?dummy=", "123}{", "http://foo?dummy=", b.getUrl("[[http://foo?dummy={123}{}]]")); - } - - @Test - public void testGetUrl140() { - final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT); - assertUrl("http://foo?dummy={123}", "", "http://foo?dummy={123}", b.getUrl("[[\"http://foo?dummy={123}\"{}]]")); - } - - public void assertUrl(String urlLink, String tooltip, String label, Url url) { - assertEquals(urlLink, url.getUrl(), "url"); - assertEquals(tooltip, url.getTooltip(), "tooltip"); - assertEquals(label, url.getLabel(), "label"); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math01Test.java b/test/net/sourceforge/plantuml/math/Math01Test.java deleted file mode 100644 index 64865c751..000000000 --- a/test/net/sourceforge/plantuml/math/Math01Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math01Test { - - private final String math = "f(x)"; - private final String expected = "{f{{\\left({x}\\right)}}}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math02Test.java b/test/net/sourceforge/plantuml/math/Math02Test.java deleted file mode 100644 index 739385d73..000000000 --- a/test/net/sourceforge/plantuml/math/Math02Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math02Test { - - private final String math = "x"; - private final String expected = "{x}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math03Test.java b/test/net/sourceforge/plantuml/math/Math03Test.java deleted file mode 100644 index 38f0b3afc..000000000 --- a/test/net/sourceforge/plantuml/math/Math03Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math03Test { - - private final String math = "color(red)(f(t))=color(blue)((a_0)/2 + sum_(n=1)^ooa_ncos((npit)/L)+sum_(n=1)^oo b_n\\ sin((npit)/L))"; - private final String expected = "{\\textcolor{red}{{f{{\\left({t}\\right)}}}}}={\\textcolor{blue}{\\frac{{{a}_{{0}}}}{{2}}+{\\sum_{{{n}={1}}}^{\\infty}}{a}_{{n}}{\\cos{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}+{\\sum_{{{n}={1}}}^{\\infty}}{b}_{{n}}\\ {\\sin{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}}}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math04Test.java b/test/net/sourceforge/plantuml/math/Math04Test.java deleted file mode 100644 index f55cba6f4..000000000 --- a/test/net/sourceforge/plantuml/math/Math04Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math04Test { - - private final String math = "abs(x)"; - private final String expected = "{\\left|{{x}}\\right|}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math05Test.java b/test/net/sourceforge/plantuml/math/Math05Test.java deleted file mode 100644 index f6e4ffebf..000000000 --- a/test/net/sourceforge/plantuml/math/Math05Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math05Test { - - private final String math = "y=ceil(x)"; - private final String expected = "{y}={\\left\\lceil{{x}}\\right\\rceil}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math06Test.java b/test/net/sourceforge/plantuml/math/Math06Test.java deleted file mode 100644 index fb9efd85d..000000000 --- a/test/net/sourceforge/plantuml/math/Math06Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math06Test { - - private final String math = "f(t)=(a_0)/2 + sum_(n=1)^ooa_ncos((npit)/L)+sum_(n=1)^oo b_n\\ sin((npit)/L)"; - private final String expected = "{f{{\\left({t}\\right)}}}=\\frac{{{a}_{{0}}}}{{2}}+{\\sum_{{{n}={1}}}^{\\infty}}{a}_{{n}}{\\cos{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}+{\\sum_{{{n}={1}}}^{\\infty}}{b}_{{n}}\\ {\\sin{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math07Test.java b/test/net/sourceforge/plantuml/math/Math07Test.java deleted file mode 100644 index 317632937..000000000 --- a/test/net/sourceforge/plantuml/math/Math07Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math07Test { - - private final String math = "[[a,b],[c,d]]"; - private final String expected = "{\\left[\\begin{matrix}{a}&{b}\\\\{c}&{d}\\end{matrix}\\right]}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math08Test.java b/test/net/sourceforge/plantuml/math/Math08Test.java deleted file mode 100644 index dd18e9a02..000000000 --- a/test/net/sourceforge/plantuml/math/Math08Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math08Test { - - private final String math = "color(red)(x)"; - private final String expected = "{\\textcolor{red}{{x}}}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/Math09Test.java b/test/net/sourceforge/plantuml/math/Math09Test.java deleted file mode 100644 index 6997a7f8b..000000000 --- a/test/net/sourceforge/plantuml/math/Math09Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.sourceforge.plantuml.math; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -class Math09Test { - - private final String math = "color(red)(t)=color(blue)(x)"; - private final String expected = "{\\textcolor{red}{{t}}}={\\textcolor{blue}{{x}}}"; - - @Test - public void testJava() { - final String res = new ASCIIMathTeXImg().getTeX(math); - assertEquals(expected, res); - } - -} diff --git a/test/net/sourceforge/plantuml/math/MathTest.java b/test/net/sourceforge/plantuml/math/MathTest.java new file mode 100644 index 000000000..d649d9c77 --- /dev/null +++ b/test/net/sourceforge/plantuml/math/MathTest.java @@ -0,0 +1,25 @@ +package net.sourceforge.plantuml.math; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +class MathTest { + @ParameterizedTest + @CsvSource(value = { + " f(x), {f{{\\left({x}\\right)}}} ", + " x, {x} ", + " color(red)(f(t))=color(blue)((a_0)/2 + sum_(n=1)^ooa_ncos((npit)/L)+sum_(n=1)^oo b_n\\ sin((npit)/L)), {\\textcolor{red}{{f{{\\left({t}\\right)}}}}}={\\textcolor{blue}{\\frac{{{a}_{{0}}}}{{2}}+{\\sum_{{{n}={1}}}^{\\infty}}{a}_{{n}}{\\cos{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}+{\\sum_{{{n}={1}}}^{\\infty}}{b}_{{n}}\\ {\\sin{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}}} ", + " abs(x), {\\left|{{x}}\\right|} ", + " y=ceil(x), {y}={\\left\\lceil{{x}}\\right\\rceil} ", + " f(t)=(a_0)/2 + sum_(n=1)^ooa_ncos((npit)/L)+sum_(n=1)^oo b_n\\ sin((npit)/L), {f{{\\left({t}\\right)}}}=\\frac{{{a}_{{0}}}}{{2}}+{\\sum_{{{n}={1}}}^{\\infty}}{a}_{{n}}{\\cos{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}}+{\\sum_{{{n}={1}}}^{\\infty}}{b}_{{n}}\\ {\\sin{{\\left(\\frac{{{n}\\pi{t}}}{{L}}\\right)}}} ", + " '[[a,b],[c,d]]', {\\left[\\begin{matrix}{a}&{b}\\\\{c}&{d}\\end{matrix}\\right]} ", + " color(red)(x), {\\textcolor{red}{{x}}} ", + " color(red)(t)=color(blue)(x), {\\textcolor{red}{{t}}}={\\textcolor{blue}{{x}}} ", + }) + public void testMath(String input, String expected) { + final String res = new ASCIIMathTeXImg().getTeX(input); + assertEquals(expected, res); + } +} diff --git a/test/net/sourceforge/plantuml/url/UrlBuilderTest.java b/test/net/sourceforge/plantuml/url/UrlBuilderTest.java new file mode 100644 index 000000000..d5cd77324 --- /dev/null +++ b/test/net/sourceforge/plantuml/url/UrlBuilderTest.java @@ -0,0 +1,43 @@ +package net.sourceforge.plantuml; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import net.sourceforge.plantuml.url.Url; +import net.sourceforge.plantuml.url.UrlBuilder; +import net.sourceforge.plantuml.url.UrlMode; + +class UrlBuilderTest { + @ParameterizedTest + @CsvSource(value = { + " [[http://foo]], STRICT, http://foo, http://foo, http://foo ", + " [[http://foo{tooltip} text]], STRICT, http://foo, tooltip, text ", + " [[http://foo {tooltip} text]], STRICT, http://foo, tooltip, text ", + " [[http://foo {tooltip}]], STRICT, http://foo, tooltip, http://foo ", + " [[http://foo text]], STRICT, http://foo, http://foo, text ", + " [[ http://foo ]], STRICT, http://foo, http://foo, http://foo ", + " [[\"http://foo text\"]], STRICT, http://foo text, http://foo text, http://foo text ", + " start [[\"http://foo test\"]] end, ANYWHERE, http://foo test, http://foo test, http://foo test ", + " [[http://google.com{a nice toolip} ]], STRICT, http://google.com, a nice toolip, ", + " [[http://google.com {a nice toolip} ]], STRICT, http://google.com, a nice toolip, ", + " [[http://google.com ]], STRICT, http://google.com, http://google.com, ", + " [[http://foo?dummy={123}&action=edit]], STRICT, http://foo?dummy={123}&action=edit, http://foo?dummy={123}&action=edit, http://foo?dummy={123}&action=edit", + " '[[http://www.plantuml.com{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]', STRICT, http://www.plantuml.com, 'Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}', http://www.plantuml.com", + " [[http://foo?dummy={123}z{}]], STRICT, http://foo?dummy=, 123}z{, http://foo?dummy= ", + " [[{tooltip} some text]], STRICT, '', tooltip, some text ", + " fromor [[www.google.com POST /session/csrStart]] end, ANYWHERE, www.google.com, www.google.com, POST /session/csrStart ", + " '[[ blaha(xyz,12){ tooltip } ]]', STRICT, 'blaha(xyz,12)', ' tooltip ', 'blaha(xyz,12)' ", + " '[[{Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}}]]', STRICT, '', 'Json: {\"firstName\":\"Bob\", \"lastName\":\"Smith\"}','' ", + " [[http://foo?dummy={123}{}]], STRICT, http://foo?dummy=, 123}{, http://foo?dummy= ", + " [[\"http://foo?dummy={123}\"{}]], STRICT, http://foo?dummy={123}, '', http://foo?dummy={123} ", + }) + public void testUrl(String input, String urlMode, String urlLink, String tooltip, String label) { + final UrlBuilder b = new UrlBuilder(null, UrlMode.valueOf(urlMode)); + final Url url = b.getUrl(input); + assertEquals(urlLink, url.getUrl(), "url"); + assertEquals(tooltip, url.getTooltip(), "tooltip"); + assertEquals(label, url.getLabel(), "label"); + } +}