Skip to content

Commit c7897a8

Browse files
committed
Add test generators for darts diamond difference-of-squares
1 parent b18fbe9 commit c7897a8

7 files changed

Lines changed: 64 additions & 19 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["input"]["x"], case["input"]["y"]] | tocsv }},""
3+
{% endfor %}

exercises/practice/darts/data.csv

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
-9,9,
2-
0,10,
3-
-5,0,
4-
0,-1,
5-
0,0,
6-
-0.1,-0.1,
7-
0.7,0.7,
8-
0.8,-0.8,
9-
-3.5,3.5,
10-
-3.6,-3.6,
11-
-7.0,7.0,
12-
7.1,-7.1,
13-
0.5,-4,
1+
-9,9,""
2+
0,10,""
3+
-5,0,""
4+
0,-1,""
5+
0,0,""
6+
-0.1,-0.1,""
7+
0.7,0.7,""
8+
0.8,-0.8,""
9+
-3.5,3.5,""
10+
-3.6,-3.6,""
11+
-7.0,7.0,""
12+
7.1,-7.1,""
13+
0.5,-4,""
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
DROP TABLE IF EXISTS tests;
2+
3+
CREATE TABLE IF NOT EXISTS tests (
4+
-- uuid and description are taken from the test.toml file
5+
uuid TEXT PRIMARY KEY,
6+
description TEXT NOT NULL,
7+
-- The following section is needed by the online test-runner
8+
status TEXT DEFAULT 'fail',
9+
message TEXT,
10+
output TEXT,
11+
test_code TEXT,
12+
task_id INTEGER DEFAULT NULL,
13+
-- Here are columns for the actual tests
14+
letter TEXT NOT NULL,
15+
expected TEXT NOT NULL
16+
);
17+
18+
INSERT INTO
19+
tests (uuid, description, letter, expected)
20+
VALUES
21+
{%- for case in cases %}
22+
(
23+
'{{ case["uuid"] }}',
24+
'{{ case["description"] | replace("'", '"') }}',
25+
'{{ case["input"]["letter"] }}',
26+
'{{ case["expected"] | join("\\n") }}'
27+
{%- if loop.last %}
28+
);
29+
{%- else %}
30+
),
31+
{%- endif %}
32+
{%- endfor %}
33+
34+
UPDATE tests
35+
SET
36+
expected = REPLACE(expected, '\n', CHAR(10));
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["input"]["letter"]] | tocsv }},""
3+
{% endfor %}

exercises/practice/diamond/create_test_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INSERT INTO
2020
VALUES
2121
(
2222
'202fb4cc-6a38-4883-9193-a29d5cb92076',
23-
'Degenerate case with a single ''A'' row',
23+
'Degenerate case with a single "A" row',
2424
'A',
2525
'A'
2626
),
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"A",
2-
"B",
3-
"C",
4-
"D",
5-
"Z",
1+
"A",""
2+
"B",""
3+
"C",""
4+
"D",""
5+
"Z",""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for case in cases -%}
2+
{{ [case["input"]["number"], case["property"]] | tocsv }},""
3+
{% endfor %}

0 commit comments

Comments
 (0)