feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_A_HASH_MAP_H
|
||||
#define TEST_A_HASH_MAP_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/a_hash_map.h"
|
||||
|
||||
|
|
@ -235,9 +234,13 @@ TEST_CASE("[AHashMap] Insert, iterate and remove many elements") {
|
|||
TEST_CASE("[AHashMap] Insert, iterate and remove many strings") {
|
||||
const int elem_max = 432;
|
||||
AHashMap<String, String> map;
|
||||
|
||||
// To not print WARNING: Excessive collision count (NN), is the right hash function being used?
|
||||
ERR_PRINT_OFF;
|
||||
for (int i = 0; i < elem_max; i++) {
|
||||
map.insert(itos(i), itos(i));
|
||||
}
|
||||
ERR_PRINT_ON;
|
||||
|
||||
//insert order should have been kept
|
||||
int idx = 0;
|
||||
|
|
@ -309,5 +312,3 @@ TEST_CASE("[AHashMap] Array methods") {
|
|||
}
|
||||
|
||||
} // namespace TestAHashMap
|
||||
|
||||
#endif // TEST_A_HASH_MAP_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_COMMAND_QUEUE_H
|
||||
#define TEST_COMMAND_QUEUE_H
|
||||
#pragma once
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/math/random_number_generator.h"
|
||||
|
|
@ -562,5 +561,3 @@ TEST_CASE("[CommandQueue] Test Parameter Passing Semantics") {
|
|||
sts.destroy_threads();
|
||||
}
|
||||
} // namespace TestCommandQueue
|
||||
|
||||
#endif // TEST_COMMAND_QUEUE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_HASH_MAP_H
|
||||
#define TEST_HASH_MAP_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
|
||||
|
|
@ -147,5 +146,3 @@ TEST_CASE("[HashMap] Const iteration") {
|
|||
}
|
||||
}
|
||||
} // namespace TestHashMap
|
||||
|
||||
#endif // TEST_HASH_MAP_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_HASH_SET_H
|
||||
#define TEST_HASH_SET_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_set.h"
|
||||
|
||||
|
|
@ -240,5 +239,3 @@ TEST_CASE("[HashSet] Copy") {
|
|||
}
|
||||
|
||||
} // namespace TestHashSet
|
||||
|
||||
#endif // TEST_HASH_SET_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_LIST_H
|
||||
#define TEST_LIST_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/list.h"
|
||||
|
||||
|
|
@ -555,5 +554,3 @@ TEST_CASE("[Stress][List] Swap random 10 elements, 1000 iterations.") {
|
|||
swap_random(list, n, 10, 1000);
|
||||
}
|
||||
} // namespace TestList
|
||||
|
||||
#endif // TEST_LIST_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_LOCAL_VECTOR_H
|
||||
#define TEST_LOCAL_VECTOR_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
|
||||
|
|
@ -179,6 +178,23 @@ TEST_CASE("[LocalVector] Remove Unordered.") {
|
|||
CHECK(vector.size() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("[LocalVector] Erase Unordered.") {
|
||||
LocalVector<int> vector;
|
||||
vector.push_back(1);
|
||||
vector.push_back(3);
|
||||
vector.push_back(0);
|
||||
vector.push_back(2);
|
||||
vector.push_back(4);
|
||||
|
||||
CHECK(vector.find(1) == 0);
|
||||
|
||||
vector.erase_unordered(1);
|
||||
|
||||
CHECK(vector.find(1) == -1);
|
||||
CHECK(vector.size() == 4);
|
||||
CHECK(vector[0] == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("[LocalVector] Erase.") {
|
||||
LocalVector<int> vector;
|
||||
vector.push_back(1);
|
||||
|
|
@ -245,5 +261,3 @@ TEST_CASE("[LocalVector] Size / Resize / Reserve.") {
|
|||
CHECK(vector.get_capacity() >= 4);
|
||||
}
|
||||
} // namespace TestLocalVector
|
||||
|
||||
#endif // TEST_LOCAL_VECTOR_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_LRU_H
|
||||
#define TEST_LRU_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/lru.h"
|
||||
|
||||
|
|
@ -95,5 +94,3 @@ TEST_CASE("[LRU] Resize and clear") {
|
|||
CHECK(!lru.has(4));
|
||||
}
|
||||
} // namespace TestLRU
|
||||
|
||||
#endif // TEST_LRU_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_OA_HASH_MAP_H
|
||||
#define TEST_OA_HASH_MAP_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/oa_hash_map.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
|
@ -247,5 +246,3 @@ TEST_CASE("[OAHashMap] Non-trivial types") {
|
|||
}
|
||||
|
||||
} // namespace TestOAHashMap
|
||||
|
||||
#endif // TEST_OA_HASH_MAP_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_PAGED_ARRAY_H
|
||||
#define TEST_PAGED_ARRAY_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/paged_array.h"
|
||||
|
||||
|
|
@ -200,5 +199,3 @@ TEST_CASE("[PagedArray] Extensive merge_unordered() test") {
|
|||
}
|
||||
|
||||
} // namespace TestPagedArray
|
||||
|
||||
#endif // TEST_PAGED_ARRAY_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_RID_H
|
||||
#define TEST_RID_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/thread.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
|
|
@ -38,6 +37,7 @@
|
|||
|
||||
#include "tests/test_macros.h"
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
#ifdef SANITIZERS_ENABLED
|
||||
#ifdef __has_feature
|
||||
#if __has_feature(thread_sanitizer)
|
||||
|
|
@ -46,7 +46,8 @@
|
|||
#elif defined(__SANITIZE_THREAD__)
|
||||
#define TSAN_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
#endif // SANITIZERS_ENABLED
|
||||
#endif // THREADS_ENABLED
|
||||
|
||||
#ifdef TSAN_ENABLED
|
||||
#include <sanitizer/tsan_interface.h>
|
||||
|
|
@ -114,6 +115,7 @@ TEST_CASE("[RID] 'get_local_index'") {
|
|||
CHECK(RID::from_uint64(4'294'967'297).get_local_index() == 1);
|
||||
}
|
||||
|
||||
#ifdef THREADS_ENABLED
|
||||
// This case would let sanitizers realize data races.
|
||||
// Additionally, on purely weakly ordered architectures, it would detect synchronization issues
|
||||
// if RID_Alloc failed to impose proper memory ordering and the test's threads are distributed
|
||||
|
|
@ -141,7 +143,7 @@ TEST_CASE("[RID_Owner] Thread safety") {
|
|||
uint32_t target = (p_step / 2 + 1) * threads.size();
|
||||
sync[buf_idx].fetch_add(1, std::memory_order_relaxed);
|
||||
do {
|
||||
std::this_thread::yield();
|
||||
Thread::yield();
|
||||
} while (sync[buf_idx].load(std::memory_order_relaxed) != target);
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +251,6 @@ TEST_CASE("[RID_Owner] Thread safety") {
|
|||
tester.test();
|
||||
}
|
||||
}
|
||||
} // namespace TestRID
|
||||
#endif // THREADS_ENABLED
|
||||
|
||||
#endif // TEST_RID_H
|
||||
} // namespace TestRID
|
||||
|
|
|
|||
70
engine/tests/core/templates/test_span.h
Normal file
70
engine/tests/core/templates/test_span.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/**************************************************************************/
|
||||
/* test_span.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/span.h"
|
||||
|
||||
#include "tests/test_macros.h"
|
||||
|
||||
namespace TestSpan {
|
||||
|
||||
TEST_CASE("[Span] Constexpr Validators") {
|
||||
constexpr Span<uint16_t> span_empty;
|
||||
static_assert(span_empty.ptr() == nullptr);
|
||||
static_assert(span_empty.size() == 0);
|
||||
static_assert(span_empty.is_empty());
|
||||
|
||||
constexpr static uint16_t value = 5;
|
||||
constexpr Span<uint16_t> span_value(&value, 1);
|
||||
static_assert(span_value.ptr() == &value);
|
||||
static_assert(span_value.size() == 1);
|
||||
static_assert(!span_value.is_empty());
|
||||
|
||||
static constexpr int ints[] = { 0, 1, 2, 3, 4, 5 };
|
||||
constexpr Span<int> span_array = ints;
|
||||
static_assert(span_array.size() == 6);
|
||||
static_assert(!span_array.is_empty());
|
||||
static_assert(span_array[0] == 0);
|
||||
static_assert(span_array[span_array.size() - 1] == 5);
|
||||
|
||||
constexpr Span<char32_t> span_string = U"122345";
|
||||
static_assert(span_string.size() == 6);
|
||||
static_assert(!span_string.is_empty());
|
||||
static_assert(span_string[0] == U'1');
|
||||
static_assert(span_string[span_string.size() - 1] == U'5');
|
||||
|
||||
int idx = 0;
|
||||
for (const char32_t &chr : span_string) {
|
||||
CHECK_EQ(chr, span_string[idx++]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TestSpan
|
||||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_VECTOR_H
|
||||
#define TEST_VECTOR_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/vector.h"
|
||||
|
||||
|
|
@ -706,5 +705,3 @@ TEST_CASE("[Vector] Cyclic Reference") {
|
|||
}
|
||||
|
||||
} // namespace TestVector
|
||||
|
||||
#endif // TEST_VECTOR_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue