[DEV] start basic test

This commit is contained in:
Edouard DUPIN 2020-08-12 00:20:00 +02:00
parent 59e2c3a845
commit cf1ed4ce54
3 changed files with 103 additions and 1 deletions

View File

@ -1,5 +1,4 @@
open module io.scenarium.logger {
exports io.scenarium.logger;
}

View File

@ -0,0 +1,59 @@
package test.scenarium.logger;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final String LIB_NAME = "sc-log-test";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
private Log() {}
public static void print(String data) {
if (PRINT_PRINT)
Logger.error(LIB_NAME_DRAW, data);
}
public static void critical(String data) {
if (PRINT_CRITICAL)
Logger.critical(LIB_NAME_DRAW, data);
}
public static void error(String data) {
if (PRINT_ERROR)
Logger.error(LIB_NAME_DRAW, data);
}
public static void warning(String data) {
if (PRINT_WARNING)
Logger.warning(LIB_NAME_DRAW, data);
}
public static void info(String data) {
if (PRINT_INFO)
Logger.info(LIB_NAME_DRAW, data);
}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
public static void verbose(String data) {
if (PRINT_VERBOSE)
Logger.verbose(LIB_NAME_DRAW, data);
}
public static void todo(String data) {
if (PRINT_TODO)
Logger.todo(LIB_NAME_DRAW, data);
}
}

View File

@ -0,0 +1,44 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Revilloud Marc - initial API and implementation
******************************************************************************/
package test.scenarium.logger;
import org.junit.Test;
public class TestBasicLog {
// TODO REFACTO REMOVE this and set it in the Test of the logger.
public static String getAAAAAAA(int dfsdf) {
int hhh = 0;
for (int kkk = 0; kkk < dfsdf; kkk++)
for (int iii = 0; iii < 10000; iii++)
for (int jjj = 0; jjj < 100000; jjj++)
for (int lll = 0; lll < 100000; lll++)
hhh++;
return "kkk" + hhh;
}
public static void testLog() {
Log.print("test direct [START]");
// test de 10 secondes contre 0.0?? second quand le niveau n'est pas assez grand ...
for (int iii = 0; iii < 1000000; iii++)
Log.debug("test direct");
Log.print("test direct [END]");
Log.print("test concat [START]");
// C'est très long dans les 2 cas ...
for (int iii = 0; iii < 10000; iii++)
Log.debug("test concat: non fonctionnel, il applelle le get a chaque log ... " + getAAAAAAA(iii));
Log.print("test concat [END]");
}
@Test
public void testSimpleLog() {
testLog();
}
}