home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (MultiplyDivideEqualsTest.groovy)

This example Groovy source code file (MultiplyDivideEqualsTest.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

character, character, groovytestcase, groovytestcase, guillaume, guillaume, multiplydivideequalstest, multiplydivideequalstest

The Groovy MultiplyDivideEqualsTest.groovy source code

package groovy

class MultiplyDivideEqualsTest extends GroovyTestCase {

    void testIntegerMultiplyEquals() {
        def x = 2
        def y = 3
        x *= y
        
        assert x == 6
        
        y *= 4
        
        assert y == 12
    }

    void testCharacterMultiplyEquals() {
        Character x = 2
        Character y = 3
        x *= y
        
        assert x == 6
        
        y *= 4
        
        assert y == 12
    }
    
    void testNumberMultiplyEquals() {
        def x = 1.2
        def y = 2
        x *= y
        
        assert x == 2.4
    }
    
    void testStringMultiplyEquals() {
        def x = "bbc"
        def y = 2
        x *= y
        
        assert x == "bbcbbc"

        x = "Guillaume"
        y = 0
        x *= y
        assert x == ""
    }
    
    
    void testIntegerDivideEquals() {
        def x = 18
        def y = 6
        x /= y
        
        assert x == 3.0
        
        y /= 3
        
        assert y == 2.0
    }
    
    void testCharacterDivideEquals() {
        Character x = 18
        Character y = 6
        x /= y
        
        assert x == 3
        
        y /= 3
        
        assert y == 2
    }
    
    void testNumberDivideEquals() {
        def x = 10.4
        def y = 2
        x /= y
        
        assert x == 5.2
    }
}

Other Groovy examples (source code examples)

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

new blog posts

 

Copyright 1998-2016 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.