Sha256: 41773458e3c763c6ec3373f6eacdb01ff9939f382b240385d5fa4624225a4824

Contents?: true

Size: 1.4 KB

Versions: 72

Compression:

Stored size: 1.4 KB

Contents

-module(spiral_matrix_tests).

-define(TESTED_MODULE, (sut(spiral_matrix))).
-define(TEST_VERSION, 1).
-include("exercism.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([], ?TESTED_MODULE:make(0)).
trivial_spiral_test() ->
    ?assertEqual(?spiral1, ?TESTED_MODULE:make(1)).
spiral_of_size_2_test() ->
    ?assertEqual(?spiral2, ?TESTED_MODULE:make(2)).
spiral_of_size_3_test() ->
    ?assertEqual(?spiral3, ?TESTED_MODULE:make(3)).
spiral_of_size_4_test() ->
    ?assertEqual(?spiral4, ?TESTED_MODULE:make(4)).
spiral_of_size_5_test() ->
    ?assertEqual(?spiral5, ?TESTED_MODULE:make(5)).
spiral_of_size_500_test() ->
    M = ?TESTED_MODULE: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 data entries

72 entries across 72 versions & 1 rubygems

Version Path
trackler-2.2.1.62 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.61 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.60 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.59 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.58 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.57 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.56 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.55 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.54 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.53 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.52 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.51 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.50 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.49 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.48 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.47 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.46 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.45 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.44 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl
trackler-2.2.1.43 tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl