Parcourir la source

Zachary Hatton's test classes

Zachary Hatton il y a 9 ans
Parent
commit
e8d842eecb

+ 20 - 0
app/src/test/java/com/example/yiupang/freefoodfinder/TestCreateEventScreen.java

@@ -0,0 +1,20 @@
+package com.example.yiupang.freefoodfinder;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by Zachary Hatton on 6/6/2017.
+ */
+
+public class TestCreateEventScreen {
+    @Test
+    public void testPlace2Coordinates(){
+        CreateEventScreen test = new CreateEventScreen();
+        float[] expected = new float[]{35.305005f,-120.662494f};
+        float[] result = test.place2Coordinates("unspecific");
+        assertEquals(expected[0],result[0],0);
+        assertEquals(expected[1],result[1],0);
+    }
+}

+ 16 - 0
app/src/test/java/com/example/yiupang/freefoodfinder/TestEventSuite.java

@@ -0,0 +1,16 @@
+package com.example.yiupang.freefoodfinder;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Created by Acer on 6/6/2017.
+ */
+
+    @RunWith(Suite.class)
+    @Suite.SuiteClasses({TestEvents.class, TestCreateEventScreen.class})
+    public class TestEventSuite {
+    {
+
+    }
+}

+ 24 - 0
app/src/test/java/com/example/yiupang/freefoodfinder/TestEvents.java

@@ -0,0 +1,24 @@
+package com.example.yiupang.freefoodfinder;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+/*
+ * Written by Zachary Hatton
+ */
+public class TestEvents {
+	@Test 
+	public void testSetName(){
+		Event test = new Event();
+		boolean expected = false;
+		boolean result = test.setName("?!?");
+		assertEquals(expected,result);
+	}
+	
+	@Test
+	public void testSetFoodType(){
+		Event test = new Event();
+		boolean expected = true;
+		boolean result = test.setName("Fruit");
+		assertEquals(expected,result);
+	}
+}