mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 17:26:22 +01:00
feat(track): all of the unevenness in one attribute, with values for each path of a switch
Usage, before endtrack, in mm, 0-100, separated by semicolons with no spaces: a plain track: uneven value;up;side;cross;dip a switch: uneven p1-p2;p3-p4;up p1-p2;side p1-p2;up p3-p4;side p3-p4 uneven 18 the value alone uneven 18;;;25;6 with its own cross level and dip at the joints uneven 0;;30 sideways alone uneven 14;35 a switch, 14 on the straight path, 35 on the diverging What's left out takes the first number, the dip goes by the up and down one, and a path p3-p4 with no numbers of its own takes those of p1-p2. This replaces unevenup, unevenside, unevencross and jointdip. The fields in the editor stay, track panel, section Ride and sound. At the end they share, the paths of a switch keep to the lower value, and each comes to its own value along the way. Joined switches take the lowest of the same path, a path joined to another path the lower of the two, and a plain track comes to the value of the path it meets. See track_uneven_doc.md.
This commit is contained in:
@@ -140,6 +140,43 @@ TEST_CASE("uneven track: the field stays within its bound")
|
||||
CHECK(highest > 0.5);
|
||||
}
|
||||
|
||||
TEST_CASE("uneven track: all the values in one attribute")
|
||||
{
|
||||
auto const one{track_uneven::read_fields<6>("18")};
|
||||
CHECK(one[0] == doctest::Approx(18.f));
|
||||
CHECK(one[1] < 0.f);
|
||||
auto const both{track_uneven::read_fields<6>("14;35")};
|
||||
CHECK(both[0] == doctest::Approx(14.f));
|
||||
CHECK(both[1] == doctest::Approx(35.f));
|
||||
CHECK(both[2] < 0.f);
|
||||
auto const gaps{track_uneven::read_fields<6>("18.5;;;25;6")};
|
||||
CHECK(gaps[0] == doctest::Approx(18.5f));
|
||||
CHECK(gaps[1] < 0.f);
|
||||
CHECK(gaps[2] < 0.f);
|
||||
CHECK(gaps[3] == doctest::Approx(25.f));
|
||||
CHECK(gaps[4] == doctest::Approx(6.f));
|
||||
auto const bounds{track_uneven::read_fields<6>("500;-3;x")};
|
||||
CHECK(bounds[0] == doctest::Approx(track_uneven::most));
|
||||
CHECK(bounds[1] == doctest::Approx(0.f));
|
||||
CHECK(bounds[2] < 0.f);
|
||||
CHECK(track_uneven::write_fields<6>({14.f, 35.f, -1.f, -1.f, -1.f, -1.f}) == "14;35");
|
||||
CHECK(track_uneven::write_fields<6>({18.5f, -1.f, -1.f, 25.f, 6.f, -1.f}) == "18.5;;;25;6");
|
||||
CHECK(track_uneven::write_fields<6>({0.f, -1.f, 30.f, -1.f, -1.f, -1.f}) == "0;;30");
|
||||
CHECK(track_uneven::write_fields<6>({18.f, -1.f, -1.f, -1.f, -1.f, -1.f}) == "18");
|
||||
}
|
||||
|
||||
TEST_CASE("uneven track: amounts take the lowest of each component")
|
||||
{
|
||||
auto const least{track_uneven::least({14.0, 9.0, 0.0}, {7.0, 35.0, 3.0})};
|
||||
CHECK(least.up == doctest::Approx(7.0));
|
||||
CHECK(least.side == doctest::Approx(9.0));
|
||||
CHECK(least.cross == doctest::Approx(0.0));
|
||||
// the diverging path of a switch: from the common end at the lowest to its own value at the far end
|
||||
double const length{30.0};
|
||||
CHECK(track_uneven::along(35.0, 7.0, 35.0, 0.0, length) == doctest::Approx(7.0));
|
||||
CHECK(track_uneven::along(35.0, 7.0, 35.0, length, length) == doctest::Approx(35.0));
|
||||
}
|
||||
|
||||
TEST_CASE("uneven track: the value along a track meets its neighbours exactly")
|
||||
{
|
||||
double const length{500.0};
|
||||
|
||||
Reference in New Issue
Block a user