Skip to content

Instantly share code, notes, and snippets.

@carlosagp
Created August 25, 2014 22:47
Show Gist options
  • Save carlosagp/f9a3a36b9c10780b8011 to your computer and use it in GitHub Desktop.
Save carlosagp/f9a3a36b9c10780b8011 to your computer and use it in GitHub Desktop.
Test for rotating a matrix counter clockwise
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