From bb3cdf2ce81551ce217e897c24ff1ac1ec303ecb Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Sat, 2 May 2020 12:35:55 -0400 Subject: [PATCH] [refactor] renamed variables in TransitionTest to reflect their containing component type --- .../rocketcomponent/TransitionTest.java | 130 ++++++++---------- 1 file changed, 61 insertions(+), 69 deletions(-) diff --git a/core/test/net/sf/openrocket/rocketcomponent/TransitionTest.java b/core/test/net/sf/openrocket/rocketcomponent/TransitionTest.java index 5e709f077..b9d12905f 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/TransitionTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/TransitionTest.java @@ -56,27 +56,25 @@ public class TransitionTest extends BaseTestCase { @Test public void testVerifyBackwardConicTransition(){ - Transition nose = new Transition(); - nose.setType( Transition.Shape.CONICAL); - nose.setForeRadius( 1.0); - nose.setAftRadius( 0.5); - nose.setLength( 5.0); - - assertEquals("nose cone length is wrong ", 5.0, nose.getLength(), EPSILON ); - assertEquals("nose cone fore radius is wrong ", 1.0, nose.getForeRadius(), EPSILON ); - assertEquals("nose cone aft radius is wrong ", 0.5, nose.getAftRadius(), EPSILON ); - assertThat("nose cone shape type is wrong ", Transition.Shape.CONICAL, equalTo(nose.getType())); - assertEquals("nose cone shape parameter is wrong ", 0.0, nose.getShapeParameter(), EPSILON ); - - assertEquals("bad shape - conical forward transition", 1.0, nose.getRadius(0.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.9, nose.getRadius(1.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.8, nose.getRadius(2.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.7, nose.getRadius(3.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.6, nose.getRadius(4.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.5, nose.getRadius(5.0), EPSILON ); - - } + Transition tail = new Transition(); + tail.setType( Transition.Shape.CONICAL); + tail.setForeRadius( 1.0); + tail.setAftRadius( 0.5); + tail.setLength( 5.0); + assertEquals("nose cone length is wrong ", 5.0, tail.getLength(), EPSILON ); + assertEquals("nose cone fore radius is wrong ", 1.0, tail.getForeRadius(), EPSILON ); + assertEquals("nose cone aft radius is wrong ", 0.5, tail.getAftRadius(), EPSILON ); + assertThat("nose cone shape type is wrong ", Transition.Shape.CONICAL, equalTo(tail.getType())); + assertEquals("nose cone shape parameter is wrong ", 0.0, tail.getShapeParameter(), EPSILON ); + + assertEquals("bad shape - conical forward transition", 1.0, tail.getRadius(0.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.9, tail.getRadius(1.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.8, tail.getRadius(2.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.7, tail.getRadius(3.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.6, tail.getRadius(4.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.5, tail.getRadius(5.0), EPSILON ); + } @Test public void testVerifyOgiveNoseCone(){ @@ -85,7 +83,7 @@ public class TransitionTest extends BaseTestCase { nose.setForeRadius( 0.0); nose.setAftRadius( 1.0); nose.setLength( 8.0); - + assertEquals("nose cone length is wrong ", 8.0, nose.getLength(), EPSILON ); assertEquals("nose cone fore radius is wrong ", 0.0, nose.getForeRadius(), EPSILON ); assertEquals("nose cone aft radius is wrong ", 1.0, nose.getAftRadius(), EPSILON ); @@ -101,73 +99,67 @@ public class TransitionTest extends BaseTestCase { assertEquals("bad shape - conical forward transition", 0.93840316661, nose.getRadius(6.0), EPSILON ); assertEquals("bad shape - conical forward transition", 0.98461174156, nose.getRadius(7.0), EPSILON ); assertEquals("bad shape - conical forward transition", 1.0, nose.getRadius(8.0), EPSILON ); - } @Test public void testVerifyForwardOgiveTransition(){ - Transition nose = new Transition(); - nose.setType( Transition.Shape.OGIVE); - nose.setForeRadius( 0.44135); - nose.setAftRadius( 1.0); - nose.setLength( 6.0); - - assertEquals("nose cone length is wrong ", 6.0, nose.getLength(), EPSILON ); - assertEquals("nose cone fore radius is wrong ", 0.44135, nose.getForeRadius(), EPSILON ); - assertEquals("nose cone aft radius is wrong ", 1.0, nose.getAftRadius(), EPSILON ); - assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(nose.getType())); - assertEquals("nose cone shape parameter is wrong ", 1.0, nose.getShapeParameter(), EPSILON ); - - assertEquals("bad shape - conical forward transition", 0.44135250736, nose.getRadius(0.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.61308144666, nose.getRadius(1.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.75290684574, nose.getRadius(2.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.86124225056, nose.getRadius(3.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.93840316661, nose.getRadius(4.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.98461174156, nose.getRadius(5.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 1.0, nose.getRadius(6.0), EPSILON ); - + Transition transition = new Transition(); + transition.setType( Transition.Shape.OGIVE); + transition.setForeRadius( 0.44135); + transition.setAftRadius( 1.0); + transition.setLength( 6.0); + + assertEquals("nose cone length is wrong ", 6.0, transition.getLength(), EPSILON ); + assertEquals("nose cone fore radius is wrong ", 0.44135, transition.getForeRadius(), EPSILON ); + assertEquals("nose cone aft radius is wrong ", 1.0, transition.getAftRadius(), EPSILON ); + assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(transition.getType())); + assertEquals("nose cone shape parameter is wrong ", 1.0, transition.getShapeParameter(), EPSILON ); + + assertEquals("bad shape - conical forward transition", 0.44135250736, transition.getRadius(0.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.61308144666, transition.getRadius(1.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.75290684574, transition.getRadius(2.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.86124225056, transition.getRadius(3.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.93840316661, transition.getRadius(4.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.98461174156, transition.getRadius(5.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 1.0, transition.getRadius(6.0), EPSILON ); } - + @Test public void testVerifyBackwardOgiveTransition(){ - Transition nose = new Transition(); - nose.setType( Transition.Shape.OGIVE); - nose.setForeRadius( 1.0); - nose.setAftRadius( 0.44135); - nose.setLength( 6.0); - - assertEquals("nose cone length is wrong ", 6.0, nose.getLength(), EPSILON ); - assertEquals("nose cone fore radius is wrong ", 1.0, nose.getForeRadius(), EPSILON ); - assertEquals("nose cone aft radius is wrong ", 0.44135, nose.getAftRadius(), EPSILON ); - assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(nose.getType())); - assertEquals("nose cone shape parameter is wrong ",1.0, nose.getShapeParameter(), EPSILON ); - - assertEquals("bad shape - conical forward transition", 1.0, nose.getRadius(0.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.98461174156, nose.getRadius(1.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.93840316661, nose.getRadius(2.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.86124225056, nose.getRadius(3.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.75290684574, nose.getRadius(4.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.61308144666, nose.getRadius(5.0), EPSILON ); - assertEquals("bad shape - conical forward transition", 0.44135250736, nose.getRadius(6.0), EPSILON ); - - - + Transition transition = new Transition(); + transition.setType( Transition.Shape.OGIVE); + transition.setForeRadius( 1.0); + transition.setAftRadius( 0.44135); + transition.setLength( 6.0); + + assertEquals("nose cone length is wrong ", 6.0, transition.getLength(), EPSILON ); + assertEquals("nose cone fore radius is wrong ", 1.0, transition.getForeRadius(), EPSILON ); + assertEquals("nose cone aft radius is wrong ", 0.44135, transition.getAftRadius(), EPSILON ); + assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(transition.getType())); + assertEquals("nose cone shape parameter is wrong ",1.0, transition.getShapeParameter(), EPSILON ); + + assertEquals("bad shape - conical forward transition", 1.0, transition.getRadius(0.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.98461174156, transition.getRadius(1.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.93840316661, transition.getRadius(2.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.86124225056, transition.getRadius(3.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.75290684574, transition.getRadius(4.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.61308144666, transition.getRadius(5.0), EPSILON ); + assertEquals("bad shape - conical forward transition", 0.44135250736, transition.getRadius(6.0), EPSILON ); } - + @Test public void testStockIntegration(){ Rocket rocket = TestRockets.makeEstesAlphaIII(); NoseCone nose = (NoseCone)rocket.getChild(0).getChild(0); - + assertEquals("Alpha3 nose cone length is wrong ", 0.07, nose.getLength(), EPSILON ); assertEquals("Alpha3 nose cone fore radius is wrong ", 0.00, nose.getForeRadius(), EPSILON ); assertEquals("Alpha3 nose cone aft radius is wrong ", 0.012, nose.getAftRadius(), EPSILON ); assertThat("Alpha3 nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(nose.getType())); assertEquals("Alpha3 nose cone shape parameter is wrong ", 1.0, nose.getShapeParameter(), EPSILON ); - + assertEquals("Alpha3 nose cone aft shoulder length is wrong ", 0.02, nose.getAftShoulderLength(), EPSILON ); assertEquals("Alpha3 nose cone aft shoulder radius is wrong ", 0.011, nose.getAftShoulderRadius(), EPSILON ); - } }