mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 12:57:06 +01:00
c3b987abb2
* fix(editor): track edits keep the joints, the norms, the records and the saved speed together
- The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the
joints tool do it; the neighbours go into the same undo step. The joint stepped before.
- A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the
speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the
norms: 120 mm at 100 km/h over 120 m, not 80 m.
- Deleting a track of the line under the route tool keeps the laying norms. They went back to the
defaults, and every later lay, extend and join used those.
- The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no
longer changes its gauge.
- The speed of a turntable set in the editor is the one saved. The editor changed the speed the
turntable runs at, while the file keeps the limit it was loaded with.
- Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go
whole, the records of the switches go with them, and the model and events of a turntable too. The
records stayed behind and on saving were given to another switch, which then showed a wrong type.
- Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the
outer track of a crossover on a curve comes down by its lift and the record of the connection
goes. Alone, the switch left the outer track up for good, and the connection to the next switch
given its name. A switch bent out of the shape of its record is found by its name.
Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests
don't reach.
* test(editor): self-test scripts that fail, a runner, and a case for each fix of the track editing
The editor's self-test scripts only logged: nothing made a run fail. Now:
- `expect` commands check the state and log `SELFTEST PASS` or `SELFTEST FAIL ... got X, expected Y`:
the cant at a track end, the joint at an end (gap, angle, cant step), the records of a switch and
the connections naming it, speed, gauge, a track present or removed, the laying norms' gauge,
heights and lifts against a mark, whether a track is in the line under the route tool, and the
includes of a turntable. A command no group takes counts as a failure, so a mistyped one can't
make the checks after it pass.
- At `quit` the result is logged, and a script whose expectations failed ends the editor with exit
code 2 (a failed start stays 1; the simulator's test mode is unchanged).
- The commit of the inspector's cant field is `track_cant_commit`, which the inspector and the
`trackcant` command both call; `routegauge` sets the laying norms as the route tool does, and
`tracksetdelete` deletes a set of tracks by name.
- `tests/editor/run.py` runs each script of `tests/editor/cases` on a copy of the fixture scenery
in the game folder, with a wall-time limit and a memory cap, reads the exit code and the
`SELFTEST` lines, and deletes the copy. A `#> reopen` line restarts the editor on the saved
scenery. See `tests/editor/README.md`.
- One case per fix of the track editing quick fixes (inspector cant, norms after deleting, the
gauge paste group, turntable speed saved, deleting a set, a set with a double switch, a slip
and a crossover, deleting a switch of a crossover, a bent switch). All pass; with the fixes
reverted all fail.
* feat(editor): the track tool panels keep their fields, results and buttons within the panel
- The card of the tool: after a long gesture the action goes under it, at its indent, when what is
left of the row is narrower than 8 font sizes or the longest word of the action. It was squeezed
into a sliver and broken in the middle of its words.
- A click on the title row of the card folds it to that row (icon, name, family, key, and a small
triangle marker) and opens it again. One flag for all the tools, kept with the editor settings
(`track_card_folded` in eu07_editor.ini), open by default: the card took 250-300 px at the top
of every tool and repeats the hint bar of the view.
- The grade labels of the vertical profile, on the graph and in the view, write the per mille as
the panel does (the translated "per mille", the per mille sign in Polish), not "o/oo".
- The track analysis window: the thresholds of the speed check and of the joints keep to their
widest name and a field of 10 font sizes where the window is wider than that, as docked across
the bottom (`begin_fields_fitted`). The results are tables with each column as wide as what is in
it: the speed check with its column names kept at the top as the list scrolls, the joints with
the kind, the value and the two tracks next to each other. A click on a row shows it as before.
- `same_line_if_fits` puts the next button beside the one before only when it fits in what is left
of the line, at the start of the next line otherwise. Used where the route design puts buttons
side by side, for "Forget the design" in the profile panel, which was cut off at the edge, and for
the buttons of a switch in the inspector.
- The laying options: the speed, the curve radius and the longest path are fields with the name on
the left in two columns (`begin_fields`/`field_row`), as in the inspector, the route and the
profile, the chips of the quick values under them. The segmented choices give the short names
less of the room when a long one doesn't fit in its even share, and go on in a second bar when
they don't fit side by side: "Through the clicked points" overflowed its third of the bar.
* fix(editor): a switch laid gets the speed of its diverging track, one breaking a hard rule of ST-T1-A6 isn't laid
- Every switch laid writes the speed of its diverging track (`velocity`): the switch tool on a
straight, into a curve, from a free end and linked, a double switch, the switches of a slip, a
switch given another template of the catalogue, and a switch moved along the curve it's bent
into. A switch of the catalogue had no limit before, one copied from a switch of the scenery kept
that one's, one laid without a track had the laying speed on both its tracks. The limit is for the
diverging track alone (`velocity -V`); the own limit of the track it goes into stays for both
where it's the lower. The switch tool says the speed and what gives it.
- The speed is formula 9.9 of PKP PLK ST-T1-A6 the other way round, V = sqrt((I + D) r / 11.8), with
the normal cant deficiency of the frog of table 9.7 (110 mm a fixed frog, 130 mm a movable nose),
rounded down to the steps of the speed limits and no more than table 11.2 gives the basic switch.
For the fixed frogs the formula gives table 11.2 itself (190 40, 300 50, 500 60, 760 80, 1200
100 km/h); the 2500-1:26.5 with a movable nose stays 130. A switch bent into a curve takes the
radius of its diverging track from table 11.8 (one-sided r" = (Rr - t^2)/(R + r), two-sided
(Rr + t^2)/(R - r)) and the cant of the line with its sign: leaning against the diverging track it
takes speed away, where the speed check counted it as helping. Rz 60E1-190-1:9 bent out of the
curve R 600 m with 60 mm: 30 km/h, not 40; the 60E1-500-1:12 of the review, out of R 1200 m with
60 mm: 60 km/h at its fixed frog (54 at I = 100 mm, the 0.65 m/s2 the editor took), not 107.
- A switch breaking a hard rule isn't laid, the tracks left as they were, and the switch tool says
why, with the value, the limit and the paragraph: the cant changing within it (11.4 pkt 7), a cant
ramp ending within it or nearer than 6 m (9.6 pkt 16-17; one ending right at an end of the switch
is let be, as the snapping of the start offers it), a double switch, a slip or a crossing bent
(11.4 pkt 4), the curvature of its diverging or its main track turning from one side to the other
(9.7 pkt 12, KZW II). They were warnings shown after the switch was laid, and on a straight the
cant wasn't looked at at all. The line is looked at 10 m past the ends of the curve or the
straight too, so the ramp on the straight before a curve counts. The previews show the refusals.
- A switch moved along its straight or the curve it's bent into, a double switch moved along its
straight, and a switch given another template go through the same checks; one breaking a rule
stays as it is.
- Warnings still: 1:9.403 and steeper than 1:9 bent (11.4 pkt 4c-d), a rule of the running and the
main tracks, which the editor doesn't tell from the side ones, as the warning now says; the limits
of table 11.9 and a cant over 100 mm in a bent switch (table 9.6), as before.
Tests: unit tests of tables 11.8 and 11.9 (the least main radius bends the diverging track to the
least radius the table gives), table 9.7, the speeds of table 11.2 by formula 9.9, the speed of a
bent switch with the cant with its sign (the example of the review), the cant over a switch on a
straight and a double switch bent. Editor cases `q2_1_switch_speed`, `q2_2_switch_refusals` and
`q2_3_switch_move`, with `expect status` (the status of the switch tool) and `expect steps` (the
undo steps), the fixture with a straight taking a cant on and a compound curve without cant. All
pass; with the changes of the editor reverted all three fail.
* test(editor): golden round trips of the tracks and of the //$ lines, the cant at the joints
The safety net of the track editor before its domain model changes (E0 of
editor-tracks-tests.md): what the editor reads from the scenery files and
writes back is read, written and read again in tests/unit, with no game data.
Tracks (test_track_text.cpp, data/tracks/). Entries written the way the game
writes them, read by TTrack::Load() and written by export_as_text(), come out
byte for byte the same, and read again give the same track field by field:
plain tracks with all their attributes (events, speed, isolated, overhead,
vradius, rail profile, friction cell), a curve with cant, radius, uneven,
buckle, cwr and sleeper models, a bridge, switches with trackbed, frogs,
movable nose, blades, uneven of both paths and timbers, a turntable, paths of
pieces, the speeds +40, -40, 0.5, 0 and none of tracks, switches and
turntables, a river, a tributary, a road and a crossing. What the game writes
otherwise than given is checked as it is (table as turn, mountain as
mountains, the length of the path, a switch heard from 10 m, the events in
order, names in lower case, model paths with forward slashes, the texture
length, rolls as floats, no overhead and no vradius left out).
The seam: TTrack built from text with no scene. The engine stubs of the tests
had none of it, so the tests link the few sources reading and writing a track
takes (world/Track.cpp, Segment.cpp, TrackUneven.cpp, MemCell.cpp,
scene/scenenode.cpp, utilities/Timer.cpp, rendering/geometrybank.cpp) and
track_stubs.cpp stands in for the rest: a renderer keeping the materials by
their names, and the scene, events, vehicles and the geometry of the rails,
which reading and writing never reach and which stop the test with their name
if one does. It tests the game's own Load() and export, where a parser of its
own would have meant rewriting Load(), and changes no code of the game. The
stub of basic_node::radius_() goes, scenenode.cpp brings the real one. The
rails don't buckle in the tests (TrackBuckle.cpp needs the environment), the
buckle declared is read and written either way; material names go through a
stand-in, the game's material manager isn't tested here.
The //$ lines (test_editor_records.cpp, data/records/). Their readers and
writers were members of editor_mode, srk_tool and the stores, with the scene
around them; they move as they were into editor/editorRecords.cpp, the one
place each kind is read and written, which the stores call (and which the
migration to the project file of E3 will need apart anyway). The methods of
scene::layer_context move into scene/scenelayercontext.cpp so it links alone.
Each kind, h r k p t w b s c o z, read from golden lines and written back comes
out the same, in the coordinates of the file and of a file placed at an
origin; //$e, the descriptions of the templates, read and saved by
editor_includes in a template in a scratch folder, leaves the file as it was.
Cant (test_cant.cpp). The paths an alignment lays roll by asin(cant/gauge),
signed with the turn, back to the cant of the line at every end; a curve the
other way rolls the other way. At a joint editor_track::match_rolls() gives
the joined track the roll for the travel across it, turned where the paths
face or stand back to back, and the track written keeps it. The inspector's
own conversion on 1500 mm stays in its lambdas here; named, as
editor_mode::cant_of_roll()/roll_of_cant(), it comes with the quick fixes.
Known bugs found, tests of the change each (doctest::should_fail, passing
until fixed, then reported to drop the decorator), data/tracks/known_lost.scn:
- angle1/angle2 are read and dropped: not written back.
- fouling1/fouling2 are read and dropped: not written back.
- name@circuit: the circuit is taken out of the name with the letter before
the @ ("tor1@iso1" becomes track "tor"; substr(0, i - 1)).
- the attributes of the entry (gauge, friction, texture sizes, speed...) are
written to 6 significant digits, a float has 9: more digits are lost on the
first save.
None in the //$ lines.
Unit tests: 957 cases before, 974 after, all passing.
* test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent
- A blank line or an indented `#` comment in a script is no longer a command no group takes.
- `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation.
- `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it.
- The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
* test(editor): the entries known to be lost are checked apart from should_fail, the cant test says where the inspector conversion is tested
- A normal test checks that known_lost.scn and each of its entries are there and read, so the should_fail tests can't pass for
data gone missing.
- The comment of test_cant.cpp said the tests of cant_of_roll()/roll_of_cant() are here; they are the self-test case
1_inspector_cant.txt, as the unit tests don't link the editor.
229 lines
11 KiB
C++
229 lines
11 KiB
C++
// the tracks of the scenery files read and written back by the game's own TTrack::Load() and export_as_text(), the safety net of the
|
|
// track editor, which writes the tracks it changes this way: the entries in data/tracks/ are written the way the game writes them,
|
|
// so each read and written back comes out the same, and what a second reading gives is what the first gave. what doesn't survive yet
|
|
// is in data/tracks/known_lost.scn, the tests of it fail until it does (doctest::should_fail)
|
|
//
|
|
// the tracks are read with no scene: the parts of the engine a track reaches for are stand-ins (track_stubs.cpp). the materials are
|
|
// kept by the names given, where the game's material manager names them after the files it finds; the rails don't buckle by the heat,
|
|
// world/TrackBuckle.cpp isn't a part of the tests, the buckle declared is read and written either way
|
|
|
|
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "track_text.h"
|
|
#include "rendering/renderer.h"
|
|
|
|
#include <cmath>
|
|
#include <fstream>
|
|
#include <memory>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace {
|
|
|
|
using test::read_track;
|
|
using test::track_reading;
|
|
using test::written;
|
|
|
|
std::string material_name(material_handle const Material) {
|
|
return Material != null_handle ? GfxRenderer->Material(Material)->GetName() : std::string{"-"};
|
|
}
|
|
|
|
void add_path(std::ostringstream &Text, segment_data const &Path) {
|
|
for (auto const &point : Path.points) {
|
|
Text << ' ' << point.x << ' ' << point.y << ' ' << point.z;
|
|
}
|
|
Text << " rolls " << Path.rolls[0] << ' ' << Path.rolls[1] << " radius " << Path.radius;
|
|
}
|
|
|
|
// what the track got of its entry, field by field, one to a line
|
|
std::string fields(TTrack &Track) {
|
|
std::ostringstream text;
|
|
text.precision(17);
|
|
text << "name " << Track.name() << '\n'
|
|
<< "type " << Track.eType << " category " << Track.iCategoryFlag << " tributary " << Track.m_tributary << '\n'
|
|
<< "width " << Track.fTrackWidth << " friction " << Track.fFriction << " sound " << Track.fSoundDistance << '\n'
|
|
<< "quality " << Track.iQualityFlag << " damage " << Track.iDamageFlag << " environment " << Track.eEnvironment << '\n'
|
|
<< "visible " << Track.visible() << '\n'
|
|
<< "materials " << material_name(Track.m_material1) << ' ' << material_name(Track.m_material2) << '\n'
|
|
<< "texture " << Track.fTexLength << ' ' << Track.fTexHeight1 - Track.fTexHeightOffset << ' ' << Track.fTexWidth << ' ' << Track.fTexSlope << '\n';
|
|
for (auto const &path : Track.m_paths) {
|
|
text << "path";
|
|
add_path(text, path);
|
|
text << '\n';
|
|
for (auto const &piece : path.pieces) {
|
|
text << " piece";
|
|
add_path(text, piece);
|
|
text << '\n';
|
|
}
|
|
}
|
|
for (auto const *events : {&Track.m_events0, &Track.m_events0all, &Track.m_events1, &Track.m_events1all, &Track.m_events2, &Track.m_events2all}) {
|
|
text << "events";
|
|
for (auto const &event : *events) {
|
|
text << ' ' << event.first;
|
|
}
|
|
text << '\n';
|
|
}
|
|
text << "velocity " << Track.VelocityGet() << '\n';
|
|
if (Track.SwitchExtension) {
|
|
auto const &extension{*Track.SwitchExtension};
|
|
text << "switch velocity " << extension.fVelocity << " trackbed " << material_name(extension.m_material3) << " frogs " << extension.m_frogs << " movable nose " << extension.m_movablenose
|
|
<< " blades " << extension.m_bladeheel << ' ' << extension.m_bladethrow << '\n';
|
|
}
|
|
text << "isolated";
|
|
for (auto const *isolated : Track.Isolated) {
|
|
text << ' ' << isolated->asName;
|
|
}
|
|
text << '\n'
|
|
<< "overhead " << Track.fOverhead << " vertical radius " << Track.fVerticalRadius << '\n'
|
|
<< "rail profile " << Track.m_profile1.first << '\n'
|
|
<< track_uneven::write_attribute(Track.m_uneven, Track.eType == tt_Switch) << '\n'
|
|
<< track_buckle::write_buckle(Track.m_buckledeclared) << track_buckle::write_cwr(Track.m_cwr) << '\n'
|
|
<< "friction cell " << Track.m_friction.first << '\n'
|
|
<< "sleepers " << Track.m_sleeper_enabled << ' ' << Track.m_sleeper_frequency << ' ' << Track.m_sleeper_model_name << ' ' << Track.m_sleeper_skin_name << ' ' << Track.m_sleeper_offset.x << ' '
|
|
<< Track.m_sleeper_offset.y << ' ' << Track.m_sleeper_offset.z << ' ' << Track.m_sleeper_ballast_z << '\n'
|
|
<< "timbers " << Track.m_timber_model_name << ' ' << Track.m_timber_skin_name << '\n';
|
|
return text.str();
|
|
}
|
|
|
|
// the entries of the file of data/tracks/, a line each; lines starting with // are comments
|
|
std::vector<std::string> entries(std::string const &File) {
|
|
std::ifstream file{std::string{EU07_UNIT_TESTS_DATA} + "/tracks/" + File, std::ios::binary};
|
|
REQUIRE(file.is_open());
|
|
std::vector<std::string> result;
|
|
for (std::string line; std::getline(file, line);) {
|
|
if (false == line.empty() && line.back() == '\r') {
|
|
line.pop_back();
|
|
}
|
|
if (line.empty() || line.starts_with("//")) {
|
|
continue;
|
|
}
|
|
result.push_back(line + '\n');
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// the entry of the track of the name in the file
|
|
std::string entry(std::string const &File, std::string const &Name) {
|
|
for (auto const &text : entries(File)) {
|
|
std::istringstream words{text};
|
|
std::string node, rangemax, rangemin, name;
|
|
words >> node >> rangemax >> rangemin >> name;
|
|
if (name == Name) {
|
|
return text;
|
|
}
|
|
}
|
|
FAIL("no track " << Name << " in " << File);
|
|
return {};
|
|
}
|
|
|
|
// read, written, read again and written again
|
|
struct round_trip {
|
|
explicit round_trip(std::string const &Text) : first{read_track(Text)}, text{written(*first)}, second{read_track(text)}, again{written(*second)} {}
|
|
std::unique_ptr<TTrack> first;
|
|
std::string text;
|
|
std::unique_ptr<TTrack> second;
|
|
std::string again;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("track text: each entry of data/tracks/ read and written back comes out the same, and read again gives the same track") {
|
|
track_reading const reading;
|
|
for (auto const *file : {"plain.scn", "switch.scn", "turntable.scn", "pieces.scn", "speeds.scn", "other.scn"}) {
|
|
for (auto const &text : entries(file)) {
|
|
CAPTURE(file);
|
|
CAPTURE(text);
|
|
round_trip const trip{text};
|
|
CHECK(trip.text == text);
|
|
CHECK(fields(*trip.second) == fields(*trip.first));
|
|
CHECK(trip.again == trip.text);
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_CASE("track text: what the game writes otherwise than it was given, the same from the first save on") {
|
|
track_reading const reading;
|
|
struct normalized {
|
|
char const *what;
|
|
std::string given;
|
|
std::string written;
|
|
};
|
|
std::string const plain{"node -1 0 n track normal 10 1.435 0.15 25 20 0 flat unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 "};
|
|
std::string const turntable{"1.435 0.15 25 20 0 flat unvis -10 0 0 0 0 0 0 0 0 0 10 0 0 0 0 endtrack\n"};
|
|
std::string const switchpaths{"0 0 0 0 0 0 0 0 0 0 0 0 33.23 0 0 0 0 0 0 0 0 11 0.6 0 -11 1.8 0 33.1 0 300 endtrack\n"};
|
|
std::vector<normalized> const cases{
|
|
{"a turntable entered as table is written as turn", "node -1 0 t track table 20 " + turntable, "node -1 0 t track turn 20 " + turntable},
|
|
{"mountain is written as mountains", "node -1 0 m track normal 10 1.435 0.15 25 20 0 mountain unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n",
|
|
"node -1 0 m track normal 10 1.435 0.15 25 20 0 mountains unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n"},
|
|
{"an environment the game doesn't know is written as none", "node -1 0 e track normal 10 1.435 0.15 25 20 0 desert unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n",
|
|
"node -1 0 e track normal 10 1.435 0.15 25 20 0 none unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n"},
|
|
{"the length is the one of the path, whatever the entry says", "node -1 0 n track normal 12 1.435 0.15 25 20 0 flat unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n", plain + "endtrack\n"},
|
|
{"a switch is heard from 10 m, whatever the entry says", "node -1 0 s track switch 33.23 1.435 0.25 25 20 0 flat unvis " + switchpaths,
|
|
"node -1 0 s track switch 33.23 1.435 0.25 10 20 0 flat unvis " + switchpaths},
|
|
{"the events go in the order of their kinds", plain + "event2 b eventall1 c event0 a endtrack\n", plain + "event0 a eventall1 c event2 b endtrack\n"},
|
|
{"the names are read in lower case, the paths of the models as they are, with forward slashes",
|
|
"node -1 0 N track normal 10 1.435 0.15 25 20 0 flat unvis 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 event0 Sem_A isolated Iso_B sleepermodel 0.6 Models\\Tory\\Podklad.e3d Skin 0 0 0 0 endtrack\n",
|
|
plain + "event0 sem_a isolated iso_b sleepermodel 0.6 Models/Tory/Podklad.e3d Skin 0 0 0 0 endtrack\n"},
|
|
{"a texture repeated at less than 1 cm is repeated at 4 m", "node -1 0 n track normal 10 1.435 0.15 25 20 0 flat vis rail 0 ballast 0.2 0.5 1.1 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n",
|
|
"node -1 0 n track normal 10 1.435 0.15 25 20 0 flat vis rail 4 ballast 0.2 0.5 1.1 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 endtrack\n"},
|
|
{"the rolls are written as the floats they're read into", "node -1 0 n track normal 10 1.435 0.15 25 20 0 flat unvis 0 0 0 3.4377 0 0 0 0 0 0 0 0 10 -3.4377 0 endtrack\n",
|
|
"node -1 0 n track normal 10 1.435 0.15 25 20 0 flat unvis 0 0 0 3.43770003318787 0 0 0 0 0 0 0 0 10 -3.43770003318787 0 endtrack\n"},
|
|
{"no overhead line (-1) and no vertical radius (0) aren't written", plain + "overhead -1 vradius 0 endtrack\n", plain + "endtrack\n"},
|
|
};
|
|
for (auto const &[what, given, expected] : cases) {
|
|
CAPTURE(what);
|
|
round_trip const trip{given};
|
|
CHECK(trip.text == expected);
|
|
CHECK(trip.again == trip.text);
|
|
}
|
|
}
|
|
|
|
// what doesn't survive yet: each fails until it does, then doctest reports the test passing against should_fail, and the entry goes
|
|
// over to the files of the entries which come out the same
|
|
|
|
// what those tests start from, checked apart from them: under should_fail a missing file or entry would pass for a loss
|
|
TEST_CASE("track text: the entries known to be lost are there, with what they're about, and read") {
|
|
track_reading const reading;
|
|
struct known {
|
|
char const *name;
|
|
char const *about;
|
|
};
|
|
for (auto const &[name, about] : {known{"angles", " angle1 15 "}, known{"fouling", " fouling1 ukres_a "}, known{"tor1@iso1", "tor1@iso1"}, known{"digits", " digits "}}) {
|
|
CAPTURE(name);
|
|
auto const text{entry("known_lost.scn", name)};
|
|
REQUIRE(false == text.empty());
|
|
CHECK(text.find(about) != std::string::npos);
|
|
CHECK(read_track(text) != nullptr);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("track text: the angles the ends are cut at are written back (known lost: read and dropped)" * doctest::should_fail()) {
|
|
track_reading const reading;
|
|
round_trip const trip{entry("known_lost.scn", "angles")};
|
|
CHECK(trip.text.find(" angle1 15 ") != std::string::npos);
|
|
CHECK(trip.text.find(" angle2 -15 ") != std::string::npos);
|
|
}
|
|
|
|
TEST_CASE("track text: the fouling points are written back (known lost: read and dropped)" * doctest::should_fail()) {
|
|
track_reading const reading;
|
|
round_trip const trip{entry("known_lost.scn", "fouling")};
|
|
CHECK(trip.text.find(" fouling1 ukres_a ") != std::string::npos);
|
|
CHECK(trip.text.find(" fouling2 ukres_b ") != std::string::npos);
|
|
}
|
|
|
|
TEST_CASE("track text: a name with the isolated circuit after @ keeps its letters (known lost: the one before the @)" * doctest::should_fail()) {
|
|
track_reading const reading;
|
|
round_trip const trip{entry("known_lost.scn", "tor1@iso1")};
|
|
// the circuit is taken out of the name and written as an attribute, which reads the same
|
|
REQUIRE(trip.first->Isolated.size() == 1);
|
|
CHECK(trip.first->Isolated.front()->asName == "iso1");
|
|
CHECK(trip.first->name() == "tor1");
|
|
}
|
|
|
|
TEST_CASE("track text: the attributes keep every digit of the floats they're read into (known lost: written to 6 digits)" * doctest::should_fail()) {
|
|
track_reading const reading;
|
|
round_trip const trip{entry("known_lost.scn", "digits")};
|
|
CHECK(fields(*trip.second) == fields(*trip.first));
|
|
}
|