From a49d34e8dcd951145b1d1c9bd1673937e5f90a40 Mon Sep 17 00:00:00 2001 From: akairala Date: Fri, 14 Oct 2016 16:47:51 +0300 Subject: [PATCH] Project finished --- bin/.gitignore | 2 ++ bin/Spreadsheet.class | Bin 613 -> 897 bytes bin/SpreadsheetTest.class | Bin 490 -> 1255 bytes src/Spreadsheet.java | 20 +++++++++++------ tests/SpreadsheetTest.java | 43 ++++++++++++++++++++++++++++++++++--- 5 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 bin/.gitignore diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..2079672 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/Spreadsheet.class +/SpreadsheetTest.class diff --git a/bin/Spreadsheet.class b/bin/Spreadsheet.class index 92b411f05752a6cee6d06c9769e1b70d40aa0840..791dfc31d47e8394882c1a911a94ef659be6e4bc 100644 GIT binary patch literal 897 zcmZ{iOK;Oa6ot>&Nlk1gaa!Kb7Wzm+MK&xzsk#6Ou}AisTbzwUeWy%86=#;Txo54|Ik*h>WsCxZ5KP(W#uwq<&$D%uBTA>f6)T= zXpuxy^}^SFdIifKX}#E@|0eI0;KQH5x5b@-ON{b_AUiS=c_Zu4T&)|JQ z>rv~!Mjax}}& K(R+j$X#WNgyS=0U literal 613 zcma)2%T5A85Ug32hdcyd=us~U9OPoWVDw<(X`=@W_hFg9kaaQ3!guM(#DgE;M;WVk zH%i1rFWuGCT~*!l{_*+-;0y;vI0}{iV`TJbJ~1XP!c}NY^-^~O9ge$q!>RFOg~Ejm zZG5SaYqbXo?)7YB%E)1(iaZJmb8p! zWsjm`LyzN@_ifydBO8u;?e!lT`>ZMlDl*Z_xYW; bTQ|8c>{tD`YvgW_n-IUw(-~Won5+ zW^O@FYHn&?Nooogg9w8dJA)`AgFt>!x_(w^US^5DV{vh6Q3(%&ID-Tu14~+BW)35R z=;V)#!c3ZBlixDw)-y0LF)%W)GOz(jcA%yDK$;OqvubT;;MfRcFfnieNsu%HPysiP zL2N>TI~ar!CUF7PG62nC1?uKzkc1h>1~(2U I1XLmg0Nx@c$N&HU diff --git a/src/Spreadsheet.java b/src/Spreadsheet.java index e4f120b..4d438c8 100644 --- a/src/Spreadsheet.java +++ b/src/Spreadsheet.java @@ -1,18 +1,24 @@ +import java.util.*; +import java.util.regex.Pattern; + public class Spreadsheet { + + HashMap cells = new HashMap(); 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(""); + //} } diff --git a/tests/SpreadsheetTest.java b/tests/SpreadsheetTest.java index 9e0936a..aaf73cd 100644 --- a/tests/SpreadsheetTest.java +++ b/tests/SpreadsheetTest.java @@ -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); + } + }