From 5e81e78985c24271526e613364118bd6ec4db919 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 19 Dec 2016 22:23:02 +0100 Subject: [PATCH] Use static_assert instead of unit test Signed-off-by: Sven Strickroth --- src/Git/gitindex.h | 5 +++++ src/Git/gittype.h | 5 +++++ test/UnitTests/GitByteArrayTest.cpp | 9 --------- test/UnitTests/GitIndexTest.cpp | 9 --------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/Git/gitindex.h b/src/Git/gitindex.h index a335cd7bd..300b7ac63 100644 --- a/src/Git/gitindex.h +++ b/src/Git/gitindex.h @@ -347,6 +347,11 @@ public: }; static const size_t NPOS = (size_t)-1; // bad/missing length/position +static_assert(MAXSIZE_T == NPOS, "NPOS must equal MAXSIZE_T"); +#pragma warning(push) +#pragma warning(disable: 4310) +static_assert(-1 == (int)NPOS, "NPOS must equal -1"); +#pragma warning(pop) template int GetRangeInSortVector(const T& vector, LPCTSTR pstr, size_t len, size_t* start, size_t* end, size_t pos) diff --git a/src/Git/gittype.h b/src/Git/gittype.h index f0a3cbe04..91a6fb869 100644 --- a/src/Git/gittype.h +++ b/src/Git/gittype.h @@ -88,6 +88,11 @@ public: memcpy(&*(begin()+oldsize),data,dataSize); } static const size_t npos = (size_t)-1; // bad/missing length/position + static_assert(MAXSIZE_T == npos, "NPOS must equal MAXSIZE_T"); +#pragma warning(push) +#pragma warning(disable: 4310) + static_assert(-1 == (int)npos, "NPOS must equal -1"); +#pragma warning(pop) }; class CGitGuardedByteArray : public CGitByteArray diff --git a/test/UnitTests/GitByteArrayTest.cpp b/test/UnitTests/GitByteArrayTest.cpp index f5cb4733c..0eda73b2f 100644 --- a/test/UnitTests/GitByteArrayTest.cpp +++ b/test/UnitTests/GitByteArrayTest.cpp @@ -20,15 +20,6 @@ #include "stdafx.h" #include "gittype.h" -TEST(CGitByteArray, ImplTest) -{ - EXPECT_EQ(MAXSIZE_T, CGitByteArray::npos); -#pragma warning(push) -#pragma warning(disable: 4310) - EXPECT_EQ(-1, (int)CGitByteArray::npos); -#pragma warning(pop) -} - TEST(CGitByteArray, Empty) { CGitByteArray byteArray; diff --git a/test/UnitTests/GitIndexTest.cpp b/test/UnitTests/GitIndexTest.cpp index 3082a10ae..9b4478ffc 100644 --- a/test/UnitTests/GitIndexTest.cpp +++ b/test/UnitTests/GitIndexTest.cpp @@ -215,15 +215,6 @@ TEST_P(GitIndexCBasicGitWithTestRepoFixture, GetFileStatus) EXPECT_EQ(git_wc_status_conflicted, status); } -TEST(GitIndex, ImplTest) -{ - EXPECT_EQ(MAXSIZE_T, NPOS); -#pragma warning(push) -#pragma warning(disable: 4310) - EXPECT_EQ(-1, (int)NPOS); -#pragma warning(pop) -} - TEST(GitIndex, SearchInSortVector) { std::vector vector; -- 2.11.4.GIT