Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Spreadsheet.class
/SpreadsheetTest.class
Binary file modified bin/Spreadsheet.class
Binary file not shown.
Binary file modified bin/SpreadsheetTest.class
Binary file not shown.
20 changes: 13 additions & 7 deletions src/Spreadsheet.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import java.util.*;
import java.util.regex.Pattern;


public class Spreadsheet {

HashMap<String,String> cells = new HashMap<String,String>();

public String get(String cell) {
// to be implemented
return null;
String value = cells.get(cell);
return value;
}

public void set(String cell, String value) {
// to be implemented
cells.put(cell, value);
}

public String evaluate(String cell) {
// to be implemented
return null;
}
// ## Not implemented yet ##
//public String evaluate(String cell) {
//
// Pattern correctFormats = Pattern.compile("");
//}

}
43 changes: 40 additions & 3 deletions tests/SpreadsheetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,47 @@

public class SpreadsheetTest {

Spreadsheet testsheet = new Spreadsheet();


@Test
public void test() {
fail("Not yet implemented");
public void testSetValueToCell() {

// Arrange value to cell A1
testsheet.set("A1", "1");

// Get value from cell A1
String value = testsheet.get("A1");

// Assert
assertEquals("Failed to return value from cell", "1", value);
}



@Test
public void testNumberHandling() {

// Arrange value to cell A1
testsheet.set("A1", "-1");

// Get value from cell A1
String value = testsheet.get("A1");

// Assert
assertEquals("Failed to return negative number from cell", "-1", value);
}


@Test
public void testErrorOnWrongFormat() {
// Arrange
testsheet.set("A1", "5A");

// Get value from cell A1
String value = testsheet.get("A1");

// Assert
assertEquals("Failed to return error on wrong format", "#Error", value);
}

}