| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960 |
- /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
- #include <stdexcept>
- #include <string>
- #include <utility>
- #include <vector>
- #include <cmext/string_view>
- #include "cmList.h"
- #include "testCommon.h"
- namespace {
- void checkResult(bool success)
- {
- if (!success) {
- std::cout << " => failed";
- }
- std::cout << std::endl;
- }
- bool testConstructors()
- {
- std::cout << "testConstructors()";
- bool result = true;
- {
- cmList list;
- if (!list.empty() || list != cmList{}) {
- result = false;
- }
- }
- {
- cmList list{ "aa;bb" };
- if (list.size() != 2 || list.to_string() != "aa;bb") {
- result = false;
- }
- }
- {
- cmList list1{ "aa", "bb" };
- cmList list2("aa;bb"_s);
- if (list1.size() != 2 || list2.size() != 2 || list1 != list2) {
- result = false;
- }
- if (list1.to_string() != "aa;bb") {
- result = false;
- }
- if (list1.to_string() != list2.to_string()) {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "aa", "bb", "cc" };
- cmList list(v.begin(), v.end());
- if (list.size() != 3 || list.to_string() != "aa;bb;cc") {
- result = false;
- }
- }
- {
- std::vector<std::string> values{ "aa;bb", "cc", "dd;ee" };
- cmList list1(values.begin(), values.end());
- cmList list2(values.begin(), values.end(), cmList::ExpandElements::No);
- if (list1.size() != 5 || list1.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- if (list2.size() != 3 || list2.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- }
- {
- std::vector<std::string> values{ "aa;bb;;cc", "", "dd;ee" };
- cmList list1(values.begin(), values.end(), cmList::ExpandElements::No,
- cmList::EmptyElements::No);
- cmList list2(values.begin(), values.end(), cmList::ExpandElements::No,
- cmList::EmptyElements::Yes);
- cmList list3(values.begin(), values.end(), cmList::ExpandElements::Yes,
- cmList::EmptyElements::No);
- cmList list4(values.begin(), values.end(), cmList::ExpandElements::Yes,
- cmList::EmptyElements::Yes);
- if (list1.size() != 2 || list1.to_string() != "aa;bb;;cc;dd;ee") {
- result = false;
- }
- if (list2.size() != 3 || list2.to_string() != "aa;bb;;cc;;dd;ee") {
- result = false;
- }
- if (list3.size() != 5 || list3.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- if (list4.size() != 7 || list4.to_string() != "aa;bb;;cc;;dd;ee") {
- result = false;
- }
- }
- {
- std::vector<std::string> values{ "aa;bb", "cc", "dd;ee" };
- cmList list1(values);
- cmList list2(values, cmList::ExpandElements::No);
- if (list1.size() != 5 || list1.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- if (list2.size() != 3 || list2.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- }
- {
- std::vector<std::string> values{ "aa", "bb", "cc", "dd", "ee" };
- cmList list(std::move(values));
- if (list.size() != 5 || list.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- if (!values.empty()) {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testAssign()
- {
- std::cout << "testAssign()";
- bool result = true;
- {
- cmList list1{ "aa", "bb" };
- cmList list2{ "cc", "dd" };
- list2 = list1;
- if (list1.size() != 2 || list2.size() != 2 || list1 != list2) {
- result = false;
- }
- if (list1.to_string() != "aa;bb") {
- result = false;
- }
- if (list1.to_string() != list2.to_string()) {
- result = false;
- }
- }
- {
- cmList list1{ "aa", "bb" };
- cmList list2{ "cc", "dd" };
- list2 = std::move(list1);
- if (!list1.empty() || list2.size() != 2) {
- result = false;
- }
- if (list2.to_string() != "aa;bb") {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "aa", "bb" };
- cmList list{ "cc", "dd" };
- list = std::move(v);
- if (!v.empty() || list.size() != 2) {
- result = false;
- }
- if (list.to_string() != "aa;bb") {
- result = false;
- }
- }
- {
- cmList list{ "cc", "dd" };
- list = "aa;bb"_s;
- if (list.size() != 2) {
- result = false;
- }
- if (list.to_string() != "aa;bb") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testConversions()
- {
- std::cout << "testConversions()";
- bool result = true;
- {
- cmList list("a;b;c"_s);
- std::string s = list.to_string();
- if (s != "a;b;c") {
- result = false;
- }
- }
- {
- cmList list("a;b;c"_s);
- std::vector<std::string> v = list;
- if (list.size() != 3 || v.size() != 3) {
- result = false;
- }
- }
- {
- cmList list("a;b;c"_s);
- std::vector<std::string> v = std::move(list);
- // Microsoft compiler is not able to handle correctly the move semantics
- // so the initial list is not moved, so do not check its size...
- if (v.size() != 3) {
- result = false;
- }
- }
- {
- cmList list("a;b;c"_s);
- std::vector<std::string> v;
- // compiler is not able to select the cmList conversion operator
- // and the std::vector assignment operator using the move semantics
- // v = std::move(list);
- v = std::move(list.data());
- if (!list.empty() || v.size() != 3) {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testAccess()
- {
- std::cout << "testAccess()";
- bool result = true;
- {
- cmList list{ "a", "b", "c" };
- if (list.get_item(1) != "b") {
- result = false;
- }
- }
- {
- cmList list{ "a", "b", "c" };
- if (list.get_item(-3) != "a") {
- result = false;
- }
- }
- {
- try {
- cmList list{ "a", "b", "c" };
- if (list.get_item(4) != "a") {
- result = false;
- }
- } catch (std::out_of_range&) {
- }
- }
- {
- try {
- cmList list{ "a", "b", "c" };
- if (list.get_item(-4) != "a") {
- result = false;
- }
- } catch (std::out_of_range&) {
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e" };
- auto sublist = list.sublist(list.begin() + 1, list.begin() + 3);
- if (sublist.size() != 2 || sublist != cmList{ "b", "c" }) {
- result = false;
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e" };
- auto sublist = list.sublist(1, 2);
- if (sublist.size() != 2 || sublist != cmList{ "b", "c" }) {
- result = false;
- }
- sublist = list.sublist(1, cmList::npos);
- if (sublist.size() != 4 || sublist != cmList{ "b", "c", "d", "e" }) {
- result = false;
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e", "f" };
- auto sublist = list.get_items({ 1, 3, 5 });
- if (sublist.size() != 3 || sublist != cmList{ "b", "d", "f" }) {
- result = false;
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e", "f" };
- auto sublist = list.get_items({ 1, -3, 5, -3 });
- if (sublist.size() != 4 || sublist != cmList{ "b", "d", "f", "d" }) {
- result = false;
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e", "f" };
- try {
- if (list.get_items({ 1, -3, 5, -3, 10 }).size() != 5) {
- result = false;
- }
- } catch (std::out_of_range&) {
- }
- }
- {
- cmList list{ "a", "b", "c", "d", "e", "f" };
- if (list.find("b") != 1) {
- result = false;
- }
- if (list.find("x") != cmList::npos) {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testModifiers()
- {
- std::cout << "testModifiers()";
- bool result = true;
- {
- cmList list{ "1;2;3;4;5" };
- auto it = list.insert(list.begin() + 2, "6;7;8"_s);
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- auto it =
- list.insert(list.begin() + 2, "6;7;8"_s, cmList::ExpandElements::No);
- if (list.size() != 6 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6;7;8") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- cmList v{ "6", "7", "8" };
- auto it = list.insert(list.begin() + 2, v);
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- cmList v{ "6", "7", "8" };
- auto it = list.insert(list.begin() + 2, std::move(v));
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- if (!v.empty()) {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6", "7", "8" };
- auto it = list.insert(list.begin() + 2, v);
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6;7", "8" };
- auto it = list.insert(list.begin() + 2, v);
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6;7", "8" };
- auto it = list.insert(list.begin() + 2, v, cmList::ExpandElements::No);
- if (list.size() != 7 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6;7") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6;;7", "8" };
- auto it = list.insert(list.begin() + 2, v);
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6;;7", "8" };
- auto it = list.insert(list.begin() + 2, v, cmList::EmptyElements::Yes);
- if (list.size() != 9 || list.to_string() != "1;2;6;;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- }
- {
- cmList list{ "1;2;3;4;5" };
- std::vector<std::string> v{ "6", "7", "8" };
- auto it = list.insert(list.begin() + 2, std::move(v));
- if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") {
- result = false;
- }
- if (*it != "6") {
- result = false;
- }
- if (!v.empty()) {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testRemoveItems()
- {
- std::cout << "testRemoveItems()";
- bool result = true;
- {
- cmList list("a;b;c;d;e;f;g;h"_s);
- list.remove_items({ 1, 3, 5 });
- if (list.size() != 5 || list.to_string() != "a;c;e;g;h") {
- result = false;
- }
- }
- {
- cmList list("a;b;c;b;a;d;e;f"_s);
- list.remove_items({ "a", "b", "h" });
- if (list.size() != 4 || list.to_string() != "c;d;e;f") {
- result = false;
- }
- }
- {
- cmList list("a;b;c;d;e;f;g;h"_s);
- std::vector<cmList::index_type> remove{ 1, 3, 5 };
- list.remove_items(remove.begin(), remove.end());
- if (list.size() != 5 || list.to_string() != "a;c;e;g;h") {
- result = false;
- }
- }
- {
- cmList list("a;b;c;b;a;d;e;f"_s);
- std::vector<std::string> remove{ "b", "a", "h" };
- list.remove_items(remove.begin(), remove.end());
- if (list.size() != 4 || list.to_string() != "c;d;e;f") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testRemoveDuplicates()
- {
- std::cout << "testRemoveDuplicates()";
- bool result = true;
- {
- cmList list("b;c;b;a;a;c;b;a;c;b"_s);
- list.remove_duplicates();
- if (list.size() != 3 || list.to_string() != "b;c;a") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testFilter()
- {
- std::cout << "testFilter()";
- bool result = true;
- {
- cmList list{ "AA", "Aa", "aA" };
- list.filter("^A", cmList::FilterMode::INCLUDE);
- if (list.size() != 2 || list.to_string() != "AA;Aa") {
- result = false;
- }
- }
- {
- cmList list{ "AA", "Aa", "aA" };
- list.filter("^A", cmList::FilterMode::EXCLUDE);
- if (list.size() != 1 || list.to_string() != "aA") {
- result = false;
- }
- }
- {
- cmList list{ "AA", "Aa", "aA" };
- try {
- list.filter("^(A", cmList::FilterMode::EXCLUDE);
- if (list.size() != 1) {
- result = false;
- }
- } catch (std::invalid_argument const&) {
- }
- }
- checkResult(result);
- return result;
- }
- bool testReverse()
- {
- std::cout << "testReverse()";
- bool result = true;
- {
- cmList list{ "a", "b", "c" };
- if (list.reverse().to_string() != "c;b;a") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testSort()
- {
- std::cout << "testSort()";
- bool result = true;
- using SortConfiguration = cmList::SortConfiguration;
- {
- cmList list{ "A", "D", "C", "B", "A" };
- list.sort();
- if (list.to_string() != "A;A;B;C;D") {
- result = false;
- }
- list.sort({ SortConfiguration::OrderMode::DESCENDING,
- SortConfiguration::CompareMethod::DEFAULT,
- SortConfiguration::CaseSensitivity::DEFAULT });
- if (list.to_string() != "D;C;B;A;A") {
- result = false;
- }
- }
- {
- SortConfiguration sortCfg;
- cmList list{ "1.0", "1.1", "2.5", "10.2" };
- list.sort(sortCfg);
- if (list.to_string() != "1.0;1.1;10.2;2.5") {
- result = false;
- }
- sortCfg.Compare = SortConfiguration::CompareMethod::NATURAL;
- list.sort(sortCfg);
- if (list.to_string() != "1.0;1.1;2.5;10.2") {
- result = false;
- }
- sortCfg.Order = SortConfiguration::OrderMode::DESCENDING;
- list.sort(sortCfg);
- if (list.to_string() != "10.2;2.5;1.1;1.0") {
- result = false;
- }
- }
- {
- SortConfiguration sortCfg;
- cmList list{ "/zz/bb.cc", "/xx/yy/dd.cc", "/aa/cc.aa" };
- list.sort(sortCfg);
- if (list.to_string() != "/aa/cc.aa;/xx/yy/dd.cc;/zz/bb.cc") {
- result = false;
- }
- sortCfg.Compare = SortConfiguration::CompareMethod::FILE_BASENAME;
- if (list.sort(sortCfg).to_string() != "/zz/bb.cc;/aa/cc.aa;/xx/yy/dd.cc") {
- result = false;
- }
- }
- {
- SortConfiguration sortCfg;
- cmList list{ "c/B", "a/c", "B/a" };
- if (list.sort().to_string() != "B/a;a/c;c/B") {
- result = false;
- }
- sortCfg.Case = SortConfiguration::CaseSensitivity::INSENSITIVE;
- if (list.sort(sortCfg).to_string() != "a/c;B/a;c/B") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testTransform()
- {
- std::cout << "testTransform()";
- bool result = true;
- using AT = cmList::TransformSelector::AT;
- using FOR = cmList::TransformSelector::FOR;
- using REGEX = cmList::TransformSelector::REGEX;
- {
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::APPEND, "-X");
- if (list.to_string() != "AA-X;BB-X;CC-X;DD-X;EE-X") {
- result = false;
- }
- }
- {
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::PREPEND, "X-");
- if (list.to_string() != "X-AA;X-BB;X-CC;X-DD;X-EE") {
- result = false;
- }
- }
- {
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER);
- if (list.to_string() != "aa;bb;cc;dd;ee") {
- result = false;
- }
- }
- {
- cmList list({ "aa", "bb", "cc", "dd", "ee" });
- list.transform(cmList::TransformAction::TOUPPER);
- if (list.to_string() != "AA;BB;CC;DD;EE") {
- result = false;
- }
- }
- {
- cmList list({ " AA", "BB ", " CC ", "DD", "EE" });
- list.transform(cmList::TransformAction::STRIP);
- if (list.to_string() != "AA;BB;CC;DD;EE") {
- result = false;
- }
- }
- {
- cmList list({ "$<CONFIG>AA", "BB$<OR>", "C$<AND>C", "$<OR>DD$<AND>",
- "$<>E$<>E$<>" });
- list.transform(cmList::TransformAction::GENEX_STRIP);
- if (list.to_string() != "AA;BB;CC;DD;EE") {
- result = false;
- }
- }
- {
- cmList list({ "ABC", "BBCB", "BCCCBC", "BCBCDD", "EBCBCEBC" });
- list.transform(cmList::TransformAction::REPLACE, "^BC|BC$", "X");
- if (list.to_string() != "AX;BBCB;XCCX;XBCDD;EBCBCEX") {
- result = false;
- }
- }
- {
- auto atSelector = cmList::TransformSelector::New<AT>({ 1, 2, 4 });
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER, std::move(atSelector));
- if (list.to_string() != "AA;bb;cc;DD;ee") {
- result = false;
- }
- }
- {
- auto atSelector = cmList::TransformSelector::New<AT>({ 1, 2, -1 });
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER, std::move(atSelector));
- if (list.to_string() != "AA;bb;cc;DD;ee") {
- result = false;
- }
- }
- {
- auto forSelector = cmList::TransformSelector::New<FOR>({ 1, 3 });
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER, std::move(forSelector));
- if (list.to_string() != "AA;bb;cc;dd;EE") {
- result = false;
- }
- }
- {
- auto forSelector = cmList::TransformSelector::New<FOR>({ 0, 4, 2 });
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER, std::move(forSelector));
- if (list.to_string() != "aa;BB;cc;DD;ee") {
- result = false;
- }
- }
- {
- auto regexSelector = cmList::TransformSelector::New<REGEX>("^(A|D|E)");
- cmList list({ "AA", "BB", "CC", "DD", "EE" });
- list.transform(cmList::TransformAction::TOLOWER, std::move(regexSelector));
- if (list.to_string() != "aa;BB;CC;dd;ee") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- bool testStaticModifiers()
- {
- std::cout << "testStaticModifiers()";
- bool result = true;
- {
- std::vector<std::string> v{ "a", "b", "c" };
- cmList::assign(v, "d;e"_s);
- if (v.size() != 2 || v[0] != "d" || v[1] != "e") {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "a", "b", "c" };
- cmList::append(v, "d;;e"_s);
- if (v.size() != 5 || v[3] != "d" || v[4] != "e") {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "a", "b", "c" };
- cmList::append(v, "d;;e"_s, cmList::EmptyElements::Yes);
- if (v.size() != 6 || v[3] != "d" || !v[4].empty() || v[5] != "e") {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "a", "b", "c" };
- cmList::prepend(v, "d;e"_s);
- if (v.size() != 5 || v[0] != "d" || v[1] != "e") {
- result = false;
- }
- }
- {
- std::vector<std::string> v{ "a", "b", "c" };
- cmList::prepend(v, "d;;e"_s, cmList::EmptyElements::Yes);
- if (v.size() != 6 || v[0] != "d" || !v[1].empty() || v[2] != "e") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- cmList::append(list, "d;e"_s);
- if (list != "a;b;c;d;e") {
- result = false;
- }
- }
- {
- std::string list;
- cmList::append(list, "d;e"_s);
- if (list != "d;e") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- cmList::append(list, ""_s);
- if (list != "a;b;c;") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- std::vector<std::string> v{ "d", "e" };
- cmList::append(list, v.begin(), v.end());
- if (list != "a;b;c;d;e") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- std::vector<std::string> v;
- cmList::append(list, v.begin(), v.end());
- if (list != "a;b;c") {
- result = false;
- }
- }
- {
- std::string list;
- std::vector<std::string> v{ "d", "e" };
- cmList::append(list, v.begin(), v.end());
- if (list != "d;e") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- cmList::prepend(list, "d;e"_s);
- if (list != "d;e;a;b;c") {
- result = false;
- }
- }
- {
- std::string list;
- cmList::prepend(list, "d;e"_s);
- if (list != "d;e") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- cmList::prepend(list, ""_s);
- if (list != ";a;b;c") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- std::vector<std::string> v{ "d", "e" };
- cmList::prepend(list, v.begin(), v.end());
- if (list != "d;e;a;b;c") {
- result = false;
- }
- }
- {
- std::string list{ "a;b;c" };
- std::vector<std::string> v;
- cmList::prepend(list, v.begin(), v.end());
- if (list != "a;b;c") {
- result = false;
- }
- }
- {
- std::string list;
- std::vector<std::string> v{ "d", "e" };
- cmList::prepend(list, v.begin(), v.end());
- if (list != "d;e") {
- result = false;
- }
- }
- checkResult(result);
- return result;
- }
- }
- int testList(int /*unused*/, char* /*unused*/[])
- {
- return runTests({ testConstructors, testAssign, testConversions, testAccess,
- testModifiers, testRemoveItems, testRemoveDuplicates,
- testFilter, testReverse, testSort, testTransform,
- testStaticModifiers },
- false);
- }
|