Skip to content

Commit

Permalink
Merge branch 'main' into ceske-drahy
Browse files Browse the repository at this point in the history
  • Loading branch information
marhei authored Jun 21, 2024
2 parents c1a49fb + b2a205d commit 98e3ec0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
10 changes: 5 additions & 5 deletions line-colors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1316,18 +1316,18 @@ vbb-vip-bus,609,,5-vbbvib-609,#907d32,#ffffff,,pill
vbb-vip-bus,612,,5-vbbvib-612,#842a26,#ffffff,,pill
vbb-vip-bus,616,,5-vbbvib-616,#0155ae,#ffffff,,pill
vbb-vip-bus,638,,5-vbbvib-638,#665fb1,#ffffff,,pill
vbb-vip-bus,639,,5-vbbvib-639,#ffffff,#9e9ace,#9e9ace,pill
vbb-vip-bus,639,,5-vbbvib-639,#f0eef6,#9e9ace,#9e9ace,pill
vbb-vip-bus,690,,5-vbbvib-690,#446080,#ffffff,,pill
vbb-vip-bus,691,,5-vbbvib-691,#ffffff,#ff9027,#ff9027,pill
vbb-vip-bus,691,,5-vbbvib-691,#feeedd,#ff9027,#ff9027,pill
vbb-vip-bus,692,,5-vbbvib-692,#00b9f2,#ffffff,,pill
vbb-vip-bus,693,,5-vbbvib-693,#e36eb5,#ffffff,,pill
vbb-vip-bus,694,,5-vbbvib-694,#70a4b8,#ffffff,,pill
vbb-vip-bus,695,,5-vbbvib-695,#bf2a4f,#bf2a4f,,pill
vbb-vip-bus,695,,5-vbbvib-695,#bf2a4f,#ffffff,,pill
vbb-vip-bus,696,,5-vbbvib-696,#eb2d4c,#ffffff,,pill
vbb-vip-bus,697,,5-vbbvib-697,#772382,#ffffff,,pill
vbb-vip-bus,698,,5-vbbvib-698,#117b40,#ffffff,,pill
vbb-vip-bus,699,,5-vbbvib-699,#d9992f,#ffffff,,pill
vbb-vip-bus,X5,,5-vbbvib-x5,#ffffff,#b167b3,#b167b3,pill
vbb-vip-bus,X5,,5-vbbvib-x5,#f2e6f1,#b167b3,#b167b3,pill
vbb-vip-bus,X15,,5-vbbvib-x15,#ffffff,#49c07d,#49c07d,pill
vbb-vip-bus,N14,,5-vbbvib-n14,#ffa32b,#ffffff,,pill
vbb-vip-bus,N15,,5-vbbvib-n15,#ff7322,#ffffff,,pill
Expand All @@ -1338,7 +1338,7 @@ vbb-vip-tram,92,,8-vbbvit-92,#024890,#ffffff,,rectangle
vbb-vip-tram,93,,8-vbbvit-93,#ff7322,#ffffff,,rectangle
vbb-vip-tram,94,,8-vbbvit-94,#89969e,#ffffff,,rectangle
vbb-vip-tram,96,,8-vbbvit-96,#00b098,#ffffff,,rectangle
vbb-vip-tram,98,,8-vbbvit-98,#ffffff,#009edd,#009edd,rectangle
vbb-vip-tram,98,,8-vbbvit-98,#daedf9,#009edd,#009edd,rectangle
vbb-vip-tram,99,,8-vbbvit-99,#5fbf49,#ffffff,,rectangle
vbg,RB 1,vogtlandbahn-die-landerbahn-gmbh-dlb,3-rd-rb1,#e30613,#ffffff,,rectangle-rounded-corner
vbg,RB 2,vogtlandbahn-die-landerbahn-gmbh-dlb,3-rd-rb2,#0067b0,#ffffff,,rectangle-rounded-corner
Expand Down
8 changes: 8 additions & 0 deletions validation/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
$i++;
}


echo "Checking that the background color isn't the text color" . PHP_EOL;
$i = 2;
foreach ($csv as $line) {
text_color_differs_background($line, $i);
$i++;
}

$sources = json_decode(file_get_contents("../sources.json"), true);
$opSources = array_map(fn($op) => $op["shortOperatorName"], $sources);
echo "Checking that operators are present in sources.json" . PHP_EOL;
Expand Down
12 changes: 10 additions & 2 deletions validation/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ function valid_shape($line, $i) {

function valid_hex_color($line, $i, $key) {
$color = $line[$key];

if (!(strlen($color) == 7 && ctype_xdigit(substr($color, 1)) && $color[0] === "#")) {
throw new Error("bad $key \"$color\" does not follow #<6 digit hex color> in row $i");
}
}
}

function text_color_differs_background($line, $i) {
$textColor = $line["textColor"];
$backgroundColor = $line["backgroundColor"];
if ($textColor === $backgroundColor) {
throw new Error("bad color combination: text color \"$textColor\" may not be background color \"$backgroundColor\" in row $i");
}
}
11 changes: 11 additions & 0 deletions validation/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ function test_throws(string $name, callable $test_case) {
valid_hex_color(["test_key" => "abcdefg"], 5, "test_key");
});

/**
* text_color_differs_background
*/
test_ok("text_color_differs_background for different colors", function() {
text_color_differs_background(["textColor" => "#ffffff", "backgroundColor" => "#000000"], 1);
});
test_throws("text_color_differs_background with the same data", function() {
$black = "#000000";
text_color_differs_background(["textColor" => $black, "backgroundColor" => $black], 2);
});

/**
* End of file
*/
Expand Down

0 comments on commit 98e3ec0

Please sign in to comment.