From 28403a1116b8ab38500a5a9fdd00c5bd2aa2eb59 Mon Sep 17 00:00:00 2001 From: The-Lum <86879521+The-Lum@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:51:17 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20add=20new=20unit=20tests=20(on=20?= =?UTF-8?q?=20text=20)=20and=20fix=20some=20side=20effect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit // new tests for code coverage "text(f)", "text({f})", "text([f])", "text( a)", "text( a )", "text", "text", "text{f}", "text[f]", "text{f", "text[f", "text{f abc", --- app/build.gradle.kts | 5 +++-- app/src/main/java/math/ASCIIMathTeXImg.java | 20 +++++++++++++------- app/src/test/java/math/UnitTestGen.java | 14 ++++++++++++++ docs/jacocoSummary.md | 12 ++++++------ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 33814e8..ec02b7f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -10,7 +10,7 @@ plugins { jacoco id("com.github.sakata1222.jacoco-markdown") version "1.4.0" pmd - id("org.sonarqube") version "4.4.1.3373" + //id("org.sonarqube") version "4.4.1.3373" } repositories { @@ -85,7 +85,7 @@ pmd { rulesMinimumPriority = 5 ruleSets = listOf("category/java/errorprone.xml", "category/java/bestpractices.xml") } - +/* sonar { properties { property("sonar.projectKey", "The-Lum_ASCIIMathTeXImg") @@ -94,3 +94,4 @@ sonar { property("sonar.coverage.jacoco.xmlReportPaths", "reports/jacoco/test/jacocoTestReport.xml") } } +*/ \ No newline at end of file diff --git a/app/src/main/java/math/ASCIIMathTeXImg.java b/app/src/main/java/math/ASCIIMathTeXImg.java index 6e70952..3ba9080 100644 --- a/app/src/main/java/math/ASCIIMathTeXImg.java +++ b/app/src/main/java/math/ASCIIMathTeXImg.java @@ -659,14 +659,20 @@ else if (symbol == AMquote) i = 0; if (i == -1) i = str.length(); - st = str.substring(1, i); - if (st.charAt(0) == ' ') { - newFrag = "\\ "; - } - newFrag += "\\text{" + st + "}"; - if (st.charAt(st.length() - 1) == ' ') { - newFrag += "\\ "; + if (i == 0) { + newFrag = "\\text{" + str.charAt(0) + "}"; + } else { + st = str.substring(1, i); + if (st.charAt(0) == ' ') { + newFrag = "\\ "; + } + newFrag += "\\text{" + st + "}"; + if (st.charAt(st.length() - 1) == ' ') { + newFrag += "\\ "; + } } + if (i == str.length()) + i = i - 1; str = AMremoveCharsAndBlanks(str, i + 1); return new String[] { newFrag, str }; diff --git a/app/src/test/java/math/UnitTestGen.java b/app/src/test/java/math/UnitTestGen.java index 140434d..d7f0941 100644 --- a/app/src/test/java/math/UnitTestGen.java +++ b/app/src/test/java/math/UnitTestGen.java @@ -506,6 +506,20 @@ static void initAll() { "2^+3", "/4", "lim_(x rarr 2^-) f(x)", + +// new tests for code coverage + "text(f)", + "text({f})", + "text([f])", + "text( a)", + "text( a )", + "text", + "text", + "text{f}", + "text[f]", + "text{f", + "text[f", + "text{f abc", }) void test(String input) { final String res = cut.getTeX(input); diff --git a/docs/jacocoSummary.md b/docs/jacocoSummary.md index 0d31da0..3f778cc 100644 --- a/docs/jacocoSummary.md +++ b/docs/jacocoSummary.md @@ -1,11 +1,11 @@ -|Type | Missed/Total| Coverage| -|:--- | ---:| ---:| -|INSTRUCTION|~~199/6126~~ 98/6127|~~96.75~~ 98.40%| -|BRANCH | ~~63/353~~ 47/353|~~82.15~~ 86.69%| -|LINE | ~~25/408~~ 17/408|~~93.87~~ 95.83%| +|Type | Missed/Total| Coverage| +|:--- | ---:| ---:| +|INSTRUCTION|~~98/6127~~ 78/6143|~~98.40~~ 98.73%| +|BRANCH | ~~47/353~~ 41/357|~~86.69~~ 88.52%| +|LINE | ~~17/408~~ 11/412|~~95.83~~ 97.33%| Class list with less coverage (Worst 5) |Class |Instructions(C0)| Branches(C1)| |:--- | ---:| ---:| -|math.ASCIIMathTeXImg| 98/6063(98.38%)|47/353(86.69%)| +|math.ASCIIMathTeXImg| 78/6079(98.72%)|41/357(88.52%)|