diff --git a/.clang-format b/.clang-format
index 6562bcd597f..f62fb6dce57 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,19 +1,19 @@
---
-# Don't try to format any languages not described by this file
-DisableFormat: true
-BasedOnStyle: LLVM
+Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
-AlignConsecutiveMacros: false
-AlignConsecutiveAssignments: false
-AlignConsecutiveDeclarations: false
+AlignArrayOfStructures: None
+AlignConsecutiveMacros: None
+AlignConsecutiveAssignments: None
+AlignConsecutiveBitFields: None
+AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
-AlignOperands: true
+AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
-AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortEnumsOnASingleLine: true
+AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty
@@ -23,12 +23,14 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
+AttributeMacros:
+ - __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
- AfterControlStatement: false
+ AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
@@ -38,27 +40,39 @@ BraceWrapping:
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
+ BeforeLambdaBody: false
+ BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 118
CommentPragmas: '^ IWYU pragma:'
+QualifierAlignment: Leave
CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
+DeriveLineEnding: true
DerivePointerAlignment: false
+DisableFormat: false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
+PackConstructorInitializers: BinPack
+BasedOnStyle: ''
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
@@ -68,68 +82,114 @@ ForEachMacros:
- TEST_CASE
- DYNAMIC_SECTION
- BENCHMARK
+IfMacros:
+ - KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
+ SortPriority: 0
+ CaseSensitive: false
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
+ SortPriority: 0
+ CaseSensitive: false
- Regex: '.*'
Priority: 1
+ SortPriority: 0
+ CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
IndentCaseLabels: true
+IndentCaseBlocks: false
+IndentGotoLabels: true
IndentPPDirectives: None
+IndentExternBlock: AfterExternBlock
+IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
+InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
+LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
+ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
+PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
PointerAlignment: Left
+PPIndentWidth: -1
+ReferenceAlignment: Left
ReflowComments: true
-SortIncludes: false
-SortUsingDeclarations: true
+RemoveBracesLLVM: false
+SeparateDefinitionBlocks: Leave
+ShortNamespaceLines: 1
+SortIncludes: Never
+SortJavaStaticImport: Before
+SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
-SpaceBeforeParens: ControlStatementsExceptForEachMacros
+SpaceBeforeParens: ControlStatementsExceptControlMacros
+SpaceBeforeParensOptions:
+ AfterControlStatements: true
+ AfterForeachMacros: false
+ AfterFunctionDefinitionName: false
+ AfterFunctionDeclarationName: false
+ AfterIfMacros: false
+ AfterOverloadedOperator: false
+ BeforeNonEmptyParentheses: false
+SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
+SpacesInAngles: Never
+SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
+SpacesInLineCommentPrefix:
+ Minimum: 1
+ Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+SpaceBeforeSquareBrackets: false
+BitFieldColonSpacing: Both
+Standard: Latest
+StatementAttributeLikeMacros:
+ - Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
+UseCRLF: false
UseTab: Never
----
-Language: Cpp
-DisableFormat: false
----
-Language: ObjC
-DisableFormat: false
+WhitespaceSensitiveMacros:
+ - STRINGIZE
+ - PP_STRINGIZE
+ - BOOST_PP_STRINGIZE
+ - NS_SWIFT_NAME
+ - CF_SWIFT_NAME
...
+
diff --git a/.project b/.project
index 48555f2457f..ae4d3317790 100644
--- a/.project
+++ b/.project
@@ -25,15 +25,6 @@
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
- 1684928805201
- external
- 30
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-false-false-catch
-
-
1684928848403
src/external
diff --git a/doc/development/coding_style_guide.cpp b/doc/development/coding_style_guide.cpp
index df65db633c1..658fb16402d 100644
--- a/doc/development/coding_style_guide.cpp
+++ b/doc/development/coding_style_guide.cpp
@@ -3,7 +3,7 @@
//
/*
- * The layout of the code is enforced by the use of clang-format - currently in version 3.9. The layout is
+ * The layout of the code is enforced by the use of clang-format - currently in version 16. The layout is
* defined by the .clang-format configuration file in the project root. You can ensure that a code change
* complies with the formatting rules in the following ways:
*
diff --git a/src/realm/array_backlink.hpp b/src/realm/array_backlink.hpp
index 190110d29fd..a28b2973700 100644
--- a/src/realm/array_backlink.hpp
+++ b/src/realm/array_backlink.hpp
@@ -86,6 +86,6 @@ class ArrayBacklink : public ArrayPayload, private Array {
void verify() const;
bool verify_backlink(size_t ndx, int64_t link);
};
-}
+} // namespace realm
#endif /* SRC_REALM_ARRAY_KEY_HPP_ */
diff --git a/src/realm/array_basic.hpp b/src/realm/array_basic.hpp
index 21eece3230b..d48b2d1e6ea 100644
--- a/src/realm/array_basic.hpp
+++ b/src/realm/array_basic.hpp
@@ -33,9 +33,7 @@ class BasicArray : public Node, public ArrayPayload {
using value_type = T;
explicit BasicArray(Allocator&) noexcept;
- ~BasicArray() noexcept override
- {
- }
+ ~BasicArray() noexcept override {}
static T default_value(bool)
{
diff --git a/src/realm/array_binary.hpp b/src/realm/array_binary.hpp
index 7e949a26dae..6c8e70d1a7b 100644
--- a/src/realm/array_binary.hpp
+++ b/src/realm/array_binary.hpp
@@ -107,6 +107,6 @@ inline BinaryData ArrayBinary::get(const char* header, size_t ndx, Allocator& al
return ArrayBigBlobs::get(header, ndx, alloc);
}
}
-}
+} // namespace realm
#endif /* SRC_REALM_ARRAY_BINARY_HPP_ */
diff --git a/src/realm/array_blob.hpp b/src/realm/array_blob.hpp
index a0f4e21d4c6..36010fa9913 100644
--- a/src/realm/array_blob.hpp
+++ b/src/realm/array_blob.hpp
@@ -31,9 +31,7 @@ class ArrayBlob : public Array {
static constexpr size_t max_binary_size = 0xFFFFF8 - Array::header_size;
explicit ArrayBlob(Allocator&) noexcept;
- ~ArrayBlob() noexcept override
- {
- }
+ ~ArrayBlob() noexcept override {}
// Disable copying, this is not allowed.
ArrayBlob& operator=(const ArrayBlob&) = delete;
@@ -67,6 +65,7 @@ class ArrayBlob : public Array {
static MemRef create_array(size_t init_size, Allocator&);
void verify() const;
+
private:
size_t calc_byte_len(size_t for_size, size_t width) const override;
size_t calc_item_count(size_t bytes, size_t width) const noexcept override;
diff --git a/src/realm/array_blobs_big.cpp b/src/realm/array_blobs_big.cpp
index dc12f36a6db..daa3df69110 100644
--- a/src/realm/array_blobs_big.cpp
+++ b/src/realm/array_blobs_big.cpp
@@ -188,7 +188,6 @@ void ArrayBigBlobs::find_all(IntegerColumn& result, BinaryData value, bool is_st
}
-
void ArrayBigBlobs::verify() const
{
#ifdef REALM_DEBUG
@@ -204,4 +203,3 @@ void ArrayBigBlobs::verify() const
}
#endif
}
-
diff --git a/src/realm/array_blobs_big.hpp b/src/realm/array_blobs_big.hpp
index a6e1e34f0d6..f64c7d679e3 100644
--- a/src/realm/array_blobs_big.hpp
+++ b/src/realm/array_blobs_big.hpp
@@ -129,7 +129,7 @@ inline BinaryData ArrayBigBlobs::get(const char* header, size_t ndx, Allocator&
inline void ArrayBigBlobs::erase(size_t ndx)
{
ref_type blob_ref = Array::get_as_ref(ndx);
- if (blob_ref != 0) { // nothing to destroy if null
+ if (blob_ref != 0) { // nothing to destroy if null
Array::destroy_deep(blob_ref, get_alloc()); // Deep
}
Array::erase(ndx);
diff --git a/src/realm/array_blobs_small.hpp b/src/realm/array_blobs_small.hpp
index dc772069887..8db3467a209 100644
--- a/src/realm/array_blobs_small.hpp
+++ b/src/realm/array_blobs_small.hpp
@@ -54,9 +54,7 @@ in set(), etc). This way no file format upgrade is needed to support nulls for B
class ArraySmallBlobs : public Array {
public:
explicit ArraySmallBlobs(Allocator&) noexcept;
- ~ArraySmallBlobs() noexcept override
- {
- }
+ ~ArraySmallBlobs() noexcept override {}
// Disable copying, this is not allowed.
ArraySmallBlobs& operator=(const ArraySmallBlobs&) = delete;
diff --git a/src/realm/array_bool.hpp b/src/realm/array_bool.hpp
index 9de45ff94db..7c11f037f23 100644
--- a/src/realm/array_bool.hpp
+++ b/src/realm/array_bool.hpp
@@ -152,6 +152,6 @@ class ArrayBoolNull : public ArrayBool {
return (val == null_value) ? util::none : util::make_optional(val != 0);
}
};
-}
+} // namespace realm
#endif /* REALM_ARRAY_BOOL_HPP */
diff --git a/src/realm/array_direct.hpp b/src/realm/array_direct.hpp
index ae75e978498..d595363c762 100644
--- a/src/realm/array_direct.hpp
+++ b/src/realm/array_direct.hpp
@@ -350,6 +350,6 @@ inline size_t upper_bound(const char* data, size_t size, int64_t value) noexcept
return low;
}
-}
+} // namespace realm
#endif /* ARRAY_TPL_HPP_ */
diff --git a/src/realm/array_integer.cpp b/src/realm/array_integer.cpp
index bf459b8161d..8cf854c671f 100644
--- a/src/realm/array_integer.cpp
+++ b/src/realm/array_integer.cpp
@@ -70,7 +70,7 @@ int64_t next_null_candidate(int64_t previous_candidate)
x += 0xfffffffbULL;
return int64_t(x);
}
-}
+} // namespace
int_fast64_t ArrayIntNull::choose_random_null(int64_t incoming) const
{
diff --git a/src/realm/array_key.hpp b/src/realm/array_key.hpp
index 07231ca5dc0..d0bb9fcd325 100644
--- a/src/realm/array_key.hpp
+++ b/src/realm/array_key.hpp
@@ -128,6 +128,6 @@ class ArrayKeyNonNullable : public ArrayKeyBase<0> {
public:
using ArrayKeyBase::ArrayKeyBase;
};
-}
+} // namespace realm
#endif /* SRC_REALM_ARRAY_KEY_HPP_ */
diff --git a/src/realm/array_list.hpp b/src/realm/array_list.hpp
index 26efda68674..700c8232348 100644
--- a/src/realm/array_list.hpp
+++ b/src/realm/array_list.hpp
@@ -95,6 +95,6 @@ class ArrayList : public ArrayPayload, private Array {
return Array::find_first(from_ref(value), begin, end);
}
};
-}
+} // namespace realm
#endif /* REALM_ARRAY_LIST_HPP */
diff --git a/src/realm/array_string.cpp b/src/realm/array_string.cpp
index 661abf2de5c..636a60a2865 100644
--- a/src/realm/array_string.cpp
+++ b/src/realm/array_string.cpp
@@ -358,7 +358,7 @@ size_t lower_bound_string(const T* arr, U value)
}
return i;
}
-}
+} // namespace
size_t ArrayString::lower_bound(StringData value)
{
diff --git a/src/realm/array_string.hpp b/src/realm/array_string.hpp
index eb6d7bb2594..4dc96646378 100644
--- a/src/realm/array_string.hpp
+++ b/src/realm/array_string.hpp
@@ -160,6 +160,6 @@ inline StringData ArrayString::get(const char* header, size_t ndx, Allocator& al
}
}
-}
+} // namespace realm
#endif /* REALM_ARRAY_STRING_HPP */
diff --git a/src/realm/array_string_short.hpp b/src/realm/array_string_short.hpp
index 5297b169ebc..da499bfcaa4 100644
--- a/src/realm/array_string_short.hpp
+++ b/src/realm/array_string_short.hpp
@@ -48,9 +48,7 @@ class ArrayStringShort : public Array {
// Constructor defaults to non-nullable because we use non-nullable ArrayStringShort so many places internally
// in core (data which isn't user payload) where null isn't needed.
explicit ArrayStringShort(Allocator&, bool nullable = false) noexcept;
- ~ArrayStringShort() noexcept override
- {
- }
+ ~ArrayStringShort() noexcept override {}
bool is_null(size_t ndx) const;
void set_null(size_t ndx);
diff --git a/src/realm/array_timestamp.cpp b/src/realm/array_timestamp.cpp
index 8efe9246e86..e2b282dc680 100644
--- a/src/realm/array_timestamp.cpp
+++ b/src/realm/array_timestamp.cpp
@@ -224,14 +224,14 @@ size_t ArrayTimestamp::find_first(Timestamp value, size_t begin, size_
util::Optional seconds = m_seconds.get(begin);
if (!seconds || *seconds != sec) {
return begin;
- }
- // We now know that neither m_value nor current value is null and that seconds part equals
- // We are just missing to compare nanoseconds part
- int32_t nanos = int32_t(m_nanoseconds.get(begin));
- if (nanos != value.get_nanoseconds()) {
- return begin;
- }
- ++begin;
+ }
+ // We now know that neither m_value nor current value is null and that seconds part equals
+ // We are just missing to compare nanoseconds part
+ int32_t nanos = int32_t(m_nanoseconds.get(begin));
+ if (nanos != value.get_nanoseconds()) {
+ return begin;
+ }
+ ++begin;
}
return not_found;
}
diff --git a/src/realm/array_timestamp.hpp b/src/realm/array_timestamp.hpp
index 9ff8acfc1d8..7381156f7cd 100644
--- a/src/realm/array_timestamp.hpp
+++ b/src/realm/array_timestamp.hpp
@@ -132,6 +132,6 @@ inline size_t ArrayTimestamp::find_first(Timestamp value, size_t begin, size_t e
return find_first(value, begin, end);
}
-}
+} // namespace realm
#endif /* SRC_REALM_ARRAY_BINARY_HPP_ */
diff --git a/src/realm/bplustree.cpp b/src/realm/bplustree.cpp
index c545fa4440c..da25593abe9 100644
--- a/src/realm/bplustree.cpp
+++ b/src/realm/bplustree.cpp
@@ -169,13 +169,11 @@ class BPlusTreeInner : public BPlusTreeNode, private Array {
return (child_ndx) > 0 ? size_t(m_offsets.get(child_ndx - 1)) : 0;
}
};
-}
+} // namespace realm
/****************************** BPlusTreeNode ********************************/
-BPlusTreeNode::~BPlusTreeNode()
-{
-}
+BPlusTreeNode::~BPlusTreeNode() {}
/****************************** BPlusTreeLeaf ********************************/
@@ -275,9 +273,7 @@ void BPlusTreeInner::create(size_t elems_per_child)
Array::create(Array::type_InnerBptreeNode, false, 1, tagged);
}
-BPlusTreeInner::~BPlusTreeInner()
-{
-}
+BPlusTreeInner::~BPlusTreeInner() {}
void BPlusTreeInner::init_from_mem(MemRef mem)
{
@@ -651,7 +647,7 @@ ref_type BPlusTreeInner::insert_bp_node(size_t child_ndx, ref_type new_sibling_r
new_split_offset = size_t(elem_ndx_offset + state.split_offset);
new_split_size = elem_ndx_offset + state.split_size;
new_sibling.add_bp_node_ref(new_sibling_ref); // Throws
- set_tree_size(new_split_offset); // Throws
+ set_tree_size(new_split_offset); // Throws
}
else {
// Case 2/2: The split child was not the last child of the
@@ -661,9 +657,9 @@ ref_type BPlusTreeInner::insert_bp_node(size_t child_ndx, ref_type new_sibling_r
new_split_offset = size_t(elem_ndx_offset + state.split_size);
new_split_size = get_tree_size() + 1;
- move(&new_sibling, new_ref_ndx, (new_split_offset - 1)); // Strips off tree size
+ move(&new_sibling, new_ref_ndx, (new_split_offset - 1)); // Strips off tree size
add_bp_node_ref(new_sibling_ref, elem_ndx_offset + state.split_offset); // Throws
- append_tree_size(new_split_offset); // Throws
+ append_tree_size(new_split_offset); // Throws
}
new_sibling.append_tree_size(new_split_size - new_split_offset); // Throws
@@ -737,9 +733,7 @@ void BPlusTreeInner::verify() const
/****************************** BPlusTreeBase ********************************/
-BPlusTreeBase::~BPlusTreeBase()
-{
-}
+BPlusTreeBase::~BPlusTreeBase() {}
void BPlusTreeBase::create()
{
diff --git a/src/realm/cluster.hpp b/src/realm/cluster.hpp
index f66fca9557f..6d3638d4a87 100644
--- a/src/realm/cluster.hpp
+++ b/src/realm/cluster.hpp
@@ -80,9 +80,9 @@ class ClusterNode : public Array {
// This structure is used to bring information back to the upper nodes when
// inserting new objects or finding existing ones.
struct State {
- int64_t split_key; // When a node is split, this variable holds the value of the
- // first key in the new node. (Relative to the key offset)
- MemRef mem; // MemRef to the Cluster holding the new/found object
+ int64_t split_key; // When a node is split, this variable holds the value of the
+ // first key in the new node. (Relative to the key offset)
+ MemRef mem; // MemRef to the Cluster holding the new/found object
size_t index = realm::npos; // The index within the Cluster at which the object is stored.
operator bool() const
@@ -113,9 +113,7 @@ class ClusterNode : public Array {
{
m_keys.set_parent(this, 0);
}
- virtual ~ClusterNode()
- {
- }
+ virtual ~ClusterNode() {}
void init_from_parent()
{
ref_type ref = get_ref_from_parent();
@@ -360,6 +358,6 @@ class Cluster : public ClusterNode {
void verify(ref_type ref, size_t index, util::Optional& sz) const;
};
-}
+} // namespace realm
#endif /* SRC_REALM_CLUSTER_HPP_ */
diff --git a/src/realm/column_binary.hpp b/src/realm/column_binary.hpp
index 0fae1c3dbb3..0ff0107eeaf 100644
--- a/src/realm/column_binary.hpp
+++ b/src/realm/column_binary.hpp
@@ -34,9 +34,7 @@ class BinaryColumn : public BPlusTree {
class BinaryIterator {
public:
- BinaryIterator()
- {
- }
+ BinaryIterator() {}
BinaryIterator(BinaryData binary)
: m_binary(binary)
diff --git a/src/realm/column_integer.hpp b/src/realm/column_integer.hpp
index f40b67d8389..0e08b8563eb 100644
--- a/src/realm/column_integer.hpp
+++ b/src/realm/column_integer.hpp
@@ -192,6 +192,6 @@ inline std::ostream& operator<<(std::ostream& out, const IntegerColumnIterator&
out << "IntegerColumnIterator at index: " << it.get_position();
return out;
}
-}
+} // namespace realm
#endif /* REALM_COLUMN_INTEGER_HPP */
diff --git a/src/realm/handover_defs.hpp b/src/realm/handover_defs.hpp
index ad8bfba3116..fcbd2fb0af4 100644
--- a/src/realm/handover_defs.hpp
+++ b/src/realm/handover_defs.hpp
@@ -29,6 +29,6 @@ namespace realm {
enum class PayloadPolicy { Copy, Stay, Move };
-} // end namespace Realm
+} // namespace realm
#endif
diff --git a/src/realm/impl/array_writer.hpp b/src/realm/impl/array_writer.hpp
index f039ad505f9..2f18affe7f3 100644
--- a/src/realm/impl/array_writer.hpp
+++ b/src/realm/impl/array_writer.hpp
@@ -26,9 +26,7 @@ namespace _impl {
class ArrayWriterBase {
public:
- virtual ~ArrayWriterBase()
- {
- }
+ virtual ~ArrayWriterBase() {}
/// Write the specified array data and its checksum into free
/// space.
@@ -38,7 +36,7 @@ class ArrayWriterBase {
virtual ref_type write_array(const char* data, size_t size, uint32_t checksum) = 0;
};
-} // namespace impl_
+} // namespace _impl
} // namespace realm
#endif // REALM_ARRAY_WRITER_HPP
diff --git a/src/realm/impl/cont_transact_hist.hpp b/src/realm/impl/cont_transact_hist.hpp
index 891ef7e54e4..5da27740616 100644
--- a/src/realm/impl/cont_transact_hist.hpp
+++ b/src/realm/impl/cont_transact_hist.hpp
@@ -75,8 +75,8 @@ class History {
/// of update_early_from_top_ref(). In that case, the caller may assume that
/// the memory references stay valid for the remainder of the transaction
/// (up until initiation of the commit operation).
- virtual void get_changesets(version_type begin_version, version_type end_version, BinaryIterator* buffer) const
- noexcept = 0;
+ virtual void get_changesets(version_type begin_version, version_type end_version,
+ BinaryIterator* buffer) const noexcept = 0;
/// \brief Specify the version of the oldest bound snapshot.
///
diff --git a/src/realm/impl/output_stream.hpp b/src/realm/impl/output_stream.hpp
index 1d022cd5318..eb459900485 100644
--- a/src/realm/impl/output_stream.hpp
+++ b/src/realm/impl/output_stream.hpp
@@ -59,9 +59,7 @@ inline OutputStream::OutputStream(std::ostream& out)
{
}
-inline OutputStream::~OutputStream() noexcept
-{
-}
+inline OutputStream::~OutputStream() noexcept {}
inline size_t OutputStream::get_ref_of_next_array() const noexcept
{
diff --git a/src/realm/impl/transact_log.hpp b/src/realm/impl/transact_log.hpp
index ad352f93c03..335856d6719 100644
--- a/src/realm/impl/transact_log.hpp
+++ b/src/realm/impl/transact_log.hpp
@@ -772,18 +772,18 @@ void TransactLogParser::parse_one(InstructionHandler& handler)
case instr_DictionarySet: {
int type = read_int(); // Throws
REALM_ASSERT(type == int(type_String));
- read_string(m_string_buffer); // skip key
- size_t dict_ndx = read_int(); // Throws
- if (!handler.collection_set(dict_ndx)) // Throws
+ read_string(m_string_buffer); // skip key
+ size_t dict_ndx = read_int(); // Throws
+ if (!handler.collection_set(dict_ndx)) // Throws
parser_error();
return;
}
case instr_DictionaryErase: {
int type = read_int(); // Throws
REALM_ASSERT(type == int(type_String));
- read_string(m_string_buffer); // skip key
- size_t dict_ndx = read_int(); // Throws
- if (!handler.collection_erase(dict_ndx)) // Throws
+ read_string(m_string_buffer); // skip key
+ size_t dict_ndx = read_int(); // Throws
+ if (!handler.collection_erase(dict_ndx)) // Throws
parser_error();
return;
}
diff --git a/src/realm/index_string.cpp b/src/realm/index_string.cpp
index f26c575a3de..b313b7c8383 100644
--- a/src/realm/index_string.cpp
+++ b/src/realm/index_string.cpp
@@ -414,7 +414,8 @@ uint32_t replicate_4_lsb_x8(uint32_t i)
return i;
}
-int32_t select_from_mask(int32_t a, int32_t b, int32_t mask) {
+int32_t select_from_mask(int32_t a, int32_t b, int32_t mask)
+{
return a ^ ((a ^ b) & mask);
}
diff --git a/src/realm/index_string.hpp b/src/realm/index_string.hpp
index eefa13fa2fc..c8941989388 100644
--- a/src/realm/index_string.hpp
+++ b/src/realm/index_string.hpp
@@ -123,9 +123,7 @@ class StringIndex : public SearchIndex {
public:
StringIndex(const ClusterColumn& target_column, Allocator&);
StringIndex(ref_type, ArrayParent*, size_t ndx_in_parent, const ClusterColumn& target_column, Allocator&);
- ~StringIndex() noexcept
- {
- }
+ ~StringIndex() noexcept {}
static bool type_supported(realm::DataType type)
{
@@ -205,8 +203,7 @@ class StringIndex : public SearchIndex {
// If the header flag is set, references point to a sub-StringIndex (nesting).
std::unique_ptr m_array;
- struct inner_node_tag {
- };
+ struct inner_node_tag {};
StringIndex(inner_node_tag, Allocator&);
StringIndex(const ClusterColumn& target_column, std::unique_ptr root)
: SearchIndex(target_column, root.get())
diff --git a/src/realm/node_header.hpp b/src/realm/node_header.hpp
index b5805fc343a..0251c796478 100644
--- a/src/realm/node_header.hpp
+++ b/src/realm/node_header.hpp
@@ -239,6 +239,6 @@ class NodeHeader {
return num_bytes;
}
};
-}
+} // namespace realm
#endif /* REALM_NODE_HEADER_HPP */
diff --git a/src/realm/obj_list.hpp b/src/realm/obj_list.hpp
index 6ea00cabb53..b8fbcfe9be0 100644
--- a/src/realm/obj_list.hpp
+++ b/src/realm/obj_list.hpp
@@ -93,6 +93,6 @@ class ObjList {
template
TableView find_all(ColKey column_key, T value) const;
};
-}
+} // namespace realm
#endif /* SRC_REALM_OBJ_LIST_HPP_ */
diff --git a/src/realm/object-store/index_set.hpp b/src/realm/object-store/index_set.hpp
index 59c59bbd64a..d61e78221f4 100644
--- a/src/realm/object-store/index_set.hpp
+++ b/src/realm/object-store/index_set.hpp
@@ -391,7 +391,8 @@ template
// Inlining this function crashes msvc when targeting arm64 in as of 19.39.33523
__declspec(noinline)
#endif
-inline void ChunkedRangeVectorIterator::next_chunk() noexcept
+inline void
+ChunkedRangeVectorIterator::next_chunk() noexcept
{
++m_outer;
m_inner = m_outer != m_end ? &m_outer->data[0] : nullptr;
diff --git a/src/realm/object-store/schema.cpp b/src/realm/object-store/schema.cpp
index 47cebb6a389..c129a9c1c5b 100644
--- a/src/realm/object-store/schema.cpp
+++ b/src/realm/object-store/schema.cpp
@@ -118,8 +118,8 @@ Schema::const_iterator Schema::find(TableKey table_key) const noexcept
namespace {
struct CheckObjectPath {
- const ObjectSchema& object; // the schema to check
- std::string path; // a printable path for error messaging
+ const ObjectSchema& object; // the schema to check
+ std::string path; // a printable path for error messaging
};
// a non-recursive search that returns a property path to the first embedded object cycle detected
diff --git a/src/realm/object-store/sync/app.cpp b/src/realm/object-store/sync/app.cpp
index 08d42aeb3f2..884d80ec7e3 100644
--- a/src/realm/object-store/sync/app.cpp
+++ b/src/realm/object-store/sync/app.cpp
@@ -1041,48 +1041,48 @@ void App::request_location(UniqueFunction)>&& compl
log_debug("App: request location: %1", req.url);
- m_config.transport->send_request_to_server(
- req, [self = shared_from_this(), completion = std::move(completion), base_url = std::move(base_url),
- redirect_count](const Response& response) mutable {
- // Check to see if a redirect occurred
- if (AppUtils::is_redirect_status_code(response.http_status_code)) {
- // Make sure we don't do too many redirects (max_http_redirects (20) is an arbitrary number)
- if (redirect_count >= s_max_http_redirects) {
- completion(AppError{ErrorCodes::ClientTooManyRedirects,
- util::format("number of redirections exceeded %1", s_max_http_redirects),
- {},
- response.http_status_code});
- return;
- }
- // Handle the redirect response when requesting the location - extract the
- // new location header field and resend the request.
- auto redir_location = AppUtils::extract_redir_location(response.headers);
- if (!redir_location) {
- // Location not found in the response, pass error response up the chain
- completion(AppError{ErrorCodes::ClientRedirectError,
- "Redirect response missing location header",
- {},
- response.http_status_code});
- return;
- }
- // try to request the location info at the new location in the redirect response
- // retry_count is passed in to track the number of subsequent redirection attempts
- self->request_location(std::move(completion), std::move(base_url), std::move(redir_location),
- redirect_count + 1);
+ m_config.transport->send_request_to_server(req, [self = shared_from_this(), completion = std::move(completion),
+ base_url = std::move(base_url),
+ redirect_count](const Response& response) mutable {
+ // Check to see if a redirect occurred
+ if (AppUtils::is_redirect_status_code(response.http_status_code)) {
+ // Make sure we don't do too many redirects (max_http_redirects (20) is an arbitrary number)
+ if (redirect_count >= s_max_http_redirects) {
+ completion(AppError{ErrorCodes::ClientTooManyRedirects,
+ util::format("number of redirections exceeded %1", s_max_http_redirects),
+ {},
+ response.http_status_code});
return;
}
-
- // Location request was successful - update the location info
- auto update_response = self->update_location(response, base_url);
- if (update_response) {
- self->log_error("App: request location failed (%1%2): %3", update_response->code_string(),
- update_response->additional_status_code
- ? util::format(" %1", *update_response->additional_status_code)
- : "",
- update_response->reason());
+ // Handle the redirect response when requesting the location - extract the
+ // new location header field and resend the request.
+ auto redir_location = AppUtils::extract_redir_location(response.headers);
+ if (!redir_location) {
+ // Location not found in the response, pass error response up the chain
+ completion(AppError{ErrorCodes::ClientRedirectError,
+ "Redirect response missing location header",
+ {},
+ response.http_status_code});
+ return;
}
- completion(update_response);
- });
+ // try to request the location info at the new location in the redirect response
+ // retry_count is passed in to track the number of subsequent redirection attempts
+ self->request_location(std::move(completion), std::move(base_url), std::move(redir_location),
+ redirect_count + 1);
+ return;
+ }
+
+ // Location request was successful - update the location info
+ auto update_response = self->update_location(response, base_url);
+ if (update_response) {
+ self->log_error("App: request location failed (%1%2): %3", update_response->code_string(),
+ update_response->additional_status_code
+ ? util::format(" %1", *update_response->additional_status_code)
+ : "",
+ update_response->reason());
+ }
+ completion(update_response);
+ });
}
std::optional App::update_location(const Response& response, const std::string& base_url)
@@ -1331,17 +1331,17 @@ void App::call_function(const std::shared_ptr& user, const std::string& na
auto args = util::format("{\"arguments\":%1,\"name\":%2%3}", args_ejson, nlohmann::json(name).dump(),
service_name_opt ? (",\"service\":" + nlohmann::json(service_name).dump()) : "");
- do_authenticated_request(
- HttpMethod::post, function_call_url_path(), std::move(args), user, RequestTokenType::AccessToken,
- [self = shared_from_this(), name = name, service_name = std::move(service_name),
- completion = std::move(completion)](const Response& response) {
- if (auto error = AppUtils::check_for_errors(response)) {
- self->log_error("App: call_function: %1 service_name: %2 -> %3 ERROR: %4", name, service_name,
- response.http_status_code, error->what());
- return completion(nullptr, error);
- }
- completion(&response.body, util::none);
- });
+ do_authenticated_request(HttpMethod::post, function_call_url_path(), std::move(args), user,
+ RequestTokenType::AccessToken,
+ [self = shared_from_this(), name = name, service_name = std::move(service_name),
+ completion = std::move(completion)](const Response& response) {
+ if (auto error = AppUtils::check_for_errors(response)) {
+ self->log_error("App: call_function: %1 service_name: %2 -> %3 ERROR: %4", name,
+ service_name, response.http_status_code, error->what());
+ return completion(nullptr, error);
+ }
+ completion(&response.body, util::none);
+ });
}
void App::call_function(const std::shared_ptr& user, const std::string& name, const BsonArray& args_bson,
diff --git a/src/realm/object-store/sync/async_open_task.cpp b/src/realm/object-store/sync/async_open_task.cpp
index 45f056ae05e..a261f94c943 100644
--- a/src/realm/object-store/sync/async_open_task.cpp
+++ b/src/realm/object-store/sync/async_open_task.cpp
@@ -195,25 +195,25 @@ void AsyncOpenTask::migrate_schema_or_complete(AsyncOpenCallback&& callback,
// * Then, pause the session, delete all tables, re-initialize the metadata, and finally restart the session.
// The lifetime of the task is extended until the bootstrap completes.
std::shared_ptr self(shared_from_this());
- session->wait_for_upload_completion([callback = std::move(callback), coordinator, session, self,
- this](Status status) mutable {
- {
- util::CheckedLockGuard lock(m_mutex);
- if (!m_session)
- return; // Swallow all events if the task has been cancelled.
- }
-
- if (!status.is_ok()) {
- self->async_open_complete(std::move(callback), coordinator, status);
- return;
- }
-
- auto migration_completed_callback = [callback = std::move(callback), coordinator = std::move(coordinator),
- self](Status status) mutable {
- self->wait_for_bootstrap_or_complete(std::move(callback), coordinator, status);
- };
- SyncSession::Internal::migrate_schema(*session, std::move(migration_completed_callback));
- });
+ session->wait_for_upload_completion(
+ [callback = std::move(callback), coordinator, session, self, this](Status status) mutable {
+ {
+ util::CheckedLockGuard lock(m_mutex);
+ if (!m_session)
+ return; // Swallow all events if the task has been cancelled.
+ }
+
+ if (!status.is_ok()) {
+ self->async_open_complete(std::move(callback), coordinator, status);
+ return;
+ }
+
+ auto migration_completed_callback = [callback = std::move(callback), coordinator = std::move(coordinator),
+ self](Status status) mutable {
+ self->wait_for_bootstrap_or_complete(std::move(callback), coordinator, status);
+ };
+ SyncSession::Internal::migrate_schema(*session, std::move(migration_completed_callback));
+ });
}
void AsyncOpenTask::wait_for_bootstrap_or_complete(AsyncOpenCallback&& callback,
diff --git a/src/realm/object-store/sync/sync_session.hpp b/src/realm/object-store/sync/sync_session.hpp
index ded953f9353..a4cd13f09d8 100644
--- a/src/realm/object-store/sync/sync_session.hpp
+++ b/src/realm/object-store/sync/sync_session.hpp
@@ -42,7 +42,7 @@ namespace sync {
class Session;
struct SessionErrorInfo;
class MigrationStore;
-}
+} // namespace sync
namespace _impl {
class RealmCoordinator;
diff --git a/src/realm/object-store/util/atomic_shared_ptr.hpp b/src/realm/object-store/util/atomic_shared_ptr.hpp
index bac414aed32..48a47b5397f 100644
--- a/src/realm/object-store/util/atomic_shared_ptr.hpp
+++ b/src/realm/object-store/util/atomic_shared_ptr.hpp
@@ -31,12 +31,10 @@ namespace _impl {
// HasAtomicPtrOps to either true_type or false_type
template >
-struct HasAtomicPtrOps : std::false_type {
-};
+struct HasAtomicPtrOps : std::false_type {};
template
-struct HasAtomicPtrOps()))>> : std::true_type {
-};
+struct HasAtomicPtrOps()))>> : std::true_type {};
} // namespace _impl
namespace util {
diff --git a/src/realm/object-store/util/event_loop_dispatcher.hpp b/src/realm/object-store/util/event_loop_dispatcher.hpp
index a9a429b1bd3..a194a8ea6f5 100644
--- a/src/realm/object-store/util/event_loop_dispatcher.hpp
+++ b/src/realm/object-store/util/event_loop_dispatcher.hpp
@@ -67,8 +67,7 @@ class EventLoopDispatcher {
namespace _impl::ForEventLoopDispatcher {
template
-struct ExtractSignatureImpl {
-};
+struct ExtractSignatureImpl {};
template
struct ExtractSignatureImpl {
using signature = void(Args...);
diff --git a/src/realm/object_id.cpp b/src/realm/object_id.cpp
index 8a599242ba0..95ad4e8d76f 100644
--- a/src/realm/object_id.cpp
+++ b/src/realm/object_id.cpp
@@ -52,8 +52,9 @@ static_assert(sizeof(ObjectId) == 12, "changing the size of an ObjectId is a fil
bool ObjectId::is_valid_str(StringData str) noexcept
{
- return str.size() == 24 &&
- std::all_of(str.data(), str.data() + str.size(), [](unsigned char c) { return std::isxdigit(c); });
+ return str.size() == 24 && std::all_of(str.data(), str.data() + str.size(), [](unsigned char c) {
+ return std::isxdigit(c);
+ });
}
ObjectId::ObjectId(StringData init) noexcept
diff --git a/src/realm/owned_data.hpp b/src/realm/owned_data.hpp
index c707f9da4cf..9d3ee6f688c 100644
--- a/src/realm/owned_data.hpp
+++ b/src/realm/owned_data.hpp
@@ -30,9 +30,7 @@ namespace realm {
class OwnedData {
public:
/// Construct a null reference.
- OwnedData() noexcept
- {
- }
+ OwnedData() noexcept {}
/// If \a data_to_copy is 'null', \a data_size must be zero.
OwnedData(const char* data_to_copy, size_t data_size)
diff --git a/src/realm/parser/driver.hpp b/src/realm/parser/driver.hpp
index e255b45bc67..207460a4958 100644
--- a/src/realm/parser/driver.hpp
+++ b/src/realm/parser/driver.hpp
@@ -145,8 +145,7 @@ class ExpressionNode : public ParserNode {
/******************************** Value Nodes ********************************/
-class ValueNode : public ExpressionNode {
-};
+class ValueNode : public ExpressionNode {};
class ConstantNode : public ValueNode {
public:
diff --git a/src/realm/query.hpp b/src/realm/query.hpp
index b3b2ac5a385..6b3c7a77afa 100644
--- a/src/realm/query.hpp
+++ b/src/realm/query.hpp
@@ -401,8 +401,8 @@ class Query final {
// m_source_collection is a pointer to a collection which must also be a ObjList*
// this includes: LnkLst, LnkSet, and DictionaryLinkValues. It cannot be a list of primitives because
// it is used to populate a query through a collection of objects and there are asserts for this.
- LinkCollectionPtr m_source_collection; // collections are owned by the query.
- TableView* m_source_table_view = nullptr; // table views are not refcounted, and not owned by the query.
+ LinkCollectionPtr m_source_collection; // collections are owned by the query.
+ TableView* m_source_table_view = nullptr; // table views are not refcounted, and not owned by the query.
std::unique_ptr m_owned_source_table_view; // <--- except when indicated here
util::bind_ptr m_ordering;
};
diff --git a/src/realm/query_conditions.hpp b/src/realm/query_conditions.hpp
index 5fdc8de31c3..cf3cf9e73d8 100644
--- a/src/realm/query_conditions.hpp
+++ b/src/realm/query_conditions.hpp
@@ -63,7 +63,7 @@ struct Contains : public HackClass {
{
return v2.contains(v1);
}
- bool operator()(StringData v1, const std::array &charmap, StringData v2) const
+ bool operator()(StringData v1, const std::array& charmap, StringData v2) const
{
return v2.contains(v1, charmap);
}
@@ -389,14 +389,15 @@ struct ContainsIns : public HackClass {
}
// Case insensitive Boyer-Moore version
- bool operator()(StringData v1, const char* v1_upper, const char* v1_lower, const std::array &charmap, StringData v2) const
+ bool operator()(StringData v1, const char* v1_upper, const char* v1_lower,
+ const std::array& charmap, StringData v2) const
{
if (v2.is_null() && !v1.is_null())
return false;
-
+
if (v1.size() == 0 && !v2.is_null())
return true;
-
+
return contains_ins(v2, v1_upper, v1_lower, v1.size(), charmap);
}
diff --git a/src/realm/query_engine.hpp b/src/realm/query_engine.hpp
index 9a84dda2284..57ae09fa731 100644
--- a/src/realm/query_engine.hpp
+++ b/src/realm/query_engine.hpp
@@ -180,9 +180,7 @@ class ParentNode {
cluster_changed();
}
- virtual void collect_dependencies(std::vector&) const
- {
- }
+ virtual void collect_dependencies(std::vector&) const {}
virtual size_t find_first_local(size_t start, size_t end) = 0;
virtual size_t find_all_local(size_t start, size_t end);
@@ -286,9 +284,7 @@ class ParentNode {
}
private:
- virtual void table_changed()
- {
- }
+ virtual void table_changed() {}
virtual void cluster_changed()
{
// TODO: Should eventually be pure
@@ -311,7 +307,6 @@ class ColumnNodeBase : public ParentNode {
: ParentNode(from)
{
}
-
};
class IndexEvaluator {
diff --git a/src/realm/sort_descriptor.hpp b/src/realm/sort_descriptor.hpp
index 09e9b6b07b6..0224ea5de6b 100644
--- a/src/realm/sort_descriptor.hpp
+++ b/src/realm/sort_descriptor.hpp
@@ -78,16 +78,15 @@ class BaseDescriptor {
public:
Sorter(std::vector> const& columns, std::vector const& ascending,
Table const& root_table, const IndexPairs& indexes);
- Sorter()
- {
- }
+ Sorter() {}
bool operator()(IndexPair i, IndexPair j, bool total_ordering = true) const;
bool has_links() const
{
- return std::any_of(m_columns.begin(), m_columns.end(),
- [](auto&& col) { return !col.translated_keys.empty(); });
+ return std::any_of(m_columns.begin(), m_columns.end(), [](auto&& col) {
+ return !col.translated_keys.empty();
+ });
}
bool any_is_null(IndexPair i) const
@@ -345,10 +344,11 @@ class DescriptorOrdering : public util::AtomicRefCountBase {
std::string get_description(ConstTableRef target_table) const;
void collect_dependencies(const Table* table);
void get_versions(const Group* group, TableVersions& versions) const;
+
private:
std::vector> m_descriptors;
std::vector m_dependencies;
};
-}
+} // namespace realm
#endif /* REALM_SORT_DESCRIPTOR_HPP */
diff --git a/src/realm/spec.hpp b/src/realm/spec.hpp
index 9db898cb969..c9f3ff0c230 100644
--- a/src/realm/spec.hpp
+++ b/src/realm/spec.hpp
@@ -101,8 +101,8 @@ class Spec {
ArrayStringShort m_names; // 2nd slot in m_top
Array m_attr; // 3rd slot in m_top
// 4th slot in m_top not cached
- Array m_enumkeys; // 5th slot in m_top
- Array m_keys; // 6th slot in m_top
+ Array m_enumkeys; // 5th slot in m_top
+ Array m_keys; // 6th slot in m_top
size_t m_num_public_columns = 0;
Spec(Allocator&) noexcept; // Unattached
diff --git a/src/realm/string_data.cpp b/src/realm/string_data.cpp
index 1c1787db560..9d00fa2dcaa 100644
--- a/src/realm/string_data.cpp
+++ b/src/realm/string_data.cpp
@@ -25,8 +25,8 @@ using namespace realm;
namespace {
template
-REALM_FORCEINLINE
-bool matchlike(const StringData& text, const StringData& pattern, const StringData* alternate_pattern=nullptr) noexcept
+REALM_FORCEINLINE bool matchlike(const StringData& text, const StringData& pattern,
+ const StringData* alternate_pattern = nullptr) noexcept
{
// If alternate_pattern is provided, it is assumed to differ from `pattern` only in case.
REALM_ASSERT_DEBUG(has_alternate_pattern == bool(alternate_pattern));
diff --git a/src/realm/string_data.hpp b/src/realm/string_data.hpp
index d174b7fbbd7..46e1df0713d 100644
--- a/src/realm/string_data.hpp
+++ b/src/realm/string_data.hpp
@@ -143,8 +143,8 @@ class StringData {
constexpr bool begins_with(StringData) const noexcept;
constexpr bool ends_with(StringData) const noexcept;
constexpr bool contains(StringData) const noexcept;
- bool contains(StringData d, const std::array &charmap) const noexcept;
-
+ bool contains(StringData d, const std::array& charmap) const noexcept;
+
// Wildcard matching ('?' for single char, '*' for zero or more chars)
// case insensitive version in unicode.hpp
bool like(StringData) const noexcept;
@@ -312,40 +312,40 @@ constexpr inline bool StringData::contains(StringData d) const noexcept
/// This method takes an array that maps chars to distance that can be moved (and zero for chars not in needle),
/// allowing the method to apply Boyer-Moore for quick substring search
/// The map is calculated in the StringNode class (so it can be reused across searches)
-inline bool StringData::contains(StringData d, const std::array &charmap) const noexcept
+inline bool StringData::contains(StringData d, const std::array& charmap) const noexcept
{
if (is_null() && !d.is_null())
return false;
-
+
size_t needle_size = d.size();
if (needle_size == 0)
return true;
-
+
// Prepare vars to avoid lookups in loop
- size_t last_char_pos = d.size()-1;
+ size_t last_char_pos = d.size() - 1;
unsigned char lastChar = d[last_char_pos];
-
+
// Do Boyer-Moore search
size_t p = last_char_pos;
while (p < m_size) {
unsigned char c = m_data[p]; // Get candidate for last char
-
+
if (c == lastChar) {
- StringData candidate = substr(p-needle_size+1, needle_size);
+ StringData candidate = substr(p - needle_size + 1, needle_size);
if (candidate == d)
return true; // text found!
}
-
+
// If we don't have a match, see how far we can move char_pos
if (charmap[c] == 0)
p += needle_size; // char was not present in search string
else
p += charmap[c];
}
-
+
return false;
}
-
+
inline bool StringData::like(StringData d) const noexcept
{
if (is_null() || d.is_null()) {
diff --git a/src/realm/sync/client.cpp b/src/realm/sync/client.cpp
index 2f783255624..b82fe2dcdb7 100644
--- a/src/realm/sync/client.cpp
+++ b/src/realm/sync/client.cpp
@@ -1397,7 +1397,7 @@ void SessionWrapper::on_commit(version_type new_version)
if (REALM_UNLIKELY(!self->m_sess))
return; // Already finalized
SessionImpl& sess = *self->m_sess;
- sess.recognize_sync_version(new_version); // Throws
+ sess.recognize_sync_version(new_version); // Throws
self->on_upload_progress(/* only_if_new_uploadable_data = */ true); // Throws
});
}
diff --git a/src/realm/sync/instruction_applier.cpp b/src/realm/sync/instruction_applier.cpp
index a8673e74c60..72139b77b66 100644
--- a/src/realm/sync/instruction_applier.cpp
+++ b/src/realm/sync/instruction_applier.cpp
@@ -174,66 +174,65 @@ void InstructionApplier::operator()(const Instruction::CreateObject& instr)
ColKey pk_col = table->get_primary_key_column();
m_last_object_key = instr.object;
- mpark::visit(
- util::overload{
- [&](mpark::monostate) {
- if (!pk_col) {
- bad_transaction_log("CreateObject(NULL) on table without a primary key");
- }
- if (!table->is_nullable(pk_col)) {
- bad_transaction_log("CreateObject(NULL) on a table with a non-nullable primary key");
- }
- m_last_object = table->create_object_with_primary_key(util::none);
- },
- [&](int64_t pk) {
- if (!pk_col) {
- bad_transaction_log("CreateObject(Int) on table without a primary key");
- }
- if (table->get_column_type(pk_col) != type_Int) {
- bad_transaction_log("CreateObject(Int) on a table with primary key type %1",
- table->get_column_type(pk_col));
- }
- m_last_object = table->create_object_with_primary_key(pk);
- },
- [&](InternString pk) {
- if (!pk_col) {
- bad_transaction_log("CreateObject(String) on table without a primary key");
- }
- if (table->get_column_type(pk_col) != type_String) {
- bad_transaction_log("CreateObject(String) on a table with primary key type %1",
- table->get_column_type(pk_col));
- }
- StringData str = get_string(pk);
- m_last_object = table->create_object_with_primary_key(str);
- },
- [&](const ObjectId& id) {
- if (!pk_col) {
- bad_transaction_log("CreateObject(ObjectId) on table without a primary key");
- }
- if (table->get_column_type(pk_col) != type_ObjectId) {
- bad_transaction_log("CreateObject(ObjectId) on a table with primary key type %1",
- table->get_column_type(pk_col));
- }
- m_last_object = table->create_object_with_primary_key(id);
- },
- [&](const UUID& id) {
- if (!pk_col) {
- bad_transaction_log("CreateObject(UUID) on table without a primary key");
- }
- if (table->get_column_type(pk_col) != type_UUID) {
- bad_transaction_log("CreateObject(UUID) on a table with primary key type %1",
- table->get_column_type(pk_col));
- }
- m_last_object = table->create_object_with_primary_key(id);
- },
- [&](GlobalKey key) {
- if (pk_col) {
- bad_transaction_log("CreateObject(GlobalKey) on table with a primary key");
- }
- m_last_object = table->create_object(key);
- },
- },
- instr.object);
+ mpark::visit(util::overload{
+ [&](mpark::monostate) {
+ if (!pk_col) {
+ bad_transaction_log("CreateObject(NULL) on table without a primary key");
+ }
+ if (!table->is_nullable(pk_col)) {
+ bad_transaction_log("CreateObject(NULL) on a table with a non-nullable primary key");
+ }
+ m_last_object = table->create_object_with_primary_key(util::none);
+ },
+ [&](int64_t pk) {
+ if (!pk_col) {
+ bad_transaction_log("CreateObject(Int) on table without a primary key");
+ }
+ if (table->get_column_type(pk_col) != type_Int) {
+ bad_transaction_log("CreateObject(Int) on a table with primary key type %1",
+ table->get_column_type(pk_col));
+ }
+ m_last_object = table->create_object_with_primary_key(pk);
+ },
+ [&](InternString pk) {
+ if (!pk_col) {
+ bad_transaction_log("CreateObject(String) on table without a primary key");
+ }
+ if (table->get_column_type(pk_col) != type_String) {
+ bad_transaction_log("CreateObject(String) on a table with primary key type %1",
+ table->get_column_type(pk_col));
+ }
+ StringData str = get_string(pk);
+ m_last_object = table->create_object_with_primary_key(str);
+ },
+ [&](const ObjectId& id) {
+ if (!pk_col) {
+ bad_transaction_log("CreateObject(ObjectId) on table without a primary key");
+ }
+ if (table->get_column_type(pk_col) != type_ObjectId) {
+ bad_transaction_log("CreateObject(ObjectId) on a table with primary key type %1",
+ table->get_column_type(pk_col));
+ }
+ m_last_object = table->create_object_with_primary_key(id);
+ },
+ [&](const UUID& id) {
+ if (!pk_col) {
+ bad_transaction_log("CreateObject(UUID) on table without a primary key");
+ }
+ if (table->get_column_type(pk_col) != type_UUID) {
+ bad_transaction_log("CreateObject(UUID) on a table with primary key type %1",
+ table->get_column_type(pk_col));
+ }
+ m_last_object = table->create_object_with_primary_key(id);
+ },
+ [&](GlobalKey key) {
+ if (pk_col) {
+ bad_transaction_log("CreateObject(GlobalKey) on table with a primary key");
+ }
+ m_last_object = table->create_object(key);
+ },
+ },
+ instr.object);
}
void InstructionApplier::operator()(const Instruction::EraseObject& instr)
diff --git a/src/realm/sync/network/default_socket.hpp b/src/realm/sync/network/default_socket.hpp
index 81c956631d1..33dbc3730d0 100644
--- a/src/realm/sync/network/default_socket.hpp
+++ b/src/realm/sync/network/default_socket.hpp
@@ -46,8 +46,7 @@ class DefaultSocketProvider : public SyncSocketProvider {
network::DeadlineTimer m_timer;
};
- struct AutoStartTag {
- };
+ struct AutoStartTag {};
using AutoStart = util::TaggedBool;
DefaultSocketProvider(const std::shared_ptr& logger, const std::string& user_agent,
diff --git a/src/realm/sync/noinst/changeset_index.hpp b/src/realm/sync/noinst/changeset_index.hpp
index 30753782226..0280b11621b 100644
--- a/src/realm/sync/noinst/changeset_index.hpp
+++ b/src/realm/sync/noinst/changeset_index.hpp
@@ -178,8 +178,7 @@ struct ChangesetIndex::RangeIterator {
}
}
- struct end_tag {
- };
+ struct end_tag {};
/// Create an iterator representing the end.
RangeIterator(ChangesetIndex::Ranges* ranges, end_tag) noexcept
: m_ranges(ranges)
diff --git a/src/realm/sync/noinst/client_impl_base.hpp b/src/realm/sync/noinst/client_impl_base.hpp
index 8c5af9963f1..6dc55bfb386 100644
--- a/src/realm/sync/noinst/client_impl_base.hpp
+++ b/src/realm/sync/noinst/client_impl_base.hpp
@@ -291,8 +291,8 @@ class ClientImpl {
std::mutex m_mutex;
- bool m_stopped = false; // Protected by `m_mutex`
- bool m_sessions_terminated = false; // Protected by `m_mutex`
+ bool m_stopped = false; // Protected by `m_mutex`
+ bool m_sessions_terminated = false; // Protected by `m_mutex`
// The set of session wrappers that are not yet wrapping a session object,
// and are not yet abandoned (still referenced by the application).
diff --git a/src/realm/sync/noinst/server/server.cpp b/src/realm/sync/noinst/server/server.cpp
index e2a0d53e249..aeac91412f5 100644
--- a/src/realm/sync/noinst/server/server.cpp
+++ b/src/realm/sync/noinst/server/server.cpp
@@ -4052,8 +4052,8 @@ void ServerImpl::handle_accept(std::error_code ec)
else {
HTTPConnection& conn = *m_next_http_conn;
if (m_config.tcp_no_delay)
- conn.get_socket().set_option(network::SocketBase::no_delay(true)); // Throws
- m_http_connections.emplace(conn.get_id(), std::move(m_next_http_conn)); // Throws
+ conn.get_socket().set_option(network::SocketBase::no_delay(true)); // Throws
+ m_http_connections.emplace(conn.get_id(), std::move(m_next_http_conn)); // Throws
Formatter& formatter = m_misc_buffers.formatter;
formatter.reset();
formatter << "[" << m_next_http_conn_endpoint.address() << "]:" << m_next_http_conn_endpoint.port(); // Throws
diff --git a/src/realm/sync/noinst/server/server_history.cpp b/src/realm/sync/noinst/server/server_history.cpp
index cbaeaf87910..e5764e1c574 100644
--- a/src/realm/sync/noinst/server/server_history.cpp
+++ b/src/realm/sync/noinst/server/server_history.cpp
@@ -1330,8 +1330,8 @@ _impl::History* ServerHistory::_get_history_write()
// Overriding member in Replication
std::unique_ptr<_impl::History> ServerHistory::_create_history_read()
{
- auto server_hist = std::make_unique(m_context); // Throws
- server_hist->initialize(*m_db); // Throws
+ auto server_hist = std::make_unique(m_context); // Throws
+ server_hist->initialize(*m_db); // Throws
return std::unique_ptr<_impl::History>(server_hist.release());
}
diff --git a/src/realm/sync/noinst/sync_metadata_schema.hpp b/src/realm/sync/noinst/sync_metadata_schema.hpp
index 0c6ac6040ff..2bd8efa2993 100644
--- a/src/realm/sync/noinst/sync_metadata_schema.hpp
+++ b/src/realm/sync/noinst/sync_metadata_schema.hpp
@@ -36,7 +36,7 @@ namespace internal_schema_groups {
constexpr static std::string_view c_flx_subscription_store("flx_subscription_store");
constexpr static std::string_view c_pending_bootstraps("pending_bootstraps");
constexpr static std::string_view c_flx_migration_store("flx_migration_store");
-}
+} // namespace internal_schema_groups
/*
* The types in this file represent the schema for tables used internally by the sync client. They are similar
@@ -88,8 +88,7 @@ struct SyncMetadataTable {
util::Optional pk_info;
std::vector columns;
- struct IsEmbeddedTag {
- };
+ struct IsEmbeddedTag {};
SyncMetadataTable(TableKey* out, std::string_view name, IsEmbeddedTag,
std::initializer_list columns)
: key_out(out)
diff --git a/src/realm/sync/subscriptions.hpp b/src/realm/sync/subscriptions.hpp
index 751ec84e457..8b735d53ac4 100644
--- a/src/realm/sync/subscriptions.hpp
+++ b/src/realm/sync/subscriptions.hpp
@@ -190,8 +190,7 @@ class SubscriptionSet {
protected:
friend class SubscriptionStore;
- struct SupersededTag {
- };
+ struct SupersededTag {};
using MakingMutableCopy = util::TaggedBool;
explicit SubscriptionSet(std::weak_ptr mgr, int64_t version, SupersededTag);
diff --git a/src/realm/table.hpp b/src/realm/table.hpp
index a7785f1863f..e175c6548f4 100644
--- a/src/realm/table.hpp
+++ b/src/realm/table.hpp
@@ -63,8 +63,7 @@ template
class SubQuery;
class TableView;
-struct Link {
-};
+struct Link {};
typedef Link BackLink;
@@ -728,13 +727,13 @@ class Table {
{
m_alloc.refresh_ref_translation();
}
- Spec m_spec; // 1st slot in m_top
- ClusterTree m_clusters; // 3rd slot in m_top
- std::unique_ptr m_tombstones; // 13th slot in m_top
- TableKey m_key; // 4th slot in m_top
- Array m_index_refs; // 5th slot in m_top
- Array m_opposite_table; // 7th slot in m_top
- Array m_opposite_column; // 8th slot in m_top
+ Spec m_spec; // 1st slot in m_top
+ ClusterTree m_clusters; // 3rd slot in m_top
+ std::unique_ptr m_tombstones; // 13th slot in m_top
+ TableKey m_key; // 4th slot in m_top
+ Array m_index_refs; // 5th slot in m_top
+ Array m_opposite_table; // 7th slot in m_top
+ Array m_opposite_column; // 8th slot in m_top
std::vector> m_index_accessors;
ColKey m_primary_key_col;
Replication* const* m_repl;
diff --git a/src/realm/table_ref.cpp b/src/realm/table_ref.cpp
index 16953b443ac..a65a7ceb33d 100644
--- a/src/realm/table_ref.cpp
+++ b/src/realm/table_ref.cpp
@@ -75,4 +75,4 @@ Table* TableRef::operator->() const
}
-}
+} // namespace realm
diff --git a/src/realm/table_view.cpp b/src/realm/table_view.cpp
index 4fbd2cab501..8b06208192c 100644
--- a/src/realm/table_view.cpp
+++ b/src/realm/table_view.cpp
@@ -70,8 +70,7 @@ TableView::TableView(TableView& src, Transaction* tr, PayloadPolicy policy_mode)
// Aggregates ----------------------------------------------------
template
-struct Aggregator {
-};
+struct Aggregator {};
template
struct Aggregator {
diff --git a/src/realm/timestamp.hpp b/src/realm/timestamp.hpp
index 5e77f2717fe..77f71f30a05 100644
--- a/src/realm/timestamp.hpp
+++ b/src/realm/timestamp.hpp
@@ -224,6 +224,6 @@ struct numeric_limits {
return realm::Timestamp(numeric_limits::max(), 0);
}
};
-}
+} // namespace std
#endif // REALM_TIMESTAMP_HPP
diff --git a/src/realm/tools/unicode_table_generator.cpp b/src/realm/tools/unicode_table_generator.cpp
index 9cd2b6626d2..45d67afcd8f 100644
--- a/src/realm/tools/unicode_table_generator.cpp
+++ b/src/realm/tools/unicode_table_generator.cpp
@@ -6,9 +6,7 @@
#include
#include
-std::vector tokenize(const char* src,
- char delim,
- bool want_empty_tokens = true)
+std::vector tokenize(const char* src, char delim, bool want_empty_tokens = true)
{
std::vector tokens;
@@ -49,20 +47,20 @@ int main()
std::cout << "static const uint32_t upper_lower[" << last_unicode << " + 1][2] = {";
- while (std::getline(infile, line))
- {
+ while (std::getline(infile, line)) {
std::istringstream iss(line);
std::vector v = tokenize(line.c_str(), ';');
uint32_t in = hex2int(v[0]);
gap:
- // The unicode characters in UnicodeData.txt can have gaps, i.e. increase by more than 1 for each new line. For skipped
- // characters (i.e. characters that have no case conversion that makes sense), we want to just return the same character
- // as we got as input. Signal that by a {0, 0}-entry.
+ // The unicode characters in UnicodeData.txt can have gaps, i.e. increase by more than 1 for each new line.
+ // For skipped characters (i.e. characters that have no case conversion that makes sense), we want to just
+ // return the same character as we got as input. Signal that by a {0, 0}-entry.
if (in > code)
std::cout << "{0, 0}";
else
- std::cout << "{" << (v[12] != "" ? "0x" + v[12] : "0") << ", " << (v[13] != "" ? "0x" + v[13] : "0") << "}";
+ std::cout << "{" << (v[12] != "" ? "0x" + v[12] : "0") << ", " << (v[13] != "" ? "0x" + v[13] : "0")
+ << "}";
if (code != last_unicode)
std::cout << ", ";
@@ -83,4 +81,3 @@ int main()
return 0;
}
-
diff --git a/src/realm/util/backtrace.hpp b/src/realm/util/backtrace.hpp
index 801102392d3..4645d397dbc 100644
--- a/src/realm/util/backtrace.hpp
+++ b/src/realm/util/backtrace.hpp
@@ -43,9 +43,7 @@ struct Backtrace {
void print(std::ostream&) const;
/// Construct an empty stack trace.
- Backtrace() noexcept
- {
- }
+ Backtrace() noexcept {}
/// Move constructor. This operation cannot fail.
Backtrace(Backtrace&&) noexcept;
diff --git a/src/realm/util/base64.cpp b/src/realm/util/base64.cpp
index e6632c32c61..e8361dfd860 100644
--- a/src/realm/util/base64.cpp
+++ b/src/realm/util/base64.cpp
@@ -21,16 +21,17 @@
#include
#if defined(_MSC_VER)
-# define REALM_RESTRICT __restrict
+#define REALM_RESTRICT __restrict
#elif defined(__GNUC__) || defined(__clang__)
-# define REALM_RESTRICT __restrict__
+#define REALM_RESTRICT __restrict__
#else
-# define REALM_RESTRICT
+#define REALM_RESTRICT
#endif
namespace {
+// clang-format off
static const char g_base64_encoding_chars[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
@@ -61,6 +62,7 @@ static const unsigned char g_base64_chars[] = {
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66
};
+// clang-format on
inline unsigned int index_of_base64_byte(unsigned char c)
{
@@ -126,9 +128,9 @@ std::optional base64_decode(Span input, Span out_buffe
char* REALM_RESTRICT o = out_buffer.data();
enum b64_byte_type {
- equals = 64, // used as padding at the end
+ equals = 64, // used as padding at the end
whitespace = 65,
- invalid = 66,
+ invalid = 66,
};
size_t bytes_written = 0;
@@ -139,9 +141,13 @@ std::optional base64_decode(Span input, Span out_buffe
// classify the base64 character
unsigned int x = index_of_base64_byte(static_cast(p[i]));
switch (x) {
- case equals: ++num_trailing_equals; continue;
- case whitespace: continue; // ignore whitespace
- case invalid: return none;
+ case equals:
+ ++num_trailing_equals;
+ continue;
+ case whitespace:
+ continue; // ignore whitespace
+ case invalid:
+ return none;
}
if (num_trailing_equals > 0)
@@ -153,8 +159,8 @@ std::optional base64_decode(Span input, Span out_buffe
if (buffer_size == 4) {
*o++ = (buffer >> 16) & 0xff;
- *o++ = (buffer >> 8) & 0xff;
- *o++ = (buffer >> 0) & 0xff;
+ *o++ = (buffer >> 8) & 0xff;
+ *o++ = (buffer >> 0) & 0xff;
buffer = 0;
buffer_size = 0;
bytes_written += 3;
@@ -166,7 +172,7 @@ std::optional base64_decode(Span input, Span out_buffe
if (num_trailing_equals == 0 && extra > 1) {
num_trailing_equals = 4 - extra;
}
-
+
// trailing bytes
if (num_trailing_equals == 0) {
if (buffer_size != 0)
@@ -174,11 +180,11 @@ std::optional base64_decode(Span input, Span out_buffe
}
else if (num_trailing_equals == 1) {
*o++ = (buffer >> 10) & 0xff;
- *o++ = (buffer >> 2) & 0xff;
+ *o++ = (buffer >> 2) & 0xff;
bytes_written += 2;
}
else if (num_trailing_equals == 2) {
- *o++ = (buffer >> 4) & 0xff;
+ *o++ = (buffer >> 4) & 0xff;
bytes_written += 1;
}
else {
diff --git a/src/realm/util/base64.hpp b/src/realm/util/base64.hpp
index d47e9d02a64..2c78ebdfe02 100644
--- a/src/realm/util/base64.hpp
+++ b/src/realm/util/base64.hpp
@@ -62,7 +62,6 @@ inline size_t base64_decoded_size(size_t base64_size) noexcept
}
-
/// base64_decode_to_vector() is a convenience function that decodes \param
/// encoded and returns the result in a std::vector with the correct size.
/// This function returns none if the input is invalid.
@@ -71,4 +70,3 @@ std::optional> base64_decode_to_vector(Span encode
} // namespace realm::util
#endif // REALM_UTIL_BASE64_HPP
-
diff --git a/src/realm/util/bind_ptr.hpp b/src/realm/util/bind_ptr.hpp
index 355648e3f1a..57bb8b9ed78 100644
--- a/src/realm/util/bind_ptr.hpp
+++ b/src/realm/util/bind_ptr.hpp
@@ -34,8 +34,7 @@ namespace util {
class bind_ptr_base {
public:
- struct adopt_tag {
- };
+ struct adopt_tag {};
};
@@ -234,8 +233,7 @@ class bind_ptr : public bind_ptr_base {
}
protected:
- struct casting_move_tag {
- };
+ struct casting_move_tag {};
template
bind_ptr(bind_ptr* p, casting_move_tag) noexcept
: m_ptr(static_cast(p->release()))
diff --git a/src/realm/util/cf_ptr.hpp b/src/realm/util/cf_ptr.hpp
index a1ec431f1b0..0c97c21034f 100644
--- a/src/realm/util/cf_ptr.hpp
+++ b/src/realm/util/cf_ptr.hpp
@@ -99,8 +99,8 @@ CFPtr[ retainCF(Ref ptr)
CFRetain(ptr);
return CFPtr][(ptr);
}
-}
-}
+} // namespace util
+} // namespace realm
#endif // REALM_PLATFORM_APPLE
diff --git a/src/realm/util/fifo_helper.hpp b/src/realm/util/fifo_helper.hpp
index 441bd29b3fe..f9dadc19f33 100644
--- a/src/realm/util/fifo_helper.hpp
+++ b/src/realm/util/fifo_helper.hpp
@@ -34,7 +34,8 @@ void create_fifo(std::string_view path); // throws
bool try_create_fifo(std::string_view path, bool has_more_fallbacks = true);
// Ensure that a path representing a directory ends with `/`
-inline std::string normalize_dir(const std::string& path) {
+inline std::string normalize_dir(const std::string& path)
+{
return (!path.empty() && path.back() != '/') ? path + '/' : path;
}
diff --git a/src/realm/util/file.cpp b/src/realm/util/file.cpp
index a0e472aa49b..6a604db8a8e 100644
--- a/src/realm/util/file.cpp
+++ b/src/realm/util/file.cpp
@@ -1578,7 +1578,7 @@ bool File::copy(const std::string& origin_path, const std::string& target_path,
}
#endif
- File origin_file{origin_path, mode_Read}; // Throws
+ File origin_file{origin_path, mode_Read}; // Throws
File target_file;
bool did_create = false;
target_file.open(target_path, did_create); // Throws
diff --git a/src/realm/util/functional.hpp b/src/realm/util/functional.hpp
index aee92d2fcdd..bd9894cf86d 100644
--- a/src/realm/util/functional.hpp
+++ b/src/realm/util/functional.hpp
@@ -169,20 +169,15 @@ class UniqueFunction {
* function pointers. We don't currently support r-value-qualified call operators.
*/
template
-struct UFDeductionHelper {
-};
+struct UFDeductionHelper {};
template
-struct UFDeductionHelper : TypeIdentity {
-};
+struct UFDeductionHelper : TypeIdentity {};
template
-struct UFDeductionHelper : TypeIdentity {
-};
+struct UFDeductionHelper : TypeIdentity {};
template
-struct UFDeductionHelper : TypeIdentity {
-};
+struct UFDeductionHelper : TypeIdentity {};
template
-struct UFDeductionHelper : TypeIdentity {
-};
+struct UFDeductionHelper : TypeIdentity {};
/**
* Deduction guides for UniqueFunction that pluck the signature off of function pointers and
diff --git a/src/realm/util/future.hpp b/src/realm/util/future.hpp
index 78f556cef2f..aad7be1ef41 100644
--- a/src/realm/util/future.hpp
+++ b/src/realm/util/future.hpp
@@ -53,8 +53,7 @@ constexpr static bool is_future> = true;
// FakeVoid is a helper type for futures for callbacks or values that return/are void but need to be represented
// as a value. It should not be visible to callers outside of future_details.
-struct FakeVoid {
-};
+struct FakeVoid {};
template
using VoidToFakeVoid = std::conditional_t, FakeVoid, T>;
diff --git a/src/realm/util/interprocess_mutex.hpp b/src/realm/util/interprocess_mutex.hpp
index 6787f32222d..d50c0dac3cc 100644
--- a/src/realm/util/interprocess_mutex.hpp
+++ b/src/realm/util/interprocess_mutex.hpp
@@ -83,8 +83,7 @@ class InterprocessMutex {
InterprocessMutex& operator=(const InterprocessMutex&) = delete;
#if REALM_ROBUST_MUTEX_EMULATION || defined(_WIN32)
- struct SharedPart {
- };
+ struct SharedPart {};
#else
using SharedPart = RobustMutex;
#endif
diff --git a/src/realm/util/memory_stream.cpp b/src/realm/util/memory_stream.cpp
index 14a2735a112..f9f65b667bc 100644
--- a/src/realm/util/memory_stream.cpp
+++ b/src/realm/util/memory_stream.cpp
@@ -110,12 +110,12 @@ auto MemoryInputStreambuf::do_seekoff(off_type offset, std::ios_base::seekdir di
}
goto bad;
- good:
+good:
if (offset >= (m_begin - anchor) && offset <= (m_end - anchor)) {
m_curr = anchor + std::ptrdiff_t(offset);
return pos_type(off_type(m_curr - m_begin));
}
- bad:
+bad:
return pos_type(off_type(-1)); // Error
}
diff --git a/src/realm/util/memory_stream.hpp b/src/realm/util/memory_stream.hpp
index 81a48523c8d..1ebf10a257f 100644
--- a/src/realm/util/memory_stream.hpp
+++ b/src/realm/util/memory_stream.hpp
@@ -74,7 +74,8 @@ class MemoryInputStream : public std::istream {
/// \{ Behavior is undefined if the size of the specified buffer exceeds
/// PTRDIFF_MAX.
void set_buffer(const char* begin, const char* end) noexcept;
- template void set_buffer(const char (&buffer)[N]) noexcept;
+ template
+ void set_buffer(const char (&buffer)[N]) noexcept;
void set_string(const std::string&) noexcept;
void set_c_string(const char* c_str) noexcept;
/// \}
@@ -92,7 +93,8 @@ class MemoryOutputStream : public std::ostream {
/// \{ Behavior is undefined if the size of the specified buffer exceeds
/// PTRDIFF_MAX.
void set_buffer(char* begin, char* end) noexcept;
- template void set_buffer(char (&buffer)[N]) noexcept;
+ template
+ void set_buffer(char (&buffer)[N]) noexcept;
/// \}
/// Returns the amount of data written to the underlying buffer.
@@ -112,9 +114,7 @@ inline MemoryInputStreambuf::MemoryInputStreambuf()
{
}
-inline MemoryInputStreambuf::~MemoryInputStreambuf() noexcept
-{
-}
+inline MemoryInputStreambuf::~MemoryInputStreambuf() noexcept {}
inline void MemoryInputStreambuf::set_buffer(const char* b, const char* e) noexcept
{
@@ -124,13 +124,9 @@ inline void MemoryInputStreambuf::set_buffer(const char* b, const char* e) noexc
}
-inline MemoryOutputStreambuf::MemoryOutputStreambuf()
-{
-}
+inline MemoryOutputStreambuf::MemoryOutputStreambuf() {}
-inline MemoryOutputStreambuf::~MemoryOutputStreambuf() noexcept
-{
-}
+inline MemoryOutputStreambuf::~MemoryOutputStreambuf() noexcept {}
inline void MemoryOutputStreambuf::set_buffer(char* b, char* e) noexcept
{
@@ -148,9 +144,7 @@ inline MemoryInputStream::MemoryInputStream()
{
}
-inline MemoryInputStream::~MemoryInputStream() noexcept
-{
-}
+inline MemoryInputStream::~MemoryInputStream() noexcept {}
inline void MemoryInputStream::set_buffer(const char* b, const char* e) noexcept
{
@@ -158,7 +152,8 @@ inline void MemoryInputStream::set_buffer(const char* b, const char* e) noexcept
clear();
}
-template inline void MemoryInputStream::set_buffer(const char (&buffer)[N]) noexcept
+template
+inline void MemoryInputStream::set_buffer(const char (&buffer)[N]) noexcept
{
const char* b = buffer;
const char* e = b + N;
@@ -185,9 +180,7 @@ inline MemoryOutputStream::MemoryOutputStream()
{
}
-inline MemoryOutputStream::~MemoryOutputStream() noexcept
-{
-}
+inline MemoryOutputStream::~MemoryOutputStream() noexcept {}
inline void MemoryOutputStream::set_buffer(char* b, char* e) noexcept
{
diff --git a/src/realm/util/priority_queue.hpp b/src/realm/util/priority_queue.hpp
index a2a28c89d6d..51e7e2180cc 100644
--- a/src/realm/util/priority_queue.hpp
+++ b/src/realm/util/priority_queue.hpp
@@ -298,7 +298,7 @@ void PriorityQueue::swap(PriorityQueue& other)
swap(m_queue, other.m_queue);
swap(compare(), other.compare());
}
-}
-}
+} // namespace util
+} // namespace realm
#endif // REALM_UTIL_PRIORITY_QUEUE_HPP
diff --git a/src/realm/util/serializer.hpp b/src/realm/util/serializer.hpp
index 81d68f26edf..4f403cbcf97 100644
--- a/src/realm/util/serializer.hpp
+++ b/src/realm/util/serializer.hpp
@@ -59,15 +59,20 @@ std::string print_value(Optional value);
constexpr static const char value_separator[] = ".";
// Specializations declared here to be defined in the cpp file
-template <> std::string print_value<>(BinaryData);
-template <> std::string print_value<>(bool);
+template <>
+std::string print_value<>(BinaryData);
+template <>
+std::string print_value<>(bool);
template <>
std::string print_value<>(float);
template <>
std::string print_value<>(double);
-template <> std::string print_value<>(realm::null);
-template <> std::string print_value<>(StringData);
-template <> std::string print_value<>(realm::Timestamp);
+template <>
+std::string print_value<>(realm::null);
+template <>
+std::string print_value<>(StringData);
+template <>
+std::string print_value<>(realm::Timestamp);
template <>
std::string print_value<>(realm::ObjectId);
template <>
@@ -99,7 +104,8 @@ std::string print_value(Optional value)
{
if (bool(value)) {
return print_value(*value);
- } else {
+ }
+ else {
return "NULL";
}
}
diff --git a/src/realm/util/span.hpp b/src/realm/util/span.hpp
index d6e2422be0e..e027096cc39 100644
--- a/src/realm/util/span.hpp
+++ b/src/realm/util/span.hpp
@@ -47,18 +47,14 @@ namespace realm::_impl {
// std::array, C arrays, and Span have separate conversions which need to be
// used instead of the generic one.
template
-struct IsSpan : public std::false_type {
-};
+struct IsSpan : public std::false_type {};
template
-struct IsSpan> : public std::true_type {
-};
+struct IsSpan> : public std::true_type {};
template
-struct IsStdArray : public std::false_type {
-};
+struct IsStdArray : public std::false_type {};
template
-struct IsStdArray> : public std::true_type {
-};
+struct IsStdArray> : public std::true_type {};
// msvc v19.28 hits an internal compiler error if these are inline in the
// template using them rather than type aliases. This appears to be fixed in
diff --git a/src/realm/util/thread.cpp b/src/realm/util/thread.cpp
index 192dacf58f3..3a878be2443 100644
--- a/src/realm/util/thread.cpp
+++ b/src/realm/util/thread.cpp
@@ -253,7 +253,7 @@ int RobustMutex::try_low_level_lock()
bool RobustMutex::is_valid() noexcept
{
-#ifdef _WIN32
+#ifdef _WIN32
REALM_ASSERT_RELEASE(false);
#else
// FIXME: This check tries to lock the mutex, and only unlocks it if the
diff --git a/src/realm/util/thread.hpp b/src/realm/util/thread.hpp
index 9906e9c26f0..738ad543741 100644
--- a/src/realm/util/thread.hpp
+++ b/src/realm/util/thread.hpp
@@ -93,10 +93,9 @@ class Thread {
static bool get_name(std::string& name) noexcept;
private:
-
#ifdef _WIN32
std::thread m_std_thread;
-#else
+#else
pthread_t m_id;
#endif
bool m_joinable;
@@ -118,8 +117,7 @@ class Mutex {
Mutex();
~Mutex() noexcept;
- struct process_shared_tag {
- };
+ struct process_shared_tag {};
/// Initialize this mutex for use across multiple processes. When
/// constructed this way, the instance may be placed in memory
/// shared by multiple processes, as well as in a memory mapped
@@ -150,11 +148,8 @@ class Mutex {
pthread_mutex_t m_impl = PTHREAD_MUTEX_INITIALIZER;
#endif
- struct no_init_tag {
- };
- Mutex(no_init_tag)
- {
- }
+ struct no_init_tag {};
+ Mutex(no_init_tag) {}
void init_as_regular();
void init_as_process_shared(bool robust_if_available);
@@ -183,8 +178,7 @@ class LockGuard {
/// See UniqueLock.
-struct defer_lock_tag {
-};
+struct defer_lock_tag {};
/// A general-purpose mutex ownership wrapper supporting deferred
/// locking as well as repeated unlocking and relocking.
@@ -340,8 +334,7 @@ class CondVar {
CondVar();
~CondVar() noexcept;
- struct process_shared_tag {
- };
+ struct process_shared_tag {};
/// Initialize this condition variable for use across multiple
/// processes. When constructed this way, the instance may be
@@ -629,9 +622,7 @@ inline RobustMutex::RobustMutex()
init_as_process_shared(robust_if_available);
}
-inline RobustMutex::~RobustMutex() noexcept
-{
-}
+inline RobustMutex::~RobustMutex() noexcept {}
template
inline void RobustMutex::lock(Func recover_func)
@@ -661,7 +652,8 @@ template
inline bool RobustMutex::try_lock(Func recover_func)
{
int lock_result = try_low_level_lock(); // Throws
- if (lock_result == 0) return false;
+ if (lock_result == 0)
+ return false;
bool no_thread_has_died = lock_result == 1;
if (REALM_LIKELY(no_thread_has_died))
return true;
@@ -740,7 +732,8 @@ inline void CondVar::wait(RobustMutex& m, Func recover_func, const struct timesp
r = GetLastError();
if (r == ERROR_TIMEOUT)
return;
- } else {
+ }
+ else {
r = 0;
}
#else
diff --git a/src/realm/util/to_string.cpp b/src/realm/util/to_string.cpp
index 2b476ca3bb9..60a1998117c 100644
--- a/src/realm/util/to_string.cpp
+++ b/src/realm/util/to_string.cpp
@@ -39,7 +39,7 @@ void quoted(std::ostream& out, T&& str, ...)
{
out << '"' << str << '"';
}
-}
+} // namespace
namespace realm {
namespace util {
diff --git a/src/realm/utilities.hpp b/src/realm/utilities.hpp
index c2c53252f53..fc3a9c5bd1a 100644
--- a/src/realm/utilities.hpp
+++ b/src/realm/utilities.hpp
@@ -271,16 +271,13 @@ struct InternalFindResult {
// realm::is_any ==
// std::is_same::value || std::is_same::value || std::is_same::value ...
template
-struct is_any : std::false_type {
-};
+struct is_any : std::false_type {};
template
-struct is_any : std::true_type {
-};
+struct is_any : std::true_type {};
template
-struct is_any : is_any {
-};
+struct is_any : is_any {};
template
inline constexpr bool is_any_v = is_any::value;
diff --git a/src/realm/uuid.hpp b/src/realm/uuid.hpp
index 17a39427972..5d0f4c7b781 100644
--- a/src/realm/uuid.hpp
+++ b/src/realm/uuid.hpp
@@ -46,8 +46,7 @@ class UUID {
explicit UUID(StringData);
/// Constructs a UUID with all zero bytes
- UUID()
- noexcept
+ UUID() noexcept
: m_bytes{}
{
}
diff --git a/src/realm/version.hpp b/src/realm/version.hpp
index eb6d8f768e3..2f6c7429bcb 100644
--- a/src/realm/version.hpp
+++ b/src/realm/version.hpp
@@ -39,9 +39,18 @@ class StringData;
class Version {
public:
- static int get_major() { return REALM_VERSION_MAJOR; }
- static int get_minor() { return REALM_VERSION_MINOR; }
- static int get_patch() { return REALM_VERSION_PATCH; }
+ static int get_major()
+ {
+ return REALM_VERSION_MAJOR;
+ }
+ static int get_minor()
+ {
+ return REALM_VERSION_MINOR;
+ }
+ static int get_patch()
+ {
+ return REALM_VERSION_PATCH;
+ }
static StringData get_extra();
static std::string get_version();
static bool is_at_least(int major, int minor, int patch, StringData extra);
diff --git a/test/benchmark-common-tasks/compatibility_legacy.cpp b/test/benchmark-common-tasks/compatibility_legacy.cpp
index 842a694a18b..2b7f7e7e84f 100644
--- a/test/benchmark-common-tasks/compatibility_legacy.cpp
+++ b/test/benchmark-common-tasks/compatibility_legacy.cpp
@@ -25,12 +25,12 @@ namespace compatibility {
DB::DurabilityLevel durability(RealmDurability level)
{
switch (level) {
- case RealmDurability::Full:
- return DB::durability_Full;
- case RealmDurability::MemOnly:
- return DB::durability_MemOnly;
- case RealmDurability::Async:
- return DB::durability_Async;
+ case RealmDurability::Full:
+ return DB::durability_Full;
+ case RealmDurability::MemOnly:
+ return DB::durability_MemOnly;
+ case RealmDurability::Async:
+ return DB::durability_Async;
}
REALM_ASSERT(false); // unhandled case
return DB::durability_Full;
@@ -42,4 +42,3 @@ DB* create_new_shared_group(std::string path, RealmDurability level, const char*
}
} // namespace compatibility
-
diff --git a/test/benchmark-common-tasks/main.cpp b/test/benchmark-common-tasks/main.cpp
index 3fc93028a09..5333e464dfc 100644
--- a/test/benchmark-common-tasks/main.cpp
+++ b/test/benchmark-common-tasks/main.cpp
@@ -85,16 +85,10 @@ const char* to_lead_cstr(DBOptions::Durability level);
const char* to_ident_cstr(DBOptions::Durability level);
struct Benchmark {
- Benchmark()
- {
- }
- virtual ~Benchmark()
- {
- }
+ Benchmark() {}
+ virtual ~Benchmark() {}
virtual const char* name() const = 0;
- virtual void before_all(DBRef)
- {
- }
+ virtual void before_all(DBRef) {}
virtual void after_all(DBRef)
{
m_keys.clear();
@@ -869,7 +863,8 @@ struct BenchmarkWithTimestamps : Benchmark {
if (r.draw_int(0, 100) / 100.0 < percent_chance_of_null) {
time = Timestamp{};
++num_nulls_added;
- } else {
+ }
+ else {
values.insert(time);
}
auto obj = t->create_object();
@@ -895,7 +890,8 @@ struct BenchmarkWithTimestamps : Benchmark {
};
struct BenchmarkQueryTimestampGreater : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10f;
percent_results_to_needle = 0.80f;
BenchmarkWithTimestamps::before_all(group);
@@ -910,7 +906,8 @@ struct BenchmarkQueryTimestampGreater : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().greater(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == values.size() - num_results_to_needle - 1, results.size(), num_results_to_needle, values.size());
+ REALM_ASSERT_EX(results.size() == values.size() - num_results_to_needle - 1, results.size(),
+ num_results_to_needle, values.size());
static_cast(results);
}
};
@@ -959,7 +956,8 @@ struct BenchmarkQueryTimestampGreaterOverLinks : BenchmarkQueryTimestampGreater
struct BenchmarkQueryTimestampGreaterEqual : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10f;
percent_results_to_needle = 0.80f;
BenchmarkWithTimestamps::before_all(group);
@@ -974,14 +972,16 @@ struct BenchmarkQueryTimestampGreaterEqual : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().greater_equal(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == values.size() - num_results_to_needle, results.size(), num_results_to_needle, values.size());
+ REALM_ASSERT_EX(results.size() == values.size() - num_results_to_needle, results.size(),
+ num_results_to_needle, values.size());
static_cast(results);
}
};
struct BenchmarkQueryTimestampLess : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10f;
percent_results_to_needle = 0.20f;
BenchmarkWithTimestamps::before_all(group);
@@ -996,13 +996,15 @@ struct BenchmarkQueryTimestampLess : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().less(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == num_results_to_needle, results.size(), num_results_to_needle, values.size());
+ REALM_ASSERT_EX(results.size() == num_results_to_needle, results.size(), num_results_to_needle,
+ values.size());
static_cast(results);
}
};
struct BenchmarkQueryTimestampLessEqual : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10f;
percent_results_to_needle = 0.20f;
BenchmarkWithTimestamps::before_all(group);
@@ -1017,14 +1019,16 @@ struct BenchmarkQueryTimestampLessEqual : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().less_equal(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == num_results_to_needle + 1, results.size(), num_results_to_needle, values.size());
+ REALM_ASSERT_EX(results.size() == num_results_to_needle + 1, results.size(), num_results_to_needle,
+ values.size());
static_cast(results);
}
};
struct BenchmarkQueryTimestampEqual : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10f;
percent_results_to_needle = 0.33f;
BenchmarkWithTimestamps::before_all(group);
@@ -1039,13 +1043,15 @@ struct BenchmarkQueryTimestampEqual : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().equal(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == values.count(needle), results.size(), num_results_to_needle, values.count(needle), values.size());
+ REALM_ASSERT_EX(results.size() == values.count(needle), results.size(), num_results_to_needle,
+ values.count(needle), values.size());
static_cast(results);
}
};
struct BenchmarkQueryTimestampNotEqual : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.60f;
percent_results_to_needle = 0.10f;
BenchmarkWithTimestamps::before_all(group);
@@ -1060,13 +1066,15 @@ struct BenchmarkQueryTimestampNotEqual : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().not_equal(m_col, needle);
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == values.size() - values.count(needle) + num_nulls_added, results.size(), values.size(), values.count(needle));
+ REALM_ASSERT_EX(results.size() == values.size() - values.count(needle) + num_nulls_added, results.size(),
+ values.size(), values.count(needle));
static_cast(results);
}
};
struct BenchmarkQueryTimestampNotNull : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.60f;
percent_results_to_needle = 0.0;
BenchmarkWithTimestamps::before_all(group);
@@ -1082,13 +1090,15 @@ struct BenchmarkQueryTimestampNotNull : BenchmarkWithTimestamps {
ConstTableRef table = m_table;
Query query = table->where().not_equal(m_col, realm::null());
TableView results = query.find_all();
- REALM_ASSERT_EX(results.size() == values.size(), results.size(), num_nulls_added, num_results_to_needle, values.size());
+ REALM_ASSERT_EX(results.size() == values.size(), results.size(), num_nulls_added, num_results_to_needle,
+ values.size());
static_cast(results);
}
};
struct BenchmarkQueryTimestampEqualNull : BenchmarkWithTimestamps {
- void before_all(DBRef group) {
+ void before_all(DBRef group)
+ {
percent_chance_of_null = 0.10;
percent_results_to_needle = 0.0;
BenchmarkWithTimestamps::before_all(group);
@@ -1930,7 +1940,8 @@ struct BenchmarkQueryInsensitiveString : BenchmarkWithStringsTable {
return str;
}
- size_t rand() {
+ size_t rand()
+ {
return seeded_rand.draw_int();
}
@@ -2048,7 +2059,6 @@ struct BenchmarkQueryNot : Benchmark {
tr.get_group().remove_table(name());
tr.commit();
}
-
};
struct BenchmarkGetLinkList : Benchmark {
diff --git a/test/benchmark-crud/main.cpp b/test/benchmark-crud/main.cpp
index 21f78b08f34..d39889181a0 100644
--- a/test/benchmark-crud/main.cpp
+++ b/test/benchmark-crud/main.cpp
@@ -70,7 +70,7 @@ inline void erase(TableRef table, const OrderVec& order)
table->remove_object(order[i]);
}
-} // anonymous namepsace
+} // namespace
extern "C" int benchmark_crud_main();
diff --git a/test/benchmark-history-types/main.cpp b/test/benchmark-history-types/main.cpp
index 6ca92cd094a..f842ed8321f 100644
--- a/test/benchmark-history-types/main.cpp
+++ b/test/benchmark-history-types/main.cpp
@@ -115,8 +115,8 @@ class Task {
std::string path = "/tmp/benchmark-history-types.realm";
util::File::try_remove(path);
- reader_histories.reset(new std::unique_ptr[ num_readers ]);
- reader_shared_groups.reset(new std::unique_ptr[ num_readers ]);
+ reader_histories.reset(new std::unique_ptr[num_readers]);
+ reader_shared_groups.reset(new std::unique_ptr[num_readers]);
for (int i = 0; i < num_readers; ++i) {
reader_histories[i] = make_history();
diff --git a/test/benchmark-row-accessor/main.cpp b/test/benchmark-row-accessor/main.cpp
index 90f78f49aa7..f4bbc669ad7 100644
--- a/test/benchmark-row-accessor/main.cpp
+++ b/test/benchmark-row-accessor/main.cpp
@@ -130,7 +130,7 @@ void balloon(Timer& timer, BenchmarkResults& results, int balloon_size, DetachOr
results.submit_single(ident, lead_text, timer);
}
-} // anonymous namepsace
+} // namespace
int main()
diff --git a/test/fuzz_group.cpp b/test/fuzz_group.cpp
index b47b0b47d68..eb423ae2b1a 100644
--- a/test/fuzz_group.cpp
+++ b/test/fuzz_group.cpp
@@ -52,8 +52,7 @@ using namespace realm::util;
namespace {
-struct EndOfFile {
-};
+struct EndOfFile {};
enum INS {
ADD_TABLE,
diff --git a/test/object-store/benchmarks/object.cpp b/test/object-store/benchmarks/object.cpp
index 24bd3d2356f..501d34635e6 100644
--- a/test/object-store/benchmarks/object.cpp
+++ b/test/object-store/benchmarks/object.cpp
@@ -97,50 +97,43 @@ TEST_CASE("Benchmark index change calculations", "[benchmark][index]") {
}
ObjKeys objkeys(indices);
- BENCHMARK("no changes")
- {
+ BENCHMARK("no changes") {
c = calc(objkeys, objkeys, none_modified);
};
REQUIRE(c.insertions.empty());
REQUIRE(c.deletions.empty());
- BENCHMARK("all modified")
- {
+ BENCHMARK("all modified") {
c = calc(objkeys, objkeys, all_modified);
};
REQUIRE(c.insertions.empty());
REQUIRE(c.deletions.empty());
- BENCHMARK("calc 1")
- {
+ BENCHMARK("calc 1") {
c = calc({1, 2, 3}, {1, 3, 2}, none_modified);
};
REQUIRE_INDICES(c.insertions, 1);
REQUIRE_INDICES(c.deletions, 2);
- BENCHMARK("calc 2")
- {
+ BENCHMARK("calc 2") {
c = calc({1, 2, 3}, {2, 1, 3}, none_modified);
};
REQUIRE_INDICES(c.insertions, 0);
REQUIRE_INDICES(c.deletions, 1);
- BENCHMARK("calc 3")
- {
+ BENCHMARK("calc 3") {
c = calc({1, 2, 3}, {2, 3, 1}, none_modified);
};
REQUIRE_INDICES(c.insertions, 2);
REQUIRE_INDICES(c.deletions, 0);
- BENCHMARK("calc 4")
- {
+ BENCHMARK("calc 4") {
c = calc({1, 2, 3}, {3, 1, 2}, none_modified);
};
REQUIRE_INDICES(c.insertions, 0);
REQUIRE_INDICES(c.deletions, 2);
- BENCHMARK("calc 5")
- {
+ BENCHMARK("calc 5") {
c = calc({1, 2, 3}, {3, 2, 1}, none_modified);
};
REQUIRE_INDICES(c.insertions, 0, 1);
@@ -209,8 +202,7 @@ TEST_CASE("Benchmark object", "[benchmark][object]") {
ObjectSchema all_types = *r->schema().find("all types");
int64_t benchmark_pk = 0;
- BENCHMARK("create object")
- {
+ BENCHMARK("create object") {
return Object::create(d, r, all_types,
std::any(AnyDict{
{"pk", benchmark_pk++},
diff --git a/test/object-store/sync/metadata.cpp b/test/object-store/sync/metadata.cpp
index dfde81dfaf4..091762032aa 100644
--- a/test/object-store/sync/metadata.cpp
+++ b/test/object-store/sync/metadata.cpp
@@ -779,7 +779,7 @@ TEST_CASE("sync metadata: can open old metadata realms", "[sync][metadata]") {
user->set_identities({{"identity 1", "a"}, {"shared identity", "shared"}});
user->add_realm_file_path("file 1");
user->add_realm_file_path("file 2");
-
+
user = manager.get_or_make_user_metadata(name, "b");
user->set_state_and_tokens(state2, token_2, refresh_token_2);
user->set_identities({{"identity 2", "b"}, {"shared identity", "shared"}});
diff --git a/test/object-store/thread_safe_reference.cpp b/test/object-store/thread_safe_reference.cpp
index 89532d69d7b..1e032a29c39 100644
--- a/test/object-store/thread_safe_reference.cpp
+++ b/test/object-store/thread_safe_reference.cpp
@@ -804,16 +804,15 @@ TEST_CASE("thread safe reference") {
}
SECTION("object results") {
- auto results =
- create_ref([](auto& r) {
- auto obj =
- create_object(r, "int array object", {{"value", AnyVector{AnyDict{{"value", INT64_C(0)}}}}});
- Results results =
- List(r, obj.get_obj(), get_table(*r, "int array object")->get_column_key("value"))
- .sort({{"value", true}});
- REQUIRE(results.size() == 1);
- return results;
- }).resolve(r);
+ auto results = create_ref([](auto& r) {
+ auto obj = create_object(r, "int array object",
+ {{"value", AnyVector{AnyDict{{"value", INT64_C(0)}}}}});
+ Results results =
+ List(r, obj.get_obj(), get_table(*r, "int array object")->get_column_key("value"))
+ .sort({{"value", true}});
+ REQUIRE(results.size() == 1);
+ return results;
+ }).resolve(r);
REQUIRE(results.is_valid());
REQUIRE(results.size() == 1);
}
@@ -937,16 +936,15 @@ TEST_CASE("thread safe reference") {
}
SECTION("object results") {
- auto results =
- create_ref([](auto& r) {
- auto obj =
- create_object(r, "int array object", {{"value", AnyVector{AnyDict{{"value", INT64_C(0)}}}}});
- Results results =
- List(r, obj.get_obj(), get_table(*r, "int array object")->get_column_key("value"))
- .sort({{"value", true}});
- REQUIRE(results.size() == 1);
- return results;
- }).resolve(r);
+ auto results = create_ref([](auto& r) {
+ auto obj = create_object(r, "int array object",
+ {{"value", AnyVector{AnyDict{{"value", INT64_C(0)}}}}});
+ Results results =
+ List(r, obj.get_obj(), get_table(*r, "int array object")->get_column_key("value"))
+ .sort({{"value", true}});
+ REQUIRE(results.size() == 1);
+ return results;
+ }).resolve(r);
REQUIRE(results.is_valid());
REQUIRE(results.size() == 1);
}
diff --git a/test/object-store/util/event_loop.cpp b/test/object-store/util/event_loop.cpp
index f2143896bf3..0f9914dcd27 100644
--- a/test/object-store/util/event_loop.cpp
+++ b/test/object-store/util/event_loop.cpp
@@ -264,7 +264,7 @@ void EventLoop::Impl::perform(util::UniqueFunction func)
{
__block auto f = std::move(func);
CFRunLoopPerformBlock(m_loop.get(), kCFRunLoopDefaultMode, ^{
- f();
+ f();
});
CFRunLoopWakeUp(m_loop.get());
}
diff --git a/test/performance/matrix.cpp b/test/performance/matrix.cpp
index c83285d78d5..864de8ef761 100644
--- a/test/performance/matrix.cpp
+++ b/test/performance/matrix.cpp
@@ -26,7 +26,7 @@
#include "../util/timer.hpp"
-//#define ONLY_CN_TESTS
+// #define ONLY_CN_TESTS
/************************************************************************************
// In Visual Studio, enable this matrix.cpp in compilation and disable test.cpp, else
@@ -263,9 +263,7 @@ class match11n {
};
class columns2 {
public:
- columns2()
- {
- }
+ columns2() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3;
@@ -273,9 +271,7 @@ class columns2 {
};
class columns3 {
public:
- columns3()
- {
- }
+ columns3() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3 && v.field4 == 15;
@@ -283,9 +279,7 @@ class columns3 {
};
class columns4 {
public:
- columns4()
- {
- }
+ columns4() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL;
@@ -293,9 +287,7 @@ class columns4 {
};
class columns5 {
public:
- columns5()
- {
- }
+ columns5() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL;
@@ -303,9 +295,7 @@ class columns5 {
};
class columns6 {
public:
- columns6()
- {
- }
+ columns6() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL &&
@@ -314,9 +304,7 @@ class columns6 {
};
class columns7 {
public:
- columns7()
- {
- }
+ columns7() {}
bool operator()(const TestStruct& v) const
{
return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL &&
diff --git a/test/realm-fuzzer/util.hpp b/test/realm-fuzzer/util.hpp
index 08af77fe271..deb6946bdfb 100644
--- a/test/realm-fuzzer/util.hpp
+++ b/test/realm-fuzzer/util.hpp
@@ -26,8 +26,7 @@ struct State {
size_t pos;
};
-struct EndOfFile {
-};
+struct EndOfFile {};
enum Instruction {
Add_Table = 0,
diff --git a/test/test_all.cpp b/test/test_all.cpp
index a2f6426901a..eeae889332f 100644
--- a/test/test_all.cpp
+++ b/test/test_all.cpp
@@ -204,7 +204,9 @@ class AggressiveGovernor : public util::PageReclaimGovernor {
public:
util::UniqueFunction current_target_getter(size_t) override
{
- return []() { return 4096; };
+ return []() {
+ return 4096;
+ };
}
void report_target_result(int64_t) override {}
};
@@ -292,9 +294,7 @@ class CustomReporter : public SimpleReporter {
{
}
- ~CustomReporter() noexcept
- {
- }
+ ~CustomReporter() noexcept {}
void end(const TestContext& context, double elapsed_seconds) override
{
diff --git a/test/test_array_mixed.cpp b/test/test_array_mixed.cpp
index 7e8c77974ca..1653ce79037 100644
--- a/test/test_array_mixed.cpp
+++ b/test/test_array_mixed.cpp
@@ -102,7 +102,7 @@ TEST(ArrayMixed_Basics)
arr.erase(5); // Erase string
CHECK_EQUAL(arr.get(5).get_binary(), BinaryData(bin.data(), bin.size()));
- arr.insert(2, Mixed()); // null
+ arr.insert(2, Mixed()); // null
arr.insert(2, int64_t(4500000000)); // Requires more than 32 bit
CHECK_EQUAL(arr.get(2).get_int(), 4500000000);
diff --git a/test/test_decimal128.cpp b/test/test_decimal128.cpp
index 5aa8e69e104..6184a42e7d2 100644
--- a/test/test_decimal128.cpp
+++ b/test/test_decimal128.cpp
@@ -71,7 +71,7 @@ TEST(Decimal_Basics)
test_double(0.1 / 1000 / 1000 / 1000 / 1000 / 1000 / 1000, "1.00000000000000E-19");
test_double(0.01 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, "1.00000000000000E16");
test_double(3.141592653589793238, "3.14159265358979"); // only 15 significant digits when converting from double
- Decimal128 pi = Decimal128("3.141592653589793238"); // 19 significant digits
+ Decimal128 pi = Decimal128("3.141592653589793238"); // 19 significant digits
CHECK_EQUAL(pi.to_string(), "3.141592653589793238");
Decimal128::Bid128 bid;
int exp;
diff --git a/test/test_destroy_guard.cpp b/test/test_destroy_guard.cpp
index 8402668ab2f..c05cb67e44c 100644
--- a/test/test_destroy_guard.cpp
+++ b/test/test_destroy_guard.cpp
@@ -83,9 +83,7 @@ class FooAlloc : public Allocator {
m_baseline = 8;
}
- ~FooAlloc() noexcept
- {
- }
+ ~FooAlloc() noexcept {}
MemRef do_alloc(const size_t size) override
{
@@ -141,9 +139,7 @@ class FooAlloc : public Allocator {
m_map.clear();
}
- void verify() const override
- {
- }
+ void verify() const override {}
void get_or_add_xover_mapping(RefTranslation&, size_t, size_t, size_t) override
{
REALM_ASSERT(false);
diff --git a/test/test_file_locks.cpp b/test/test_file_locks.cpp
index 96412d269b0..a15e56cc6f5 100644
--- a/test/test_file_locks.cpp
+++ b/test/test_file_locks.cpp
@@ -156,7 +156,9 @@ TEST(File_NoSpuriousTryLockFailures)
std::string str_path = path;
ThreadWrapper slaves[num_slaves];
for (int i = 0; i != num_slaves; ++i) {
- slaves[i].start([=] { slave(i, str_path); });
+ slaves[i].start([=] {
+ slave(i, str_path);
+ });
}
master();
for (int i = 0; i != num_slaves; ++i)
@@ -190,21 +192,21 @@ TEST_IF(File_NoSpuriousTryLockFailures2, !(running_with_valgrind || running_with
// More threads than cores will give OS time slice yields at random places which is good for randomness
size_t num_slaves = 2 * std::thread::hardware_concurrency(); // The number includes HyperThread cores
- std::atomic lock_taken { 0 };
- std::atomic barrier_1 { 0 };
- std::atomic barrier_2 { 0 };
- std::atomic lock_not_taken { 0 };
+ std::atomic lock_taken{0};
+ std::atomic barrier_1{0};
+ std::atomic barrier_2{0};
+ std::atomic lock_not_taken{0};
auto slave = [&](std::string path) {
File file(path, File::mode_Write);
- for(size_t t = 0; t < num_rounds; t++) {
+ for (size_t t = 0; t < num_rounds; t++) {
lock_taken = 0;
lock_not_taken = 0;
// Thread barrier
barrier_1++;
- while(barrier_1 < num_slaves) {
+ while (barrier_1 < num_slaves) {
}
// All threads race for the lock
@@ -212,7 +214,7 @@ TEST_IF(File_NoSpuriousTryLockFailures2, !(running_with_valgrind || running_with
barrier_2 = 0;
- if(owns_lock) {
+ if (owns_lock) {
lock_taken++;
}
else {
@@ -220,12 +222,12 @@ TEST_IF(File_NoSpuriousTryLockFailures2, !(running_with_valgrind || running_with
}
// Thread barrier
- while(lock_taken + lock_not_taken < num_slaves) {
+ while (lock_taken + lock_not_taken < num_slaves) {
}
CHECK_EQUAL(lock_taken.load(), size_t(1));
- if(owns_lock) {
+ if (owns_lock) {
file.rw_unlock();
}
@@ -233,7 +235,7 @@ TEST_IF(File_NoSpuriousTryLockFailures2, !(running_with_valgrind || running_with
// Thread barrier. After this barrier, the file is guaranteed to be unlocked regardless who owned it.
barrier_2++;
- while(barrier_2 < num_slaves) {
+ while (barrier_2 < num_slaves) {
}
}
};
@@ -242,7 +244,9 @@ TEST_IF(File_NoSpuriousTryLockFailures2, !(running_with_valgrind || running_with
std::string str_path = path;
ThreadWrapper slaves[100];
for (size_t i = 0; i != num_slaves; ++i) {
- slaves[i].start([=] { slave(str_path); });
+ slaves[i].start([=] {
+ slave(str_path);
+ });
}
for (size_t i = 0; i != num_slaves; ++i)
diff --git a/test/test_index_string.cpp b/test/test_index_string.cpp
index f2944baf3b1..83ed8c342ec 100644
--- a/test/test_index_string.cpp
+++ b/test/test_index_string.cpp
@@ -1519,12 +1519,33 @@ TEST_TYPES(StringIndex_Insensitive, string_column, nullable_string_column, enum_
TEST_TYPE test_resources;
typename TEST_TYPE::ColumnTestType& col = test_resources.get_column();
- const char* strings[] = {
- "john", "John", "jOhn", "JOhn", "joHn", "JoHn", "jOHn", "JOHn", "johN", "JohN", "jOhN", "JOhN", "joHN", "JoHN", "jOHN", "JOHN", "john" /* yes, an extra to test the "bucket" case as well */,
- "hans", "Hansapark", "george", "billion dollar startup",
- "abcde", "abcdE", "Abcde", "AbcdE",
- "common", "common"
- };
+ const char* strings[] = {"john",
+ "John",
+ "jOhn",
+ "JOhn",
+ "joHn",
+ "JoHn",
+ "jOHn",
+ "JOHn",
+ "johN",
+ "JohN",
+ "jOhN",
+ "JOhN",
+ "joHN",
+ "JoHN",
+ "jOHN",
+ "JOHN",
+ "john" /* yes, an extra to test the "bucket" case as well */,
+ "hans",
+ "Hansapark",
+ "george",
+ "billion dollar startup",
+ "abcde",
+ "abcdE",
+ "Abcde",
+ "AbcdE",
+ "common",
+ "common"};
for (const char* string : strings) {
col.add(string);
@@ -1558,7 +1579,6 @@ TEST_TYPES(StringIndex_Insensitive, string_column, nullable_string_column, enum_
for (size_t i = 0; i < results.size(); ++i) {
auto upper_result = case_map(col.get(results[i]), true);
CHECK_EQUAL(upper_result, upper_needle);
-
}
check_result_order(results, test_context);
results.clear();
@@ -1681,7 +1701,8 @@ TEST_TYPES(StringIndex_45, string_column, nullable_string_column, enum_column, n
namespace {
-std::string create_random_a_string(size_t max_len) {
+std::string create_random_a_string(size_t max_len)
+{
std::string s;
size_t len = size_t(fastrand(max_len));
for (size_t p = 0; p < len; p++) {
@@ -1690,7 +1711,7 @@ std::string create_random_a_string(size_t max_len) {
return s;
}
-}
+} // namespace
// Excluded when run with valgrind because it takes a long time
diff --git a/test/test_json.cpp b/test/test_json.cpp
index 02a550651c2..92f28ae5039 100644
--- a/test/test_json.cpp
+++ b/test/test_json.cpp
@@ -85,13 +85,13 @@ const bool generate_all = false;
void setup_multi_table(Table& table, size_t rows)
{
// Create table with all column types
- table.add_column(type_Int, "int"); // 0
- table.add_column(type_Bool, "bool"); // 1
- table.add_column(type_Timestamp, "date"); // 2
- table.add_column(type_Float, "float"); // 3
- table.add_column(type_Double, "double"); // 4
- table.add_column(type_String, "string"); // 5
- table.add_column(type_String, "string_long"); // 6
+ table.add_column(type_Int, "int"); // 0
+ table.add_column(type_Bool, "bool"); // 1
+ table.add_column(type_Timestamp, "date"); // 2
+ table.add_column(type_Float, "float"); // 3
+ table.add_column(type_Double, "double"); // 4
+ table.add_column(type_String, "string"); // 5
+ table.add_column(type_String, "string_long"); // 6
ColKey col_string_big = table.add_column(type_String, "string_big_blobs"); // 7
ColKey col_string_enum = table.add_column(type_String, "string_enum"); // 8 - becomes StringEnumColumn
ColKey col_binary = table.add_column(type_Binary, "binary"); // 9
diff --git a/test/test_lang_bind_helper.cpp b/test/test_lang_bind_helper.cpp
index d8fdb175a4c..cbc882f8332 100644
--- a/test/test_lang_bind_helper.cpp
+++ b/test/test_lang_bind_helper.cpp
@@ -2224,8 +2224,7 @@ TEST(LangBindHelper_AdvanceReadTransact_ErrorInObserver)
wt->commit();
}
- struct ObserverError {
- };
+ struct ObserverError {};
try {
struct Parser : _impl::NoOpTransactionLogParser {
TestContext& test_context;
diff --git a/test/test_parser.cpp b/test/test_parser.cpp
index 2803e0d3e85..cc014e69cb5 100644
--- a/test/test_parser.cpp
+++ b/test/test_parser.cpp
@@ -853,9 +853,9 @@ TEST(Parser_LinksToDifferentTable)
verify_query(test_context, t, "items = obj('Items', 'coffee')", 0); // nobody buys coffee
verify_query(test_context, t, "items = obj('Items', 'milk')", 2); // but milk
verify_query(test_context, t, "items = O0", 2); // how many people bought milk?
- verify_query(test_context, t, "items.@count > 2", 3); // how many people bought more than two items?
- verify_query(test_context, t, "items.price > 3.0", 3); // how many people buy items over $3.0?
- verify_query(test_context, t, "items.name ==[c] 'milk'", 2); // how many people buy milk?
+ verify_query(test_context, t, "items.@count > 2", 3); // how many people bought more than two items?
+ verify_query(test_context, t, "items.price > 3.0", 3); // how many people buy items over $3.0?
+ verify_query(test_context, t, "items.name ==[c] 'milk'", 2); // how many people buy milk?
// how many people bought items with an active sale?
verify_query(test_context, t, "items.discount.active == true", 3);
// how many people bought an item marked down by more than $2.0?
@@ -3974,7 +3974,7 @@ TEST(Parser_OperatorIN)
verify_query(test_context, t, "NULL IN items.price", 0); // null
verify_query(test_context, t, "'dairy' IN fav_item.allergens.name", 2); // through link prefix
verify_query(test_context, items, "20 IN @links.Person.items.account_balance", 1); // backlinks
- verify_query(test_context, t, "fav_item.price IN items.price", 2); // single property in list
+ verify_query(test_context, t, "fav_item.price IN items.price", 2); // single property in list
// list property compared to a constant list
verify_query(test_context, t, "ANY {5.5, 4.0} IN ANY items.price", 2);
@@ -4770,7 +4770,7 @@ TEST(Parser_Mixed)
verify_query(test_context, table, "mixed contains bin(\"trin\")", 1);
verify_query(test_context, table, "mixed like \"Strin*\"", 24);
verify_query(test_context, table, "mixed like bin(\"Strin*\")", 1); // 28
- verify_query(test_context, table, "mixed endswith \"4\"", 5); // 4, 24, 44, 64, 84
+ verify_query(test_context, table, "mixed endswith \"4\"", 5); // 4, 24, 44, 64, 84
verify_query(test_context, table, "mixed endswith bin(\"4\")", 0);
verify_query(test_context, table, "mixed endswith bin(\"Binary\")", 1);
verify_query(test_context, table, "mixed.@size > 7", 22);
diff --git a/test/test_query.cpp b/test/test_query.cpp
index c1802c9bf2e..6df86fb2b1f 100644
--- a/test/test_query.cpp
+++ b/test/test_query.cpp
@@ -711,9 +711,8 @@ TEST(Query_NextGenSyntaxMonkey)
Random random(random_int()); // Seed from slow global generator
for (int iter = 1; iter < 5 * (TEST_DURATION * TEST_DURATION * TEST_DURATION + 1); iter++) {
// Set 'rows' to at least '* 20' else some tests will give 0 matches and bad coverage
- const size_t rows = 1 +
- random.draw_int_mod(REALM_MAX_BPNODE_SIZE * 20 *
- (TEST_DURATION * TEST_DURATION * TEST_DURATION + 1));
+ const size_t rows = 1 + random.draw_int_mod(REALM_MAX_BPNODE_SIZE * 20 *
+ (TEST_DURATION * TEST_DURATION * TEST_DURATION + 1));
Table table;
auto col_int0 = table.add_column(type_Int, "first");
auto col_int1 = table.add_column(type_Int, "second");
@@ -3321,8 +3320,8 @@ TEST(Query_Float3_where)
t.create_object().set_all(float(1.1), double(2.1), 1);
t.create_object().set_all(float(1.2), double(2.2), 2);
t.create_object().set_all(float(1.3), double(2.3), 3);
- t.create_object().set_all(float(1.4), double(2.4), 4); // match
- t.create_object().set_all(float(1.5), double(2.5), 5); // match
+ t.create_object().set_all(float(1.4), double(2.4), 4); // match
+ t.create_object().set_all(float(1.5), double(2.5), 5); // match
t.create_object(ObjKey(0xc001ede1b0)).set_all(float(1.6), double(2.6), 6); // match
t.create_object().set_all(float(1.7), double(2.7), 7);
t.create_object().set_all(float(1.8), double(2.8), 8);
@@ -4157,21 +4156,21 @@ TEST(Query_EmptyDescriptors)
std::vector results = {4, 3, 2, 3}; // original order
- { // Sorting with an empty sort descriptor is a no-op
+ { // Sorting with an empty sort descriptor is a no-op
TableView tv = t1->where().find_all();
tv.sort(SortDescriptor());
for (size_t i = 0; i < results.size(); ++i) {
CHECK_EQUAL(tv[i].get(t1_int_col), results[i]);
}
}
- { // Distinct with an empty descriptor is a no-op
+ { // Distinct with an empty descriptor is a no-op
TableView tv = t1->where().find_all();
tv.distinct(DistinctDescriptor());
for (size_t i = 0; i < results.size(); ++i) {
CHECK_EQUAL(tv[i].get(t1_int_col), results[i]);
}
}
- { // Empty sort, empty distinct is still a no-op
+ { // Empty sort, empty distinct is still a no-op
TableView tv = t1->where().find_all();
tv.sort(SortDescriptor());
tv.distinct(DistinctDescriptor());
@@ -4179,7 +4178,7 @@ TEST(Query_EmptyDescriptors)
CHECK_EQUAL(tv[i].get(t1_int_col), results[i]);
}
}
- { // Arbitrary compounded empty sort and distinct is still a no-op
+ { // Arbitrary compounded empty sort and distinct is still a no-op
TableView tv = t1->where().find_all();
tv.sort(SortDescriptor());
tv.sort(SortDescriptor());
@@ -4192,7 +4191,7 @@ TEST(Query_EmptyDescriptors)
CHECK_EQUAL(tv[i].get(t1_int_col), results[i]);
}
}
- { // Empty distinct compounded on a valid distinct is a no-op
+ { // Empty distinct compounded on a valid distinct is a no-op
TableView tv = t1->where().find_all();
tv.distinct(DistinctDescriptor());
tv.distinct(DistinctDescriptor({{t1_int_col}}));
@@ -4202,7 +4201,7 @@ TEST(Query_EmptyDescriptors)
CHECK_EQUAL(tv[i].get(t1_int_col), results[i]);
}
}
- { // Empty sort compounded on a valid sort is a no-op
+ { // Empty sort compounded on a valid sort is a no-op
TableView tv = t1->where().find_all();
tv.sort(SortDescriptor());
tv.sort(SortDescriptor({{t1_int_col}}));
@@ -4626,7 +4625,7 @@ TEST(Query_DistinctAndSort)
// 5 | 2 "A" 4 | 2 |
using ResultList = std::vector>; // value, key
- { // distinct with no sort keeps original order
+ { // distinct with no sort keeps original order
TableView tv = t1->where().find_all();
ResultList expected = {{1, t1_keys[0]}, {2, t1_keys[3]}};
tv.distinct(t1_int_col);
@@ -4636,7 +4635,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct on a sorted view retains sorted order
+ { // distinct on a sorted view retains sorted order
TableView tv = t1->where().find_all();
ResultList expected = {{1, t1_keys[0]}, {2, t1_keys[4]}};
tv.sort(SortDescriptor({{t1_str_col}, {t1_int_col}}));
@@ -4647,7 +4646,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct on a view sorted descending retains sorted order
+ { // distinct on a view sorted descending retains sorted order
TableView tv = t1->where().find_all();
ResultList expected = {{2, t1_keys[3]}, {1, t1_keys[2]}};
tv.sort(SortDescriptor({{t1_str_col}, {t1_int_col}}, {false /* descending */, false /* descending */}));
@@ -4658,7 +4657,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct on a sorted view (different from table order) retains sorted order
+ { // distinct on a sorted view (different from table order) retains sorted order
TableView tv = t1->where().find_all();
ResultList expected = {{2, t1_keys[3]}, {1, t1_keys[0]}};
tv.sort(t1_int_col, false /* descending */);
@@ -4669,7 +4668,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct across links on an unsorted view retains original order
+ { // distinct across links on an unsorted view retains original order
TableView tv = t1->where().find_all();
ResultList expected = {{1, t1_keys[0]}, {1, t1_keys[2]}, {2, t1_keys[4]}};
tv.distinct(DistinctDescriptor({{t1_link_col, t2_int_col}}));
@@ -4679,7 +4678,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct on a view sorted across links retains sorted order
+ { // distinct on a view sorted across links retains sorted order
TableView tv = t1->where().find_all();
ResultList expected = {{1, t1_keys[0]}, {2, t1_keys[3]}};
tv.sort(SortDescriptor({{t1_link_col, t2_int_col}}));
@@ -4690,7 +4689,7 @@ TEST(Query_DistinctAndSort)
CHECK_EQUAL(tv.get_key(i), expected[i].second);
}
}
- { // distinct across links and sort across links
+ { // distinct across links and sort across links
TableView tv = t1->where().find_all();
ResultList expected = {{1, t1_keys[0]}, {1, t1_keys[2]}, {2, t1_keys[4]}};
tv.sort(SortDescriptor({{t1_link_col, t2_int_col}}));
@@ -4742,7 +4741,7 @@ TEST(Query_SortDistinctOrderThroughHandover)
// 3 | 300 "A" |
// 4 | 400 "A" |
- { // sort descending then distinct
+ { // sort descending then distinct
TableView tv = t1->where().find_all();
ResultList results = {{"A", k4}};
tv.sort(SortDescriptor({{t1_int_col}}, {false}));
@@ -4779,7 +4778,7 @@ TEST(Query_SortDistinctOrderThroughHandover)
auto tv2 = tr->import_copy_of(tv, PayloadPolicy::Stay);
check_across_handover(results, std::move(tv2));
}
- { // distinct then sort descending
+ { // distinct then sort descending
TableView tv = t1->where().find_all();
std::vector> results = {{"A", k0}};
tv.distinct(DistinctDescriptor({{t1_str_col}}));
@@ -4793,7 +4792,7 @@ TEST(Query_SortDistinctOrderThroughHandover)
auto tv2 = tr->import_copy_of(tv, PayloadPolicy::Stay);
check_across_handover(results, std::move(tv2));
}
- { // sort descending then multicolumn distinct
+ { // sort descending then multicolumn distinct
TableView tv = t1->where().find_all();
std::vector> results = {{"A", k4}, {"A", k2}, {"A", k1}, {"A", k0}};
tv.sort(SortDescriptor({{t1_int_col}}, {false}));
@@ -4807,7 +4806,7 @@ TEST(Query_SortDistinctOrderThroughHandover)
auto tv2 = tr->import_copy_of(tv, PayloadPolicy::Stay);
check_across_handover(results, std::move(tv2));
}
- { // multicolumn distinct then sort descending
+ { // multicolumn distinct then sort descending
TableView tv = t1->where().find_all();
std::vector> results = {{"A", k4}, {"A", k2}, {"A", k1}, {"A", k0}};
tv.distinct(DistinctDescriptor({{t1_str_col}, {t1_int_col}}));
@@ -4823,7 +4822,8 @@ TEST(Query_SortDistinctOrderThroughHandover)
}
}
-TEST(Query_CompoundDescriptors) {
+TEST(Query_CompoundDescriptors)
+{
SHARED_GROUP_TEST_PATH(path);
std::unique_ptr hist_w(make_in_realm_history());
DBRef sg_w = DB::create(*hist_w, path, DBOptions(crypt_key()));
@@ -4863,7 +4863,7 @@ TEST(Query_CompoundDescriptors) {
// 4 | 2 "A" |
// 5 | 2 "A" |
- { // sorting twice should the same as a single sort with both criteria
+ { // sorting twice should the same as a single sort with both criteria
// but reversed: sort(a).sort(b) == sort(b, a)
ResultList results = {{2, k3}, {1, k2}, {2, k4}, {2, k5}, {1, k0}, {1, k1}};
TableView tv = t1->where().find_all();
@@ -4889,7 +4889,7 @@ TEST(Query_CompoundDescriptors) {
check_across_handover(results, std::move(hp));
}
- { // two distincts are not the same as a single distinct with both criteria
+ { // two distincts are not the same as a single distinct with both criteria
ResultList results = {{1, k0}, {2, k3}};
TableView tv = t1->where().find_all();
tv.distinct(DistinctDescriptor({{t1_int_col}}));
@@ -4915,7 +4915,7 @@ TEST(Query_CompoundDescriptors) {
check_across_handover(results, std::move(hp));
}
- { // check results of sort-distinct-sort-distinct
+ { // check results of sort-distinct-sort-distinct
TableView tv = t1->where().find_all();
tv.sort(SortDescriptor({{t1_str_col}, {t1_int_col}}, {true, true}));
tv.distinct(DistinctDescriptor({{t1_int_col}}));
diff --git a/test/test_query2.cpp b/test/test_query2.cpp
index 94d4a3dc126..9c587011010 100644
--- a/test/test_query2.cpp
+++ b/test/test_query2.cpp
@@ -4941,9 +4941,12 @@ TEST(Query_IntOrQueryOptimisation)
auto obj = table->create_object();
obj.set(col_active, (i % 10) != 0);
obj.set(col_id, i);
- if (i == 0) obj.set(col_optype, "CREATE");
- if (i == 1) obj.set(col_optype, "DELETE");
- if (i == 2) obj.set(col_optype, "CREATE");
+ if (i == 0)
+ obj.set(col_optype, "CREATE");
+ if (i == 1)
+ obj.set(col_optype, "DELETE");
+ if (i == 2)
+ obj.set(col_optype, "CREATE");
}
auto optype = table->column(col_optype);
auto active = table->column(col_active);
@@ -5360,9 +5363,9 @@ TEST(Query_LinksWithIndex)
Query q1 =
origin->link(col_linklist).link(col_link).backlink(*foo, col_foo).column(col_location) == "Fyn";
- CHECK_EQUAL(q1.find(), obj0.get_key());
+ CHECK_EQUAL(q1.find(), obj0.get_key());
Query q2 = origin->link(col_linklist).link(col_link).backlink(*foo, col_foo).column(col_score) == 5;
- CHECK_EQUAL(q2.find(), obj0.get_key());
+ CHECK_EQUAL(q2.find(), obj0.get_key());
// Make sure that changes in the table are reflected in the query result
middle->get_object(m3).set(col_link, target->find_first(col_value, strings[1]));
diff --git a/test/test_query_big.cpp b/test/test_query_big.cpp
index 7b18ca81696..6ac3ba33860 100644
--- a/test/test_query_big.cpp
+++ b/test/test_query_big.cpp
@@ -176,9 +176,18 @@ struct QueryInitHelper {
// This is to allow type-erasing a function that can be passed either an lvalue- or rvalue-reference,
// but needs to use it as a mutable reference.
struct QueryAnyRef {
- QueryAnyRef(Query& q) : ptr(&q) {}
- QueryAnyRef(Query&& q) : ptr(&q) {}
- operator Query&() { return *ptr; }
+ QueryAnyRef(Query& q)
+ : ptr(&q)
+ {
+ }
+ QueryAnyRef(Query&& q)
+ : ptr(&q)
+ {
+ }
+ operator Query&()
+ {
+ return *ptr;
+ }
Query* ptr;
};
@@ -238,7 +247,9 @@ size_t QueryInitHelper::run(const TestFunc& fn)
auto table = rt->get_table(TableKey(0));
size_t count;
Query query = table->where();
- fn(query, [&](auto&& q2) { count = Compose{*this}(q2); });
+ fn(query, [&](auto&& q2) {
+ count = Compose{*this}(q2);
+ });
rt->end_read();
return count;
}
@@ -316,9 +327,15 @@ TEST(Query_TableInitialization)
QueryInitHelper helper{test_context, sg, {}, initial_version, extra_col_version};
// links_to
- helper([&](Query& q, auto&& test) { test(q.links_to(col_link, keys[0])); });
- helper([&](Query& q, auto&& test) { test(q.links_to(col_list, keys[0])); });
- helper([&](Query& q, auto&& test) { test(q.Not().links_to(col_link, keys[0])); });
+ helper([&](Query& q, auto&& test) {
+ test(q.links_to(col_link, keys[0]));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.links_to(col_list, keys[0]));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.Not().links_to(col_link, keys[0]));
+ });
helper([&](Query& q, auto&& test) {
auto it = q.get_table()->begin();
ObjKey k0 = it->get_key();
@@ -328,39 +345,95 @@ TEST(Query_TableInitialization)
});
// compare to null
- helper([&](Query& q, auto&& test) { test(q.equal(col_int_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_float_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_bool_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_double_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_string_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_binary_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.equal(col_timestamp_null, null{})); });
-
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_int_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_float_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_bool_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_double_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_string_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_binary_null, null{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_timestamp_null, null{})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_int_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_float_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_bool_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_double_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_string_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_binary_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_timestamp_null, null{}));
+ });
+
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_int_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_float_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_bool_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_double_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_string_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_binary_null, null{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_timestamp_null, null{}));
+ });
// Conditions: int64_t
- helper([&](Query& q, auto&& test) { test(q.equal(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.greater(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.greater_equal(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.less(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.less_equal(col_int, int64_t{})); });
- helper([&](Query& q, auto&& test) { test(q.between(col_int, int64_t{}, {})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater_equal(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less_equal(col_int, int64_t{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.between(col_int, int64_t{}, {}));
+ });
// Conditions: int
- helper([&](Query& q, auto&& test) { test(q.equal(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.greater(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.greater_equal(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.less(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.less_equal(col_int, int{})); });
- helper([&](Query& q, auto&& test) { test(q.between(col_int, int{}, {})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater_equal(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less_equal(col_int, int{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.between(col_int, int{}, {}));
+ });
// Conditions: 2 int columns
helper([&](Query& q, auto&& test) {
@@ -383,13 +456,27 @@ TEST(Query_TableInitialization)
});
// Conditions: float
- helper([&](Query& q, auto&& test) { test(q.equal(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.greater(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.greater_equal(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.less(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.less_equal(col_float, float{})); });
- helper([&](Query& q, auto&& test) { test(q.between(col_float, float{}, {})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater_equal(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less_equal(col_float, float{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.between(col_float, float{}, {}));
+ });
// Conditions: 2 float columns
helper([&](Query& q, auto&& test) {
@@ -412,13 +499,27 @@ TEST(Query_TableInitialization)
});
// Conditions: double
- helper([&](Query& q, auto&& test) { test(q.equal(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.greater(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.greater_equal(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.less(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.less_equal(col_double, double{})); });
- helper([&](Query& q, auto&& test) { test(q.between(col_double, double{}, {})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater_equal(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less_equal(col_double, double{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.between(col_double, double{}, {}));
+ });
// Conditions: 2 double columns
helper([&](Query& q, auto&& test) {
@@ -441,51 +542,123 @@ TEST(Query_TableInitialization)
});
// Conditions: timestamp
- helper([&](Query& q, auto&& test) { test(q.equal(col_timestamp, Timestamp{5, 5})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_timestamp, Timestamp{5, 5})); });
- helper([&](Query& q, auto&& test) { test(q.greater(col_timestamp, Timestamp{5, 5})); });
- helper([&](Query& q, auto&& test) { test(q.greater_equal(col_timestamp, Timestamp{5, 5})); });
- helper([&](Query& q, auto&& test) { test(q.less_equal(col_timestamp, Timestamp{5, 5})); });
- helper([&](Query& q, auto&& test) { test(q.less(col_timestamp, Timestamp{5, 5})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_timestamp, Timestamp{5, 5}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_timestamp, Timestamp{5, 5}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater(col_timestamp, Timestamp{5, 5}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.greater_equal(col_timestamp, Timestamp{5, 5}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less_equal(col_timestamp, Timestamp{5, 5}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.less(col_timestamp, Timestamp{5, 5}));
+ });
// Conditions: bool
- helper([&](Query& q, auto&& test) { test(q.equal(col_bool, bool{})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_bool, bool{}));
+ });
// Conditions: strings
- helper([&](Query& q, auto&& test) { test(q.equal(col_string, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_string, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.begins_with(col_string, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.ends_with(col_string, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.contains(col_string, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.like(col_string, StringData{})); });
-
- helper([&](Query& q, auto&& test) { test(q.equal(col_string, StringData{}, false)); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_string, StringData{}, false)); });
- helper([&](Query& q, auto&& test) { test(q.begins_with(col_string, StringData{}, false)); });
- helper([&](Query& q, auto&& test) { test(q.ends_with(col_string, StringData{}, false)); });
- helper([&](Query& q, auto&& test) { test(q.contains(col_string, StringData{}, false)); });
- helper([&](Query& q, auto&& test) { test(q.like(col_string, StringData{}, false)); });
-
- helper([&](Query& q, auto&& test) { test(q.equal(col_string_enum, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_string_enum, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.begins_with(col_string_enum, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.ends_with(col_string_enum, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.contains(col_string_enum, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.like(col_string_enum, StringData{})); });
-
- helper([&](Query& q, auto&& test) { test(q.equal(col_string_indexed, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_string_indexed, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.begins_with(col_string_indexed, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.ends_with(col_string_indexed, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.contains(col_string_indexed, StringData{})); });
- helper([&](Query& q, auto&& test) { test(q.like(col_string_indexed, StringData{})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_string, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_string, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.begins_with(col_string, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.ends_with(col_string, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.contains(col_string, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.like(col_string, StringData{}));
+ });
+
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_string, StringData{}, false));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_string, StringData{}, false));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.begins_with(col_string, StringData{}, false));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.ends_with(col_string, StringData{}, false));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.contains(col_string, StringData{}, false));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.like(col_string, StringData{}, false));
+ });
+
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_string_enum, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_string_enum, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.begins_with(col_string_enum, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.ends_with(col_string_enum, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.contains(col_string_enum, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.like(col_string_enum, StringData{}));
+ });
+
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_string_indexed, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_string_indexed, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.begins_with(col_string_indexed, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.ends_with(col_string_indexed, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.contains(col_string_indexed, StringData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.like(col_string_indexed, StringData{}));
+ });
// Conditions: binary data
- helper([&](Query& q, auto&& test) { test(q.equal(col_binary, BinaryData{})); });
- helper([&](Query& q, auto&& test) { test(q.not_equal(col_binary, BinaryData{})); });
- helper([&](Query& q, auto&& test) { test(q.begins_with(col_binary, BinaryData{})); });
- helper([&](Query& q, auto&& test) { test(q.ends_with(col_binary, BinaryData{})); });
- helper([&](Query& q, auto&& test) { test(q.contains(col_binary, BinaryData{})); });
+ helper([&](Query& q, auto&& test) {
+ test(q.equal(col_binary, BinaryData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.not_equal(col_binary, BinaryData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.begins_with(col_binary, BinaryData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.ends_with(col_binary, BinaryData{}));
+ });
+ helper([&](Query& q, auto&& test) {
+ test(q.contains(col_binary, BinaryData{}));
+ });
enum class Mode { Direct, Link, LinkList };
@@ -493,12 +666,18 @@ TEST(Query_TableInitialization)
auto test_query_expression = [&](util::FunctionRef] get_table, Mode mode) {
auto test_operator = [&](auto&& op, auto&& column, auto&& v) {
if (mode != Mode::LinkList)
- helper([&](Query&, auto&& test) { test(op(column(), column())); });
- helper([&](Query&, auto&& test) { test(op(column(), v)); });
+ helper([&](Query&, auto&& test) {
+ test(op(column(), column()));
+ });
+ helper([&](Query&, auto&& test) {
+ test(op(column(), v));
+ });
};
auto test_numeric = [&](auto value, ColKey col, ColKey null_col) {
using Type = decltype(value);
- auto get_column = [&] { return get_table().template column(col); };
+ auto get_column = [&] {
+ return get_table().template column(col);
+ };
test_operator(std::equal_to<>(), get_column, value);
test_operator(std::not_equal_to<>(), get_column, value);
test_operator(std::greater<>(), get_column, value);
@@ -506,17 +685,23 @@ TEST(Query_TableInitialization)
test_operator(std::greater_equal<>(), get_column, value);
test_operator(std::less_equal<>(), get_column, value);
- auto get_null_column = [&] { return get_table().template column(null_col); };
+ auto get_null_column = [&] {
+ return get_table().template column(null_col);
+ };
test_operator(std::equal_to<>(), get_null_column, null{});
test_operator(std::not_equal_to<>(), get_null_column, null{});
};
auto test_bool = [&](auto value, ColKey col, ColKey null_col) {
using Type = decltype(value);
- auto get_column = [&] { return get_table().template column(col); };
+ auto get_column = [&] {
+ return get_table().template column(col);
+ };
test_operator(std::equal_to<>(), get_column, value);
test_operator(std::not_equal_to<>(), get_column, value);
- auto get_null_column = [&] { return get_table().template column(null_col); };
+ auto get_null_column = [&] {
+ return get_table().template column(null_col);
+ };
test_operator(std::equal_to<>(), get_null_column, null{});
test_operator(std::not_equal_to<>(), get_null_column, null{});
};
@@ -527,64 +712,162 @@ TEST(Query_TableInitialization)
test_numeric(Double(), col_double, col_double_null);
test_numeric(Timestamp(), col_timestamp, col_timestamp_null);
- auto string_col = [&] { return get_table().template column(col_string); };
+ auto string_col = [&] {
+ return get_table().template column(col_string);
+ };
test_operator(std::equal_to<>(), string_col, StringData());
test_operator(std::not_equal_to<>(), string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.begins_with(b); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.ends_with(b); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.contains(b); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.like(b); }, string_col, StringData());
-
- test_operator([](auto&& a, auto&& b) { return a.equal(b, false); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.not_equal(b, false); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.begins_with(b, false); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.ends_with(b, false); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.contains(b, false); }, string_col, StringData());
- test_operator([](auto&& a, auto&& b) { return a.like(b, false); }, string_col, StringData());
-
- auto null_string_col = [&] { return get_table().template column(col_string_null); };
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.begins_with(b);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.ends_with(b);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.contains(b);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.like(b);
+ },
+ string_col, StringData());
+
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.equal(b, false);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.not_equal(b, false);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.begins_with(b, false);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.ends_with(b, false);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.contains(b, false);
+ },
+ string_col, StringData());
+ test_operator(
+ [](auto&& a, auto&& b) {
+ return a.like(b, false);
+ },
+ string_col, StringData());
+
+ auto null_string_col = [&] {
+ return get_table().template column(col_string_null);
+ };
test_operator(std::equal_to<>(), null_string_col, null());
test_operator(std::not_equal_to<>(), null_string_col, null());
- auto binary_col = [&] { return get_table().template column(col_binary); };
- helper([&](Query&, auto&& test) { test(binary_col() == BinaryData()); });
- helper([&](Query&, auto&& test) { test(binary_col() != BinaryData()); });
- helper([&](Query&, auto&& test) { test(binary_col().size() != 0); });
-
- auto link_col = [&] { return get_table().template column(col_link); };
- auto list_col = [&] { return get_table().template column(col_list); };
- auto get_obj0 = [&] { return get_table().get_object(keys[0]); };
+ auto binary_col = [&] {
+ return get_table().template column(col_binary);
+ };
+ helper([&](Query&, auto&& test) {
+ test(binary_col() == BinaryData());
+ });
+ helper([&](Query&, auto&& test) {
+ test(binary_col() != BinaryData());
+ });
+ helper([&](Query&, auto&& test) {
+ test(binary_col().size() != 0);
+ });
+
+ auto link_col = [&] {
+ return get_table().template column(col_link);
+ };
+ auto list_col = [&] {
+ return get_table().template column(col_list);
+ };
+ auto get_obj0 = [&] {
+ return get_table().get_object(keys[0]);
+ };
if (mode == Mode::Direct) { // link equality over links isn't implemented
- helper([&](Query&, auto&& test) { test(link_col().is_null()); });
- helper([&](Query&, auto&& test) { test(link_col().is_not_null()); });
-
- helper([&](Query&, auto&& test) { test(link_col() == get_obj0()); });
- helper([&](Query&, auto&& test) { test(link_col() != get_obj0()); });
-
- helper([&](Query&, auto&& test) { test(list_col() == get_obj0()); });
- helper([&](Query&, auto&& test) { test(list_col() != get_obj0()); });
+ helper([&](Query&, auto&& test) {
+ test(link_col().is_null());
+ });
+ helper([&](Query&, auto&& test) {
+ test(link_col().is_not_null());
+ });
+
+ helper([&](Query&, auto&& test) {
+ test(link_col() == get_obj0());
+ });
+ helper([&](Query&, auto&& test) {
+ test(link_col() != get_obj0());
+ });
+
+ helper([&](Query&, auto&& test) {
+ test(list_col() == get_obj0());
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_col() != get_obj0());
+ });
}
- helper([&](Query&, auto&& test) { test(list_col().count() == 1); });
- helper([&](Query&, auto&& test) { test(list_col().column(col_int).max() > 0); });
- helper([&](Query&, auto&& test) { test(list_col().column(col_int).min() > 0); });
- helper([&](Query&, auto&& test) { test(list_col().column(col_int).sum() > 0); });
- helper([&](Query&, auto&& test) { test(list_col().column(col_int).average() > 0); });
-
- auto list_int = [&] { return get_table().template column>(col_list_int); };
+ helper([&](Query&, auto&& test) {
+ test(list_col().count() == 1);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_col().column(col_int).max() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_col().column(col_int).min() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_col().column(col_int).sum() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_col().column(col_int).average() > 0);
+ });
+
+ auto list_int = [&] {
+ return get_table().template column>(col_list_int);
+ };
- helper([&](Query&, auto&& test) { test(list_int().size() == 1); });
- helper([&](Query&, auto&& test) { test(list_int() > 0); });
- helper([&](Query&, auto&& test) { test(list_int().max() > 0); });
- helper([&](Query&, auto&& test) { test(list_int().min() > 0); });
- helper([&](Query&, auto&& test) { test(list_int().sum() > 0); });
- helper([&](Query&, auto&& test) { test(list_int().average() > 0); });
+ helper([&](Query&, auto&& test) {
+ test(list_int().size() == 1);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_int() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_int().max() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_int().min() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_int().sum() > 0);
+ });
+ helper([&](Query&, auto&& test) {
+ test(list_int().average() > 0);
+ });
};
// Test all of the query expressions directly, over a link, over a backlink
// over a linklist, and over two links
- test_query_expression([&]() -> Table& { return helper.get_table(); }, Mode::Direct);
+ test_query_expression(
+ [&]() -> Table& {
+ return helper.get_table();
+ },
+ Mode::Direct);
test_query_expression(
[&]() -> Table& {
Table& t = helper.get_table();
diff --git a/test/test_self.cpp b/test/test_self.cpp
index 75b3be1875a..6f8f3943338 100644
--- a/test/test_self.cpp
+++ b/test/test_self.cpp
@@ -61,9 +61,7 @@ namespace {
TestList zero_tests_list, zero_checks_list;
-TEST_EX(ZeroChecks, zero_checks_list, true, true)
-{
-}
+TEST_EX(ZeroChecks, zero_checks_list, true, true) {}
TestList one_check_success_list, one_check_failure_list;
@@ -171,9 +169,7 @@ TEST_EX(Mixed_2_Y, mixed_list, true, true)
CHECK_GREATER(1, 0);
}
-TEST_EX(Mixed_3_X, mixed_list, true, true)
-{
-}
+TEST_EX(Mixed_3_X, mixed_list, true, true) {}
TEST_EX(Mixed_4_Y, mixed_list, true, true)
{
@@ -190,9 +186,7 @@ TEST_EX(Mixed_5_X, mixed_list, true, true)
CHECK_GREATER(1, 0);
}
-TEST_EX(Mixed_6_Y, mixed_list, true, true)
-{
-}
+TEST_EX(Mixed_6_Y, mixed_list, true, true) {}
TEST_EX(Mixed_7_Y, mixed_list, true, true)
{
@@ -469,8 +463,7 @@ TEST_EX(Failure_Pointer, failure_list, true, true) // Test #5, accum checks = 93
CHECK_GREATER_EQUAL(p_1, p_2);
}
-struct FooException {
-};
+struct FooException {};
struct BarException : std::exception {
const char* what() const noexcept override
@@ -489,9 +482,7 @@ void throw_bar()
throw BarException();
}
-void throw_nothing()
-{
-}
+void throw_nothing() {}
TEST_EX(Success_Exception, success_list, true, true) // Test #6, accum checks = 85 + 2 = 87
{
diff --git a/test/test_sync.cpp b/test/test_sync.cpp
index 2ee1cdc8c35..fcf0810d309 100644
--- a/test/test_sync.cpp
+++ b/test/test_sync.cpp
@@ -6188,7 +6188,6 @@ TEST(Sync_CollectionInMixed)
CHECK_EQUAL(list.size(), 0);
// Replace list with Dictionary on property
obj.set_collection(col_any, CollectionType::Dictionary);
-
});
session_2.wait_for_upload_complete_or_client_stopped();
diff --git a/test/test_table.cpp b/test/test_table.cpp
index fe7a892a644..0061c55f3c4 100644
--- a/test/test_table.cpp
+++ b/test/test_table.cpp
@@ -45,8 +45,8 @@ using namespace std::chrono;
#include "test_table_helper.hpp"
#include "test_types_helper.hpp"
-//#include
-//#define PERFORMACE_TESTING
+// #include
+// #define PERFORMACE_TESTING
using namespace realm;
using namespace realm::util;
@@ -4341,11 +4341,9 @@ struct generator> {
// specialize for Optional and Optional just to trigger errors if ever used
template <>
-struct generator> {
-};
+struct generator> {};
template <>
-struct generator> {
-};
+struct generator> {};
template
void test_lists(TestContext& test_context, DBRef sg, const realm::DataType type_id, bool optional = false)
diff --git a/test/test_table_helper.hpp b/test/test_table_helper.hpp
index b4144b30bfd..0b866d20d5d 100644
--- a/test/test_table_helper.hpp
+++ b/test/test_table_helper.hpp
@@ -153,7 +153,7 @@ class ReplSyncClient : public MyTrivialReplication {
bool m_upgraded = false;
std::unique_ptr m_arr;
};
-}
+} // namespace realm
enum Days { Mon, Tue, Wed, Thu, Fri, Sat, Sun };
diff --git a/test/test_table_view.cpp b/test/test_table_view.cpp
index 89773dd30f7..a7f9e1ac8da 100644
--- a/test/test_table_view.cpp
+++ b/test/test_table_view.cpp
@@ -228,11 +228,11 @@ TEST(TableView_Sum)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
TableView v = table.find_all_int(c0, 2);
CHECK_EQUAL(5, v.size());
@@ -246,11 +246,11 @@ TEST(TableView_Average)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
- table.create_object().set_all( 2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
+ table.create_object().set_all(2);
TableView v = table.find_all_int(c0, 2);
CHECK_EQUAL(5, v.size());
@@ -264,9 +264,9 @@ TEST(TableView_SumNegative)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
v[0].set(c0, 11);
@@ -281,9 +281,9 @@ TEST(TableView_IsAttached)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
TableView v2 = table.find_all_int(c0, 0);
@@ -300,9 +300,9 @@ TEST(TableView_Max)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
v[0].set(c0, -1);
@@ -318,9 +318,9 @@ TEST(TableView_Max2)
Table table;
auto c0 = table.add_column(type_Int, "1");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
v[0].set(c0, -1);
@@ -337,9 +337,9 @@ TEST(TableView_Min)
Table table;
auto c0 = table.add_column(type_Int, "first");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
v[0].set(c0, -1);
@@ -360,9 +360,9 @@ TEST(TableView_Min2)
Table table;
auto c0 = table.add_column(type_Int, "first");
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
- table.create_object().set_all( 0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
+ table.create_object().set_all(0);
TableView v = table.find_all_int(c0, 0);
v[0].set(c0, -1);
@@ -574,10 +574,10 @@ TEST(TableView_StringSort)
Table table;
auto col = table.add_column(type_String, "1");
- table.create_object().set_all( "alpha");
- table.create_object().set_all( "zebra");
- table.create_object().set_all( "ALPHA");
- table.create_object().set_all( "ZEBRA");
+ table.create_object().set_all("alpha");
+ table.create_object().set_all("zebra");
+ table.create_object().set_all("ALPHA");
+ table.create_object().set_all("ZEBRA");
// Core-only is default comparer
TableView v = table.where().find_all();
@@ -2241,7 +2241,7 @@ TEST(TableView_TimestampMaxRemoveRow)
CHECK_EQUAL(tv.max(col_date)->get_timestamp(), Timestamp(9, 0));
table.remove_object(ObjKey(9));
- CHECK_EQUAL(tv.size(), 10); // not changed since sync_if_needed hasn't been called
+ CHECK_EQUAL(tv.size(), 10); // not changed since sync_if_needed hasn't been called
CHECK_EQUAL(tv.max(col_date)->get_timestamp(), Timestamp(8, 0)); // but aggregate functions skip removed rows
tv.sync_if_needed();
diff --git a/test/test_thread.cpp b/test/test_thread.cpp
index 0872a98aac8..d1a6b246528 100644
--- a/test/test_thread.cpp
+++ b/test/test_thread.cpp
@@ -529,7 +529,9 @@ TEST(Thread_MutexTryLock)
init_done = true;
}
cv.notify_one();
- while(!mutex2.try_lock()) { millisleep(1); }
+ while (!mutex2.try_lock()) {
+ millisleep(1);
+ }
CHECK(mutex2.owns_lock());
mutex2.unlock();
};
@@ -541,7 +543,9 @@ TEST(Thread_MutexTryLock)
thread.start(do_async);
{
std::unique_lock guard(cv_lock);
- cv.wait(guard, [&]{return init_done;});
+ cv.wait(guard, [&] {
+ return init_done;
+ });
}
m.unlock();
thread.join();
@@ -578,7 +582,9 @@ TEST(Thread_RobustMutexTryLock)
init_done = true;
}
control_cv.notify_one();
- while(!m.try_lock(recover_function)) { millisleep(1); }
+ while (!m.try_lock(recover_function)) {
+ millisleep(1);
+ }
// exit the thread with the lock held to check robustness
};
@@ -587,7 +593,9 @@ TEST(Thread_RobustMutexTryLock)
thread.start(do_async);
{
std::unique_lock lock(control_mutex);
- control_cv.wait(lock, [&]{ return init_done; });
+ control_cv.wait(lock, [&] {
+ return init_done;
+ });
}
m.unlock();
thread.join();
@@ -628,7 +636,9 @@ NONCONCURRENT_TEST(Thread_InterprocessMutexTryLock)
init_done = true;
}
cv.notify_one();
- while(!m2.try_lock()) { millisleep(1); }
+ while (!m2.try_lock()) {
+ millisleep(1);
+ }
m2.unlock();
};
@@ -637,7 +647,9 @@ NONCONCURRENT_TEST(Thread_InterprocessMutexTryLock)
thread.start(do_async);
{
std::unique_lock ul(cv_mutex);
- cv.wait(ul, [&]{return init_done;});
+ cv.wait(ul, [&] {
+ return init_done;
+ });
}
m.unlock();
thread.join();
@@ -689,7 +701,6 @@ void wakeup_signaller(int* signal_state, InterprocessMutex* mutex, InterprocessC
}
-
void waiter(InterprocessMutex* mutex, InterprocessCondVar* cv, std::mutex* control_mutex,
std::condition_variable* control_cv, size_t* num_threads_holding_lock)
{
@@ -703,7 +714,7 @@ void waiter(InterprocessMutex* mutex, InterprocessCondVar* cv, std::mutex* contr
cv->wait(*mutex, nullptr);
}
-}
+} // namespace
// Verify, that a wait on a condition variable actually waits
// - this test relies on assumptions about scheduling, which
@@ -835,7 +846,9 @@ NONCONCURRENT_TEST(Thread_CondvarNotifyAllWakeup)
{
// allow all waiters to start and obtain the InterprocessCondVar
std::unique_lock unique_lock(control_mutex);
- control_cv.wait(unique_lock, [&]{ return num_threads_holding_lock == num_waiters; });
+ control_cv.wait(unique_lock, [&] {
+ return num_threads_holding_lock == num_waiters;
+ });
}
mutex.lock();
@@ -887,15 +900,15 @@ TEST_IF(Thread_CondvarAtomicWaitUnlock, !running_with_valgrind && TEST_DURATION
signal = true;
// A gap in wait() could be very tight, so we need a way to preemt it between two instructions.
- // Problem is that we have so many/frequent operating system wait calls in this that they might
- // be invoked closer than a thread time slice, so preemption would never occur. So we create
+ // Problem is that we have so many/frequent operating system wait calls in this that they might
+ // be invoked closer than a thread time slice, so preemption would never occur. So we create
// some work that some times willsome times bring the current time slice close to its end.
// Wait between 0 and number of clocks on 100 ms on a on 3 GHz machine (100 ms is Linux default
// time slice)
- uint64_t clocks_to_wait = fastrand(3ULL * 1000000000ULL / 1000000ULL * 100ULL);
+ uint64_t clocks_to_wait = fastrand(3ULL * 1000000000ULL / 1000000ULL * 100ULL);
- // This loop can wait alot more than 100 ms because each iteration takes many more clocks than
+ // This loop can wait alot more than 100 ms because each iteration takes many more clocks than
// just 1. That's intentional and will cover other OS'es with bigger time slices.
volatile int sum = 0; // must be volatile, else it compiles into no-op
for (uint64_t t = 0; t < clocks_to_wait; t++) {
@@ -920,7 +933,7 @@ TEST_IF(Thread_CondvarAtomicWaitUnlock, !running_with_valgrind && TEST_DURATION
mutex.unlock();
}
});
-
+
t1.join();
t2.join();
}));
diff --git a/test/test_transactions_lasse.cpp b/test/test_transactions_lasse.cpp
index 6d5705087fc..926ba912486 100644
--- a/test/test_transactions_lasse.cpp
+++ b/test/test_transactions_lasse.cpp
@@ -95,11 +95,11 @@ REALM_FORCEINLINE void rand_sleep(Random& random)
std::this_thread::yield();
}
else if (r <= 254) {
-// Release current time slice and get time slice according to normal scheduling
+ // Release current time slice and get time slice according to normal scheduling
millisleep(0);
}
else {
-// Release time slices for at least 200 ms
+ // Release time slices for at least 200 ms
millisleep(200);
}
}
@@ -173,10 +173,14 @@ TEST_IF(Transactions_Stress1, TEST_DURATION >= 3)
}
for (int i = 0; i < READERS1; ++i)
- read_threads[i].start([&] { read_thread(test_context, path); });
+ read_threads[i].start([&] {
+ read_thread(test_context, path);
+ });
for (int i = 0; i < WRITERS1; ++i)
- write_threads[i].start([this, &path, i] { write_thread(test_context, path, i); });
+ write_threads[i].start([this, &path, i] {
+ write_thread(test_context, path, i);
+ });
for (int i = 0; i < READERS1; ++i) {
bool reader_has_thrown = read_threads[i].join();
@@ -426,7 +430,9 @@ TEST_IF(Transactions_Stress4, TEST_DURATION >= 3)
read_threads[i].start(read_thread);
for (int i = 0; i < WRITERS; ++i)
- write_threads[i].start([=] { write_thread(i); });
+ write_threads[i].start([=] {
+ write_thread(i);
+ });
for (int i = 0; i < WRITERS; ++i) {
bool writer_has_thrown = write_threads[i].join();
diff --git a/test/test_transform.cpp b/test/test_transform.cpp
index a6a8e6e1c19..e413dcc8bd5 100644
--- a/test/test_transform.cpp
+++ b/test/test_transform.cpp
@@ -929,7 +929,7 @@ TEST(Transform_EraseSelectedLinkView)
LnkLst link_list = (origin->begin() + 1)->get_linklist("ll");
auto target_table = link_list.get_target_table();
link_list.set(0, target_table->get_object(2).get_key()); // Select the link list of the 2nd row
- origin->remove_object(origin->begin() + 0); // Move that link list
+ origin->remove_object(origin->begin() + 0); // Move that link list
if (link_list.size() > 1) {
link_list.set(1, target_table->get_object(3).get_key()); // Now modify it again
}
diff --git a/test/test_util_base64.cpp b/test/test_util_base64.cpp
index 173578339d0..56a6a2b1875 100644
--- a/test/test_util_base64.cpp
+++ b/test/test_util_base64.cpp
@@ -42,15 +42,7 @@ TEST(Base64_Decode)
"SGVsb G8sIF\ndvc mxkIQ==", // contains whitespace
};
- static const char* expected[] = {
- "",
- "f",
- "fo",
- "foo",
- "floo",
- "floor",
- "Hello, World!"
- };
+ static const char* expected[] = {"", "f", "fo", "foo", "floo", "floor", "Hello, World!"};
static const size_t num_tests = sizeof(inputs) / sizeof(inputs[0]);
@@ -61,11 +53,11 @@ TEST(Base64_Decode)
}
static const char* bad_inputs[] = {
- "!", // invalid char
- ":", // invalid char
- "Zg===", // invalid length
- "====", // only padding
- "()", // invalid chars
+ "!", // invalid char
+ ":", // invalid char
+ "Zg===", // invalid length
+ "====", // only padding
+ "()", // invalid chars
"Zm9v====", // wrong amount of padding
};
static const size_t num_bad_tests = sizeof(bad_inputs) / sizeof(bad_inputs[0]);
diff --git a/test/test_util_file.cpp b/test/test_util_file.cpp
index 01d9f2ec777..91c525a879a 100644
--- a/test/test_util_file.cpp
+++ b/test/test_util_file.cpp
@@ -218,16 +218,16 @@ TEST(Utils_File_TryRemoveDirRecursive)
TEST_DIR(dir_0);
bool did_exist = false;
- std::string dir_1 = File::resolve("dir_1", dir_0);
+ std::string dir_1 = File::resolve("dir_1", dir_0);
make_dir(dir_1);
did_exist = try_remove_dir_recursive(dir_1);
CHECK(did_exist);
- std::string dir_2 = File::resolve("dir_2", dir_0);
+ std::string dir_2 = File::resolve("dir_2", dir_0);
did_exist = try_remove_dir_recursive(dir_2);
CHECK(!did_exist);
- std::string dir_3 = File::resolve("dir_3", dir_0);
+ std::string dir_3 = File::resolve("dir_3", dir_0);
make_dir(dir_3);
std::string file_1 = File::resolve("file_1", dir_3);
File(file_1, File::mode_Write);
@@ -245,19 +245,19 @@ TEST(Utils_File_ForEach)
auto touch = [](const std::string& path) {
File(path, File::mode_Write);
};
- std::string dir_1 = File::resolve("dir_1", dir_0);
+ std::string dir_1 = File::resolve("dir_1", dir_0);
make_dir(dir_1);
std::string file_1 = File::resolve("file_1", dir_0);
touch(file_1);
- std::string dir_2 = File::resolve("dir_2", dir_0);
+ std::string dir_2 = File::resolve("dir_2", dir_0);
make_dir(dir_2);
std::string file_2 = File::resolve("file_2", dir_0);
touch(file_2);
- std::string dir_3 = File::resolve("dir_3", dir_1);
+ std::string dir_3 = File::resolve("dir_3", dir_1);
make_dir(dir_3);
std::string file_3 = File::resolve("file_3", dir_1);
touch(file_3);
- std::string dir_4 = File::resolve("dir_4", dir_2);
+ std::string dir_4 = File::resolve("dir_4", dir_2);
make_dir(dir_4);
std::string file_4 = File::resolve("file_4", dir_2);
touch(file_4);
@@ -275,17 +275,17 @@ TEST(Utils_File_ForEach)
std::string dir_1_3 = File::resolve("dir_3", "dir_1");
std::string dir_2_4 = File::resolve("dir_4", "dir_2");
if (CHECK_EQUAL(6, files.size())) {
- CHECK_EQUAL("", files[0].first);
+ CHECK_EQUAL("", files[0].first);
CHECK_EQUAL("file_1", files[0].second);
- CHECK_EQUAL("", files[1].first);
+ CHECK_EQUAL("", files[1].first);
CHECK_EQUAL("file_2", files[1].second);
- CHECK_EQUAL("dir_1", files[2].first);
+ CHECK_EQUAL("dir_1", files[2].first);
CHECK_EQUAL("file_3", files[2].second);
- CHECK_EQUAL(dir_1_3, files[3].first);
+ CHECK_EQUAL(dir_1_3, files[3].first);
CHECK_EQUAL("file_5", files[3].second);
- CHECK_EQUAL("dir_2", files[4].first);
+ CHECK_EQUAL("dir_2", files[4].first);
CHECK_EQUAL("file_4", files[4].second);
- CHECK_EQUAL(dir_2_4, files[5].first);
+ CHECK_EQUAL(dir_2_4, files[5].first);
CHECK_EQUAL("file_6", files[5].second);
}
}
diff --git a/test/test_util_json_parser.cpp b/test/test_util_json_parser.cpp
index 9da40cfbfad..528f0dcf1e7 100644
--- a/test/test_util_json_parser.cpp
+++ b/test/test_util_json_parser.cpp
@@ -152,7 +152,7 @@ TEST(JSONParser_UnescapeString)
"\"\\ud87e\\udd10\"", // Emoji 'zipper-mouth face' (surrogate pair)
};
static const char* expected[] = {
- "\\u0abg", "A", "א", "⼈",
+ "\\u0abg", "A", "א", "⼈",
"人", // NOTE! This character looks identical to the one above, but is a different codepoint.
"�", "🤐",
};
diff --git a/test/test_util_logger.cpp b/test/test_util_logger.cpp
index 7b866a8b446..fc8e5c13cc4 100644
--- a/test/test_util_logger.cpp
+++ b/test/test_util_logger.cpp
@@ -61,7 +61,7 @@ namespace {
TEST(Util_Logger_LevelToFromString)
{
- auto check = [& test_context = test_context](util::Logger::Level level, const char* name) {
+ auto check = [&test_context = test_context](util::Logger::Level level, const char* name) {
std::ostringstream out;
out.imbue(std::locale::classic());
out << level;
@@ -93,7 +93,7 @@ TEST(Util_Logger_LevelThreshold)
auto threadsafe_logger = std::make_shared(base_logger);
auto prefix_logger =
PrefixLogger(util::LogCategory::realm, "test", threadsafe_logger); // created using Logger shared_ptr
- auto prefix_logger2 = PrefixLogger("test2", prefix_logger); // created using PrefixLogger
+ auto prefix_logger2 = PrefixLogger("test2", prefix_logger); // created using PrefixLogger
auto default_log_level = util::LogCategory::realm.get_default_level_threshold();
CHECK(base_logger->get_level_threshold() == default_log_level);
@@ -353,7 +353,9 @@ TEST(Util_Logger_ThreadSafe)
const int num_threads = 8;
std::unique_ptr