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
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" path="/voogasalad_LoopsGoatCheeseSalad"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion src/debug/ContainerArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


public class ContainerArray<E> {
private int initialCapacity = 10;
private int limit = 10;
private int currentSize = 0;
private Object[] internalArray;

Expand Down
39 changes: 39 additions & 0 deletions src/debug/ContainerArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,43 @@ public void testObjectIsRemoved () {
myContainer.remove("Bear");
assertEquals("Remove should be same reference", alligator, myContainer.get(0));
}

//
@Test
public void testObjectIsRemoved2(){
String dog = "Dog";
myContainer.add(dog);
String cat = "Cat";
myContainer.add(cat);
myContainer.remove(dog);
assertEquals("Remove should be same reference", cat, myContainer.get(0));
}

@Test
public void testAddPastCapacity(){
myContainer.add("a");
myContainer.add("b");
myContainer.add("c");
myContainer.add("d");
myContainer.add("e");
myContainer.add("f");
myContainer.add("g");
myContainer.add("h");
myContainer.add("i");
myContainer.add("j");
myContainer.add("k");
assertEquals(myContainer.size(), myContainer.get(10));

}

@Test
public void testSizeChange(){
String me = "Michelle";
myContainer.add(me);
myContainer.add("Michael");
//myContainer.remove("Michelle");
assertEquals("My size", 1, myContainer.size());
}

//also the constructor size will always be 10--that's bad design
}
35 changes: 35 additions & 0 deletions src/tdd/Sheet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tdd;

import java.util.HashMap;

public class Sheet {

private HashMap<String, String> myCells = new HashMap<String,String>();

public String get(String string) {
if(myCells.get(string)!=null){
try{
Integer.parseInt(myCells.get(string).trim());
return myCells.get(string).trim();
}
catch(Exception e){
return myCells.get(string);
}
}
return "";


}

public void put(String cell, String value) {
myCells.put(cell,value);
}

public String getLiteral(String theCell) {
if(myCells.get(theCell)!=null){
return myCells.get(theCell);
}
return "";
}

}
85 changes: 85 additions & 0 deletions src/tdd/TestSheet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package tdd;

import static org.junit.Assert.*;

import org.junit.Test;


public class TestSheet {

@Test
public void test() {
Sheet sheet = new Sheet();
assertEquals("", sheet.get("A1"));
assertEquals("", sheet.get("ZX347"));
}

@Test
public void testThatTextCellsAreStored() {
Sheet sheet = new Sheet();
String theCell = "A21";

sheet.put(theCell, "A string");
assertEquals("A string", sheet.get(theCell));

sheet.put(theCell, "A different string");
assertEquals("A different string", sheet.get(theCell));

sheet.put(theCell, "");
assertEquals("", sheet.get(theCell));
}

@Test
public void testThatManyCellsExist() {
Sheet sheet = new Sheet();
sheet.put("A1", "First");
sheet.put("X27", "Second");
sheet.put("ZX901", "Third");

assertEquals("A1", "First", sheet.get("A1"));
assertEquals("X27", "Second", sheet.get("X27"));
assertEquals("ZX901", "Third", sheet.get("ZX901"));

sheet.put("A1", "Fourth");
assertEquals("A1 after", "Fourth", sheet.get("A1"));
assertEquals("X27 same", "Second", sheet.get("X27"));
assertEquals("ZX901 same", "Third", sheet.get("ZX901"));
}

@Test
public void testThatNumericCellsAreIdentifiedAndStored() {
Sheet sheet = new Sheet();
String theCell = "A21";

sheet.put(theCell, "X99"); // "Obvious" string
assertEquals("X99", sheet.get(theCell));

sheet.put(theCell, "14"); // "Obvious" number
assertEquals("14", sheet.get(theCell));

sheet.put(theCell, " 99 X"); // Whole string must be numeric
assertEquals(" 99 X", sheet.get(theCell));

sheet.put(theCell, " 1234 "); // Blanks ignored
assertEquals("1234", sheet.get(theCell));

sheet.put(theCell, " "); // Just a blank
assertEquals(" ", sheet.get(theCell));
}

@Test
public void testThatWeHaveAccessToCellLiteralValuesForEditing() {
Sheet sheet = new Sheet();
String theCell = "A21";

sheet.put(theCell, "Some string");
assertEquals("Some string", sheet.getLiteral(theCell));

sheet.put(theCell, " 1234 ");
assertEquals(" 1234 ", sheet.getLiteral(theCell));

sheet.put(theCell, "=7"); // Foreshadowing formulas:)
assertEquals("=7", sheet.getLiteral(theCell));
}

}
14 changes: 14 additions & 0 deletions src/voogasalad/VoogaTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package voogasalad;

import static org.junit.Assert.*;

import org.junit.Test;

public class VoogaTests {

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

}