Permalink
Browse files

Added beginning of shunting yard algorithm.

  • Loading branch information...
1 parent 198e9b0 commit 0efd041a0e70984672bd04478cebdba4560addb9 @schuchert committed Nov 25, 2013
@@ -0,0 +1,7 @@
+package shoe.example.firstproject;
+
+public class ShuntingYardAlgorithm {
+ public String translate(String infixExpression) {
+ return infixExpression != null ? infixExpression : "";
+ }
+}
@@ -0,0 +1,34 @@
+package shoe.example.firstproject;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ShuntingYardAlgorithmTest {
+ private ShuntingYardAlgorithm shuntingYardAlgorithm;
+
+ @Before
+ public void init() {
+ shuntingYardAlgorithm = new ShuntingYardAlgorithm();
+ }
+
+ @Test
+ public void shouldHandleNull() {
+ String result = shuntingYardAlgorithm.translate(null);
+ assertThat(result, is(""));
+ }
+
+ @Test
+ public void shouldHandleEmptyString() {
+ String result = shuntingYardAlgorithm.translate("");
+ assertThat(result, is(""));
+ }
+
+ @Test
+ public void shouldReturnNumberUnchanged() {
+ String result = shuntingYardAlgorithm.translate("45");
+ assertThat(result, is("45"));
+ }
+}

0 comments on commit 0efd041

Please sign in to comment.