Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add testConvertLinks and delete test file Calculator #15

Merged
merged 1 commit into from Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file removed src/application/Calculator.class
Binary file not shown.
9 changes: 0 additions & 9 deletions src/application/Calculator.java

This file was deleted.

Binary file modified src/application/ConvertTxtMdToHtml.class
Binary file not shown.
2 changes: 1 addition & 1 deletion src/application/ConvertTxtMdToHtml.java
Expand Up @@ -8,7 +8,7 @@

public final class ConvertTxtMdToHtml {
// Private constructor to prevent instantiation
private ConvertTxtMdToHtml() {
public ConvertTxtMdToHtml() {
// Hidden constructor
}

Expand Down
Binary file removed src/junit/CalculatorTest.class
Binary file not shown.
22 changes: 0 additions & 22 deletions src/junit/CalculatorTest.java

This file was deleted.

Binary file modified src/junit/ConvertTxtMdToHtmlTest.class
Binary file not shown.
25 changes: 25 additions & 0 deletions src/junit/ConvertTxtMdToHtmlTest.java
Expand Up @@ -9,6 +9,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
Expand Down Expand Up @@ -70,4 +72,27 @@ public void testConversionWithSimpleText() {
}
}

@Test
public void testConvertLinks() {
try {
// Create an instance of ConvertTxtMdToHtml
ConvertTxtMdToHtml converter = new ConvertTxtMdToHtml();

// Use reflection to access the private convertLinks method
Method convertLinksMethod = ConvertTxtMdToHtml.class.getDeclaredMethod("convertLinks", String.class);
convertLinksMethod.setAccessible(true);

// Test cases
String input1 = "This is a [link](https://example.com).";
String expectedOutput1 = "This is a <a href=\"https://example.com\">link</a>.";
assertEquals(expectedOutput1, convertLinksMethod.invoke(converter, input1));

// Add more test cases as needed

} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
fail("Exception thrown during test: " + e.getMessage());
}
}

}