|
| 1 | +Red [ |
| 2 | + description: {Tests for "Flower Field" Exercism exercise} |
| 3 | + author: "loziniak" |
| 4 | +] |
| 5 | + |
| 6 | +#include %testlib.red |
| 7 | + |
| 8 | +test-init/limit %flower-field.red 1 |
| 9 | +; test-init/limit %.meta/example.red 1 ; test example solution |
| 10 | + |
| 11 | +canonical-cases: [#[ |
| 12 | + description: "no rows" |
| 13 | + input: #[ |
| 14 | + garden: [] |
| 15 | + ] |
| 16 | + expected: [] |
| 17 | + function: "annotate" |
| 18 | + uuid: "237ff487-467a-47e1-9b01-8a891844f86c" |
| 19 | +] #[ |
| 20 | + description: "no columns" |
| 21 | + input: #[ |
| 22 | + garden: [""] |
| 23 | + ] |
| 24 | + expected: [""] |
| 25 | + function: "annotate" |
| 26 | + uuid: "4b4134ec-e20f-439c-a295-664c38950ba1" |
| 27 | +] #[ |
| 28 | + description: "no flowers" |
| 29 | + input: #[ |
| 30 | + garden: [" " " " " "] |
| 31 | + ] |
| 32 | + expected: [" " " " " "] |
| 33 | + function: "annotate" |
| 34 | + uuid: "d774d054-bbad-4867-88ae-069cbd1c4f92" |
| 35 | +] #[ |
| 36 | + description: "garden full of flowers" |
| 37 | + input: #[ |
| 38 | + garden: ["***" "***" "***"] |
| 39 | + ] |
| 40 | + expected: ["***" "***" "***"] |
| 41 | + function: "annotate" |
| 42 | + uuid: "225176a0-725e-43cd-aa13-9dced501f16e" |
| 43 | +] #[ |
| 44 | + description: "flower surrounded by spaces" |
| 45 | + input: #[ |
| 46 | + garden: [" " " * " " "] |
| 47 | + ] |
| 48 | + expected: ["111" "1*1" "111"] |
| 49 | + function: "annotate" |
| 50 | + uuid: "3f345495-f1a5-4132-8411-74bd7ca08c49" |
| 51 | +] #[ |
| 52 | + description: "space surrounded by flowers" |
| 53 | + input: #[ |
| 54 | + garden: ["***" "* *" "***"] |
| 55 | + ] |
| 56 | + expected: ["***" "*8*" "***"] |
| 57 | + function: "annotate" |
| 58 | + uuid: "6cb04070-4199-4ef7-a6fa-92f68c660fca" |
| 59 | +] #[ |
| 60 | + description: "horizontal line" |
| 61 | + input: #[ |
| 62 | + garden: [" * * "] |
| 63 | + ] |
| 64 | + expected: ["1*2*1"] |
| 65 | + function: "annotate" |
| 66 | + uuid: "272d2306-9f62-44fe-8ab5-6b0f43a26338" |
| 67 | +] #[ |
| 68 | + description: "horizontal line, flowers at edges" |
| 69 | + input: #[ |
| 70 | + garden: ["* *"] |
| 71 | + ] |
| 72 | + expected: ["*1 1*"] |
| 73 | + function: "annotate" |
| 74 | + uuid: "c6f0a4b2-58d0-4bf6-ad8d-ccf4144f1f8e" |
| 75 | +] #[ |
| 76 | + description: "vertical line" |
| 77 | + input: #[ |
| 78 | + garden: [" " "*" " " "*" " "] |
| 79 | + ] |
| 80 | + expected: ["1" "*" "2" "*" "1"] |
| 81 | + function: "annotate" |
| 82 | + uuid: "a54e84b7-3b25-44a8-b8cf-1753c8bb4cf5" |
| 83 | +] #[ |
| 84 | + description: "vertical line, flowers at edges" |
| 85 | + input: #[ |
| 86 | + garden: ["*" " " " " " " "*"] |
| 87 | + ] |
| 88 | + expected: ["*" "1" " " "1" "*"] |
| 89 | + function: "annotate" |
| 90 | + uuid: "b40f42f5-dec5-4abc-b167-3f08195189c1" |
| 91 | +] #[ |
| 92 | + description: "cross" |
| 93 | + input: #[ |
| 94 | + garden: [" * " " * " "*****" " * " " * "] |
| 95 | + ] |
| 96 | + expected: [" 2*2 " "25*52" "*****" "25*52" " 2*2 "] |
| 97 | + function: "annotate" |
| 98 | + uuid: "58674965-7b42-4818-b930-0215062d543c" |
| 99 | +] #[ |
| 100 | + description: "large garden" |
| 101 | + input: #[ |
| 102 | + garden: [" * * " " * " " * " " * *" " * * " " "] |
| 103 | + ] |
| 104 | + expected: ["1*22*1" "12*322" " 123*2" "112*4*" "1*22*2" "111111"] |
| 105 | + function: "annotate" |
| 106 | + uuid: "dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8" |
| 107 | +]] |
| 108 | + |
| 109 | + |
| 110 | +foreach c-case canonical-cases [ |
| 111 | + case-code: reduce [ |
| 112 | + 'expect c-case/expected compose [ |
| 113 | + (to word! c-case/function) (values-of c-case/input) |
| 114 | + ] |
| 115 | + ] |
| 116 | + |
| 117 | + test c-case/description case-code |
| 118 | +] |
| 119 | + |
| 120 | +test-results/print |
0 commit comments