re-introduce old nss im too tired for this

This commit is contained in:
wuggy 2026-06-30 06:37:32 +01:00
commit 3a838106b9
2871 changed files with 1374431 additions and 1762417 deletions

View file

@ -37,7 +37,6 @@
#endif // GTEST_OS_MAC
#include <list>
#include <memory>
#include <utility> // For std::pair and std::make_pair.
#include <vector>
@ -90,10 +89,10 @@ TEST(IsXDigitTest, ReturnsFalseForWideNonAscii) {
class Base {
public:
// Copy constructor and assignment operator do exactly what we need, so we
// use them.
Base() : member_(0) {}
explicit Base(int n) : member_(n) {}
Base(const Base&) = default;
Base& operator=(const Base&) = default;
virtual ~Base() {}
int member() { return member_; }
@ -201,13 +200,32 @@ TEST(ImplicitCastTest, CanUseImplicitConstructor) {
EXPECT_TRUE(converted);
}
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
TEST(IteratorTraitsTest, WorksForSTLContainerIterators) {
StaticAssertTypeEq<int,
IteratorTraits< ::std::vector<int>::const_iterator>::value_type>();
StaticAssertTypeEq<bool,
IteratorTraits< ::std::list<bool>::iterator>::value_type>();
}
TEST(IteratorTraitsTest, WorksForPointerToNonConst) {
StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>();
StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>();
}
TEST(IteratorTraitsTest, WorksForPointerToConst) {
StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>();
StaticAssertTypeEq<const void*,
IteratorTraits<const void* const*>::value_type>();
}
// Tests that the element_type typedef is available in scoped_ptr and refers
// to the parameter type.
TEST(ScopedPtrTest, DefinesElementType) {
StaticAssertTypeEq<int, ::testing::internal::scoped_ptr<int>::element_type>();
}
// FIXME: Implement THE REST of scoped_ptr tests.
TEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) {
if (AlwaysFalse())
GTEST_CHECK_(false) << "This should never be executed; "
@ -223,9 +241,6 @@ TEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) {
else
GTEST_CHECK_(true) << "";
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
switch (0) {
@ -247,9 +262,9 @@ TEST(FormatFileLocationTest, FormatsFileLocation) {
}
TEST(FormatFileLocationTest, FormatsUnknownFile) {
EXPECT_PRED_FORMAT2(IsSubstring, "unknown file",
FormatFileLocation(nullptr, 42));
EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(nullptr, 42));
EXPECT_PRED_FORMAT2(
IsSubstring, "unknown file", FormatFileLocation(NULL, 42));
EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(NULL, 42));
}
TEST(FormatFileLocationTest, FormatsUknownLine) {
@ -257,7 +272,7 @@ TEST(FormatFileLocationTest, FormatsUknownLine) {
}
TEST(FormatFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ("unknown file:", FormatFileLocation(nullptr, -1));
EXPECT_EQ("unknown file:", FormatFileLocation(NULL, -1));
}
// Verifies behavior of FormatCompilerIndependentFileLocation.
@ -267,7 +282,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {
EXPECT_EQ("unknown file:42",
FormatCompilerIndependentFileLocation(nullptr, 42));
FormatCompilerIndependentFileLocation(NULL, 42));
}
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
@ -275,17 +290,15 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
}
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1));
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1));
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
GTEST_OS_NETBSD || GTEST_OS_OPENBSD
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA
void* ThreadFunc(void* data) {
internal::Mutex* mutex = static_cast<internal::Mutex*>(data);
mutex->Lock();
mutex->Unlock();
return nullptr;
return NULL;
}
TEST(GetThreadCountTest, ReturnsCorrectValue) {
@ -373,14 +386,21 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {
#if GTEST_USES_POSIX_RE
# if GTEST_HAS_TYPED_TEST
template <typename Str>
class RETest : public ::testing::Test {};
// Defines StringTypes as the list of all string types that class RE
// supports.
typedef testing::Types< ::std::string, const char*> StringTypes;
typedef testing::Types<
::std::string,
# if GTEST_HAS_GLOBAL_STRING
::string,
# endif // GTEST_HAS_GLOBAL_STRING
const char*> StringTypes;
TYPED_TEST_SUITE(RETest, StringTypes);
TYPED_TEST_CASE(RETest, StringTypes);
// Tests RE's implicit constructors.
TYPED_TEST(RETest, ImplicitConstructorWorks) {
@ -428,6 +448,8 @@ TYPED_TEST(RETest, PartialMatchWorks) {
EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
}
# endif // GTEST_HAS_TYPED_TEST
#elif GTEST_USES_SIMPLE_RE
TEST(IsInSetTest, NulCharIsNotInAnySet) {
@ -943,7 +965,7 @@ TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {
EXPECT_EQ(0, t1.get());
ThreadLocal<void*> t2;
EXPECT_TRUE(t2.get() == nullptr);
EXPECT_TRUE(t2.get() == NULL);
}
TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
@ -993,7 +1015,7 @@ void AddTwo(int* param) { *param += 2; }
TEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) {
int i = 40;
ThreadWithParam<int*> thread(&AddTwo, &i, nullptr);
ThreadWithParam<int*> thread(&AddTwo, &i, NULL);
thread.Join();
EXPECT_EQ(42, i);
}
@ -1033,10 +1055,10 @@ class AtomicCounterWithMutex {
// functionality as we are testing them here.
pthread_mutex_t memory_barrier_mutex;
GTEST_CHECK_POSIX_SUCCESS_(
pthread_mutex_init(&memory_barrier_mutex, nullptr));
pthread_mutex_init(&memory_barrier_mutex, NULL));
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex));
SleepMilliseconds(static_cast<int>(random_.Generate(30)));
SleepMilliseconds(random_.Generate(30));
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex));
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex));
@ -1044,7 +1066,7 @@ class AtomicCounterWithMutex {
// On Windows, performing an interlocked access puts up a memory barrier.
volatile LONG dummy = 0;
::InterlockedIncrement(&dummy);
SleepMilliseconds(static_cast<int>(random_.Generate(30)));
SleepMilliseconds(random_.Generate(30));
::InterlockedIncrement(&dummy);
#else
# error "Memory barrier not implemented on this platform."
@ -1073,7 +1095,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
typedef ThreadWithParam<pair<AtomicCounterWithMutex*, int> > ThreadType;
const int kCycleCount = 20;
const int kThreadCount = 7;
std::unique_ptr<ThreadType> counting_threads[kThreadCount];
scoped_ptr<ThreadType> counting_threads[kThreadCount];
Notification threads_can_start;
// Creates and runs kThreadCount threads that increment locked_counter
// kCycleCount times each.
@ -1096,7 +1118,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
template <typename T>
void RunFromThread(void (func)(T), T param) {
ThreadWithParam<T> thread(func, param, nullptr);
ThreadWithParam<T> thread(func, param, NULL);
thread.Join();
}
@ -1186,6 +1208,8 @@ class DestructorTracker {
return DestructorCall::List().size() - 1;
}
const size_t index_;
GTEST_DISALLOW_ASSIGN_(DestructorTracker);
};
typedef ThreadLocal<DestructorTracker>* ThreadParam;
@ -1226,8 +1250,8 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
ASSERT_EQ(0U, DestructorCall::List().size());
// This creates another DestructorTracker object in the new thread.
ThreadWithParam<ThreadParam> thread(&CallThreadLocalGet,
&thread_local_tracker, nullptr);
ThreadWithParam<ThreadParam> thread(
&CallThreadLocalGet, &thread_local_tracker, NULL);
thread.Join();
// The thread has exited, and we should have a DestroyedTracker