alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (PrimitiveDefaultValueTest.groovy)

This example Groovy source code file (PrimitiveDefaultValueTest.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

classforprimitivedefaultvalue, classforprimitivedefaultvalue, groovytestcase, groovytestcase, primitivedefaultvaluetest, primitivedefaultvaluetest

The Groovy PrimitiveDefaultValueTest.groovy source code

package groovy

/**
 * @todo GROOVY-1037
 *
 *    $Revision 1.0
 *    Test for non-initialized fields or variables of the primitive types.
 *
 * @author Pilho Kim
 */

class PrimitiveDefaultValueTest extends GroovyTestCase {

    private int x
    private long y
    private double z
    private byte b
    private short s
    private float f
    private boolean flag
    private char c

    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
    }

    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
    }

    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
    }

    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
    }
}

class ClassForPrimitiveDefaultValue {
    int x
    long y
    double z
    byte b
    short s
    float f
    boolean flag
    char c

    int x1
    long y1
    double z1
    byte b1
    short s1
    float f1
    boolean flag1
    char c1
}


Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy PrimitiveDefaultValueTest.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.