Sha256: 1f3093d1edbddeca4d9e6317f26413a83183cea2598c74a569b9d743c77bc94e

Contents?: true

Size: 1.46 KB

Versions: 116

Compression:

Stored size: 1.46 KB

Contents

-module(spiral_matrix_tests).

-include_lib("erl_exercism/include/exercism.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(spiral1, [[1]]).
-define(spiral2, [[1,2],
                  [4,3]]).
-define(spiral3, [[1,2,3],
                  [8,9,4],
                  [7,6,5]]).
-define(spiral4, [[ 1, 2, 3, 4],
                  [12,13,14, 5],
                  [11,16,15, 6],
                  [10, 9, 8, 7]]).
-define(spiral5, [[ 1,  2,  3,  4, 5],
                  [16, 17, 18, 19, 6],
                  [15, 24, 25, 20, 7],
                  [14, 23, 22, 21, 8],
                  [13, 12, 11, 10, 9]]).
-define(get(X,Y,L), lists:nth(X,lists:nth(Y,L))).

empty_spiral_test() ->
    ?assertEqual([], spiral_matrix:make(0)).
trivial_spiral_test() ->
    ?assertEqual(?spiral1, spiral_matrix:make(1)).
spiral_of_size_2_test() ->
    ?assertEqual(?spiral2, spiral_matrix:make(2)).
spiral_of_size_3_test() ->
    ?assertEqual(?spiral3, spiral_matrix:make(3)).
spiral_of_size_4_test() ->
    ?assertEqual(?spiral4, spiral_matrix:make(4)).
spiral_of_size_5_test() ->
    ?assertEqual(?spiral5, spiral_matrix:make(5)).
spiral_of_size_500_test() ->
    M = spiral_matrix:make(500),
    ?assertEqual(1, ?get(1,1,M)),
    ?assertEqual(1997, ?get(2,2,M)),
    ?assertEqual(38894, ?get(480,55,M)),
    ?assertEqual(121053, ?get(430,364,M)),
    ?assertEqual(158597, ?get(99,299,M)),
    ?assertEqual(250000, ?get(250,251,M)).

version_test() ->
  ?assertMatch(1, spiral_matrix:test_version()).

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.138 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.137 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.136 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.135 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.134 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.133 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.132 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.131 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.130 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.129 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.128 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.127 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.126 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.125 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.124 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.123 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.122 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.121 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.120 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl