Segmentation: Split-Splice algorithm implementation complete

...and verified including corner cases...
This commit is contained in:
Fischlurch 2023-05-04 15:59:17 +02:00
parent 3f2f3db568
commit 52dad70753
4 changed files with 110 additions and 42 deletions

View file

@ -70,9 +70,10 @@
** values until matching the end of the preceding segment
** - if both values are omitted, the new segment will replace the last segment of the given axis.
** The new segment may span an arbitrary range within the domain and may thus possibly supersede
** several existing segments, which are then removed by the `DELETE` operation.
** several existing segments, which are then removed by the `DELETE` operation.
**
** @todo 2023 WIP
** @see SplitSplice_test
** @see steam::fixture::Segmentation::splitSplice
*/
@ -335,9 +336,6 @@ namespace lib {
}
};
}//(End) namespace splitsplace
}//namespace splitsplace
} // namespace lib
#endif /*LIB_SPLIT_SPLICE_H*/

View file

@ -585,7 +585,7 @@ return: 0
END
PLANNED "Split/Splice segmentation" SplitSplice_test <<END
TEST "Split/Splice segmentation" SplitSplice_test <<END
return: 0
END

View file

@ -225,7 +225,7 @@ namespace test {
* Perform the »SplitSplice« Algorithm to splice a new Segment
* into the given [segmentation of the integer-axis](\ref SegL).
* A local λ-binding is setup to define the basic operations
* required by the Algo implementation to work with this
* required by the algorithm implementation to work with this
* specific kind of data.
* @return Tuple `(s,n,e)` to indicate where changes happened
* - s the first changed element
@ -388,9 +388,10 @@ namespace test {
CHECK (segmentation == expectedResult);
CHECK (segmentation.isValid());
};
////////
testCase (SegL{}, -23,24, "├[-100~-23[[-23_24[[24~100[┤"_expect); // simple segment into empty axis
// insert smaller segment
testCase (SegL{5,10}, 2,3, "├[-100~2[[2_3[[3~5[[5_10[[10~100[┤"_expect); // smaller segment left spaced off
testCase (SegL{5,10}, 4,5, "├[-100~4[[4_5[[5_10[[10~100[┤"_expect); // left adjacent
testCase (SegL{5,10}, 4,8, "├[-100~4[[4_8[[8_10[[10~100[┤"_expect); // left overlapping
@ -401,12 +402,15 @@ namespace test {
testCase (SegL{5,10}, 10,13, "├[-100~5[[5_10[[10_13[[13~100[┤"_expect); // right adjacent
testCase (SegL{5,10}, 13,23, "├[-100~5[[5_10[[10~13[[13_23[[23~100[┤"_expect); // right spaced off
// insert identical segment
testCase (SegL{5,10}, 5,10, "├[-100~5[[5_10[[10~100[┤"_expect); // identical size replacement
// insert larger segment
testCase (SegL{5,10}, 3,10, "├[-100~3[[3_10[[10~100[┤"_expect); // larger segment right aligned
testCase (SegL{5,10}, 3,23, "├[-100~3[[3_23[[23~100[┤"_expect); // larger segment overarching
testCase (SegL{5,10}, 5,23, "├[-100~5[[5_23[[23~100[┤"_expect); // larger segment left aligned
}
} //////
/**
@ -415,8 +419,50 @@ namespace test {
void
verify_cornerCases()
{
UNIMPLEMENTED ("corner cases");
}
auto testCase = [](SegL segmentation
,OptInt startNew // Note: these are optional...
,OptInt afterNew
,ExpectString expectedResult)
{
invokeSplitSplice (segmentation, startNew, afterNew);
CHECK (segmentation == expectedResult);
CHECK (segmentation.isValid());
};
auto x = std::nullopt;
//////
testCase (SegL{}, 3,2, "├[-100~2[[2_3[[3~100[┤"_expect); // flipped interval spec is reoriented
//////
testCase (SegL{}, 3,x, "├[-100~3[[3_100[┤"_expect); // expanded until domain end
testCase (SegL{}, x,5, "├[-100_5[[5~100[┤"_expect); // expanded to start of domain
/////
testCase (SegL{4,6}, 5,x, "├[-100~4[[4_5[[5_6[[6~100[┤"_expect); // expanded until end of enclosing segment
testCase (SegL{4,6}, x,5, "├[-100~4[[4_5[[5_6[[6~100[┤"_expect); // expanded to start of enclosing segment
/////
testCase (SegL{4,6}, 3,x, "├[-100~3[[3_4[[4_6[[6~100[┤"_expect); // expanded to fill gap to next segment
testCase (SegL{4,6}, x,3, "├[-100_3[[3~4[[4_6[[6~100[┤"_expect); // expanded to cover predecessor completely
testCase (SegL{4,6}, 4,x, "├[-100~4[[4_6[[6~100[┤"_expect); // expanded to cover (replace) successor
testCase (SegL{4,6}, x,4, "├[-100_4[[4_6[[6~100[┤"_expect); // expanded to cover (replace) predecessor
/////
testCase (SegL{4,6}, 7,x, "├[-100~4[[4_6[[6~7[[7_100[┤"_expect); // shorten successor and expand new segment to end of successor (=domain end)
testCase (SegL{4,6}, x,7, "├[-100~4[[4_6[[6_7[[7~100[┤"_expect); // fill gap between predecessor and given new segment end
testCase (SegL{4,6}, 6,x, "├[-100~4[[4_6[[6_100[┤"_expect); // expand to cover (replace) the following segment until domain end
testCase (SegL{4,6}, x,6, "├[-100~4[[4_6[[6~100[┤"_expect); // expanded to cover (replace) the preceding segment
/////
testCase (SegL{}, x,x, "├[-100_100[┤"_expect); // without any specification, the whole domain is covered
testCase (SegL{4}, x,x, "├[-100~4[[4_100[┤"_expect); // otherwise, without any spec the last segment is replaced
testCase (SegL{4,6}, x,x, "├[-100~4[[4_6[[6_100[┤"_expect);
/////
testCase (SegL{4,5,6,8}, 3,6, "├[-100~3[[3_6[[6_8[[8~100[┤"_expect); // spanning and thus replacing multiple segments
testCase (SegL{4,5,6,8}, 4,6, "├[-100~4[[4_6[[6_8[[8~100[┤"_expect);
testCase (SegL{4,5,6,8}, 4,7, "├[-100~4[[4_7[[7_8[[8~100[┤"_expect);
testCase (SegL{4,5,6,8}, 3,7, "├[-100~3[[3_7[[7_8[[8~100[┤"_expect);
testCase (SegL{4,5,6,8}, 3,8, "├[-100~3[[3_8[[8~100[┤"_expect);
testCase (SegL{4,5,6,8}, 4,8, "├[-100~4[[4_8[[8~100[┤"_expect);
testCase (SegL{4,5,6,8}, 4,9, "├[-100~4[[4_9[[9~100[┤"_expect);
testCase (SegL{4,5,6,8}, 5,9, "├[-100~4[[4_5[[5_9[[9~100[┤"_expect);
testCase (SegL{4,5,6,8}, 5,x, "├[-100~4[[4_5[[5_6[[6_8[[8~100[┤"_expect);
testCase (SegL{4,5,7,8}, x,6, "├[-100~4[[4_5[[5_6[[6_7[[7_8[[8~100[┤"_expect);
} /////
};
LAUNCHER (SplitSplice_test, "unit common");

View file

@ -70278,9 +70278,9 @@
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683046958233" ID="ID_226373762" MODIFIED="1683047000567" TEXT="isoliert testbar machen">
<arrowlink COLOR="#e31dc4" DESTINATION="ID_1714211009" ENDARROW="Default" ENDINCLINATION="-141;9;" ID="Arrow_ID_816334190" STARTARROW="None" STARTINCLINATION="-192;20;"/>
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683046958233" ID="ID_226373762" MODIFIED="1683208595655" TEXT="isoliert testbar machen">
<arrowlink COLOR="#2ec3d8" DESTINATION="ID_1714211009" ENDARROW="Default" ENDINCLINATION="-141;9;" ID="Arrow_ID_816334190" STARTARROW="None" STARTINCLINATION="-192;20;"/>
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1683158281268" ID="ID_1471352554" MODIFIED="1683158303513" TEXT="Verdrahtung f&#xfc;r Dummy-Integer-Segmente">
<icon BUILTIN="button_ok"/>
</node>
@ -70309,15 +70309,15 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1682993091685" ID="ID_988617455" MODIFIED="1682993099148" TEXT="systematische Testabdeckung">
<icon BUILTIN="hourglass"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1682993091685" ID="ID_988617455" MODIFIED="1683208612560" TEXT="systematische Testabdeckung">
<icon BUILTIN="pencil"/>
<node CREATED="1682993100755" ID="ID_1651031348" MODIFIED="1682993128370" TEXT="es sind 12 Basis-F&#xe4;lle">
<icon BUILTIN="info"/>
</node>
<node CREATED="1682993108314" ID="ID_317827435" MODIFIED="1682993122827" TEXT="hinzu kommt die Variante, da&#xdf; leere Intervalle zusammengef&#xfc;hrt werden"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1683046966788" ID="ID_1714211009" MODIFIED="1683120265331" TEXT="splitSplice-Algo isoliert testen">
<linktarget COLOR="#e31dc4" DESTINATION="ID_1714211009" ENDARROW="Default" ENDINCLINATION="-141;9;" ID="Arrow_ID_816334190" SOURCE="ID_226373762" STARTARROW="None" STARTINCLINATION="-192;20;"/>
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1683046966788" ID="ID_1714211009" MODIFIED="1683208598606" TEXT="splitSplice-Algo isoliert testen">
<linktarget COLOR="#2ec3d8" DESTINATION="ID_1714211009" ENDARROW="Default" ENDINCLINATION="-141;9;" ID="Arrow_ID_816334190" SOURCE="ID_226373762" STARTARROW="None" STARTINCLINATION="-192;20;"/>
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1683120139366" ID="ID_255513798" MODIFIED="1683120148509" TEXT="Test-Setup mit einfachen int-Intevallen">
<icon BUILTIN="button_ok"/>
</node>
@ -70346,11 +70346,14 @@
<icon BUILTIN="ksmiletris"/>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1683158382175" ID="ID_1213737514" MODIFIED="1683199886418" TEXT="Setup f&#xfc;r Einzelfall-Tests">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1683158382175" ID="ID_1213737514" MODIFIED="1683208577001" TEXT="Setup f&#xfc;r Einzelfall-Tests">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1683199848866" ID="ID_890601228" MODIFIED="1683199875667" TEXT="voll definierte Bouds">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683208568957" ID="ID_1505138970" MODIFIED="1683208575478" TEXT="partiell definierte Bounds">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node COLOR="#338800" CREATED="1683047015402" ID="ID_1729864005" MODIFIED="1683203798608" TEXT="M&#xf6;gliche Intervall-Anordnungen">
<icon BUILTIN="button_ok"/>
@ -70453,34 +70456,55 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047063010" ID="ID_1521759912" MODIFIED="1683047144754" TEXT="degenerierte F&#xe4;lle">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047111300" ID="ID_592313563" MODIFIED="1683047141649" TEXT="Ende vor Start &#x27f9; flip">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047063010" ID="ID_1521759912" MODIFIED="1683208562370" TEXT="degenerierte F&#xe4;lle">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1683047111300" ID="ID_592313563" MODIFIED="1683204557100" TEXT="Ende vor Start &#x27f9; flip">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047568998" ID="ID_717909997" MODIFIED="1683047593595" TEXT="nur Start in leer">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047568998" ID="ID_717909997" MODIFIED="1683204814732" TEXT="nur Start in leer">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047600842" ID="ID_1296939767" MODIFIED="1683047604778" TEXT="nur Ende in leer">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047600842" ID="ID_1296939767" MODIFIED="1683204815920" TEXT="nur Ende in leer">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047624559" ID="ID_1509703991" MODIFIED="1683047708973" TEXT="nur Start in Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047624559" ID="ID_1509703991" MODIFIED="1683205236476" TEXT="nur Start in Seg">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047654979" ID="ID_1521058039" MODIFIED="1683047708973" TEXT="nur Ende in Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047654979" ID="ID_1521058039" MODIFIED="1683205236475" TEXT="nur Ende in Seg">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047688030" ID="ID_1363163343" MODIFIED="1683047708974" TEXT="nur Start vor Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047688030" ID="ID_1363163343" MODIFIED="1683205615492" TEXT="nur Start vor Seg">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047693102" ID="ID_848292031" MODIFIED="1683047708974" TEXT="nur Ende vor Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047693102" ID="ID_848292031" MODIFIED="1683205615492" TEXT="nur Ende vor Seg">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047697837" ID="ID_1072007349" MODIFIED="1683047708975" TEXT="nur Start nach Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047688030" ID="ID_1243727539" MODIFIED="1683205615493" TEXT="nur Start vor Seg b&#xfc;ndig">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1683047704284" ID="ID_695991119" MODIFIED="1683047708975" TEXT="nur Ende nach Seg">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1683047693102" ID="ID_1566033672" MODIFIED="1683205615493" TEXT="nur Ende vor Seg b&#xfc;ndig">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683047697837" ID="ID_1072007349" MODIFIED="1683205991794" TEXT="nur Start nach Seg">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683047704284" ID="ID_695991119" MODIFIED="1683205991794" TEXT="nur Ende nach Seg">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683047688030" ID="ID_338317609" MODIFIED="1683205991795" TEXT="nur Start nach Seg b&#xfc;ndig">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683047693102" ID="ID_1890127575" MODIFIED="1683205991795" TEXT="nur Ende nach Seg b&#xfc;ndig">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683207052920" ID="ID_1558440128" MODIFIED="1683207476505" TEXT="keine Angabe in leer">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683207078324" ID="ID_1025210162" MODIFIED="1683207476505" TEXT="keine Angabe + bestehendes Segment">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1683207090858" ID="ID_149796036" MODIFIED="1683207476506" TEXT="keine Angabe + bestehendes Segment b&#xfc;ndig zum Ende">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>