Repository: groovy Updated Branches: refs/heads/master 8bbe3a9ca -> 6318f5726
minor refactor: add missing assertions Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6318f572 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6318f572 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6318f572 Branch: refs/heads/master Commit: 6318f57268e9e391409e7e26839eacbae11ee86e Parents: 8bbe3a9 Author: paulk <pa...@asert.com.au> Authored: Sun Jun 5 09:34:35 2016 +1000 Committer: paulk <pa...@asert.com.au> Committed: Sun Jun 5 09:34:35 2016 +1000 ---------------------------------------------------------------------- .../groovy/PrimitiveDefaultValueTest.groovy | 90 ++++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/6318f572/src/test/groovy/PrimitiveDefaultValueTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/PrimitiveDefaultValueTest.groovy b/src/test/groovy/PrimitiveDefaultValueTest.groovy index 2520bf9..af84f3b 100644 --- a/src/test/groovy/PrimitiveDefaultValueTest.groovy +++ b/src/test/groovy/PrimitiveDefaultValueTest.groovy @@ -19,14 +19,8 @@ package groovy /** - * @todo GROOVY-1037 - * - * $Revision 1.0 - * Test for non-initialized fields or variables of the primitive types. - * - * @author Pilho Kim + * Test for non-initialized fields or variables of the primitive types. */ - class PrimitiveDefaultValueTest extends GroovyTestCase { private int x @@ -38,63 +32,65 @@ class PrimitiveDefaultValueTest extends GroovyTestCase { private boolean flag private char c + private static final Character ZERO = '\0' + void testThisPrimitiveDefaultValues() { - this.x == 0 - this.y == 0L - this.z == 0.0 - this.b == (byte) 0 - this.s == (short) 0 - this.f == 0.0F - this.flag == false - this.c == (char) 0 + assertEquals(this.x, 0) + assertEquals(this.y, 0L) + assertEquals(this.z, 0.0d) + assertEquals(this.b, (byte) 0) + assertEquals(this.s, (short) 0) + assertEquals(this.f, 0.0f) + assertFalse(this.flag) + assertEquals(this.c, ZERO) } void testPrimitiveDefaultValues() { def a = new ClassForPrimitiveDefaultValue() - a.x == 0 - a.y == 0L - a.z == 0.0 - a.b == (byte) 0 - a.s == (short) 0 - a.f == 0.0F - a.flag == false - a.c == (char) 0 + assertEquals(a.x, 0) + assertEquals(a.y, 0L) + assertEquals(a.z, 0.0d) + assertEquals(a.b, (byte) 0) + assertEquals(a.s, (short) 0) + assertEquals(a.f, 0.0f) + assertFalse(a.flag) + assertEquals(a.c, ZERO) } void testDefaultPrimitiveValuesForAttributes() { def a = new ClassForPrimitiveDefaultValue() - a.@x == 0 - a.@y == 0L - a.@z == 0.0 - a.@b == (byte) 0 - a.@s == (short) 0 - a.@f == 0.0F - a.@flag == false - a.@c == (char) 0 + assertEquals(a.@x, 0) + assertEquals(a.@y, 0L) + assertEquals(a.@z, 0.0d) + assertEquals(a.@b, (byte) 0) + assertEquals(a.@s, (short) 0) + assertEquals(a.@f, 0.0f) + assertFalse(a.@flag) + assertEquals(a.@c, ZERO) } void testDefaultPrimitiveValuesForProperties() { def a = new ClassForPrimitiveDefaultValue() - a.x1 == 0 - a.y1 == 0L - a.z1 == 0.0 - a.b1 == (byte) 0 - a.s1 == (short) 0 - a.f1 == 0.0F - a.flag1 == false - a.c1 == (char) 0 + assertEquals(a.x1, 0) + assertEquals(a.y1, 0L) + assertEquals(a.z1, 0.0d) + assertEquals(a.b1, (byte) 0) + assertEquals(a.s1, (short) 0) + assertEquals(a.f1, 0.0f) + assertFalse(a.flag1) + assertEquals(a.c1, ZERO) } } class ClassForPrimitiveDefaultValue { - int x - long y - double z - byte b - short s - float f - boolean flag - char c + public int x + public long y + public double z + public byte b + public short s + public float f + public boolean flag + public char c int x1 long y1