Skip to content
Snippets Groups Projects
Commit 40e705c5 authored by Elrabu's avatar Elrabu
Browse files

eb093: update: fixed server.java, added Tests

parent 13b16f91
No related branches found
Tags v0.1.5
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!54Update: coreMaps.json (added new maps),!51Multiplayer
......@@ -30,7 +30,7 @@ public class Client {
public static int[] convertStringToArray(String inputString) {
// Remove brackets and split by comma
String[] parts = inputString.substring(0, inputString.length()).split(","); //1 .length() -1
String[] parts = inputString.substring(1, inputString.length() - 1).split(","); //1 .length() -1
// Convert each part to integer
int[] result = new int[parts.length];
......
......@@ -36,11 +36,11 @@ public class Server {
private static String ipaddress = "localhost";
//Uncomment these lines to test the server starting manually:
/* public static void main(String[] args) throws IOException { //main method for testing purposes
public static void main(String[] args) throws IOException { //main method for testing purposes
Server server = new Server();
log.info("server starting...");
server.start(ipaddress, 4444);
} */
server.start(4444);
}
//use this method to start the server from another class
public void startServer() throws IOException {
......
......@@ -11,12 +11,11 @@ class ClientTest {
public static void main(String[] args) {
int[] result = Client.convertStringToArray("1234");
System.out.println(Arrays.toString(result)); //[I@537f60bf
System.out.println(result.length);
}
@Test
void convertStringToArray() {
int array[] = {1234};
int[] array = {23}; //Array must be formatted like this for Server transfer
int[] result = Client.convertStringToArray("1234");
assertEquals(Arrays.toString(array), Arrays.toString(result));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment