Assumptions:
- Go has been successfully installed and the installation tested.
- The "go" version installed on the test system is 1.9.2
- The OS installed on the test system is Ubuntu 16.04.
Repository code structure contains two directories as below:
- golangexercises/driver/ is the main package that contains a driver file to test out the functionality provided by the rectangle package.
- golangexercises/rectangle/ is the packagage that provides the method to calculate intersection between 2 rectangles.
- golangexercises/DifferentScenarios is a JPG file that illustrates the different scenarios with respect to rectangles and may help understand with the algorithm and test data.
Test 1: Execute the default driver program that has predefined test data: Follow the below steps:
- Execute "go get -u github.com/vishwanathj/golangexercises/driver"
- cd to the bin directory and execute ./driver to see 4 lines of output that displays intersecting rectangle of the given 2 rectangles.
Test 2: Execute the driver program by adding additional test data
- Edit the src/github.com/vishwanathj/golangexercises/driver/driver.go file to add additional data by following instructions in the source file at lines 10 - 15
- cd to src directory and execute "go build github.com/vishwanathj/golangexercises/driver/"
- Next execute "go install github.com/vishwanathj/golangexercises/driver"
- cd to the bin directory and execute ./driver to see calculated intersection rectangles.
Test 3: Execute the tests in rectangle package
- cd to the src directory
- Execute the command "go test github.com/vishwanathj/golangexercises/rectangle/rectangle_test.go"