Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions exercises/practice/tournament/.meta/template.create_test_table.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
DROP TABLE IF EXISTS tests;

CREATE TABLE IF NOT EXISTS tests (
-- uuid and description are taken from the test.toml file
uuid TEXT PRIMARY KEY,
description TEXT NOT NULL,
-- The following section is needed by the online test-runner
status TEXT DEFAULT 'fail',
message TEXT,
output TEXT,
test_code TEXT,
task_id INTEGER DEFAULT NULL,
-- Here are columns for the actual tests
input TEXT NOT NULL,
expected TEXT NOT NULL
);

INSERT INTO
tests (uuid, description, input, expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
'{{ case["input"]["rows"] | join("\n") }}',
'{{ case["expected"] | join("\n") }}'
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}

UPDATE tests
SET
input = REPLACE(input, '\n', CHAR(10));

UPDATE tests
SET
expected = REPLACE(expected, '\n', CHAR(10));
3 changes: 3 additions & 0 deletions exercises/practice/tournament/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
"{{ case["input"]["rows"] | join("\\n") }}",""
{% endfor %}
86 changes: 68 additions & 18 deletions exercises/practice/tournament/create_test_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,117 @@ VALUES
'1b4a8aef-0734-4007-80a2-0626178c88f4',
'a win is three points, a loss is zero points',
'Allegoric Alaskans;Blithering Badgers;win',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 1 | 0 | 0 | 3\nBlithering Badgers | 1 | 0 | 0 | 1 | 0'
'Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 1 | 0 | 0 | 3
Blithering Badgers | 1 | 0 | 0 | 1 | 0'
),
(
'5f45ac09-4efe-46e7-8ddb-75ad85f86e05',
'a win can also be expressed as a loss',
'Blithering Badgers;Allegoric Alaskans;loss',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 1 | 0 | 0 | 3\nBlithering Badgers | 1 | 0 | 0 | 1 | 0'
'Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 1 | 0 | 0 | 3
Blithering Badgers | 1 | 0 | 0 | 1 | 0'
),
(
'fd297368-efa0-442d-9f37-dd3f9a437239',
'a different team can win',
'Blithering Badgers;Allegoric Alaskans;win',
'Team | MP | W | D | L | P\nBlithering Badgers | 1 | 1 | 0 | 0 | 3\nAllegoric Alaskans | 1 | 0 | 0 | 1 | 0'
'Team | MP | W | D | L | P
Blithering Badgers | 1 | 1 | 0 | 0 | 3
Allegoric Alaskans | 1 | 0 | 0 | 1 | 0'
),
(
'26c016f9-e753-4a93-94e9-842f7b4d70fc',
'a draw is one point each',
'Allegoric Alaskans;Blithering Badgers;draw',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 1 | 0 | 1 | 0 | 1\nBlithering Badgers | 1 | 0 | 1 | 0 | 1'
'Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 0 | 1 | 0 | 1
Blithering Badgers | 1 | 0 | 1 | 0 | 1'
),
(
'731204f6-4f34-4928-97eb-1c307ba83e62',
'There can be more than one match',
'Allegoric Alaskans;Blithering Badgers;win\nAllegoric Alaskans;Blithering Badgers;win',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 2 | 0 | 0 | 6\nBlithering Badgers | 2 | 0 | 0 | 2 | 0'
'Allegoric Alaskans;Blithering Badgers;win
Allegoric Alaskans;Blithering Badgers;win',
'Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 2 | 0 | 0 | 6
Blithering Badgers | 2 | 0 | 0 | 2 | 0'
),
(
'49dc2463-42af-4ea6-95dc-f06cc5776adf',
'There can be more than one winner',
'Allegoric Alaskans;Blithering Badgers;loss\nAllegoric Alaskans;Blithering Badgers;win',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 1 | 0 | 1 | 3\nBlithering Badgers | 2 | 1 | 0 | 1 | 3'
'Allegoric Alaskans;Blithering Badgers;loss
Allegoric Alaskans;Blithering Badgers;win',
'Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 1 | 0 | 1 | 3
Blithering Badgers | 2 | 1 | 0 | 1 | 3'
),
(
'6d930f33-435c-4e6f-9e2d-63fa85ce7dc7',
'There can be more than two teams',
'Allegoric Alaskans;Blithering Badgers;win\nBlithering Badgers;Courageous Californians;win\nCourageous Californians;Allegoric Alaskans;loss',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 2 | 2 | 0 | 0 | 6\nBlithering Badgers | 2 | 1 | 0 | 1 | 3\nCourageous Californians | 2 | 0 | 0 | 2 | 0'
'Allegoric Alaskans;Blithering Badgers;win
Blithering Badgers;Courageous Californians;win
Courageous Californians;Allegoric Alaskans;loss',
'Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 2 | 0 | 0 | 6
Blithering Badgers | 2 | 1 | 0 | 1 | 3
Courageous Californians | 2 | 0 | 0 | 2 | 0'
),
(
'97022974-0c8a-4a50-8fe7-e36bdd8a5945',
'typical input',
'Allegoric Alaskans;Blithering Badgers;win\nDevastating Donkeys;Courageous Californians;draw\nDevastating Donkeys;Allegoric Alaskans;win\nCourageous Californians;Blithering Badgers;loss\nBlithering Badgers;Devastating Donkeys;loss\nAllegoric Alaskans;Courageous Californians;win',
'Team | MP | W | D | L | P\nDevastating Donkeys | 3 | 2 | 1 | 0 | 7\nAllegoric Alaskans | 3 | 2 | 0 | 1 | 6\nBlithering Badgers | 3 | 1 | 0 | 2 | 3\nCourageous Californians | 3 | 0 | 1 | 2 | 1'
'Allegoric Alaskans;Blithering Badgers;win
Devastating Donkeys;Courageous Californians;draw
Devastating Donkeys;Allegoric Alaskans;win
Courageous Californians;Blithering Badgers;loss
Blithering Badgers;Devastating Donkeys;loss
Allegoric Alaskans;Courageous Californians;win',
'Team | MP | W | D | L | P
Devastating Donkeys | 3 | 2 | 1 | 0 | 7
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
Blithering Badgers | 3 | 1 | 0 | 2 | 3
Courageous Californians | 3 | 0 | 1 | 2 | 1'
),
(
'fe562f0d-ac0a-4c62-b9c9-44ee3236392b',
'incomplete competition (not all pairs have played)',
'Allegoric Alaskans;Blithering Badgers;loss\nDevastating Donkeys;Allegoric Alaskans;loss\nCourageous Californians;Blithering Badgers;draw\nAllegoric Alaskans;Courageous Californians;win',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 3 | 2 | 0 | 1 | 6\nBlithering Badgers | 2 | 1 | 1 | 0 | 4\nCourageous Californians | 2 | 0 | 1 | 1 | 1\nDevastating Donkeys | 1 | 0 | 0 | 1 | 0'
'Allegoric Alaskans;Blithering Badgers;loss
Devastating Donkeys;Allegoric Alaskans;loss
Courageous Californians;Blithering Badgers;draw
Allegoric Alaskans;Courageous Californians;win',
'Team | MP | W | D | L | P
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
Blithering Badgers | 2 | 1 | 1 | 0 | 4
Courageous Californians | 2 | 0 | 1 | 1 | 1
Devastating Donkeys | 1 | 0 | 0 | 1 | 0'
),
(
'3aa0386f-150b-4f99-90bb-5195e7b7d3b8',
'ties broken alphabetically',
'Courageous Californians;Devastating Donkeys;win\nAllegoric Alaskans;Blithering Badgers;win\nDevastating Donkeys;Allegoric Alaskans;loss\nCourageous Californians;Blithering Badgers;win\nBlithering Badgers;Devastating Donkeys;draw\nAllegoric Alaskans;Courageous Californians;draw',
'Team | MP | W | D | L | P\nAllegoric Alaskans | 3 | 2 | 1 | 0 | 7\nCourageous Californians | 3 | 2 | 1 | 0 | 7\nBlithering Badgers | 3 | 0 | 1 | 2 | 1\nDevastating Donkeys | 3 | 0 | 1 | 2 | 1'
'Courageous Californians;Devastating Donkeys;win
Allegoric Alaskans;Blithering Badgers;win
Devastating Donkeys;Allegoric Alaskans;loss
Courageous Californians;Blithering Badgers;win
Blithering Badgers;Devastating Donkeys;draw
Allegoric Alaskans;Courageous Californians;draw',
'Team | MP | W | D | L | P
Allegoric Alaskans | 3 | 2 | 1 | 0 | 7
Courageous Californians | 3 | 2 | 1 | 0 | 7
Blithering Badgers | 3 | 0 | 1 | 2 | 1
Devastating Donkeys | 3 | 0 | 1 | 2 | 1'
),
(
'f9e20931-8a65-442a-81f6-503c0205b17a',
'ensure points sorted numerically',
'Devastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nDevastating Donkeys;Blithering Badgers;win\nBlithering Badgers;Devastating Donkeys;win',
'Team | MP | W | D | L | P\nDevastating Donkeys | 5 | 4 | 0 | 1 | 12\nBlithering Badgers | 5 | 1 | 0 | 4 | 3'
'Devastating Donkeys;Blithering Badgers;win
Devastating Donkeys;Blithering Badgers;win
Devastating Donkeys;Blithering Badgers;win
Devastating Donkeys;Blithering Badgers;win
Blithering Badgers;Devastating Donkeys;win',
'Team | MP | W | D | L | P
Devastating Donkeys | 5 | 4 | 0 | 1 | 12
Blithering Badgers | 5 | 1 | 0 | 4 | 3'
);

UPDATE tests
Expand Down
37 changes: 37 additions & 0 deletions exercises/practice/transpose/.meta/template.create_test_table.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
DROP TABLE IF EXISTS tests;

CREATE TABLE IF NOT EXISTS tests (
-- uuid and description are taken from the test.toml file
uuid TEXT PRIMARY KEY,
description TEXT NOT NULL,
-- The following section is needed by the online test-runner
status TEXT DEFAULT 'fail',
message TEXT,
output TEXT,
test_code TEXT,
task_id INTEGER DEFAULT NULL,
-- Here are columns for the actual tests
lines TEXT NOT NULL,
expected TEXT NOT NULL
);

INSERT INTO
tests (uuid, description, lines, expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
'{{ case["input"]["lines"] | join("\n") }}',
'{{ case["expected"] | join("\n") }}'
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}

UPDATE tests
SET
lines = REPLACE(lines, '\n', CHAR(10)),
expected = REPLACE(expected, '\n', CHAR(10));
3 changes: 3 additions & 0 deletions exercises/practice/transpose/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
"{{ case["input"]["lines"] | join("\\n") }}",""
{% endfor %}
Loading