package net.e175.klaus.solarpositioning;

import static org.junit.Assert.assertEquals;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.SimpleTimeZone;

import org.junit.Test;

public class SPATest {

	private static final double TOLERANCE = 0.0001;

	@Test
	public void testSpaExample() {
		GregorianCalendar time = new GregorianCalendar(new SimpleTimeZone(-7 * 60 * 60 * 1000, "LST"));
		time.set(2003, Calendar.OCTOBER, 17, 12, 30, 30); // 17 October 2003, 12:30:30 LST-07:00

		AzimuthZenithAngle result = SPA.calculateSolarPosition(time, 39.742476, -105.1786, 1830.14, 67, 820, 11);

		assertEquals(194.34024, result.getAzimuth(), TOLERANCE);
		assertEquals(50.11162, result.getZenithAngle(), TOLERANCE);
	}

}

@@ -183,16 +183,44 @@
 meZone;%0D
+%0Aimport java.util.TimeZone;%0D
 %0A%0D%0Aimpor
@@ -792,11 +792,1030 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09@Test%0D%0A%09public void testNearEquator1() %7B%0D%0A%09%09GregorianCalendar time = new GregorianCalendar(new SimpleTimeZone(-4 * 60 * 60 * 1000, %22AMT%22));%0D%0A%09%09time.set(2015, Calendar.JUNE, 12, 9, 34, 11);%0D%0A%0D%0A%09%09AzimuthZenithAngle result = SPA.calculateSolarPosition(time, -3.107, -60.025, 100, 69, 1000, 20);%0D%0A%0D%0A%09%09assertEquals(51.608, result.getAzimuth(), TOLERANCE);%0D%0A%09%09assertEquals(44.1425, result.getZenithAngle(), TOLERANCE);%0D%0A%09%7D%0D%0A%0D%0A%09@Test%0D%0A%09public void testSouthernSolstice() %7B%0D%0A%09%09GregorianCalendar time = new GregorianCalendar(TimeZone.getTimeZone(%22GMT%22));%0D%0A%09%09time.set(2012, Calendar.DECEMBER, 22, 12, 0, 0);%0D%0A%0D%0A%09%09AzimuthZenithAngle result = SPA.calculateSolarPosition(time, -41, 0, 100, 0, 1000, 20);%0D%0A%0D%0A%09%09assertEquals(359.086, result.getAzimuth(), TOLERANCE);%0D%0A%09%09assertEquals(17.5658, result.getZenithAngle(), TOLERANCE);%0D%0A%0D%0A%09%09result = SPA.calculateSolarPosition(time, -3, 0, 100, 0, 1000, 20);%0D%0A%0D%0A%09%09assertEquals(180.7903, result.getAzimuth(), TOLERANCE);%0D%0A%09%09assertEquals(20.4285, result.getZenithAngle(), TOLERANCE);%0D%0A%09%7D%0D%0A%0D%0A%0D%0A
 %7D%0D%0A

add near-equator and southern hemisphere tests inspired by http://stackoverflow.com/a/8764866