Skip to content

Commit

Permalink
added basic color rendering tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Sep 16, 2017
1 parent cf69386 commit b11eb3e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions jansi/src/main/java/org/fusesource/jansi/AnsiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Reader;
import java.util.Properties;

Expand Down Expand Up @@ -90,6 +91,11 @@ public static void main(String... args) throws IOException {
System.out.println("Jansi System.err mode: " + AnsiConsole.JANSI_STDERR_TYPE);

try {
System.out.println();

testAnsi(false);
testAnsi(true);

if (args.length == 0) {
printJansiLogoDemo();
return;
Expand Down Expand Up @@ -140,6 +146,26 @@ private static void diagnoseTty(boolean stderr) {
+ (stderr ? "err" : "out") + " " + ((isatty == 0) ? "is *NOT*" : "is") + " a terminal");
}

private static void testAnsi(boolean stderr) {
@SuppressWarnings( "resource" )
PrintStream s = stderr ? System.err : System.out;
s.print("test on System." + (stderr ? "err" : "out") + ":");
for(Ansi.Color c: Ansi.Color.values()) {
s.print(" " + ansi().fg(c) + c + ansi().reset());
}
s.println();
s.print(" bright:");
for(Ansi.Color c: Ansi.Color.values()) {
s.print(" " + ansi().fgBright(c) + c + ansi().reset());
}
s.println();
s.print(" bold:");
for(Ansi.Color c: Ansi.Color.values()) {
s.print(" " + ansi().bold().fg(c) + c + ansi().reset());
}
s.println();
}

private static String getPomPropertiesVersion(String path) throws IOException {
InputStream in = AnsiMain.class.getResourceAsStream("/META-INF/maven/" + path + "/pom.properties");
if (in == null) {
Expand Down

0 comments on commit b11eb3e

Please sign in to comment.