Skip to content

Commit c9d70a4

Browse files
author
Jim Carr
committed
Refactored TestLib init
1 parent f10a05f commit c9d70a4

File tree

4 files changed

+10
-67
lines changed

4 files changed

+10
-67
lines changed

src/TestCoordinates.java

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
public class TestCoordinates {
2424
PACoordinates paCoordinates;
25+
TestLib testLib;
2526

2627
public TestCoordinates() {
2728
paCoordinates = new PACoordinates();
29+
testLib = new TestLib();
2830
}
2931

3032
public void testAngleToFromDecimalDegrees() {
31-
TestLib testLib = new TestLib();
32-
3333
double decimalDegrees = paCoordinates.angleToDecimalDegrees(182, 31, 27);
3434

3535
testLib.setTestName("Decimal Degrees for 182d 31m 27s").Assert(182.524167, PAUtil.round(decimalDegrees, 6));
@@ -41,8 +41,6 @@ public void testAngleToFromDecimalDegrees() {
4141
}
4242

4343
public void testRightAscensionToFromHourAngle() {
44-
TestLib testLib = new TestLib();
45-
4644
HourAngle hourAngle = paCoordinates.rightAscensionToHourAngle(18, 32, 21, 14, 36, 51.67, false, -4, 22, 4, 1980,
4745
-64);
4846

@@ -59,8 +57,6 @@ public void testRightAscensionToFromHourAngle() {
5957
}
6058

6159
public void testEquatorialCoordinatesToFromHorizonCoordinates() {
62-
TestLib testLib = new TestLib();
63-
6460
HorizonCoordinates horizonCoordinates = paCoordinates.equatorialCoordinatesToHorizonCoordinates(5, 51, 44, 23,
6561
13, 10, 52);
6662

@@ -82,17 +78,13 @@ public void testEquatorialCoordinatesToFromHorizonCoordinates() {
8278
}
8379

8480
public void testMeanObliquityOfTheEcliptic() {
85-
TestLib testLib = new TestLib();
86-
8781
double meanObliquityOfTheEcliptic = PAUtil.round(paCoordinates.meanObliquityOfTheEcliptic(6, 7, 2009), 8);
8882

8983
testLib.setTestName("Mean Obliquity of the Ecliptic for 7/6/2009").Assert(23.43805531,
9084
meanObliquityOfTheEcliptic);
9185
}
9286

9387
public void testEclipticCoordinateToFromEquatorialCoordinate() {
94-
TestLib testLib = new TestLib();
95-
9688
EquatorialCoordinatesRA equatorialCoordinatesRA = paCoordinates.eclipticCoordinateToEquatorialCoordinate(139,
9789
41, 10, 4, 52, 31, 6, 7, 2009);
9890

@@ -116,8 +108,6 @@ public void testEclipticCoordinateToFromEquatorialCoordinate() {
116108
}
117109

118110
public void testEquatorialCoordinateToFromGalacticCoordinate() {
119-
TestLib testLib = new TestLib();
120-
121111
GalacticCoordinates galacticCoordinates = paCoordinates.equatorialCoordinateToGalacticCoordinate(10, 21, 0, 10,
122112
3, 11);
123113

@@ -141,8 +131,6 @@ public void testEquatorialCoordinateToFromGalacticCoordinate() {
141131
}
142132

143133
public void testAngleBetweenTwoObjects() {
144-
TestLib testLib = new TestLib();
145-
146134
Angle angle = paCoordinates.angleBetweenTwoObjects(5, 13, 31.7, -8, 13, 30, 6, 44, 13.4, -16, 41, 11,
147135
AngleMeasure.HOURS);
148136

@@ -152,8 +140,6 @@ public void testAngleBetweenTwoObjects() {
152140
}
153141

154142
public void testRisingAndSetting() {
155-
TestLib testLib = new TestLib();
156-
157143
RiseSet riseSet = paCoordinates.risingAndSetting(23, 39, 20, 21, 42, 0, 24, 8, 2010, 64, 30, 0.5667);
158144

159145
testLib.setTestName(
@@ -164,8 +150,6 @@ public void testRisingAndSetting() {
164150
}
165151

166152
public void testCorrectForPrecession() {
167-
TestLib testLib = new TestLib();
168-
169153
RightAscensionDeclination rightAscensionDeclination = paCoordinates.correctForPrecession(9, 10, 43, 14, 23, 25,
170154
0.923, 1, 1950, 1, 6, 1979);
171155

@@ -180,8 +164,6 @@ public void testCorrectForPrecession() {
180164
}
181165

182166
public void testNutationInEclipticLongitudeAndObliquity() {
183-
TestLib testLib = new TestLib();
184-
185167
Nutation nutation = paCoordinates.nutationInEclipticLongitudeAndObliquity(1, 9, 1988);
186168

187169
testLib.setTestName("Nutation in Ecliptic Longitude and Obliquity for Greenwich Date 9/1/1988")
@@ -190,8 +172,6 @@ public void testNutationInEclipticLongitudeAndObliquity() {
190172
}
191173

192174
public void testCorrectForAberration() {
193-
TestLib testLib = new TestLib();
194-
195175
Aberration aberration = paCoordinates.correctForAberration(0, 0, 0, 8, 9, 1988, 352, 37, 10.1, -1, 32, 56.4);
196176

197177
testLib.setTestName(
@@ -202,8 +182,6 @@ public void testCorrectForAberration() {
202182
}
203183

204184
public void testRefraction() {
205-
TestLib testLib = new TestLib();
206-
207185
RightAscensionDeclination correctedCoordinates = paCoordinates.atmosphericRefraction(23, 14, 0, 40, 10, 0,
208186
CoordinateType.TRUE, 0.17, 51.2036110, 0, 0, 23, 3, 1987, 1, 1, 24, 1012, 21.7);
209187

@@ -216,8 +194,6 @@ public void testRefraction() {
216194
}
217195

218196
public void testParallax() {
219-
TestLib testLib = new TestLib();
220-
221197
RightAscensionDeclination correctedCoordinates = paCoordinates.correctionsForGeocentricParallax(22, 35, 19, -7,
222198
41, 13, CoordinateType.TRUE, 1.019167, -100, 50, 60, 0, -6, 26, 2, 1979, 10, 45, 0);
223199

@@ -230,8 +206,6 @@ public void testParallax() {
230206
}
231207

232208
public void testHeliographicCoordinates() {
233-
TestLib testLib = new TestLib();
234-
235209
HeliographicCoordinates heliographicCoordinates = paCoordinates.heliographicCoordinates(220, 10.5, 1, 5, 1988);
236210

237211
testLib.setTestName("Heliographic Coordinates")
@@ -240,16 +214,12 @@ public void testHeliographicCoordinates() {
240214
}
241215

242216
public void testCarringtonRotationNumber() {
243-
TestLib testLib = new TestLib();
244-
245217
int carringtonRotationNumber = paCoordinates.carringtonRotationNumber(27, 1, 1975);
246218

247219
testLib.setTestName("Carrington Rotation Number").Assert(1624, carringtonRotationNumber);
248220
}
249221

250222
public void testSelenographicCoordinates1() {
251-
TestLib testLib = new TestLib();
252-
253223
SelenographicCoordinates1 selenographicCoordinates1 = paCoordinates.selenographicCoordinates1(1, 5, 1988);
254224

255225
testLib.setTestName("Selenographic Coordinates (1)")
@@ -259,8 +229,6 @@ public void testSelenographicCoordinates1() {
259229
}
260230

261231
public void testSelenographicCoordinates2() {
262-
TestLib testLib = new TestLib();
263-
264232
SelenographicCoordinates2 selenographicCoordinates2 = paCoordinates.selenographicCoordinates2(1, 5, 1988);
265233

266234
testLib.setTestName("Selenographic Coordinates (2)")

src/TestDateTime.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import astro.practical.lib.PADateTime;
12
import astro.practical.lib.PAUtil;
23
import astro.practical.models.CivilDate;
34
import astro.practical.models.CivilDateTime;
@@ -10,10 +11,12 @@
1011
import astro.practical.types.WarningFlag;
1112

1213
public class TestDateTime {
13-
astro.practical.lib.PADateTime paDateTime;
14+
PADateTime paDateTime;
15+
TestLib testLib;
1416

1517
public TestDateTime() {
1618
paDateTime = new astro.practical.lib.PADateTime();
19+
testLib = new TestLib();
1720
}
1821

1922
/**
@@ -22,8 +25,6 @@ public TestDateTime() {
2225
public void testDateOfEaster() {
2326
CivilDate dateOfEaster;
2427

25-
TestLib testLib = new TestLib();
26-
2728
dateOfEaster = paDateTime.getDateOfEaster(2003);
2829

2930
testLib.setTestName("Date of Easter for 2003").Assert(4, dateOfEaster.month)
@@ -44,8 +45,6 @@ public void testDateOfEaster() {
4445
* Test Civil Date to Day Number.
4546
*/
4647
public void testCivilDateToDayNumber() {
47-
TestLib testLib = new TestLib();
48-
4948
testLib.setTestName("Day Number for 1/1/2000").Assert(1, paDateTime.civilDateToDayNumber(1, 1, 2000));
5049
testLib.setTestName("Day Number for 3/1/2000").Assert(61, paDateTime.civilDateToDayNumber(3, 1, 2000));
5150
testLib.setTestName("Day Number for 6/1/2003").Assert(152, paDateTime.civilDateToDayNumber(6, 1, 2003));
@@ -56,8 +55,6 @@ public void testCivilDateToDayNumber() {
5655
* Test Civil Time to/from Decimal Hours.
5756
*/
5857
public void testCivilTimeToFromDecimalHours() {
59-
TestLib testLib = new TestLib();
60-
6158
testLib.setTestName("Convert Civil Time to Decimal Hours").Assert(18.52416667,
6259
PAUtil.round(paDateTime.civilTimeToDecimalHours((double) 18, (double) 31, (double) 27), 8));
6360

@@ -71,8 +68,6 @@ public void testCivilTimeToFromDecimalHours() {
7168
* Test Local Civil Time to/from Universal Time.
7269
*/
7370
public void testLocalCivilTimeToFromUniversalTime() {
74-
TestLib testLib = new TestLib();
75-
7671
UniversalDateTime uDT = paDateTime.localCivilTimeToUniversalTime(3, 37, 0, true, 4, 1, 7, 2013);
7772

7873
testLib.setTestName("Convert Local Civil Time to Universal Time").Assert(22, uDT.hours).Assert(37, uDT.minutes)
@@ -88,8 +83,6 @@ public void testLocalCivilTimeToFromUniversalTime() {
8883
* Test Universal Time to/from Greenwich Sidereal Time.
8984
*/
9085
public void testUniversalTimeToFromGreenwichSiderealTime() {
91-
TestLib testLib = new TestLib();
92-
9386
GreenwichSiderealTime gST = paDateTime.universalTimeToGreenwichSiderealTime(14, 36, 51.67, 22, 4, 1980);
9487

9588
testLib.setTestName("Convert Universal Time to Greenwich Sidereal Time").Assert(4.0, gST.hours)
@@ -105,8 +98,6 @@ public void testUniversalTimeToFromGreenwichSiderealTime() {
10598
* Test Greenwich Sidereal Time to/from Local Sidereal Time.
10699
*/
107100
public void testGreenwichSiderealTimeToFromLocalSiderealTime() {
108-
TestLib testLib = new TestLib();
109-
110101
LocalSiderealTime lST = paDateTime.greenwichSiderealTimeToLocalSiderealTime(4, 40, 5.23, -64);
111102

112103
testLib.setTestName("Convert Greenwich Sidereal Time to Local Sidereal Time").Assert(0.0, lST.hours)

src/TestPlanet.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
public class TestPlanet {
77
PAPlanet paPlanet;
8+
TestLib testLib;
89

910
public TestPlanet() {
1011
paPlanet = new PAPlanet();
12+
testLib = new TestLib();
1113
}
1214

1315
public void testApproximatePositionOfPlanet() {
14-
TestLib testLib = new TestLib();
15-
1616
PlanetPosition planetPosition = paPlanet.approximatePositionOfPlanet(0, 0, 0, false, 0, 22, 11, 2003,
1717
"Jupiter");
1818

@@ -26,8 +26,6 @@ public void testApproximatePositionOfPlanet() {
2626
}
2727

2828
public void testPrecisePositionOfPlanet() {
29-
TestLib testLib = new TestLib();
30-
3129
PlanetPosition planetPosition = paPlanet.precisePositionOfPlanet(0, 0, 0, false, 0, 22, 11, 2003, "Jupiter");
3230

3331
testLib.setTestName("Precise Position of Planet")
@@ -40,8 +38,6 @@ public void testPrecisePositionOfPlanet() {
4038
}
4139

4240
public void testVisualAspectsOfAPlanet() {
43-
TestLib testLib = new TestLib();
44-
4541
VisualAspectsOfAPlanet visualAspectsOfAPlanet = paPlanet.visualAspectsOfAPlanet(0, 0, 0, false, 0, 22, 11, 2003,
4642
"Jupiter");
4743

src/TestSun.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
public class TestSun {
1313
PASun paSun;
14+
TestLib testLib;
1415

1516
public TestSun() {
1617
paSun = new PASun();
18+
testLib = new TestLib();
1719
}
1820

1921
public void testApproximatePositionOfSun() {
20-
TestLib testLib = new TestLib();
21-
2222
PositionOfSun approximatePositionOfSun = paSun.approximatePositionOfSun(0, 0, 0, 27, 7, 2003, false,
2323
0);
2424

@@ -32,8 +32,6 @@ public void testApproximatePositionOfSun() {
3232
}
3333

3434
public void testPrecisePositionOfSun() {
35-
TestLib testLib = new TestLib();
36-
3735
PositionOfSun precisePositionOfSun = paSun.precisePositionOfSun(0, 0, 0, 27, 7, 1988, false,
3836
0);
3937

@@ -47,8 +45,6 @@ public void testPrecisePositionOfSun() {
4745
}
4846

4947
public void testSunDistanceAndAngularSize() {
50-
TestLib testLib = new TestLib();
51-
5248
SunDistanceAndAngularSize sunDistanceAndAngularSize = paSun.sunDistanceAndAngularSize(0, 0, 0, 27, 7,
5349
1988,
5450
false, 0);
@@ -61,8 +57,6 @@ public void testSunDistanceAndAngularSize() {
6157
}
6258

6359
public void testSunriseAndSunset() {
64-
TestLib testLib = new TestLib();
65-
6660
SunriseAndSunset sunriseAndSunset = paSun.sunriseAndSunset(10, 3, 1986, false, -5, -71.05, 42.37);
6761

6862
testLib.setTestName("Sunrise and Sunset")
@@ -76,8 +70,6 @@ public void testSunriseAndSunset() {
7670
}
7771

7872
public void testMorningAndEveningTwilight() {
79-
TestLib testLib = new TestLib();
80-
8173
MorningAndEveningTwilight morningAndEveningTwilight = paSun.morningAndEveningTwilight(7, 9, 1979, false,
8274
0, 0, 52, TwilightType.ASTRONOMICAL);
8375

@@ -90,8 +82,6 @@ public void testMorningAndEveningTwilight() {
9082
}
9183

9284
public void testEquationOfTime() {
93-
TestLib testLib = new TestLib();
94-
9585
EquationOfTime equationOfTime = paSun.equationOfTime(27, 7, 2010);
9686

9787
testLib.setTestName("Equation of Time")
@@ -100,8 +90,6 @@ public void testEquationOfTime() {
10090
}
10191

10292
public void testSolarElongation() {
103-
TestLib testLib = new TestLib();
104-
10593
double solarElongation = paSun.solarElongation(10, 6, 45, 11, 57, 27, 27.8333333, 7, 2010);
10694

10795
testLib.setTestName("Solar Elongation")

0 commit comments

Comments
 (0)