mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +01:00
fix(utilities): Bezogonkow() takes the marks off the same letters in every build
The table of Bezogonkow() had the plus-minus sign of 0xB1 written as the character, in a source kept in utf-8. GCC and Clang (and MSVC with /utf-8) made two bytes of it, so every entry from 0xB2 on was off by one: the polish letters came out as "ALELDNSZZ,le,dnszl", and with them the file names of the destination boards and the names of the stations the python screens get. The entry is the byte now. Nothing changes for a build which made one byte of the sign (MSVC on a machine with a central or western european code page). The test checks the one table in place of whichever the build had.
This commit is contained in:
@@ -139,7 +139,6 @@ The tests are written for the first two columns, and for what the game doesn't c
|
||||
- **`utilities.cpp`:**
|
||||
- `Now()`, `user_config_path()`, `user_cache_path()` and `true_random_seed()` depend on the clock, the environment and the entropy source of the system. The tests call them and check the shape of the result. The branches for a system without the variables or without an entropy source aren't run, and those of the other systems aren't compiled.
|
||||
- `FileCased()` looks through the working folder for a name given without a folder, and through the folder of the file elsewhere; on Windows it only asks whether the file is there. The search is run on Linux only.
|
||||
- `Bezogonkow()` gives other letters with MSVC than with GCC and Clang, see the findings. The test takes either, told by the entry of the table the difference starts at, so each build checks the half it is.
|
||||
- **`ladderlogic.cpp`:** the two `return`s marked "not reachable" after the switches over the kind of an element.
|
||||
|
||||
**Code nothing in the game runs** (checked against the whole source tree):
|
||||
@@ -201,7 +200,7 @@ The tests record the behaviour as it is. The following points may deserve a look
|
||||
- `deserialize_map()` (`utilities.h`, the sound overrides) therefore reads an empty key from an empty file, and one from a file ending with a line break; in a file with Windows line ends its values keep the carriage return. The game's `sound_overrides.txt` is a single line without a line break.
|
||||
- The separators given as a null pointer are taken as none by the tokenizer, but passed on to `strcmp` for a token of 7 characters or more starting with `i`, which crashes (tried by hand, not kept as a test). No caller gives a null pointer.
|
||||
- **The helpers (`utilities.cpp`, `utilities.h`):**
|
||||
- `Bezogonkow()`, which takes the marks off the letters for the timetable and the on-screen texts: its table has a `±` in the source, a UTF-8 file. MSVC makes one byte of it, GCC and Clang two, which moves every entry from 0xB2 on by one. With MSVC the 18 polish letters come out as `ACELNOSZZacelnoszz`; with GCC as `ALELDNSZZ,le,dnszl`: `Ć` as L, `Ń` as D, `Ó` as N, `ą` and `ł` as a comma, `ć` as l, `ń` as d, `ó` as n, `ż` as l, only `Ę` and `ę` by luck as themselves. The Linux and macOS builds of the game show the names of the stations that way. The test checks whichever table the build has (the GCC one was tried with the table alone, compiled by GCC 6.3).
|
||||
- `Bezogonkow()`, which takes the marks off the letters for the file names, the scripts and the multiplayer texts: its table had a `±` written as the character in the source, a UTF-8 file. MSVC made one byte of it, GCC and Clang two, which moved every entry from 0xB2 on by one: with GCC the 18 polish letters came out as `ALELDNSZZ,le,dnszl`. Fixed with MaSzyna-EU07/maszyna#94: the entry is written as the byte `±`, and the test checks the one table in every build.
|
||||
- `to_minutes_str()` reads past its table of raised digits for minutes with a fraction of 0.99 or more, and before it for negative minutes, which `CompareTime()` can give it for a timetable whose times go back. Tried by hand, both ended in `std::bad_alloc`, the text read from outside of the table being no text; not kept as a test. A width under 2 throws `std::length_error`.
|
||||
- `stol_def()` gives its default only for an empty text. A text which isn't a number gives 0 (the flags of an event, the log setting).
|
||||
- `split_string_and_number()` throws for a name with a hyphen which no digit follows (`a-b`), and for a number too big. The gamepad bindings and the PLC use it on names from files.
|
||||
|
||||
@@ -364,18 +364,18 @@ TEST_CASE("utilities: a text for the timetable loses its marks, control characte
|
||||
CHECK(Bezogonkow("Bia\xA3" "a_Podlaska", true) == "BiaLa Podlaska");
|
||||
}
|
||||
|
||||
TEST_CASE("utilities: the polish letters from 0xB2 on lose their marks only in a build which makes one byte of the table's mark") {
|
||||
// the table of Bezogonkow() has a plus-minus sign for 0xB1, written as the character in the source, a utf-8 file.
|
||||
// MSVC puts it into the table as the one byte of the system's code page, and the table is as it was meant.
|
||||
// GCC and Clang put the two bytes of utf-8 there, which moves the entries after it by one (see COVERAGE.md)
|
||||
if (Bezogonkow("\xB1") == "\xB1") {
|
||||
CHECK(Bezogonkow(kWin1250) == "ACELNOSZZacelnoszz");
|
||||
}
|
||||
else {
|
||||
// the first byte of the sign for 0xB1, the second for 0xB2, and each letter after them as the entry before its own
|
||||
CHECK(Bezogonkow("\xB1\xB2") == "\xC2\xB1");
|
||||
CHECK(Bezogonkow(kWin1250) == "ALELDNSZZ,le,dnszl");
|
||||
}
|
||||
TEST_CASE("utilities: the polish letters from 0xB2 on lose their marks in every build") {
|
||||
// the table of Bezogonkow() has the plus-minus sign for 0xB1. it used to be written as the character in the source,
|
||||
// a utf-8 file: GCC and Clang put the two bytes of utf-8 into the table, which moved the entries after it by one
|
||||
// (the polish letters came out as "ALELDNSZZ,le,dnszl"). now it's the byte, and the table is the same everywhere
|
||||
CHECK(Bezogonkow("\xB1") == "\xB1");
|
||||
CHECK(Bezogonkow("\xB1\xB2") == "\xB1,");
|
||||
CHECK(Bezogonkow(kWin1250) == "ACELNOSZZacelnoszz");
|
||||
// the last entry of the table, and the first: none is left out and none added
|
||||
CHECK(Bezogonkow("\xFF") == "?");
|
||||
CHECK(Bezogonkow("\x80") == "E");
|
||||
// the letters of other languages the table knows (c-caron, e-caron, s-caron, u-ring, a-acute)
|
||||
CHECK(Bezogonkow("\xE8\xEC\x9A\xF9\xE1") == "cesua");
|
||||
}
|
||||
|
||||
TEST_CASE("utilities: utf-8 is decoded into code points of one to four bytes") {
|
||||
|
||||
@@ -458,8 +458,11 @@ void win1250_to_utf32(std::string const &Text, std::u32string &Output)
|
||||
}
|
||||
|
||||
// Ra: tymczasowe rozwiązanie kwestii zagranicznych (czeskich) napisów
|
||||
// NOTE: the entry of 0xB1 (the plus-minus sign of windows-1250, left as it is) is written as its byte. written as the
|
||||
// character it took two bytes in the builds which keep the texts of the sources in utf-8 (GCC, Clang, MSVC with /utf-8),
|
||||
// and every entry after it was off by one
|
||||
char const charsetconversiontable[] = "E?,?\"_++?%S<STZZ?`'\"\".--??s>stzz"
|
||||
" ^^L$A|S^CS<--RZo±,l'uP.,as>L\"lz"
|
||||
" ^^L$A|S^CS<--RZo\xB1,l'uP.,as>L\"lz"
|
||||
"RAAAALCCCEEEEIIDDNNOOOOxRUUUUYTB"
|
||||
"raaaalccceeeeiiddnnoooo-ruuuuyt?";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user