package com.google.sps;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.lang.Math;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.google.sps.data.SmallCityService;
import com.google.sps.data.Listing;
import com.google.sps.data.MapLocation;
import com.google.sps.data.User;

@RunWith(JUnit4.class)
public final class UserTest {
  // Pittsburgh Google Office Location
  private final MapLocation USER_MAP_LOCATION = new MapLocation(40.45717, -79.91669);
  private final String USER_ZIPCODE = "15206";
  private final String USER_CITY = "Pittsburgh";
  
  private User userWithMapLocation;
  private User userWithZipCode;
  private User userWithCity;

  @Before
  public void setUp() {
    userWithMapLocation = new User(USER_MAP_LOCATION);
    userWithZipCode = new User(USER_ZIPCODE);
    userWithCity = new User(USER_CITY);
  }

  @Test
  public void geolocationUserWithMapLocation() {
    MapLocation actual = userWithMapLocation.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    Assert.assertEquals(expected, actual);
  }

  @Test
  public void geolocationUserWithZipCode() {
    MapLocation actual = userWithZipCode.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    boolean inRange = false;
    if ((Math.abs(actual.lat - expected.lat) <= 0.06) && (Math.abs(actual.lng - expected.lng)) <= 0.05) {
      inRange = true;
    }
    Assert.assertTrue(inRange);
  }

  @Test
  public void geolocationUserWithCity() {
    MapLocation actual = userWithCity.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    boolean inRange = false;
    if ((Math.abs(actual.lat - expected.lat) <= 0.16) && (Math.abs(actual.lng - expected.lng)) <= 0.2) {
      inRange = true;
    }   
    Assert.assertTrue(inRange);
  }
}
@@ -411,16 +411,51 @@
 .User;%0A%0A
+/** Test class for User Object **/%0A
 @RunWith
@@ -720,16 +720,81 @@
 burgh%22;%0A
+  private final MapLocation NULL_ISLAND = new MapLocation(0, 0);%0A
   %0A  pri
@@ -1459,32 +1459,101 @@
 nRange = false;%0A
+    // Approximate range of lat and lng coordinates in 15206 ZipCode%0A
     if ((Math.ab
@@ -1590,16 +1590,27 @@
 = 0.06) 
+%0A          
 && (Math
@@ -1895,24 +1895,90 @@
 ge = false;%0A
+    // Approximate range of lat and lng coordinates in Pittsburgh%0A
     if ((Mat
@@ -2019,16 +2019,27 @@
 = 0.16) 
+%0A          
 && (Math

Complete tests