From c052dc91be0a4d5c5405ecdc66d5bfdb67cef336 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Sun, 26 Oct 2014 16:39:14 +0000 Subject: [PATCH] namespace elt to etl Corrected namespace from elt to etl --- .gitattributes | 63 +++++++ .gitignore | 9 +- array.h | 14 +- test/main.cpp | 32 ++++ test/test_array.cpp | 308 ++++++++++++++++++++++++++++++++ test/vs2013/etl.sln | 22 +++ test/vs2013/etl.vcxproj | 149 +++++++++++++++ test/vs2013/etl.vcxproj.filters | 195 ++++++++++++++++++++ 8 files changed, 784 insertions(+), 8 deletions(-) create mode 100644 .gitattributes create mode 100644 test/main.cpp create mode 100644 test/test_array.cpp create mode 100644 test/vs2013/etl.sln create mode 100644 test/vs2013/etl.vcxproj create mode 100644 test/vs2013/etl.vcxproj.filters diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..1ff0c423 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 7945f299..e647a84d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ + +################# +## Personal +################# +docs/ +test/msvs/Debug +test/msvs/Release + ################# ## Eclipse ################# @@ -7,7 +15,6 @@ .metadata bin/ tmp/ -docs/ *.tmp *.bak *.swp diff --git a/array.h b/array.h index 8b4b614b..e1ad11d1 100644 --- a/array.h +++ b/array.h @@ -353,7 +353,7 @@ namespace etl ///\param rhs Reference to the second array. //************************************************************************* template - void swap(elt::array &lhs, etl::array &rhs) + void swap(etl::array &lhs, etl::array &rhs) { lhs.swap(rhs); } @@ -367,7 +367,7 @@ namespace etl ///\return true if the arrays are equal, otherwise false //************************************************************************* template - bool operator ==(const elt::array& lhs, const elt::array& rhs) + bool operator ==(const etl::array& lhs, const etl::array& rhs) { return std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()); } @@ -379,7 +379,7 @@ namespace etl ///\return true if the arrays are not equal, otherwise false //************************************************************************* template - bool operator !=(const elt::array& lhs, const elt::array& rhs) + bool operator !=(const etl::array& lhs, const etl::array& rhs) { return !(lhs == rhs); } @@ -391,7 +391,7 @@ namespace etl ///\return true if the first array is lexicographically less than the second, otherwise false //************************************************************************* template - bool operator <(const elt::array& lhs, const elt::array& rhs) + bool operator <(const etl::array& lhs, const etl::array& rhs) { return std::lexicographical_compare(lhs.cbegin(), lhs.cend(), @@ -406,7 +406,7 @@ namespace etl ///\return true if the first array is lexicographically less than or equal to the second, otherwise false //************************************************************************* template - bool operator <=(const elt::array& lhs, const elt::array& rhs) + bool operator <=(const etl::array& lhs, const etl::array& rhs) { return !std::lexicographical_compare(lhs.cbegin(), lhs.cend(), @@ -422,7 +422,7 @@ namespace etl ///\return true if the first array is lexicographically greater than the second, otherwise false template //************************************************************************* - bool operator >(const elt::array& lhs, const elt::array& rhs) + bool operator >(const etl::array& lhs, const etl::array& rhs) { return std::lexicographical_compare(lhs.cbegin(), lhs.cend(), @@ -438,7 +438,7 @@ namespace etl ///\return true if the first array is lexicographically greater than or equal to the second, otherwise false //************************************************************************* template - bool operator >=(const elt::array& lhs, const elt::array& rhs) + bool operator >=(const etl::array& lhs, const etl::array& rhs) { return !std::lexicographical_compare(lhs.cbegin(), lhs.cend(), diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 00000000..37157c28 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,32 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. + +Copyright(c) 2014 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include + +int main() +{ + return UnitTest::RunAllTests(); +} diff --git a/test/test_array.cpp b/test/test_array.cpp new file mode 100644 index 00000000..92083427 --- /dev/null +++ b/test/test_array.cpp @@ -0,0 +1,308 @@ + +#include + +#include "../Array.h" + +#include +#include +#include + +namespace +{ + SUITE(ArrayTest) + { + static const size_t SIZE = 10; + + typedef etl::array Data; + typedef std::vector TestData; + + Data data; + TestData testData; + TestData initialData; + + //************************************************************************* + struct SetupFixture + { + SetupFixture() + { + int n[] = { 2, 1, 4, 3, 6, 5, 8, 7, 10, 9 }; + + std::copy(std::begin(n), std::end(n), data.begin()); + initialData.assign(std::begin(n), std::end(n)); + testData.assign(std::begin(n), std::end(n)); + } + }; + + //************************************************************************* + TEST(DefaultConstructor) + { + Data data; + + CHECK_EQUAL(data.size(), size_t(SIZE)); + CHECK_EQUAL(data.max_size(), SIZE); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Iterator) + { + bool isEqual = std::equal(data.begin(), + data.end(), + testData.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, ConstIterator) + { + bool isEqual = std::equal(data.cbegin(), + data.cend(), + testData.cbegin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, ReverseIterator) + { + bool isEqual = std::equal(data.rbegin(), + data.rend(), + testData.rbegin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, ConstReverseIterator) + { + bool isEqual = std::equal(data.crbegin(), + data.crend(), + testData.crbegin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST(Begin) + { + Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const Data constData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + CHECK_EQUAL(data.begin(), &data[0]); + CHECK_EQUAL(constData.cbegin(), &constData[0]); + } + + //************************************************************************* + TEST(End) + { + Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const Data constData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + CHECK_EQUAL(data.end(), &data[SIZE]); + CHECK_EQUAL(constData.cend(), &constData[SIZE]); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Indexing) + { + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], testData[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, IndexingConst) + { + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], testData[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, at) + { + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data.at(i), testData.at(i)); + } + + bool gotException = false; + + try + { + data.at(data.size()); + } + catch (etl::array_out_of_range_exception) + { + gotException = true; + } + + CHECK(gotException); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, AtConst) + { + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data.at(i), testData.at(i)); + } + + bool gotException = false; + + try + { + data.at(data.size()); + } + catch (etl::array_out_of_range_exception) + { + gotException = true; + } + + CHECK(gotException); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Front) + { + CHECK(data.front() == testData.front()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Back) + { + CHECK(data.back() == testData.back()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Assignment) + { + Data otherData; + + otherData = data; + + bool isEqual = std::equal(data.begin(), + data.end(), + otherData.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST(Fill) + { + Data data; + data.fill(1); + + TestData testData(data.max_size(), 1); + + bool isEqual = std::equal(data.begin(), + data.end(), + testData.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, DataAccess) + { + bool isEqual = std::equal(data.begin(), + data.end(), + data.data()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, Swap) + { + TestData testData2(initialData.begin() + 2, initialData.end()); + Data otherData; + std::copy(initialData.begin() + 2, initialData.end(), otherData.begin()); + + testData.swap(testData2); + + data.swap(otherData); + + bool isEqual = std::equal(testData.begin(), + testData.end(), + data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST(Equal) + { + const Data data1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const Data data2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data1 == data2); + + const Data data = { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data1 != data); + } + + //************************************************************************* + TEST(NotEqual) + { + const Data data1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const Data data2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data1 == data2); + + const Data data3 = { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data1 != data3); + } + + //************************************************************************* + TEST(GreaterThan) + { + const Data lesser = { 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 }; + const Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(lesser <= data); + + const Data greater = { 0, 1, 2, 3, 5, 5, 6, 7, 8, 9 }; + CHECK(greater > data); + } + + //************************************************************************* + TEST(LessThan) + { + const Data lesser = { 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 }; + const Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(lesser < data); + + const Data greater = { 0, 1, 2, 3, 5, 5, 6, 7, 8, 9 }; + CHECK(greater >= data); + } + + //************************************************************************* + TEST(GreaterThanEqual) + { + const Data lesser = { 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 }; + const Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(lesser < data); + + const Data greater = { 0, 1, 2, 3, 5, 5, 6, 7, 8, 9 }; + CHECK(greater >= data); + + const Data data2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data2 >= data); + } + + //************************************************************************* + TEST(LessThanEqual) + { + const Data lesser = { 0, 1, 2, 3, 4, 4, 6, 7, 8, 9 }; + const Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(lesser <= data); + + const Data greater = { 0, 1, 2, 3, 5, 5, 6, 7, 8, 9 }; + CHECK(greater > data); + + const Data data2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + CHECK(data2 <= data); + } + }; +} \ No newline at end of file diff --git a/test/vs2013/etl.sln b/test/vs2013/etl.sln new file mode 100644 index 00000000..81805c06 --- /dev/null +++ b/test/vs2013/etl.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.ActiveCfg = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.Build.0 = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.ActiveCfg = Release|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test/vs2013/etl.vcxproj b/test/vs2013/etl.vcxproj new file mode 100644 index 00000000..7a9a7907 --- /dev/null +++ b/test/vs2013/etl.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB} + Win32Proj + unittest + etl + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_USE_EXCEPTIONS;%(PreprocessorDefinitions) + ../../../unittest-cpp + + + Console + true + + + $(OutDir)\etl.exe + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + ../../../UnitTest++/src/ + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vs2013/etl.vcxproj.filters b/test/vs2013/etl.vcxproj.filters new file mode 100644 index 00000000..da206089 --- /dev/null +++ b/test/vs2013/etl.vcxproj.filters @@ -0,0 +1,195 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {ecfaf316-dc6d-4dc1-9838-24061047ad63} + + + {53c3a373-0496-4db0-a981-86bf14a1fac9} + + + {107d7e33-580f-4dc5-be11-a4b2076c2c10} + + + + + ETL + + + ETL + + + ETL + + + ETL + + + ETL + + + ETL + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++\Win32 + + + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++\Win32 + + + Source Files + + + Source Files + + + \ No newline at end of file