mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
Reformatted tests
This commit is contained in:
@@ -53,7 +53,8 @@ public class LoggingTest {
|
||||
void testDisableLogsForClass_addsLoggerWithOff() {
|
||||
Logging.disableLogsForClass(LoggingTest.class);
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
assertNotNull(loggerConfig);
|
||||
assertEquals(Level.OFF, loggerConfig.getLevel());
|
||||
}
|
||||
@@ -62,7 +63,8 @@ public class LoggingTest {
|
||||
void testEnableLogsForClass_addsLoggerWithLevel() {
|
||||
Logging.enableLogsForClass(LoggingTest.class, Level.ERROR);
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
assertNotNull(loggerConfig);
|
||||
assertEquals(Level.ERROR, loggerConfig.getLevel());
|
||||
}
|
||||
@@ -71,7 +73,8 @@ public class LoggingTest {
|
||||
void testEnableLogsForClass_withStringLevel() {
|
||||
Logging.enableLogsForClass(LoggingTest.class.getName(), "INFO");
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
assertNotNull(loggerConfig);
|
||||
assertEquals(Level.INFO, loggerConfig.getLevel());
|
||||
}
|
||||
@@ -80,7 +83,8 @@ public class LoggingTest {
|
||||
void testEnableDebugLogsForClass_setsDebug() {
|
||||
Logging.enableDebugLogsForClass(LoggingTest.class);
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
assertNotNull(loggerConfig);
|
||||
assertEquals(Level.DEBUG, loggerConfig.getLevel());
|
||||
}
|
||||
@@ -89,7 +93,8 @@ public class LoggingTest {
|
||||
void testEnableInfoLogsForClass_setsInfo() {
|
||||
Logging.enableInfoLogsForClass(LoggingTest.class);
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get(LoggingTest.class.getName());
|
||||
assertNotNull(loggerConfig);
|
||||
assertEquals(Level.INFO, loggerConfig.getLevel());
|
||||
}
|
||||
@@ -98,7 +103,8 @@ public class LoggingTest {
|
||||
void testDisableLogsForNonexistentClass_doesNothing() {
|
||||
Logging.disableLogsForClass("org.toop.DoesNotExist");
|
||||
|
||||
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggers().get("org.toop.DoesNotExist");
|
||||
LoggerConfig loggerConfig =
|
||||
ctx.getConfiguration().getLoggers().get("org.toop.DoesNotExist");
|
||||
assertNull(loggerConfig); // class doesn't exist, so no logger added
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.toop.backend;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.toop.backend.tictactoe.ParsedCommand;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
class TcpServerTest {
|
||||
|
||||
@@ -39,7 +37,8 @@ class TcpServerTest {
|
||||
server.stop();
|
||||
try {
|
||||
serverThread.join(1000);
|
||||
} catch (InterruptedException ignored) {}
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,16 +77,16 @@ class TcpServerTest {
|
||||
client.close();
|
||||
}
|
||||
|
||||
// @Test
|
||||
// void testGetNewestCommand() throws InterruptedException {
|
||||
// String command = "move 1 2";
|
||||
// server.receivedQueue.put(command);
|
||||
//
|
||||
// ParsedCommand parsed = server.getNewestCommand();
|
||||
// System.out.println(parsed);
|
||||
// assertNotNull(parsed);
|
||||
// assertEquals(command, parsed.returnMessage); TODO: Test later
|
||||
// }
|
||||
// @Test
|
||||
// void testGetNewestCommand() throws InterruptedException {
|
||||
// String command = "move 1 2";
|
||||
// server.receivedQueue.put(command);
|
||||
//
|
||||
// ParsedCommand parsed = server.getNewestCommand();
|
||||
// System.out.println(parsed);
|
||||
// assertNotNull(parsed);
|
||||
// assertEquals(command, parsed.returnMessage); TODO: Test later
|
||||
// }
|
||||
|
||||
@Test
|
||||
void testMultipleClients() throws IOException, InterruptedException {
|
||||
@@ -106,4 +105,4 @@ class TcpServerTest {
|
||||
client1.close();
|
||||
client2.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ package org.toop.eventbus;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
class GlobalEventBusTest {
|
||||
|
||||
@@ -70,16 +69,16 @@ class GlobalEventBusTest {
|
||||
assertFalse(called.get(), "Consumer should not be called after unregister");
|
||||
}
|
||||
|
||||
// @Test
|
||||
// void testPost_storesEventInRegistry() {
|
||||
// // Simple EventMeta check
|
||||
// class MyEvent {}
|
||||
//
|
||||
// MyEvent event = new MyEvent();
|
||||
// GlobalEventBus.post(event);
|
||||
//
|
||||
// EventMeta<MyEvent> stored = EventRegistry.getStoredEvent(MyEvent.class);
|
||||
// assertNotNull(stored, "EventMeta should be stored");
|
||||
// assertEquals(event, stored.event(), "Stored event should match the posted one");
|
||||
// }
|
||||
}
|
||||
// @Test
|
||||
// void testPost_storesEventInRegistry() {
|
||||
// // Simple EventMeta check
|
||||
// class MyEvent {}
|
||||
//
|
||||
// MyEvent event = new MyEvent();
|
||||
// GlobalEventBus.post(event);
|
||||
//
|
||||
// EventMeta<MyEvent> stored = EventRegistry.getStoredEvent(MyEvent.class);
|
||||
// assertNotNull(stored, "EventMeta should be stored");
|
||||
// assertEquals(event, stored.event(), "Stored event should match the posted one");
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -35,26 +35,26 @@ class BoundsTest {
|
||||
@Test
|
||||
void testCheckInsideBounds() {
|
||||
// Points inside the bounds
|
||||
assertTrue(bounds.check(10, 20)); // top-left corner
|
||||
assertTrue(bounds.check(110, 70)); // bottom-right corner
|
||||
assertTrue(bounds.check(60, 45)); // inside
|
||||
assertTrue(bounds.check(10, 20)); // top-left corner
|
||||
assertTrue(bounds.check(110, 70)); // bottom-right corner
|
||||
assertTrue(bounds.check(60, 45)); // inside
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckOutsideBounds() {
|
||||
// Points outside the bounds
|
||||
assertFalse(bounds.check(9, 20)); // left
|
||||
assertFalse(bounds.check(10, 19)); // above
|
||||
assertFalse(bounds.check(111, 70)); // right
|
||||
assertFalse(bounds.check(110, 71)); // below
|
||||
assertFalse(bounds.check(9, 20)); // left
|
||||
assertFalse(bounds.check(10, 19)); // above
|
||||
assertFalse(bounds.check(111, 70)); // right
|
||||
assertFalse(bounds.check(110, 71)); // below
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckOnEdgeBounds() {
|
||||
// Points on the edges should be considered inside
|
||||
assertTrue(bounds.check(10, 20)); // top-left
|
||||
assertTrue(bounds.check(110, 20)); // top-right
|
||||
assertTrue(bounds.check(10, 70)); // bottom-left
|
||||
assertTrue(bounds.check(110, 70)); // bottom-right
|
||||
assertTrue(bounds.check(10, 20)); // top-left
|
||||
assertTrue(bounds.check(110, 20)); // top-right
|
||||
assertTrue(bounds.check(10, 70)); // bottom-left
|
||||
assertTrue(bounds.check(110, 70)); // bottom-right
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,4 @@ class GameBaseTest {
|
||||
assertEquals(GameBase.State.INVALID, game.play(-1));
|
||||
assertEquals(GameBase.State.INVALID, game.play(9));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user