Created
August 25, 2014 22:47
-
-
Save carlosagp/f9a3a36b9c10780b8011 to your computer and use it in GitHub Desktop.
Test for rotating a matrix counter clockwise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'solution' | |
class RotationTest < Test::Unit::TestCase | |
def test_square_rotation | |
square = [ | |
[0, 1, 0, 0], | |
[0, 1, 1, 0], | |
[0, 0, 1, 0], | |
[0, 0, 0, 0] | |
] | |
square_rotated = [ | |
[0, 0, 0, 0], | |
[0, 1, 1, 0], | |
[1, 1, 0, 0], | |
[0, 0, 0, 0] | |
] | |
assert_equal square_rotated, Matrix.rotate(square) | |
end | |
def test_rectangular_rotation | |
rectangle = [ | |
[0, 1, 0], | |
[1, 1, 1] | |
] | |
rectangle_rotated = [ | |
[0, 1], | |
[1, 1], | |
[0, 1] | |
] | |
assert_equal rectangle_rotated, Matrix.rotate(rectangle) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment