summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
Diffstat (limited to 'AK')
-rw-r--r--AK/Atomic.h1
-rw-r--r--AK/Badge.h3
-rw-r--r--AK/Function.h4
-rw-r--r--AK/GenericLexer.cpp1
-rw-r--r--AK/HashFunctions.h2
-rw-r--r--AK/HashMap.h2
-rw-r--r--AK/IDAllocator.h6
-rw-r--r--AK/InlineLinkedList.h2
-rw-r--r--AK/JsonArray.h4
-rw-r--r--AK/JsonObject.h4
-rw-r--r--AK/LexicalPath.cpp6
-rw-r--r--AK/MACAddress.h6
-rw-r--r--AK/NonnullOwnPtrVector.h5
-rw-r--r--AK/NonnullRefPtrVector.h3
-rw-r--r--AK/Queue.h1
-rw-r--r--AK/RefPtr.h4
-rw-r--r--AK/Result.h9
-rw-r--r--AK/ScopeGuard.h2
-rw-r--r--AK/Singleton.h3
-rw-r--r--AK/SinglyLinkedListWithCount.h4
-rw-r--r--AK/Tests/TestAtomic.cpp578
-rw-r--r--AK/Tests/TestCircularDeque.cpp2
-rw-r--r--AK/Tests/TestOptional.cpp2
-rw-r--r--AK/Tests/TestQueue.cpp2
-rw-r--r--AK/Tests/TestRefPtr.cpp16
-rw-r--r--AK/Tests/TestStringUtils.cpp12
-rw-r--r--AK/Time.h4
-rw-r--r--AK/WeakPtr.h4
28 files changed, 347 insertions, 345 deletions
diff --git a/AK/Atomic.h b/AK/Atomic.h
index 7d7901bf95..365d6d31d9 100644
--- a/AK/Atomic.h
+++ b/AK/Atomic.h
@@ -85,7 +85,6 @@ template<typename T, typename V = typename RemoveVolatile<T>::Type>
return __atomic_compare_exchange_n(const_cast<V**>(var), &expected, nullptr, false, order, order);
}
-
template<typename T>
static inline T atomic_fetch_add(volatile T* var, T val, MemoryOrder order = memory_order_seq_cst) noexcept
{
diff --git a/AK/Badge.h b/AK/Badge.h
index 850b597370..a8e146f670 100644
--- a/AK/Badge.h
+++ b/AK/Badge.h
@@ -31,7 +31,7 @@ namespace AK {
template<typename T>
class Badge {
friend T;
- Badge() {}
+ Badge() { }
Badge(const Badge&) = delete;
Badge& operator=(const Badge&) = delete;
@@ -43,4 +43,3 @@ class Badge {
}
using AK::Badge;
-
diff --git a/AK/Function.h b/AK/Function.h
index bea6708ca5..61759acfb9 100644
--- a/AK/Function.h
+++ b/AK/Function.h
@@ -38,7 +38,7 @@ template<typename Out, typename... In>
class Function<Out(In...)> {
public:
Function() = default;
- Function(std::nullptr_t) {}
+ Function(std::nullptr_t) { }
template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::value>::Type>
Function(CallableType&& callable)
@@ -83,7 +83,7 @@ public:
private:
class CallableWrapperBase {
public:
- virtual ~CallableWrapperBase() {}
+ virtual ~CallableWrapperBase() { }
virtual Out call(In...) const = 0;
};
diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp
index d288809ab2..c5818f714b 100644
--- a/AK/GenericLexer.cpp
+++ b/AK/GenericLexer.cpp
@@ -276,7 +276,6 @@ void GenericLexer::ignore_until(Condition condition)
m_index++;
}
-
bool is_control(char c)
{
return (c >= 0 && c <= 31) || c == 127;
diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h
index ffa21a0190..757c43653e 100644
--- a/AK/HashFunctions.h
+++ b/AK/HashFunctions.h
@@ -53,7 +53,7 @@ inline unsigned u64_hash(u64 key)
inline unsigned ptr_hash(FlatPtr ptr)
{
- if constexpr(sizeof(ptr) == 8)
+ if constexpr (sizeof(ptr) == 8)
return u64_hash((u64)ptr);
else
return int_hash((u32)ptr);
diff --git a/AK/HashMap.h b/AK/HashMap.h
index dedd185655..33e982cb33 100644
--- a/AK/HashMap.h
+++ b/AK/HashMap.h
@@ -47,7 +47,7 @@ private:
};
public:
- HashMap() {}
+ HashMap() { }
bool is_empty() const { return m_table.is_empty(); }
size_t size() const { return m_table.size(); }
diff --git a/AK/IDAllocator.h b/AK/IDAllocator.h
index 04e967b465..e55a31cb0f 100644
--- a/AK/IDAllocator.h
+++ b/AK/IDAllocator.h
@@ -26,16 +26,16 @@
#pragma once
-#include <stdlib.h>
#include <AK/HashTable.h>
+#include <stdlib.h>
namespace AK {
class IDAllocator {
public:
- IDAllocator() {}
- ~IDAllocator() {}
+ IDAllocator() { }
+ ~IDAllocator() { }
int allocate()
{
diff --git a/AK/InlineLinkedList.h b/AK/InlineLinkedList.h
index 94c685737c..d40634e838 100644
--- a/AK/InlineLinkedList.h
+++ b/AK/InlineLinkedList.h
@@ -104,7 +104,7 @@ inline T* InlineLinkedListNode<T>::next() const
template<typename T>
class InlineLinkedList {
public:
- InlineLinkedList() {}
+ InlineLinkedList() { }
bool is_empty() const { return !m_head; }
size_t size_slow() const;
diff --git a/AK/JsonArray.h b/AK/JsonArray.h
index af8654f631..63ac74a4e0 100644
--- a/AK/JsonArray.h
+++ b/AK/JsonArray.h
@@ -34,8 +34,8 @@ namespace AK {
class JsonArray {
public:
- JsonArray() {}
- ~JsonArray() {}
+ JsonArray() { }
+ ~JsonArray() { }
JsonArray(const JsonArray& other)
: m_values(other.m_values)
diff --git a/AK/JsonObject.h b/AK/JsonObject.h
index 0e970cf560..2fe396c026 100644
--- a/AK/JsonObject.h
+++ b/AK/JsonObject.h
@@ -37,8 +37,8 @@ namespace AK {
class JsonObject {
public:
- JsonObject() {}
- ~JsonObject() {}
+ JsonObject() { }
+ ~JsonObject() { }
JsonObject(const JsonObject& other)
: m_order(other.m_order)
diff --git a/AK/LexicalPath.cpp b/AK/LexicalPath.cpp
index 6a7d2ff46e..a699b5aa8c 100644
--- a/AK/LexicalPath.cpp
+++ b/AK/LexicalPath.cpp
@@ -92,10 +92,10 @@ void LexicalPath::canonicalize()
Optional<size_t> last_dot = StringView(m_basename).find_last_of('.');
if (last_dot.has_value()) {
- m_title = m_basename.substring(0, last_dot.value());
- m_extension = m_basename.substring(last_dot.value() + 1, m_basename.length() - last_dot.value() - 1);
+ m_title = m_basename.substring(0, last_dot.value());
+ m_extension = m_basename.substring(last_dot.value() + 1, m_basename.length() - last_dot.value() - 1);
} else {
- m_title = m_basename;
+ m_title = m_basename;
}
StringBuilder builder(approximate_canonical_length);
diff --git a/AK/MACAddress.h b/AK/MACAddress.h
index 4de31bfcc8..e511da23f1 100644
--- a/AK/MACAddress.h
+++ b/AK/MACAddress.h
@@ -33,7 +33,7 @@
class [[gnu::packed]] MACAddress
{
public:
- MACAddress() {}
+ MACAddress() { }
MACAddress(const u8 data[6])
{
__builtin_memcpy(m_data, data, 6);
@@ -47,7 +47,7 @@ public:
m_data[4] = e;
m_data[5] = f;
}
- ~MACAddress() {}
+ ~MACAddress() { }
u8 operator[](int i) const
{
@@ -78,7 +78,7 @@ static_assert(sizeof(MACAddress) == 6);
namespace AK {
-template <>
+template<>
struct Traits<MACAddress> : public GenericTraits<MACAddress> {
static unsigned hash(const MACAddress& address) { return string_hash((const char*)&address, sizeof(address)); }
};
diff --git a/AK/NonnullOwnPtrVector.h b/AK/NonnullOwnPtrVector.h
index b5e440a4d5..ae4aca2954 100644
--- a/AK/NonnullOwnPtrVector.h
+++ b/AK/NonnullOwnPtrVector.h
@@ -26,14 +26,13 @@
#pragma once
-#include <AK/NonnullPtrVector.h>
#include <AK/NonnullOwnPtr.h>
+#include <AK/NonnullPtrVector.h>
namespace AK {
template<typename T, int inline_capacity = 0>
-class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, inline_capacity>
-{
+class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, inline_capacity> {
};
}
diff --git a/AK/NonnullRefPtrVector.h b/AK/NonnullRefPtrVector.h
index ca6898e1c0..9becc30165 100644
--- a/AK/NonnullRefPtrVector.h
+++ b/AK/NonnullRefPtrVector.h
@@ -32,8 +32,7 @@
namespace AK {
template<typename T, int inline_capacity = 0>
-class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, inline_capacity>
-{
+class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, inline_capacity> {
};
}
diff --git a/AK/Queue.h b/AK/Queue.h
index f686fab6e0..320c31e9c7 100644
--- a/AK/Queue.h
+++ b/AK/Queue.h
@@ -88,4 +88,3 @@ private:
}
using AK::Queue;
-
diff --git a/AK/RefPtr.h b/AK/RefPtr.h
index 394d786919..98ba2ff352 100644
--- a/AK/RefPtr.h
+++ b/AK/RefPtr.h
@@ -44,7 +44,7 @@ public:
Adopt
};
- RefPtr() {}
+ RefPtr() { }
RefPtr(const T* ptr)
: m_ptr(const_cast<T*>(ptr))
{
@@ -108,7 +108,7 @@ public:
m_ptr = (T*)(0xe0e0e0e0);
#endif
}
- RefPtr(std::nullptr_t) {}
+ RefPtr(std::nullptr_t) { }
template<typename U>
RefPtr(const OwnPtr<U>&) = delete;
diff --git a/AK/Result.h b/AK/Result.h
index fd0c3982b1..6c72163b19 100644
--- a/AK/Result.h
+++ b/AK/Result.h
@@ -32,7 +32,8 @@
namespace AK {
template<typename ValueType, typename ErrorType>
-class [[nodiscard]] Result {
+class [[nodiscard]] Result
+{
public:
Result(const ValueType& res)
: m_result(res)
@@ -50,13 +51,19 @@ public:
{
}
+ // FIXME: clang-format gets confused about Result. Why?
+ // clang-format off
Result(Result&& other)
+ // clang-format on
: m_result(move(other.m_result))
, m_error(move(other.m_error))
{
}
+ // FIXME: clang-format gets confused about Result. Why?
+ // clang-format off
Result(Result& other)
+ // clang-format on
: m_result(other.m_result)
, m_error(other.m_error)
{
diff --git a/AK/ScopeGuard.h b/AK/ScopeGuard.h
index b6b1892220..02d2821957 100644
--- a/AK/ScopeGuard.h
+++ b/AK/ScopeGuard.h
@@ -70,5 +70,5 @@ private:
}
-using AK::ScopeGuard;
using AK::ArmedScopeGuard;
+using AK::ScopeGuard;
diff --git a/AK/Singleton.h b/AK/Singleton.h
index 0abfa2b277..ae686a64d2 100644
--- a/AK/Singleton.h
+++ b/AK/Singleton.h
@@ -30,7 +30,7 @@
#include <AK/Atomic.h>
#include <AK/kmalloc.h>
#ifdef KERNEL
-#include <Kernel/Arch/i386/CPU.h>
+# include <Kernel/Arch/i386/CPU.h>
#endif
#ifndef __serenity__
@@ -51,6 +51,7 @@ template<typename T, T* (*InitFunction)() = SingletonInstanceCreator<T>::create>
class Singleton {
AK_MAKE_NONCOPYABLE(Singleton);
AK_MAKE_NONMOVABLE(Singleton);
+
public:
Singleton() = default;
diff --git a/AK/SinglyLinkedListWithCount.h b/AK/SinglyLinkedListWithCount.h
index 16087b5c6f..f46daa7a82 100644
--- a/AK/SinglyLinkedListWithCount.h
+++ b/AK/SinglyLinkedListWithCount.h
@@ -34,8 +34,8 @@ template<typename T>
class SinglyLinkedListWithCount : private SinglyLinkedList<T> {
public:
- SinglyLinkedListWithCount() {}
- ~SinglyLinkedListWithCount() {}
+ SinglyLinkedListWithCount() { }
+ ~SinglyLinkedListWithCount() { }
using List = SinglyLinkedList<T>;
diff --git a/AK/Tests/TestAtomic.cpp b/AK/Tests/TestAtomic.cpp
index 62fcab7b04..8a49baf875 100644
--- a/AK/Tests/TestAtomic.cpp
+++ b/AK/Tests/TestAtomic.cpp
@@ -30,335 +30,335 @@
TEST_CASE(construct_empty)
{
- EXPECT(Atomic<bool>().load() == false);
- EXPECT(Atomic<u32>().load() == 0);
- EXPECT(Atomic<u16>().load() == 0);
- EXPECT(Atomic<u8>().load() == 0);
-
- EXPECT(Atomic<u16*>().load() == nullptr);
+ EXPECT(Atomic<bool>().load() == false);
+ EXPECT(Atomic<u32>().load() == 0);
+ EXPECT(Atomic<u16>().load() == 0);
+ EXPECT(Atomic<u8>().load() == 0);
+
+ EXPECT(Atomic<u16*>().load() == nullptr);
}
TEST_CASE(construct_with_value)
{
- EXPECT(Atomic<bool>(false).load() == false);
- EXPECT(Atomic<bool>(true).load() == true);
- EXPECT(Atomic<u32>(2).load() == 2);
- EXPECT(Atomic<u16>(3).load() == 3);
- EXPECT(Atomic<u8>(4).load() == 4);
-
- u16 v_u16 = 0;
- EXPECT(Atomic<u16*>(&v_u16).load() == &v_u16);
+ EXPECT(Atomic<bool>(false).load() == false);
+ EXPECT(Atomic<bool>(true).load() == true);
+ EXPECT(Atomic<u32>(2).load() == 2);
+ EXPECT(Atomic<u16>(3).load() == 3);
+ EXPECT(Atomic<u8>(4).load() == 4);
+
+ u16 v_u16 = 0;
+ EXPECT(Atomic<u16*>(&v_u16).load() == &v_u16);
}
TEST_CASE(do_exchange)
{
- Atomic<bool> a_bool(false);
- EXPECT(a_bool.exchange(true) == false);
- EXPECT(a_bool.load() == true && static_cast<bool>(a_bool) == true);
-
- Atomic<u32> a_u32(2);
- EXPECT(a_u32.exchange(22) == 2);
- EXPECT(a_u32.load() == 22 && static_cast<u8>(a_u32) == 22);
-
- Atomic<u16> a_u16(3);
- EXPECT(a_u16.exchange(33) == 3);
- EXPECT(a_u16.load() == 33 && static_cast<u8>(a_u16) == 33);
-
- Atomic<u8> a_u8(4);
- EXPECT(a_u8.exchange(44) == 4);
- EXPECT(a_u8.load() == 44 && static_cast<u8>(a_u8) == 44);
-
- u16 v_u16[6];
- Atomic<u16*> a_pu16(&v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
+ Atomic<bool> a_bool(false);
+ EXPECT(a_bool.exchange(true) == false);
+ EXPECT(a_bool.load() == true && static_cast<bool>(a_bool) == true);
+
+ Atomic<u32> a_u32(2);
+ EXPECT(a_u32.exchange(22) == 2);
+ EXPECT(a_u32.load() == 22 && static_cast<u8>(a_u32) == 22);
+
+ Atomic<u16> a_u16(3);
+ EXPECT(a_u16.exchange(33) == 3);
+ EXPECT(a_u16.load() == 33 && static_cast<u8>(a_u16) == 33);
+
+ Atomic<u8> a_u8(4);
+ EXPECT(a_u8.exchange(44) == 4);
+ EXPECT(a_u8.load() == 44 && static_cast<u8>(a_u8) == 44);
+
+ u16 v_u16[6];
+ Atomic<u16*> a_pu16(&v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
}
TEST_CASE(do_compare_exchange)
{
- Atomic<bool> a_bool(false);
- bool e_bool = true;
- EXPECT(a_bool.compare_exchange_strong(e_bool, true) == false);
- EXPECT(e_bool == false);
- EXPECT(a_bool.load() == false && static_cast<bool>(a_bool) == false);
- e_bool = false;
- EXPECT(a_bool.compare_exchange_strong(e_bool, true) == true);
- EXPECT(a_bool.load() == true && static_cast<bool>(a_bool) == true);
-
- Atomic<u32> a_u32(2);
- u32 e_u32 = 99;
- EXPECT(a_u32.compare_exchange_strong(e_u32, 22) == false);
- EXPECT(e_u32 == 2);
- EXPECT(a_u32.load() == 2 && static_cast<u32>(a_u32) == 2);
- e_u32 = 2;
- EXPECT(a_u32.compare_exchange_strong(e_u32, 22) == true);
- EXPECT(a_u32.load() == 22 && static_cast<u32>(a_u32) == 22);
-
- Atomic<u16> a_u16(3);
- u16 e_u16 = 99;
- EXPECT(a_u16.compare_exchange_strong(e_u16, 33) == false);
- EXPECT(e_u16 == 3);
- EXPECT(a_u16.load() == 3 && static_cast<u16>(a_u16) == 3);
- e_u16 = 3;
- EXPECT(a_u16.compare_exchange_strong(e_u16, 33) == true);
- EXPECT(a_u16.load() == 33 && static_cast<u16>(a_u16) == 33);
-
- Atomic<u8> a_u8(4);
- u8 e_u8 = 99;
- EXPECT(a_u8.compare_exchange_strong(e_u8, 44) == false);
- EXPECT(e_u8 == 4);
- EXPECT(a_u8.load() == 4 && static_cast<u16>(a_u8) == 4);
- e_u8 = 4;
- EXPECT(a_u8.compare_exchange_strong(e_u8, 44) == true);
- EXPECT(a_u8.load() == 44 && static_cast<u16>(a_u8) == 44);
+ Atomic<bool> a_bool(false);
+ bool e_bool = true;
+ EXPECT(a_bool.compare_exchange_strong(e_bool, true) == false);
+ EXPECT(e_bool == false);
+ EXPECT(a_bool.load() == false && static_cast<bool>(a_bool) == false);
+ e_bool = false;
+ EXPECT(a_bool.compare_exchange_strong(e_bool, true) == true);
+ EXPECT(a_bool.load() == true && static_cast<bool>(a_bool) == true);
+
+ Atomic<u32> a_u32(2);
+ u32 e_u32 = 99;
+ EXPECT(a_u32.compare_exchange_strong(e_u32, 22) == false);
+ EXPECT(e_u32 == 2);
+ EXPECT(a_u32.load() == 2 && static_cast<u32>(a_u32) == 2);
+ e_u32 = 2;
+ EXPECT(a_u32.compare_exchange_strong(e_u32, 22) == true);
+ EXPECT(a_u32.load() == 22 && static_cast<u32>(a_u32) == 22);
+
+ Atomic<u16> a_u16(3);
+ u16 e_u16 = 99;
+ EXPECT(a_u16.compare_exchange_strong(e_u16, 33) == false);
+ EXPECT(e_u16 == 3);
+ EXPECT(a_u16.load() == 3 && static_cast<u16>(a_u16) == 3);
+ e_u16 = 3;
+ EXPECT(a_u16.compare_exchange_strong(e_u16, 33) == true);
+ EXPECT(a_u16.load() == 33 && static_cast<u16>(a_u16) == 33);
+
+ Atomic<u8> a_u8(4);
+ u8 e_u8 = 99;
+ EXPECT(a_u8.compare_exchange_strong(e_u8, 44) == false);
+ EXPECT(e_u8 == 4);
+ EXPECT(a_u8.load() == 4 && static_cast<u16>(a_u8) == 4);
+ e_u8 = 4;
+ EXPECT(a_u8.compare_exchange_strong(e_u8, 44) == true);
+ EXPECT(a_u8.load() == 44 && static_cast<u16>(a_u8) == 44);
}
TEST_CASE(fetch_add)
{
- Atomic<u32> a_u32(5);
- EXPECT(a_u32.fetch_add(2) == 5);
- EXPECT(a_u32.load() == 7 && static_cast<u32>(a_u32) == 7);
-
- Atomic<u16> a_u16(5);
- EXPECT(a_u16.fetch_add(2) == 5);
- EXPECT(a_u16.load() == 7 && static_cast<u16>(a_u16) == 7);
-
- Atomic<u8> a_u8(5);
- EXPECT(a_u8.fetch_add(2) == 5);
- EXPECT(a_u8.load() == 7 && static_cast<u8>(a_u8) == 7);
-
- u32 v_u32[6];
- Atomic<u32*> a_pu32(&v_u32[2]);
- EXPECT(a_pu32.load() == &v_u32[2] && static_cast<u32*>(a_pu32) == &v_u32[2]);
- EXPECT(a_pu32.fetch_add(2) == &v_u32[2]);
- EXPECT(a_pu32.load() == &v_u32[4] && static_cast<u32*>(a_pu32) == &v_u32[4]);
- EXPECT(a_pu32.fetch_add(-3) == &v_u32[4]);
- EXPECT(a_pu32.load() == &v_u32[1] && static_cast<u32*>(a_pu32) == &v_u32[1]);
-
- u16 v_u16[6];
- Atomic<u16*> a_pu16(&v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
- EXPECT(a_pu16.fetch_add(2) == &v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[4] && static_cast<u16*>(a_pu16) == &v_u16[4]);
- EXPECT(a_pu16.fetch_add(-3) == &v_u16[4]);
- EXPECT(a_pu16.load() == &v_u16[1] && static_cast<u16*>(a_pu16) == &v_u16[1]);
-
- u8 v_u8[6];
- Atomic<u8*> a_pu8(&v_u8[2]);
- EXPECT(a_pu8.load() == &v_u8[2] && static_cast<u8*>(a_pu8) == &v_u8[2]);
- EXPECT(a_pu8.fetch_add(2) == &v_u8[2]);
- EXPECT(a_pu8.load() == &v_u8[4] && static_cast<u8*>(a_pu8) == &v_u8[4]);
- EXPECT(a_pu8.fetch_add(-3) == &v_u8[4]);
- EXPECT(a_pu8.load() == &v_u8[1] && static_cast<u8*>(a_pu8) == &v_u8[1]);
+ Atomic<u32> a_u32(5);
+ EXPECT(a_u32.fetch_add(2) == 5);
+ EXPECT(a_u32.load() == 7 && static_cast<u32>(a_u32) == 7);
+
+ Atomic<u16> a_u16(5);
+ EXPECT(a_u16.fetch_add(2) == 5);
+ EXPECT(a_u16.load() == 7 && static_cast<u16>(a_u16) == 7);
+
+ Atomic<u8> a_u8(5);
+ EXPECT(a_u8.fetch_add(2) == 5);
+ EXPECT(a_u8.load() == 7 && static_cast<u8>(a_u8) == 7);
+
+ u32 v_u32[6];
+ Atomic<u32*> a_pu32(&v_u32[2]);
+ EXPECT(a_pu32.load() == &v_u32[2] && static_cast<u32*>(a_pu32) == &v_u32[2]);
+ EXPECT(a_pu32.fetch_add(2) == &v_u32[2]);
+ EXPECT(a_pu32.load() == &v_u32[4] && static_cast<u32*>(a_pu32) == &v_u32[4]);
+ EXPECT(a_pu32.fetch_add(-3) == &v_u32[4]);
+ EXPECT(a_pu32.load() == &v_u32[1] && static_cast<u32*>(a_pu32) == &v_u32[1]);
+
+ u16 v_u16[6];
+ Atomic<u16*> a_pu16(&v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
+ EXPECT(a_pu16.fetch_add(2) == &v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[4] && static_cast<u16*>(a_pu16) == &v_u16[4]);
+ EXPECT(a_pu16.fetch_add(-3) == &v_u16[4]);
+ EXPECT(a_pu16.load() == &v_u16[1] && static_cast<u16*>(a_pu16) == &v_u16[1]);
+
+ u8 v_u8[6];
+ Atomic<u8*> a_pu8(&v_u8[2]);
+ EXPECT(a_pu8.load() == &v_u8[2] && static_cast<u8*>(a_pu8) == &v_u8[2]);
+ EXPECT(a_pu8.fetch_add(2) == &v_u8[2]);
+ EXPECT(a_pu8.load() == &v_u8[4] && static_cast<u8*>(a_pu8) == &v_u8[4]);
+ EXPECT(a_pu8.fetch_add(-3) == &v_u8[4]);
+ EXPECT(a_pu8.load() == &v_u8[1] && static_cast<u8*>(a_pu8) == &v_u8[1]);
}
TEST_CASE(fetch_sub)
{
- Atomic<u32> a_u32(5);
- EXPECT(a_u32.fetch_sub(2) == 5);
- EXPECT(a_u32.load() == 3 && static_cast<u32>(a_u32) == 3);
-
- Atomic<u16> a_u16(5);
- EXPECT(a_u16.fetch_sub(2) == 5);
- EXPECT(a_u16.load() == 3 && static_cast<u16>(a_u16) == 3);
-
- Atomic<u8> a_u8(5);
- EXPECT(a_u8.fetch_sub(2) == 5);
- EXPECT(a_u8.load() == 3 && static_cast<u8>(a_u8) == 3);
-
- u32 v_u32[6];
- Atomic<u32*> a_pu32(&v_u32[2]);
- EXPECT(a_pu32.load() == &v_u32[2] && static_cast<u32*>(a_pu32) == &v_u32[2]);
- EXPECT(a_pu32.fetch_sub(2) == &v_u32[2]);
- EXPECT(a_pu32.load() == &v_u32[0] && static_cast<u32*>(a_pu32) == &v_u32[0]);
- EXPECT(a_pu32.fetch_sub(-3) == &v_u32[0]);
- EXPECT(a_pu32.load() == &v_u32[3] && static_cast<u32*>(a_pu32) == &v_u32[3]);
-
- u16 v_u16[6];
- Atomic<u16*> a_pu16(&v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
- EXPECT(a_pu16.fetch_sub(2) == &v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[0] && static_cast<u16*>(a_pu16) == &v_u16[0]);
- EXPECT(a_pu16.fetch_sub(-3) == &v_u16[0]);
- EXPECT(a_pu16.load() == &v_u16[3] && static_cast<u16*>(a_pu16) == &v_u16[3]);
-
- u8 v_u8[6];
- Atomic<u8*> a_pu8(&v_u8[2]);
- EXPECT(a_pu8.load() == &v_u8[2] && static_cast<u8*>(a_pu8) == &v_u8[2]);
- EXPECT(a_pu8.fetch_sub(2) == &v_u8[2]);
- EXPECT(a_pu8.load() == &v_u8[0] && static_cast<u8*>(a_pu8) == &v_u8[0]);
- EXPECT(a_pu8.fetch_sub(-3) == &v_u8[0]);
- EXPECT(a_pu8.load() == &v_u8[3] && static_cast<u8*>(a_pu8) == &v_u8[3]);
+ Atomic<u32> a_u32(5);
+ EXPECT(a_u32.fetch_sub(2) == 5);
+ EXPECT(a_u32.load() == 3 && static_cast<u32>(a_u32) == 3);
+
+ Atomic<u16> a_u16(5);
+ EXPECT(a_u16.fetch_sub(2) == 5);
+ EXPECT(a_u16.load() == 3 && static_cast<u16>(a_u16) == 3);
+
+ Atomic<u8> a_u8(5);
+ EXPECT(a_u8.fetch_sub(2) == 5);
+ EXPECT(a_u8.load() == 3 && static_cast<u8>(a_u8) == 3);
+
+ u32 v_u32[6];
+ Atomic<u32*> a_pu32(&v_u32[2]);
+ EXPECT(a_pu32.load() == &v_u32[2] && static_cast<u32*>(a_pu32) == &v_u32[2]);
+ EXPECT(a_pu32.fetch_sub(2) == &v_u32[2]);
+ EXPECT(a_pu32.load() == &v_u32[0] && static_cast<u32*>(a_pu32) == &v_u32[0]);
+ EXPECT(a_pu32.fetch_sub(-3) == &v_u32[0]);
+ EXPECT(a_pu32.load() == &v_u32[3] && static_cast<u32*>(a_pu32) == &v_u32[3]);
+
+ u16 v_u16[6];
+ Atomic<u16*> a_pu16(&v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[2] && static_cast<u16*>(a_pu16) == &v_u16[2]);
+ EXPECT(a_pu16.fetch_sub(2) == &v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[0] && static_cast<u16*>(a_pu16) == &v_u16[0]);
+ EXPECT(a_pu16.fetch_sub(-3) == &v_u16[0]);
+ EXPECT(a_pu16.load() == &v_u16[3] && static_cast<u16*>(a_pu16) == &v_u16[3]);
+
+ u8 v_u8[6];
+ Atomic<u8*> a_pu8(&v_u8[2]);
+ EXPECT(a_pu8.load() == &v_u8[2] && static_cast<u8*>(a_pu8) == &v_u8[2]);
+ EXPECT(a_pu8.fetch_sub(2) == &v_u8[2]);
+ EXPECT(a_pu8.load() == &v_u8[0] && static_cast<u8*>(a_pu8) == &v_u8[0]);
+ EXPECT(a_pu8.fetch_sub(-3) == &v_u8[0]);
+ EXPECT(a_pu8.load() == &v_u8[3] && static_cast<u8*>(a_pu8) == &v_u8[3]);
}
TEST_CASE(fetch_inc)
{
- Atomic<u32> a_u32(5);
- EXPECT(a_u32++ == 5);
- EXPECT(a_u32.load() == 6 && a_u32 == 6);
- EXPECT(++a_u32 == 7);
- EXPECT(a_u32.load() == 7 && a_u32 == 7);
- EXPECT((a_u32 += 2) == 9);
- EXPECT(a_u32.load() == 9 && a_u32 == 9);
-
- Atomic<u16> a_u16(5);
- EXPECT(a_u16++ == 5);
- EXPECT(a_u16.load() == 6 && a_u16 == 6);
- EXPECT(++a_u16 == 7);
- EXPECT(a_u16.load() == 7 && a_u16 == 7);
- EXPECT((a_u16 += 2) == 9);
- EXPECT(a_u16.load() == 9 && a_u16 == 9);
-
- Atomic<u8> a_u8(5);
- EXPECT(a_u8++ == 5);
- EXPECT(a_u8.load() == 6 && a_u8 == 6);
- EXPECT(++a_u8 == 7);
- EXPECT(a_u8.load() == 7 && a_u8 == 7);
- EXPECT((a_u8 += 2) == 9);
- EXPECT(a_u8.load() == 9 && a_u8 == 9);
-
- u32 v_u32[8];
- Atomic<u32*> a_pu32(&v_u32[2]);
- EXPECT(a_pu32++ == &v_u32[2]);
- EXPECT(a_pu32.load() == &v_u32[3] && a_pu32 == &v_u32[3]);
- EXPECT(++a_pu32 == &v_u32[4]);
- EXPECT(a_pu32.load() == &v_u32[4] && a_pu32 == &v_u32[4]);
- EXPECT((a_pu32 += 2) == &v_u32[6]);
- EXPECT(a_pu32.load() == &v_u32[6] && a_pu32 == &v_u32[6]);
-
- u16 v_u16[8];
- Atomic<u16*> a_pu16(&v_u16[2]);
- EXPECT(a_pu16++ == &v_u16[2]);
- EXPECT(a_pu16.load() == &v_u16[3] && a_pu16 == &v_u16[3]);
- EXPECT(++a_pu16 == &v_u16[4]);
- EXPECT(a_pu16.load() == &v_u16[4] && a_pu16 == &v_u16[4]);
- EXPECT((a_pu16 += 2) == &v_u16[6]);
- EXPECT(a_pu16.load() == &v_u16[6] && a_pu16 == &v_u16[6]);
-
- u8 v_u8[8];
- Atomic<u8*> a_pu8(&v_u8[2]);
- EXPECT(a_pu8++ == &v_u8[2]);
- EXPECT(a_pu8.load() == &v_u8[3] && a_pu8 == &v_u8[3]);
- EXPECT(++a_pu8 == &v_u8[4]);
- EXPECT(a_pu8.load() == &v_u8[4] && a_pu8 == &v_u8[4]);
- EXPECT((a_pu8 += 2) == &v_u8[6]);
- EXPECT(a_pu8.load() == &v_u8[6] && a_pu8 == &v_u8[6]);
+ Atomic<u32> a_u32(5);
+ EXPECT(a_u32++ == 5);
+ EXPECT(a_u32.load() == 6 && a_u32 == 6);
+ EXPECT(++a_u32 == 7);
+ EXPECT(a_u32.load() == 7 && a_u32 == 7);
+ EXPECT((a_u32 += 2) == 9);
+ EXPECT(a_u32.load() == 9 && a_u32 == 9);
+
+ Atomic<u16> a_u16(5);
+ EXPECT(a_u16++ == 5);
+ EXPECT(a_u16.load() == 6 && a_u16 == 6);
+ EXPECT(++a_u16 == 7);
+ EXPECT(a_u16.load() == 7 && a_u16 == 7);
+ EXPECT((a_u16 += 2) == 9);
+ EXPECT(a_u16.load() == 9 && a_u16 == 9);
+
+ Atomic<u8> a_u8(5);
+ EXPECT(a_u8++ == 5);
+ EXPECT(a_u8.load() == 6 && a_u8 == 6);
+ EXPECT(++a_u8 == 7);
+ EXPECT(a_u8.load() == 7 && a_u8 == 7);
+ EXPECT((a_u8 += 2) == 9);
+ EXPECT(a_u8.load() == 9 && a_u8 == 9);
+
+ u32 v_u32[8];
+ Atomic<u32*> a_pu32(&v_u32[2]);
+ EXPECT(a_pu32++ == &v_u32[2]);
+ EXPECT(a_pu32.load() == &v_u32[3] && a_pu32 == &v_u32[3]);
+ EXPECT(++a_pu32 == &v_u32[4]);
+ EXPECT(a_pu32.load() == &v_u32[4] && a_pu32 == &v_u32[4]);
+ EXPECT((a_pu32 += 2) == &v_u32[6]);
+ EXPECT(a_pu32.load() == &v_u32[6] && a_pu32 == &v_u32[6]);
+
+ u16 v_u16[8];
+ Atomic<u16*> a_pu16(&v_u16[2]);
+ EXPECT(a_pu16++ == &v_u16[2]);
+ EXPECT(a_pu16.load() == &v_u16[3] && a_pu16 == &v_u16[3]);
+ EXPECT(++a_pu16 == &v_u16[4]);
+ EXPECT(a_pu16.load() == &v_u16[4] && a_pu16 == &v_u16[4]);
+ EXPECT((a_pu16 += 2) == &v_u16[6]);
+ EXPECT(a_pu16.load() == &v_u16[6] && a_pu16 == &v_u16[6]);
+
+ u8 v_u8[8];
+ Atomic<u8*> a_pu8(&v_u8[2]);
+ EXPECT(a_pu8++ == &v_u8[2]);
+ EXPECT(a_pu8.load() == &v_u8[3] && a_pu8 == &v_u8[3]);
+ EXPECT(++a_pu8 == &v_u8[4]);
+ EXPECT(a_pu8.load() == &v_u8[4] && a_pu8 == &v_u8[4]);
+ EXPECT((a_pu8 += 2) == &v_u8[6]);
+ EXPECT(a_pu8.load() == &v_u8[6] && a_pu8 == &v_u8[6]);
}
TEST_CASE(fetch_dec)
{
- Atomic<u32> a_u32(5);
- EXPECT(a_u32-- == 5);
- EXPECT(a_u32.load() == 4 && a_u32 == 4);
- EXPECT(--a_u32 == 3);
- EXPECT(a_u32.load() == 3 && a_u32 == 3);
- EXPECT((a_u32 -= 2) == 1);
- EXPECT(a_u32.load() == 1 && a_u32 == 1);
-
- Atomic<u16> a_u16(5);
- EXPECT(a_u16-- == 5);
- EXPECT(a_u16.load() == 4 && a_u16 == 4);
- EXPECT(--a_u16 == 3);
- EXPECT(a_u16.load() == 3 && a_u16 == 3);
- EXPECT((a_u16 -= 2) == 1);
- EXPECT(a_u16.load() == 1 && a_u16 == 1);
-
- Atomic<u8> a_u8(5);
- EXPECT(a_u8-- == 5);
- EXPECT(a_u8.load() == 4 && a_u8 == 4);
- EXPECT(--a_u8 == 3);
- EXPECT(a_u8.load() == 3 && a_u8 == 3);
- EXPECT((a_u8 -= 2) == 1);
- EXPECT(a_u8.load() == 1 && a_u8 == 1);
-
- u32 v_u32[8];
- Atomic<u32*> a_pu32(&v_u32[7]);
- EXPECT(a_pu32-- == &v_u32[7]);
- EXPECT(a_pu32.load() == &v_u32[6] && a_pu32 == &v_u32[6]);
- EXPECT(--a_pu32 == &v_u32[5]);
- EXPECT(a_pu32.load() == &v_u32[5] && a_pu32 == &v_u32[5]);
- EXPECT((a_pu32 -= 2) == &v_u32[3]);
- EXPECT(a_pu32.load() == &v_u32[3] && a_pu32 == &v_u32[3]);
-
- u16 v_u16[8];
- Atomic<u16*> a_pu16(&v_u16[7]);
- EXPECT(a_pu16-- == &v_u16[7]);
- EXPECT(a_pu16.load() == &v_u16[6] && a_pu16 == &v_u16[6]);
- EXPECT(--a_pu16 == &v_u16[5]);
- EXPECT(a_pu16.load() == &v_u16[5] && a_pu16 == &v_u16[5]);
- EXPECT((a_pu16 -= 2) == &v_u16[3]);
- EXPECT(a_pu16.load() == &v_u16[3] && a_pu16 == &v_u16[3]);
-
- u8 v_u8[8];
- Atomic<u8*> a_pu8(&v_u8[7]);
- EXPECT(a_pu8-- == &v_u8[7]);
- EXPECT(a_pu8.load() == &v_u8[6] && a_pu8 == &v_u8[6]);
- EXPECT(--a_pu8 == &v_u8[5]);
- EXPECT(a_pu8.load() == &v_u8[5] && a_pu8 == &v_u8[5]);
- EXPECT((a_pu8 -= 2) == &v_u8[3]);
- EXPECT(a_pu8.load() == &v_u8[3] && a_pu8 == &v_u8[3]);
+ Atomic<u32> a_u32(5);
+ EXPECT(a_u32-- == 5);
+ EXPECT(a_u32.load() == 4 && a_u32 == 4);
+ EXPECT(--a_u32 == 3);
+ EXPECT(a_u32.load() == 3 && a_u32 == 3);
+ EXPECT((a_u32 -= 2) == 1);
+ EXPECT(a_u32.load() == 1 && a_u32 == 1);
+
+ Atomic<u16> a_u16(5);
+ EXPECT(a_u16-- == 5);
+ EXPECT(a_u16.load() == 4 && a_u16 == 4);
+ EXPECT(--a_u16 == 3);
+ EXPECT(a_u16.load() == 3 && a_u16 == 3);
+ EXPECT((a_u16 -= 2) == 1);
+ EXPECT(a_u16.load() == 1 && a_u16 == 1);
+
+ Atomic<u8> a_u8(5);
+ EXPECT(a_u8-- == 5);
+ EXPECT(a_u8.load() == 4 && a_u8 == 4);
+ EXPECT(--a_u8 == 3);
+ EXPECT(a_u8.load() == 3 && a_u8 == 3);
+ EXPECT((a_u8 -= 2) == 1);
+ EXPECT(a_u8.load() == 1 && a_u8 == 1);
+
+ u32 v_u32[8];
+ Atomic<u32*> a_pu32(&v_u32[7]);
+ EXPECT(a_pu32-- == &v_u32[7]);
+ EXPECT(a_pu32.load() == &v_u32[6] && a_pu32 == &v_u32[6]);
+ EXPECT(--a_pu32 == &v_u32[5]);
+ EXPECT(a_pu32.load() == &v_u32[5] && a_pu32 == &v_u32[5]);
+ EXPECT((a_pu32 -= 2) == &v_u32[3]);
+ EXPECT(a_pu32.load() == &v_u32[3] && a_pu32 == &v_u32[3]);
+
+ u16 v_u16[8];
+ Atomic<u16*> a_pu16(&v_u16[7]);
+ EXPECT(a_pu16-- == &v_u16[7]);
+ EXPECT(a_pu16.load() == &v_u16[6] && a_pu16 == &v_u16[6]);
+ EXPECT(--a_pu16 == &v_u16[5]);
+ EXPECT(a_pu16.load() == &v_u16[5] && a_pu16 == &v_u16[5]);
+ EXPECT((a_pu16 -= 2) == &v_u16[3]);
+ EXPECT(a_pu16.load() == &v_u16[3] && a_pu16 == &v_u16[3]);
+
+ u8 v_u8[8];
+ Atomic<u8*> a_pu8(&v_u8[7]);
+ EXPECT(a_pu8-- == &v_u8[7]);
+ EXPECT(a_pu8.load() == &v_u8[6] && a_pu8 == &v_u8[6]);
+ EXPECT(--a_pu8 == &v_u8[5]);
+ EXPECT(a_pu8.load() == &v_u8[5] && a_pu8 == &v_u8[5]);
+ EXPECT((a_pu8 -= 2) == &v_u8[3]);
+ EXPECT(a_pu8.load() == &v_u8[3] && a_pu8 == &v_u8[3]);
}
TEST_CASE(fetch_and)
{
- Atomic<u32> a_u32(0xdeadbeef);
- EXPECT(a_u32.fetch_and(0x8badf00d) == 0xdeadbeef);
- EXPECT(a_u32.load() == 0x8aadb00d && static_cast<u32>(a_u32) == 0x8aadb00d);
- a_u32 = 0xdeadbeef;
- EXPECT((a_u32 &= 0x8badf00d) == 0x8aadb00d);
-
- Atomic<u16> a_u16(0xbeef);
- EXPECT(a_u16.fetch_and(0xf00d) == 0xbeef);
- EXPECT(a_u16.load() == 0xb00d && static_cast<u16>(a_u16) == 0xb00d);
- a_u16 = 0xbeef;
- EXPECT((a_u16 &= 0xf00d) == 0xb00d);
-
- Atomic<u8> a_u8(0xef);
- EXPECT(a_u8.fetch_and(0x0d) == 0xef);
- EXPECT(a_u8.load() == 0x0d && static_cast<u8>(a_u8) == 0x0d);
- a_u8 = 0xef;
- EXPECT((a_u8 &= 0x0d) == 0x0d);
+ Atomic<u32> a_u32(0xdeadbeef);
+ EXPECT(a_u32.fetch_and(0x8badf00d) == 0xdeadbeef);
+ EXPECT(a_u32.load() == 0x8aadb00d && static_cast<u32>(a_u32) == 0x8aadb00d);
+ a_u32 = 0xdeadbeef;
+ EXPECT((a_u32 &= 0x8badf00d) == 0x8aadb00d);
+
+ Atomic<u16> a_u16(0xbeef);
+ EXPECT(a_u16.fetch_and(0xf00d) == 0xbeef);
+ EXPECT(a_u16.load() == 0xb00d && static_cast<u16>(a_u16) == 0xb00d);
+ a_u16 = 0xbeef;
+ EXPECT((a_u16 &= 0xf00d) == 0xb00d);
+
+ Atomic<u8> a_u8(0xef);
+ EXPECT(a_u8.fetch_and(0x0d) == 0xef);
+ EXPECT(a_u8.load() == 0x0d && static_cast<u8>(a_u8) == 0x0d);
+ a_u8 = 0xef;
+ EXPECT((a_u8 &= 0x0d) == 0x0d);
}
TEST_CASE(fetch_or)
{
- Atomic<u32> a_u32(0xaadb00d);
- EXPECT(a_u32.fetch_or(0xdeadbeef) == 0xaadb00d);
- EXPECT(a_u32.load() == 0xdeadbeef && static_cast<u32>(a_u32) == 0xdeadbeef);
- a_u32 = 0xaadb00d;
- EXPECT((a_u32 |= 0xdeadbeef) == 0xdeadbeef);
-
- Atomic<u16> a_u16(0xb00d);
- EXPECT(a_u16.fetch_or(0xbeef) == 0xb00d);
- EXPECT(a_u16.load() == 0xbeef && static_cast<u16>(a_u16) == 0xbeef);
- a_u16 = 0xb00d;
- EXPECT((a_u16 |= 0xbeef) == 0xbeef);
-
- Atomic<u8> a_u8(0x0d);
- EXPECT(a_u8.fetch_or(0xef) == 0x0d);
- EXPECT(a_u8.load() == 0xef && static_cast<u8>(a_u8) == 0xef);
- a_u8 = 0x0d;
- EXPECT((a_u8 |= 0xef) == 0xef);
+ Atomic<u32> a_u32(0xaadb00d);
+ EXPECT(a_u32.fetch_or(0xdeadbeef) == 0xaadb00d);
+ EXPECT(a_u32.load() == 0xdeadbeef && static_cast<u32>(a_u32) == 0xdeadbeef);
+ a_u32 = 0xaadb00d;
+ EXPECT((a_u32 |= 0xdeadbeef) == 0xdeadbeef);
+
+ Atomic<u16> a_u16(0xb00d);
+ EXPECT(a_u16.fetch_or(0xbeef) == 0xb00d);
+ EXPECT(a_u16.load() == 0xbeef && static_cast<u16>(a_u16) == 0xbeef);
+ a_u16 = 0xb00d;
+ EXPECT((a_u16 |= 0xbeef) == 0xbeef);
+
+ Atomic<u8> a_u8(0x0d);
+ EXPECT(a_u8.fetch_or(0xef) == 0x0d);
+ EXPECT(a_u8.load() == 0xef && static_cast<u8>(a_u8) == 0xef);
+ a_u8 = 0x0d;
+ EXPECT((a_u8 |= 0xef) == 0xef);
}
TEST_CASE(fetch_xor)
{
- Atomic<u32> a_u32(0x55004ee2);
- EXPECT(a_u32.fetch_xor(0xdeadbeef) == 0x55004ee2);
- EXPECT(a_u32.load() == 0x8badf00d && static_cast<u32>(a_u32) == 0x8badf00d);
- a_u32 = 0x55004ee2;
- EXPECT((a_u32 ^= 0xdeadbeef) == 0x8badf00d);
-
- Atomic<u16> a_u16(0x4ee2);
- EXPECT(a_u16.fetch_xor(0xbeef) == 0x4ee2);
- EXPECT(a_u16.load() == 0xf00d && static_cast<u16>(a_u16) == 0xf00d);
- a_u16 = 0x4ee2;
- EXPECT((a_u16 ^= 0xbeef) == 0xf00d);
-
- Atomic<u8> a_u8(0xe2);
- EXPECT(a_u8.fetch_xor(0xef) == 0xe2);
- EXPECT(a_u8.load() == 0x0d && static_cast<u8>(a_u8) == 0x0d);
- a_u8 = 0xe2;
- EXPECT((a_u8 ^= 0xef) == 0x0d);
+ Atomic<u32> a_u32(0x55004ee2);
+ EXPECT(a_u32.fetch_xor(0xdeadbeef) == 0x55004ee2);
+ EXPECT(a_u32.load() == 0x8badf00d && static_cast<u32>(a_u32) == 0x8badf00d);
+ a_u32 = 0x55004ee2;
+ EXPECT((a_u32 ^= 0xdeadbeef) == 0x8badf00d);
+
+ Atomic<u16> a_u16(0x4ee2);
+ EXPECT(a_u16.fetch_xor(0xbeef) == 0x4ee2);
+ EXPECT(a_u16.load() == 0xf00d && static_cast<u16>(a_u16) == 0xf00d);
+ a_u16 = 0x4ee2;
+ EXPECT((a_u16 ^= 0xbeef) == 0xf00d);
+
+ Atomic<u8> a_u8(0xe2);
+ EXPECT(a_u8.fetch_xor(0xef) == 0xe2);
+ EXPECT(a_u8.load() == 0x0d && static_cast<u8>(a_u8) == 0x0d);
+ a_u8 = 0xe2;
+ EXPECT((a_u8 ^= 0xef) == 0x0d);
}
TEST_MAIN(Atomic)
diff --git a/AK/Tests/TestCircularDeque.cpp b/AK/Tests/TestCircularDeque.cpp
index 7a9d7070b1..7263d12b89 100644
--- a/AK/Tests/TestCircularDeque.cpp
+++ b/AK/Tests/TestCircularDeque.cpp
@@ -59,7 +59,7 @@ TEST_CASE(enqueue_begin_being_moved_from)
{
CircularDeque<String, 2> strings;
- String str{"test"};
+ String str { "test" };
strings.enqueue_begin(move(str));
EXPECT(str.is_null());
}
diff --git a/AK/Tests/TestOptional.cpp b/AK/Tests/TestOptional.cpp
index 8128249dd1..76b3bf2676 100644
--- a/AK/Tests/TestOptional.cpp
+++ b/AK/Tests/TestOptional.cpp
@@ -26,8 +26,8 @@
#include <AK/TestSuite.h>
-#include <AK/String.h>
#include <AK/Optional.h>
+#include <AK/String.h>
TEST_CASE(basic_optional)
{
diff --git a/AK/Tests/TestQueue.cpp b/AK/Tests/TestQueue.cpp
index 4ddaba9511..0142324ec2 100644
--- a/AK/Tests/TestQueue.cpp
+++ b/AK/Tests/TestQueue.cpp
@@ -26,8 +26,8 @@
#include <AK/TestSuite.h>
-#include <AK/String.h>
#include <AK/Queue.h>
+#include <AK/String.h>
TEST_CASE(construct)
{
diff --git a/AK/Tests/TestRefPtr.cpp b/AK/Tests/TestRefPtr.cpp
index 5208dc03ad..93261ce2e0 100644
--- a/AK/Tests/TestRefPtr.cpp
+++ b/AK/Tests/TestRefPtr.cpp
@@ -80,14 +80,14 @@ TEST_CASE(assign_copy_self)
RefPtr<Object> object = adopt(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
- #ifdef __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wself-assign-overloaded"
- #endif
- object = object;
- #ifdef __clang__
- #pragma clang diagnostic pop
- #endif
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wself-assign-overloaded"
+#endif
+ object = object;
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
EXPECT_EQ(object->ref_count(), 1u);
}
diff --git a/AK/Tests/TestStringUtils.cpp b/AK/Tests/TestStringUtils.cpp
index d2a18d48df..a34c91c253 100644
--- a/AK/Tests/TestStringUtils.cpp
+++ b/AK/Tests/TestStringUtils.cpp
@@ -157,22 +157,22 @@ TEST_CASE(ends_with)
{
String test_string = "ABCDEF";
EXPECT(AK::StringUtils::ends_with(test_string, "DEF", CaseSensitivity::CaseSensitive));
- EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive));
+ EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE", CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDEFG", CaseSensitivity::CaseSensitive));
- EXPECT(AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseInsensitive));
- EXPECT(!AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseSensitive));
+ EXPECT(AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseInsensitive));
+ EXPECT(!AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseSensitive));
}
TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
EXPECT(AK::StringUtils::starts_with(test_string, "ABC", CaseSensitivity::CaseSensitive));
- EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive));
+ EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::starts_with(test_string, "BCDEF", CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::starts_with(test_string, "ABCDEFG", CaseSensitivity::CaseSensitive));
- EXPECT(AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseInsensitive));
- EXPECT(!AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseSensitive));
+ EXPECT(AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseInsensitive));
+ EXPECT(!AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseSensitive));
}
TEST_MAIN(StringUtils)
diff --git a/AK/Time.h b/AK/Time.h
index e1475033d4..a919f36f5e 100644
--- a/AK/Time.h
+++ b/AK/Time.h
@@ -133,8 +133,8 @@ inline void timespec_add_timeval(const TimespecType& a, const TimevalType& b, Ti
template<typename TimevalType, typename TimespecType>
inline void timeval_to_timespec(const TimevalType& tv, TimespecType& ts)
{
- ts.tv_sec = tv.tv_sec;
- ts.tv_nsec = tv.tv_usec * 1000;
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
}
template<typename TimespecType, typename TimevalType>
diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h
index bec76e7d96..e5f50e7788 100644
--- a/AK/WeakPtr.h
+++ b/AK/WeakPtr.h
@@ -39,8 +39,8 @@ class WeakPtr {
friend class Weakable<T>;
public:
- WeakPtr() {}
- WeakPtr(std::nullptr_t) {}
+ WeakPtr() { }
+ WeakPtr(std::nullptr_t) { }
template<typename U>
WeakPtr(WeakPtr<U>&& other)