diff options
Diffstat (limited to 'indra/llfilesystem/tests')
-rw-r--r-- | indra/llfilesystem/tests/lldir_test.cpp | 398 | ||||
-rw-r--r-- | indra/llfilesystem/tests/lldiriterator_test.cpp | 18 |
2 files changed, 208 insertions, 208 deletions
diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp index 60265cade6..6e191ad096 100644 --- a/indra/llfilesystem/tests/lldir_test.cpp +++ b/indra/llfilesystem/tests/lldir_test.cpp @@ -6,21 +6,21 @@ * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -190,228 +190,228 @@ struct LLDir_Dummy: public LLDir namespace tut { - struct LLDirTest + struct LLDirTest { }; typedef test_group<LLDirTest> LLDirTest_t; typedef LLDirTest_t::object LLDirTest_object_t; tut::LLDirTest_t tut_LLDirTest("LLDir"); - template<> template<> - void LLDirTest_object_t::test<1>() - // getDirDelimiter - { - ensure("getDirDelimiter", !gDirUtilp->getDirDelimiter().empty()); - } - - template<> template<> - void LLDirTest_object_t::test<2>() - // getBaseFileName - { - std::string delim = gDirUtilp->getDirDelimiter(); - std::string rawFile = "foo"; - std::string rawFileExt = "foo.bAr"; - std::string rawFileNullExt = "foo."; - std::string rawExt = ".bAr"; - std::string rawDot = "."; - std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; - std::string pathExt = pathNoExt + ".eXt"; - std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; - std::string dottedPathExt = dottedPathNoExt + ".eXt"; - - // foo[.bAr] - - ensure_equals("getBaseFileName/r-no-ext/no-strip-exten", - gDirUtilp->getBaseFileName(rawFile, false), - "foo"); - - ensure_equals("getBaseFileName/r-no-ext/strip-exten", - gDirUtilp->getBaseFileName(rawFile, true), - "foo"); - - ensure_equals("getBaseFileName/r-ext/no-strip-exten", - gDirUtilp->getBaseFileName(rawFileExt, false), - "foo.bAr"); - - ensure_equals("getBaseFileName/r-ext/strip-exten", - gDirUtilp->getBaseFileName(rawFileExt, true), - "foo"); - - // foo. + template<> template<> + void LLDirTest_object_t::test<1>() + // getDirDelimiter + { + ensure("getDirDelimiter", !gDirUtilp->getDirDelimiter().empty()); + } + + template<> template<> + void LLDirTest_object_t::test<2>() + // getBaseFileName + { + std::string delim = gDirUtilp->getDirDelimiter(); + std::string rawFile = "foo"; + std::string rawFileExt = "foo.bAr"; + std::string rawFileNullExt = "foo."; + std::string rawExt = ".bAr"; + std::string rawDot = "."; + std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; + std::string pathExt = pathNoExt + ".eXt"; + std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; + std::string dottedPathExt = dottedPathNoExt + ".eXt"; + + // foo[.bAr] + + ensure_equals("getBaseFileName/r-no-ext/no-strip-exten", + gDirUtilp->getBaseFileName(rawFile, false), + "foo"); + + ensure_equals("getBaseFileName/r-no-ext/strip-exten", + gDirUtilp->getBaseFileName(rawFile, true), + "foo"); + + ensure_equals("getBaseFileName/r-ext/no-strip-exten", + gDirUtilp->getBaseFileName(rawFileExt, false), + "foo.bAr"); + + ensure_equals("getBaseFileName/r-ext/strip-exten", + gDirUtilp->getBaseFileName(rawFileExt, true), + "foo"); + + // foo. + + ensure_equals("getBaseFileName/rn-no-ext/no-strip-exten", + gDirUtilp->getBaseFileName(rawFileNullExt, false), + "foo."); + + ensure_equals("getBaseFileName/rn-no-ext/strip-exten", + gDirUtilp->getBaseFileName(rawFileNullExt, true), + "foo"); + + // .bAr + // interesting case - with no basename, this IS the basename, not the extension. + + ensure_equals("getBaseFileName/e-ext/no-strip-exten", + gDirUtilp->getBaseFileName(rawExt, false), + ".bAr"); + + ensure_equals("getBaseFileName/e-ext/strip-exten", + gDirUtilp->getBaseFileName(rawExt, true), + ".bAr"); + + // . + + ensure_equals("getBaseFileName/d/no-strip-exten", + gDirUtilp->getBaseFileName(rawDot, false), + "."); - ensure_equals("getBaseFileName/rn-no-ext/no-strip-exten", - gDirUtilp->getBaseFileName(rawFileNullExt, false), - "foo."); + ensure_equals("getBaseFileName/d/strip-exten", + gDirUtilp->getBaseFileName(rawDot, true), + "."); - ensure_equals("getBaseFileName/rn-no-ext/strip-exten", - gDirUtilp->getBaseFileName(rawFileNullExt, true), - "foo"); - - // .bAr - // interesting case - with no basename, this IS the basename, not the extension. - - ensure_equals("getBaseFileName/e-ext/no-strip-exten", - gDirUtilp->getBaseFileName(rawExt, false), - ".bAr"); - - ensure_equals("getBaseFileName/e-ext/strip-exten", - gDirUtilp->getBaseFileName(rawExt, true), - ".bAr"); - - // . - - ensure_equals("getBaseFileName/d/no-strip-exten", - gDirUtilp->getBaseFileName(rawDot, false), - "."); - - ensure_equals("getBaseFileName/d/strip-exten", - gDirUtilp->getBaseFileName(rawDot, true), - "."); - - // aa/bb/cc/dd/ee[.eXt] - - ensure_equals("getBaseFileName/no-ext/no-strip-exten", - gDirUtilp->getBaseFileName(pathNoExt, false), - "ee"); - - ensure_equals("getBaseFileName/no-ext/strip-exten", - gDirUtilp->getBaseFileName(pathNoExt, true), - "ee"); - - ensure_equals("getBaseFileName/ext/no-strip-exten", - gDirUtilp->getBaseFileName(pathExt, false), - "ee.eXt"); - - ensure_equals("getBaseFileName/ext/strip-exten", - gDirUtilp->getBaseFileName(pathExt, true), - "ee"); - - // aa/bb/cc.dd/ee[.eXt] - - ensure_equals("getBaseFileName/d-no-ext/no-strip-exten", - gDirUtilp->getBaseFileName(dottedPathNoExt, false), - "ee"); - - ensure_equals("getBaseFileName/d-no-ext/strip-exten", - gDirUtilp->getBaseFileName(dottedPathNoExt, true), - "ee"); - - ensure_equals("getBaseFileName/d-ext/no-strip-exten", - gDirUtilp->getBaseFileName(dottedPathExt, false), - "ee.eXt"); - - ensure_equals("getBaseFileName/d-ext/strip-exten", - gDirUtilp->getBaseFileName(dottedPathExt, true), - "ee"); - } - - template<> template<> - void LLDirTest_object_t::test<3>() - // getDirName - { - std::string delim = gDirUtilp->getDirDelimiter(); - std::string rawFile = "foo"; - std::string rawFileExt = "foo.bAr"; - std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; - std::string pathExt = pathNoExt + ".eXt"; - std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; - std::string dottedPathExt = dottedPathNoExt + ".eXt"; + // aa/bb/cc/dd/ee[.eXt] - // foo[.bAr] + ensure_equals("getBaseFileName/no-ext/no-strip-exten", + gDirUtilp->getBaseFileName(pathNoExt, false), + "ee"); - ensure_equals("getDirName/r-no-ext", - gDirUtilp->getDirName(rawFile), - ""); + ensure_equals("getBaseFileName/no-ext/strip-exten", + gDirUtilp->getBaseFileName(pathNoExt, true), + "ee"); - ensure_equals("getDirName/r-ext", - gDirUtilp->getDirName(rawFileExt), - ""); + ensure_equals("getBaseFileName/ext/no-strip-exten", + gDirUtilp->getBaseFileName(pathExt, false), + "ee.eXt"); - // aa/bb/cc/dd/ee[.eXt] + ensure_equals("getBaseFileName/ext/strip-exten", + gDirUtilp->getBaseFileName(pathExt, true), + "ee"); - ensure_equals("getDirName/no-ext", - gDirUtilp->getDirName(pathNoExt), - "aa" + delim + "bb" + delim + "cc" + delim + "dd"); + // aa/bb/cc.dd/ee[.eXt] - ensure_equals("getDirName/ext", - gDirUtilp->getDirName(pathExt), - "aa" + delim + "bb" + delim + "cc" + delim + "dd"); + ensure_equals("getBaseFileName/d-no-ext/no-strip-exten", + gDirUtilp->getBaseFileName(dottedPathNoExt, false), + "ee"); - // aa/bb/cc.dd/ee[.eXt] + ensure_equals("getBaseFileName/d-no-ext/strip-exten", + gDirUtilp->getBaseFileName(dottedPathNoExt, true), + "ee"); - ensure_equals("getDirName/d-no-ext", - gDirUtilp->getDirName(dottedPathNoExt), - "aa" + delim + "bb" + delim + "cc.dd"); + ensure_equals("getBaseFileName/d-ext/no-strip-exten", + gDirUtilp->getBaseFileName(dottedPathExt, false), + "ee.eXt"); - ensure_equals("getDirName/d-ext", - gDirUtilp->getDirName(dottedPathExt), - "aa" + delim + "bb" + delim + "cc.dd"); - } + ensure_equals("getBaseFileName/d-ext/strip-exten", + gDirUtilp->getBaseFileName(dottedPathExt, true), + "ee"); + } + + template<> template<> + void LLDirTest_object_t::test<3>() + // getDirName + { + std::string delim = gDirUtilp->getDirDelimiter(); + std::string rawFile = "foo"; + std::string rawFileExt = "foo.bAr"; + std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; + std::string pathExt = pathNoExt + ".eXt"; + std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; + std::string dottedPathExt = dottedPathNoExt + ".eXt"; + + // foo[.bAr] + + ensure_equals("getDirName/r-no-ext", + gDirUtilp->getDirName(rawFile), + ""); - template<> template<> - void LLDirTest_object_t::test<4>() - // getExtension - { - std::string delim = gDirUtilp->getDirDelimiter(); - std::string rawFile = "foo"; - std::string rawFileExt = "foo.bAr"; - std::string rawFileNullExt = "foo."; - std::string rawExt = ".bAr"; - std::string rawDot = "."; - std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; - std::string pathExt = pathNoExt + ".eXt"; - std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; - std::string dottedPathExt = dottedPathNoExt + ".eXt"; + ensure_equals("getDirName/r-ext", + gDirUtilp->getDirName(rawFileExt), + ""); - // foo[.bAr] + // aa/bb/cc/dd/ee[.eXt] - ensure_equals("getExtension/r-no-ext", - gDirUtilp->getExtension(rawFile), - ""); + ensure_equals("getDirName/no-ext", + gDirUtilp->getDirName(pathNoExt), + "aa" + delim + "bb" + delim + "cc" + delim + "dd"); - ensure_equals("getExtension/r-ext", - gDirUtilp->getExtension(rawFileExt), - "bar"); + ensure_equals("getDirName/ext", + gDirUtilp->getDirName(pathExt), + "aa" + delim + "bb" + delim + "cc" + delim + "dd"); - // foo. + // aa/bb/cc.dd/ee[.eXt] + + ensure_equals("getDirName/d-no-ext", + gDirUtilp->getDirName(dottedPathNoExt), + "aa" + delim + "bb" + delim + "cc.dd"); + + ensure_equals("getDirName/d-ext", + gDirUtilp->getDirName(dottedPathExt), + "aa" + delim + "bb" + delim + "cc.dd"); + } + + template<> template<> + void LLDirTest_object_t::test<4>() + // getExtension + { + std::string delim = gDirUtilp->getDirDelimiter(); + std::string rawFile = "foo"; + std::string rawFileExt = "foo.bAr"; + std::string rawFileNullExt = "foo."; + std::string rawExt = ".bAr"; + std::string rawDot = "."; + std::string pathNoExt = "aa" + delim + "bb" + delim + "cc" + delim + "dd" + delim + "ee"; + std::string pathExt = pathNoExt + ".eXt"; + std::string dottedPathNoExt = "aa" + delim + "bb" + delim + "cc.dd" + delim + "ee"; + std::string dottedPathExt = dottedPathNoExt + ".eXt"; - ensure_equals("getExtension/rn-no-ext", - gDirUtilp->getExtension(rawFileNullExt), - ""); + // foo[.bAr] - // .bAr - // interesting case - with no basename, this IS the basename, not the extension. + ensure_equals("getExtension/r-no-ext", + gDirUtilp->getExtension(rawFile), + ""); - ensure_equals("getExtension/e-ext", - gDirUtilp->getExtension(rawExt), - ""); + ensure_equals("getExtension/r-ext", + gDirUtilp->getExtension(rawFileExt), + "bar"); - // . + // foo. - ensure_equals("getExtension/d", - gDirUtilp->getExtension(rawDot), - ""); + ensure_equals("getExtension/rn-no-ext", + gDirUtilp->getExtension(rawFileNullExt), + ""); - // aa/bb/cc/dd/ee[.eXt] - - ensure_equals("getExtension/no-ext", - gDirUtilp->getExtension(pathNoExt), - ""); - - ensure_equals("getExtension/ext", - gDirUtilp->getExtension(pathExt), - "ext"); - - // aa/bb/cc.dd/ee[.eXt] + // .bAr + // interesting case - with no basename, this IS the basename, not the extension. - ensure_equals("getExtension/d-no-ext", - gDirUtilp->getExtension(dottedPathNoExt), - ""); + ensure_equals("getExtension/e-ext", + gDirUtilp->getExtension(rawExt), + ""); - ensure_equals("getExtension/d-ext", - gDirUtilp->getExtension(dottedPathExt), - "ext"); - } + // . + + ensure_equals("getExtension/d", + gDirUtilp->getExtension(rawDot), + ""); + + // aa/bb/cc/dd/ee[.eXt] + + ensure_equals("getExtension/no-ext", + gDirUtilp->getExtension(pathNoExt), + ""); + + ensure_equals("getExtension/ext", + gDirUtilp->getExtension(pathExt), + "ext"); + + // aa/bb/cc.dd/ee[.eXt] + + ensure_equals("getExtension/d-no-ext", + gDirUtilp->getExtension(dottedPathNoExt), + ""); + + ensure_equals("getExtension/d-ext", + gDirUtilp->getExtension(dottedPathExt), + "ext"); + } std::string makeTestFile( const std::string& dir, const std::string& file ) { @@ -431,7 +431,7 @@ namespace tut std::string uniqueDir; bool foundUnused; std::string delim = gDirUtilp->getDirDelimiter(); - + for (counter=0, foundUnused=false; !foundUnused; counter++ ) { char counterStr[3]; @@ -440,7 +440,7 @@ namespace tut foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) ); } ensure("test directory '" + uniqueDir + "' creation failed", !LLFile::mkdir(uniqueDir)); - + return uniqueDir + delim; // HACK - apparently, the trailing delimiter is needed... } @@ -487,7 +487,7 @@ namespace tut } } } - + template<> template<> void LLDirTest_object_t::test<5>() // LLDirIterator::next diff --git a/indra/llfilesystem/tests/lldiriterator_test.cpp b/indra/llfilesystem/tests/lldiriterator_test.cpp index a65e3dada5..dc573b5555 100644 --- a/indra/llfilesystem/tests/lldiriterator_test.cpp +++ b/indra/llfilesystem/tests/lldiriterator_test.cpp @@ -6,21 +6,21 @@ * $LicenseInfo:firstyear=2011&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2011, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only., - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -32,7 +32,7 @@ namespace tut { - + struct LLDirIteratorFixture { LLDirIteratorFixture() @@ -45,19 +45,19 @@ namespace tut /* CHOP-662 was originally introduced to deal with crashes deleting files from - a directory (VWR-25500). However, this introduced a crash looking for + a directory (VWR-25500). However, this introduced a crash looking for old chat logs as the glob_to_regex function in lldiriterator wasn't escaping lots of regexp characters */ void test_chop_662(void) { - // Check a selection of bad group names from the crash reports + // Check a selection of bad group names from the crash reports LLDirIterator iter(".","+bad-group-name]+?\?-??.*"); LLDirIterator iter1(".","))--@---bad-group-name2((?\?-??.*\\.txt"); - LLDirIterator iter2(".","__^v--x)Cuide d sua vida(x--v^__?\?-??.*"); + LLDirIterator iter2(".","__^v--x)Cuide d sua vida(x--v^__?\?-??.*"); } template<> template<> - void LLDirIteratorTest_t::test<1>() + void LLDirIteratorTest_t::test<1>() { test_chop_662(); } |