1 /*
  2  * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package hat.test.engine;
 26 
 27 public class HATTestFormatter {
 28 
 29     public static void appendClass(StringBuilder builder, String className) {
 30         builder.append(Colours.CYAN)
 31                 .append("Class: ")
 32                 .append(className)
 33                 .append(Colours.RESET)
 34                 .append("\n");;
 35     }
 36 
 37     public static void testing(StringBuilder builder, String methodName) {
 38         builder.append(Colours.BLUE)
 39                 .append(String.format("Testing: #%-30s", methodName))
 40                 .append(String.format("%-20s", "..................... "))
 41                 .append(Colours.RESET);
 42     }
 43 
 44     public static void passed(StringBuilder builder) {
 45         builder.append(Colours.GREEN)
 46                 .append("[passed]")
 47                 .append(Colours.RESET)
 48                 .append("\n");;
 49     }
 50 
 51     public static void fail(StringBuilder builder) {
 52         builder.append(Colours.RED)
 53                 .append("[fail]")
 54                 .append(Colours.RESET)
 55                 .append("\n");;
 56     }
 57 
 58     public static void expectedToFail(StringBuilder builder, String reason) {
 59         builder.append(Colours.YELLOW)
 60                 .append("[FAIL][EXPECTED]")
 61                 .append(Colours.RED)
 62                 .append(" Reason: ")
 63                 .append(reason)
 64                 .append(Colours.RESET)
 65                 .append("\n");;
 66     }
 67 
 68     public static void expectedPrecisionError(StringBuilder builder, String reason) {
 69         builder.append(Colours.RED)
 70                 .append("[EXPECTED][PRECISION ERROR]")
 71                 .append(" Reason: ")
 72                 .append(reason)
 73                 .append(Colours.RESET)
 74                 .append("\n");;
 75     }
 76 
 77     public static void failWithReason(StringBuilder builder, String reason) {
 78         builder.append(Colours.RED)
 79                 .append("[fail]")
 80                 .append(Colours.YELLOW)
 81                 .append(" Reason: ")
 82                 .append(reason)
 83                 .append(Colours.RESET)
 84                 .append("\n");;
 85     }
 86 
 87     public static void backendNotSupported(StringBuilder builder, String reason) {
 88         builder.append(Colours.YELLOW)
 89                 .append("[FAIL][EXPECTED]")
 90                 .append(Colours.RED)
 91                 .append(" Reason: ")
 92                 .append(reason)
 93                 .append(Colours.RESET)
 94                 .append("\n");
 95     }
 96 
 97     public static void illegal(StringBuilder builder) {
 98         builder.append(Colours.YELLOW)
 99                 .append("[illegal]")
100                 .append(Colours.RESET)
101                 .append("\n");;
102     }
103 
104 }