Skip to content

Commit 9011325

Browse files
committed
Add tests for Windage and Retard
1 parent 4d08efb commit 9011325

5 files changed

Lines changed: 84 additions & 41 deletions

File tree

test/ConversionTests.vala

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@
1919
public class ConversionTests : AbstractTestCase {
2020
public ConversionTests () {
2121
base ("Conversion") ;
22-
add_test ("[Angle] Degree to MOA", test_degree_to_moa) ;
23-
add_test ("[Angle] Degree to Radian", test_degree_to_radian) ;
24-
add_test ("[Angle] Radian to Degree", test_radian_to_degree) ;
25-
add_test ("[Angle] Radian to MOA", test_radian_to_moa) ;
26-
add_test ("[Angle] MOA to Degree", test_moa_to_degree) ;
27-
add_test ("[Angle] MOA to Radian", test_moa_to_radian) ;
28-
29-
add_test ("[Mass] Grain to Pound", test_grain_to_pound) ;
30-
add_test ("[Mass] Grain to Ounce", test_grain_to_ounce) ;
31-
add_test ("[Mass] Grain to Miligram", test_grain_to_miligram) ;
32-
add_test ("[Mass] Miligram to Grain", test_miligram_to_grain) ;
33-
add_test ("[Mass] Miligram to Pound", test_miligram_to_pound) ;
34-
add_test ("[Mass] Miligram to Ounce", test_miligram_to_ounce) ;
35-
add_test ("[Mass] Pound to Grain", test_pound_to_grain) ;
36-
add_test ("[Mass] Pound to Miligram", test_pound_to_miligram) ;
37-
add_test ("[Mass] Pound to Ounce", test_pound_to_ounce) ;
38-
add_test ("[Mass] Ounce to Grain", test_ounce_to_grain) ;
39-
add_test ("[Mass] Ounce to Miligram", test_ounce_to_miligram) ;
40-
add_test ("[Mass] Ounce to Pound", test_ounce_to_pound) ;
41-
42-
add_test ("[Temp] Fahrenheit to Kelvin", test_fahrenheit_to_kelvin) ;
43-
add_test ("[Temp] Fahrenheit to Celsius", test_fahrenheit_to_celsius) ;
44-
add_test ("[Temp] Fahrenheit to Rankine", test_fahrenheit_to_rankine) ;
45-
add_test ("[Temp] Kelvin to Fahrenheit", test_kelvin_to_fahrenheit) ;
46-
add_test ("[Temp] Kelvin to Celsius", test_kelvin_to_celsius) ;
47-
add_test ("[Temp] Kelvin to Rankine", test_kelvin_to_rankine) ;
48-
add_test ("[Temp] Celsius to Fahrenheit", test_celsius_to_fahrenheit) ;
49-
add_test ("[Temp] Celsius to Kelvin", test_celsius_to_kelvin) ;
50-
add_test ("[Temp] Celsius to Rankine", test_celsius_to_rankine) ;
51-
add_test ("[Temp] Rankine to Fahrenheit", test_rankine_to_fahrenheit) ;
52-
add_test ("[Temp] Rankine to Celsius", test_rankine_to_celsius) ;
53-
add_test ("[Temp] Rankine to Kelvin", test_rankine_to_kelvin) ;
22+
add_test ("Angle Degree to MOA", test_degree_to_moa) ;
23+
add_test ("Angle Degree to Radian", test_degree_to_radian) ;
24+
add_test ("Angle Radian to Degree", test_radian_to_degree) ;
25+
add_test ("Angle Radian to MOA", test_radian_to_moa) ;
26+
add_test ("Angle MOA to Degree", test_moa_to_degree) ;
27+
add_test ("Angle MOA to Radian", test_moa_to_radian) ;
28+
29+
add_test ("Mass Grain to Pound", test_grain_to_pound) ;
30+
add_test ("Mass Grain to Ounce", test_grain_to_ounce) ;
31+
add_test ("Mass Grain to Miligram", test_grain_to_miligram) ;
32+
add_test ("Mass Miligram to Grain", test_miligram_to_grain) ;
33+
add_test ("Mass Miligram to Pound", test_miligram_to_pound) ;
34+
add_test ("Mass Miligram to Ounce", test_miligram_to_ounce) ;
35+
add_test ("Mass Pound to Grain", test_pound_to_grain) ;
36+
add_test ("Mass Pound to Miligram", test_pound_to_miligram) ;
37+
add_test ("Mass Pound to Ounce", test_pound_to_ounce) ;
38+
add_test ("Mass Ounce to Grain", test_ounce_to_grain) ;
39+
add_test ("Mass Ounce to Miligram", test_ounce_to_miligram) ;
40+
add_test ("Mass Ounce to Pound", test_ounce_to_pound) ;
41+
42+
add_test ("Temp Fahrenheit to Kelvin", test_fahrenheit_to_kelvin) ;
43+
add_test ("Temp Fahrenheit to Celsius", test_fahrenheit_to_celsius) ;
44+
add_test ("Temp Fahrenheit to Rankine", test_fahrenheit_to_rankine) ;
45+
add_test ("Temp Kelvin to Fahrenheit", test_kelvin_to_fahrenheit) ;
46+
add_test ("Temp Kelvin to Celsius", test_kelvin_to_celsius) ;
47+
add_test ("Temp Kelvin to Rankine", test_kelvin_to_rankine) ;
48+
add_test ("Temp Celsius to Fahrenheit", test_celsius_to_fahrenheit) ;
49+
add_test ("Temp Celsius to Kelvin", test_celsius_to_kelvin) ;
50+
add_test ("Temp Celsius to Rankine", test_celsius_to_rankine) ;
51+
add_test ("Temp Rankine to Fahrenheit", test_rankine_to_fahrenheit) ;
52+
add_test ("Temp Rankine to Celsius", test_rankine_to_celsius) ;
53+
add_test ("Temp Rankine to Kelvin", test_rankine_to_kelvin) ;
5454
}
5555

5656
/*

test/GreenhillTests.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class GreenhillTests : AbstractTestCase {
2020
public GreenhillTests () {
2121
base ("Greenhill") ;
22-
add_test ("[Twist] Calculate twist", test_calc_twist) ;
22+
add_test ("Twist Calculate twist", test_calc_twist) ;
2323
}
2424

2525
public virtual void test_calc_twist() {

test/LibBalisticaTests.vala

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919
public class LibBalisticaTests : AbstractTestCase {
2020
public LibBalisticaTests () {
2121
base ("LibBalistica") ;
22-
add_test ("[LibBalistica] Verify gravity", test_gravity) ;
23-
add_test ("[LibBalistica] Verify standard pressure", test_standard_pressure) ;
24-
add_test ("[LibBalistica] Verify standard tempurature", test_standard_tempurature) ;
25-
add_test ("[LibBalistica] Verify computational unit", test_computation_unit) ;
26-
add_test ("[LibBalistica] Verify Zero calculation", test_zero_calculation) ;
22+
add_test ("Computational unit", test_computation_unit) ;
23+
add_test ("Gravity", test_gravity) ;
24+
add_test ("Standard pressure", test_standard_pressure) ;
25+
add_test ("Standard tempurature", test_standard_tempurature) ;
26+
add_test ("Retard", test_retard_calcretard) ;
27+
add_test ("Windage CalcWindage", test_windage_calc) ;
28+
add_test ("Windage HeadWindage", test_windage_head) ;
29+
add_test ("Windage CrossWindage", test_windage_cross) ;
30+
add_test ("Zero", test_zero_calculation) ;
31+
// TODO add_test ("PBR", test_pbr) ;
32+
// TODO add_test ("Atmosphere", test_atmosphere) ;
33+
// TODO add_test ("Solve", test_solve) ;
34+
// TODO add_test ("Solution", test_solution) ;
2735
}
2836

2937
public virtual void test_gravity() {
@@ -82,4 +90,39 @@ public class LibBalisticaTests : AbstractTestCase {
8290
assert (B == 0.1000823974609375) ;
8391
}
8492

93+
public virtual void test_retard_calcretard() {
94+
double G1 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G1, 0.465, 2650) ;
95+
double G2 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G2, 0.465, 2650) ;
96+
double G5 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G5, 0.465, 2650) ;
97+
double G6 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G6, 0.465, 2650) ;
98+
double G7 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G7, 0.465, 2650) ;
99+
double G8 = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.G8, 0.465, 2650) ;
100+
double I = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.I, 0.465, 2650) ;
101+
double B = LibBalistica.Retard.CalcRetard (LibBalistica.DragFunction.B, 0.465, 2650) ;
102+
103+
assert (G1 == 1700.6101549599655) ;
104+
assert (G2 == 836.74681264648268) ;
105+
assert (G5 == 1091.469144250384) ;
106+
assert (G6 == 949.69767441680813) ;
107+
assert (G7 == 846.55271847810116) ;
108+
assert (G8 == 912.72086631572529) ;
109+
assert (I == 1768.585858301544) ;
110+
assert (B == 1721.5850610419966) ;
111+
}
112+
113+
public virtual void test_windage_calc() {
114+
double val = LibBalistica.Windage.CalcWindage (2.0, 1200, 100, 3) ;
115+
assert (val == 102.66666666666667) ;
116+
}
117+
118+
public virtual void test_windage_head() {
119+
double val = LibBalistica.Windage.HeadWind (2.0, 0) ;
120+
assert (val == 2) ;
121+
}
122+
123+
public virtual void test_windage_cross() {
124+
double val = LibBalistica.Windage.CrossWind (2.0, 0) ;
125+
assert (val == 0) ;
126+
}
127+
85128
}

test/MillerTests.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
public class MillerTests : AbstractTestCase {
2020
public MillerTests () {
2121
base ("Miller") ;
22-
add_test ("[Twist] Calculate twist", test_calc_twist) ;
23-
add_test ("[Stability] Calculate stability", test_calc_stability) ;
22+
add_test ("Twist Calculate twist", test_calc_twist) ;
23+
add_test ("Stability Calculate stability", test_calc_stability) ;
2424
}
2525

2626
public virtual void test_calc_twist() {

test/TestRunner.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
void main(string[] args) {
2020
Test.init (ref args) ;
2121

22-
TestSuite.get_root ().add_suite (new LibBalisticaTests ().get_suite ()) ;
2322
TestSuite.get_root ().add_suite (new ConversionTests ().get_suite ()) ;
2423
TestSuite.get_root ().add_suite (new GreenhillTests ().get_suite ()) ;
24+
TestSuite.get_root ().add_suite (new LibBalisticaTests ().get_suite ()) ;
2525
TestSuite.get_root ().add_suite (new MillerTests ().get_suite ()) ;
2626

2727
Test.run () ;

0 commit comments

Comments
 (0)