• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to test below program using spock and groovy?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class RectFun {

    public static void main(String[] args) {
       RectangularShape rectangularShape
       rectangularShape = new Rectangle2D.Double(10,20,30,50)
       Rectangle2D rectangle = rotateRect(rectangularShape,30)
        println(rectangle)
    }
   static Rectangle2D rotateRect (RectangularShape rect, int angle, Point2D  pivot = null )
   {


       if (pivot == null)
       {
           pivot = new Point2D.Double(rect.x + (int) Math.round(rect.width / 2d), rect.y + (int) Math.round(rect.height / 2d))
       }

       double rad = angle * Math.PI / 180;
       double diffX = rect.x - pivot.x
       double diffY = rect.y - pivot.y
       int x = (int) Math.round(rect.x - diffX + (diffX * Math.cos(rad)) + (diffY * Math.sin(rad)))
       int y = (int) Math.round(rect.y - diffY + (diffY * Math.cos(rad)) - (diffX * Math.sin(rad)))

       return new Rectangle2D.Double(x, y, rect.width, rect.height)
   }
}
 
Sheriff
Posts: 17357
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you searched for how to test with Spock and Groovy?
 
Narayanan Krish
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Have you searched for how to test with Spock and Groovy?



Yes , but could not get better idea on particular program.
 
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you insist on specifying the “how” (implementation)? Wouldn't it be better to work out what needs testing in yout application?
 
Our first order of business must be this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic