Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 32 additions & 38 deletions indra/llcommon/tests/lldependencies_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <string>
// std headers
// external library headers
#include <boost/assign/list_of.hpp>
// Precompiled header
#include "linden_common.h"
// associated header
Expand Down Expand Up @@ -106,8 +105,6 @@ std::ostream& operator<<(std::ostream& out, const std::set<ENTRY>& set)
/*****************************************************************************
* Other helpers
*****************************************************************************/
using boost::assign::list_of;

typedef LLDependencies<> StringDeps;
typedef StringDeps::KeyList StringList;

Expand Down Expand Up @@ -165,7 +162,7 @@ namespace tut
// The quick brown fox jumps over the lazy yellow dog.
// (note, "The" and "the" are distinct, else this test wouldn't work)
deps.add("lazy");
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")));
ensure_equals(sorted_keys(deps), StringList{"lazy"});
deps.add("jumps");
ensure("found lazy", deps.get("lazy"));
ensure("not found dog.", ! deps.get("dog."));
Expand All @@ -175,24 +172,23 @@ namespace tut
// A change to the implementation of boost::topological_sort() would
// be an acceptable reason, and you can simply update the expected
// test output.
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")));
deps.add("The", 0, empty, list_of("fox")("dog."));
ensure_equals(sorted_keys(deps), StringList{ "lazy", "jumps" });
deps.add("The", 0, empty, { "fox", "dog." });
// Test key accessors
ensure("empty before deps for missing key", is_empty(deps.get_before_range("bogus")));
ensure("empty before deps for jumps", is_empty(deps.get_before_range("jumps")));
ensure_equals(instance_from_range< std::set<std::string> >(deps.get_before_range("The")),
make< std::set<std::string> >(list_of("dog.")("fox")));
ensure_equals(instance_from_range< std::set<std::string> >(deps.get_before_range("The")), std::set<std::string>{ "dog.", "fox" });
// resume building dependencies
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The")));
deps.add("the", 0, list_of("The"));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The")("the")));
deps.add("fox", 0, list_of("The"), list_of("jumps"));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
deps.add("the", 0, list_of("The")); // same, see if cache works
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
deps.add("jumps", 0, empty, list_of("over")); // update jumps deps
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
/*==========================================================================*|
ensure_equals(sorted_keys(deps), StringList{ "lazy", "jumps", "The" });
deps.add("the", 0, { "The" });
ensure_equals(sorted_keys(deps), StringList{ "lazy", "jumps", "The", "the" });
deps.add("fox", 0, { "The" }, { "jumps" });
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "the", "fox", "jumps" });
deps.add("the", 0, { "The" }); // same, see if cache works
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "the", "fox", "jumps" });
deps.add("jumps", 0, empty, { "over" }); // update jumps deps
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "the", "fox", "jumps" });
/*==========================================================================*|
// It drives me nuts that this test doesn't work in the test
// framework, because -- for reasons unknown -- running the test
// framework on Mac OS X 10.5 Leopard and Windows XP Pro, the catch
Expand All @@ -216,22 +212,21 @@ namespace tut
deps.remove("over");
}
|*==========================================================================*/
deps.add("dog.", 0, list_of("yellow")("lazy"));
ensure_equals(instance_from_range< std::set<std::string> >(deps.get_after_range("dog.")),
make< std::set<std::string> >(list_of("lazy")("yellow")));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")("dog.")));
deps.add("quick", 0, list_of("The"), list_of("fox")("brown"));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("quick")("fox")("jumps")("dog.")));
deps.add("over", 0, list_of("jumps"), list_of("yellow")("the"));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("quick")("fox")("jumps")("over")("the")("dog.")));
deps.add("yellow", 0, list_of("the"), list_of("lazy"));
ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("fox")("jumps")("over")("the")("yellow")("lazy")("dog.")));
deps.add("dog.", 0, { "yellow", "lazy" });
ensure_equals(instance_from_range< std::set<std::string> >(deps.get_after_range("dog.")), std::set<std::string>{ "lazy", "yellow" });
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "the", "fox", "jumps", "dog." });
deps.add("quick", 0, { "The" }, { "fox", "brown" });
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "the", "quick", "fox", "jumps", "dog." });
deps.add("over", 0, { "jumps" }, { "yellow", "the" });
ensure_equals(sorted_keys(deps), StringList{ "lazy", "The", "quick", "fox", "jumps", "over", "the", "dog." });
deps.add("yellow", 0, { "the" }, { "lazy" });
ensure_equals(sorted_keys(deps), StringList{ "The", "quick", "fox", "jumps", "over", "the", "yellow", "lazy", "dog." });
deps.add("brown");
// By now the dependencies are pretty well in place. A change to THIS
// order should be viewed with suspicion.
ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("brown")("fox")("jumps")("over")("the")("yellow")("lazy")("dog.")));
ensure_equals(sorted_keys(deps), StringList{ "The", "quick", "brown", "fox", "jumps", "over", "the", "yellow", "lazy", "dog." });

StringList keys(make<StringList>(list_of("The")("brown")("dog.")("fox")("jumps")("lazy")("over")("quick")("the")("yellow")));
StringList keys(StringList{ "The", "brown", "dog.", "fox", "jumps", "lazy", "over", "quick", "the", "yellow" });
ensure_equals(instance_from_range<StringList>(deps.get_key_range()), keys);
#if (! defined(__GNUC__)) || (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
// This is the succinct way, works on modern compilers
Expand All @@ -255,9 +250,9 @@ namespace tut
typedef LLDependencies<std::string, int> NameIndexDeps;
NameIndexDeps nideps;
const NameIndexDeps& const_nideps(nideps);
nideps.add("def", 2, list_of("ghi"));
nideps.add("def", 2, { "ghi" });
nideps.add("ghi", 3);
nideps.add("abc", 1, list_of("def"));
nideps.add("abc", 1, { "def" });
NameIndexDeps::range range(nideps.get_range());
ensure_equals(range.begin()->first, "abc");
ensure_equals(range.begin()->second, 1);
Expand All @@ -269,20 +264,20 @@ namespace tut
ensure_equals(const_iterator->first, "def");
ensure_equals(const_iterator->second, 2);
// NameIndexDeps::node_range node_range(nideps.get_node_range());
// ensure_equals(instance_from_range<std::vector<int> >(node_range), make< std::vector<int> >(list_of(1)(2)(3)));
// ensure_equals(instance_from_range<std::vector<int> >(node_range), make< std::vector<int> >(list_of(1,2,3)));
// *node_range.begin() = 0;
// *node_range.begin() = 1;
NameIndexDeps::const_node_range const_node_range(const_nideps.get_node_range());
ensure_equals(instance_from_range<std::vector<int> >(const_node_range), make< std::vector<int> >(list_of(1)(2)(3)));
ensure_equals(instance_from_range<std::vector<int>>(const_node_range), std::vector<int>{ 1, 2, 3 });
NameIndexDeps::const_key_range const_key_range(const_nideps.get_key_range());
ensure_equals(instance_from_range<StringList>(const_key_range), make<StringList>(list_of("abc")("def")("ghi")));
ensure_equals(instance_from_range<StringList>(const_key_range), StringList{ "abc", "def", "ghi" });
NameIndexDeps::sorted_range sorted(const_nideps.sort());
NameIndexDeps::sorted_iterator sortiter(sorted.begin());
ensure_equals(sortiter->first, "ghi");
ensure_equals(sortiter->second, 3);

// test all iterator-flavored versions of get_after_range()
StringList def(make<StringList>(list_of("def")));
StringList def{"def"};
ensure("empty abc before list", is_empty(nideps.get_before_range(nideps.get_range().begin())));
ensure_equals(instance_from_range<StringList>(nideps.get_after_range(nideps.get_range().begin())),
def);
Expand All @@ -296,7 +291,6 @@ namespace tut
def);
// advance from "ghi" to "def", which must come after "ghi"
++sortiter;
ensure_equals(instance_from_range<StringList>(const_nideps.get_after_range(sortiter)),
make<StringList>(list_of("ghi")));
ensure_equals(instance_from_range<StringList>(const_nideps.get_after_range(sortiter)), StringList{ "ghi" });
}
} // namespace tut
50 changes: 19 additions & 31 deletions indra/llcommon/tests/llstring_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@

#include "linden_common.h"

#include <boost/assign/list_of.hpp>
#include "../llstring.h"
#include "StringVec.h" // must come BEFORE lltut.h
#include "../test/lltut.h"

using boost::assign::list_of;

namespace tut
{
struct string_index
Expand Down Expand Up @@ -763,14 +760,14 @@ namespace tut
ensure_equals("only delims",
LLStringUtil::getTokens(" \r\n ", " \r\n"), StringVec());
ensure_equals("sequence of delims",
LLStringUtil::getTokens(",,, one ,,,", ","), list_of("one"));
LLStringUtil::getTokens(",,, one ,,,", ","), StringVec{"one"});
// nat considers this a dubious implementation side effect, but I'd
// hate to change it now...
ensure_equals("noncontiguous tokens",
LLStringUtil::getTokens(", ,, , one ,,,", ","), list_of("")("")("one"));
LLStringUtil::getTokens(", ,, , one ,,,", ","), StringVec{ "", "", "one" });
ensure_equals("space-padded tokens",
LLStringUtil::getTokens(", one , two ,", ","), list_of("one")("two"));
ensure_equals("no delims", LLStringUtil::getTokens("one", ","), list_of("one"));
LLStringUtil::getTokens(", one , two ,", ","), StringVec{"one", "two"});
ensure_equals("no delims", LLStringUtil::getTokens("one", ","), StringVec{ "one" });
}

// Shorthand for verifying that getTokens() behaves the same when you
Expand Down Expand Up @@ -817,55 +814,46 @@ namespace tut
ensure_getTokens("only delims",
" \r\n ", " \r\n", "", StringVec());
ensure_getTokens("sequence of delims",
",,, one ,,,", ", ", "", list_of("one"));
",,, one ,,,", ", ", "", StringVec{"one"});
// Note contrast with the case in the previous method
ensure_getTokens("noncontiguous tokens",
", ,, , one ,,,", ", ", "", list_of("one"));
", ,, , one ,,,", ", ", "", StringVec{"one"});
ensure_getTokens("space-padded tokens",
", one , two ,", ", ", "",
list_of("one")("two"));
ensure_getTokens("no delims", "one", ",", "", list_of("one"));
StringVec{"one", "two"});
ensure_getTokens("no delims", "one", ",", "", StringVec{ "one" });

// drop_delims vs. keep_delims
ensure_getTokens("arithmetic",
" ab+def / xx* yy ", " ", "+-*/",
list_of("ab")("+")("def")("/")("xx")("*")("yy"));
" ab+def / xx* yy ", " ", "+-*/", { "ab", "+", "def", "/", "xx", "*", "yy" });

// quotes
ensure_getTokens("no quotes",
"She said, \"Don't go.\"", " ", ",", "",
list_of("She")("said")(",")("\"Don't")("go.\""));
"She said, \"Don't go.\"", " ", ",", "", { "She", "said", ",", "\"Don't", "go.\"" });
ensure_getTokens("quotes",
"She said, \"Don't go.\"", " ", ",", "\"",
list_of("She")("said")(",")("Don't go."));
"She said, \"Don't go.\"", " ", ",", "\"", { "She", "said", ",", "Don't go." });
ensure_getTokens("quotes and delims",
"run c:/'Documents and Settings'/someone", " ", "", "'",
list_of("run")("c:/Documents and Settings/someone"));
{ "run", "c:/Documents and Settings/someone" });
ensure_getTokens("unmatched quote",
"baby don't leave", " ", "", "'",
list_of("baby")("don't")("leave"));
"baby don't leave", " ", "", "'", { "baby", "don't", "leave" });
ensure_getTokens("adjacent quoted",
"abc'def \"ghi'\"jkl' mno\"pqr", " ", "", "\"'",
list_of("abcdef \"ghijkl' mnopqr"));
"abc'def \"ghi'\"jkl' mno\"pqr", " ", "", "\"'", { "abcdef \"ghijkl' mnopqr" });
ensure_getTokens("quoted empty string",
"--set SomeVar ''", " ", "", "'",
list_of("--set")("SomeVar")(""));
"--set SomeVar ''", " ", "", "'", { "--set", "SomeVar", "" });

// escapes
// Don't use backslash as an escape for these tests -- you'll go nuts
// between the C++ string scanner and getTokens() escapes. Test with
// something else!
ensure_equals("escaped delims",
LLStringUtil::getTokens("^ a - dog^-gone^ phrase", " ", "-", "", "^"),
list_of(" a")("-")("dog-gone phrase"));
StringVec{ " a", "-", "dog-gone phrase" });
ensure_equals("escaped quotes",
LLStringUtil::getTokens("say: 'this isn^'t w^orking'.", " ", "", "'", "^"),
list_of("say:")("this isn't working."));
StringVec{ "say:", "this isn't working." });
ensure_equals("escaped escape",
LLStringUtil::getTokens("want x^^2", " ", "", "", "^"),
list_of("want")("x^2"));
ensure_equals("escape at end",
LLStringUtil::getTokens("it's^ up there^", " ", "", "'", "^"),
list_of("it's up")("there^"));
LLStringUtil::getTokens("want x^^2", " ", "", "", "^"), StringVec{ "want", "x^2" });
ensure_equals("escape at end", LLStringUtil::getTokens("it's^ up there^", " ", "", "'", "^"), StringVec{ "it's up", "there^" });
}
}
59 changes: 26 additions & 33 deletions indra/llfilesystem/lldir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,9 @@
#include "stringize.h"
#include "llstring.h"
#include <boost/filesystem.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <algorithm>

using boost::assign::list_of;
using boost::assign::map_list_of;

#if LL_WINDOWS
#include "lldir_win32.h"
LLDir_Win32 gDirUtil;
Expand Down Expand Up @@ -448,28 +441,28 @@ const std::string &LLDir::getUserName() const
static std::string ELLPathToString(ELLPath location)
{
typedef std::map<ELLPath, const char*> ELLPathMap;
#define ENT(symbol) (symbol, #symbol)
static const ELLPathMap sMap = map_list_of
ENT(LL_PATH_NONE)
ENT(LL_PATH_USER_SETTINGS)
ENT(LL_PATH_APP_SETTINGS)
ENT(LL_PATH_PER_SL_ACCOUNT) // returns/expands to blank string if we don't know the account name yet
ENT(LL_PATH_CACHE)
ENT(LL_PATH_CHARACTER)
ENT(LL_PATH_HELP)
ENT(LL_PATH_LOGS)
ENT(LL_PATH_TEMP)
ENT(LL_PATH_SKINS)
ENT(LL_PATH_TOP_SKIN)
ENT(LL_PATH_CHAT_LOGS)
ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS)
ENT(LL_PATH_USER_SKIN)
ENT(LL_PATH_LOCAL_ASSETS)
ENT(LL_PATH_EXECUTABLE)
ENT(LL_PATH_DEFAULT_SKIN)
ENT(LL_PATH_FONTS)
ENT(LL_PATH_LAST)
;
#define ENT(symbol) { symbol, #symbol }
static const ELLPathMap sMap = {
ENT(LL_PATH_NONE),
ENT(LL_PATH_USER_SETTINGS),
ENT(LL_PATH_APP_SETTINGS),
ENT(LL_PATH_PER_SL_ACCOUNT), // returns/expands to blank string if we don't know the account name yet
ENT(LL_PATH_CACHE),
ENT(LL_PATH_CHARACTER),
ENT(LL_PATH_HELP),
ENT(LL_PATH_LOGS),
ENT(LL_PATH_TEMP),
ENT(LL_PATH_SKINS),
ENT(LL_PATH_TOP_SKIN),
ENT(LL_PATH_CHAT_LOGS),
ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS),
ENT(LL_PATH_USER_SKIN),
ENT(LL_PATH_LOCAL_ASSETS),
ENT(LL_PATH_EXECUTABLE),
ENT(LL_PATH_DEFAULT_SKIN),
ENT(LL_PATH_FONTS),
ENT(LL_PATH_LAST),
};
#undef ENT

ELLPathMap::const_iterator found = sMap.find(location);
Expand Down Expand Up @@ -725,10 +718,10 @@ std::vector<std::string> LLDir::findSkinnedFilenames(const std::string& subdir,
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;

// Recognize subdirs that have no localization.
static const std::set<std::string> sUnlocalized = list_of
("") // top-level directory not localized
("textures") // textures not localized
;
static const std::set<std::string> sUnlocalized = {
"", // top-level directory not localized
"textures" // textures not localized
};

LL_DEBUGS("LLDir") << "subdir '" << subdir << "', filename '" << filename
<< "', constraint "
Expand Down
Loading