Skip to content

Commit

Permalink
✅ add new unit tests (on text ) and fix some side effect
Browse files Browse the repository at this point in the history
// new tests for code coverage
		"text(f)",
		"text({f})",
		"text([f])",
		"text(  a)",
		"text(  a  )",
		"text<a>",
		"text<a >",
		"text{f}",
		"text[f]",
		"text{f",
		"text[f",
		"text{f abc",
  • Loading branch information
The-Lum committed Mar 18, 2024
1 parent ce1ba78 commit 28403a1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand All @@ -94,3 +94,4 @@ sonar {
property("sonar.coverage.jacoco.xmlReportPaths", "reports/jacoco/test/jacocoTestReport.xml")
}
}
*/
20 changes: 13 additions & 7 deletions app/src/main/java/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
14 changes: 14 additions & 0 deletions app/src/test/java/math/UnitTestGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<a>",
"text<a >",
"text{f}",
"text[f]",
"text{f",
"text[f",
"text{f abc",
})
void test(String input) {
final String res = cut.getTeX(input);
Expand Down
12 changes: 6 additions & 6 deletions docs/jacocoSummary.md
Original file line number Diff line number Diff line change
@@ -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%)|

0 comments on commit 28403a1

Please sign in to comment.