Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F140423
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index ce2a12a..b338d58 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,76 +1,77 @@
include(CTest)
set(KAZVTEST_RESPATH ${CMAKE_CURRENT_SOURCE_DIR}/resources)
configure_file(kazvtest-respath.hpp.in kazvtest-respath.hpp)
add_executable(kazvtest
testmain.cpp
basejobtest.cpp
event-test.cpp
cursorutiltest.cpp
base/serialization-test.cpp
base/types-test.cpp
base/immer-utils-test.cpp
base/json-utils-test.cpp
client/client-test-util.cpp
client/discovery-test.cpp
client/sync-test.cpp
client/content-test.cpp
client/paginate-test.cpp
client/util-test.cpp
client/serialization-test.cpp
client/encrypted-file-test.cpp
client/sdk-test.cpp
client/thread-safety-test.cpp
client/room-test.cpp
client/random-generator-test.cpp
client/profile-test.cpp
client/kick-test.cpp
client/ban-test.cpp
client/join-test.cpp
client/keys-test.cpp
client/device-ops-test.cpp
client/send-test.cpp
client/encryption-test.cpp
client/redact-test.cpp
client/tagging-test.cpp
client/account-data-test.cpp
client/room/room-actions-test.cpp
client/room/local-echo-test.cpp
client/room/event-relationships-test.cpp
client/push-rules-desc-test.cpp
client/notification-handler-test.cpp
client/validator-test.cpp
client/power-levels-desc-test.cpp
+ client/client-test.cpp
kazvjobtest.cpp
event-emitter-test.cpp
crypto-test.cpp
crypto/deterministic-test.cpp
promise-test.cpp
store-test.cpp
file-desc-test.cpp
)
target_include_directories(
kazvtest
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/client)
target_compile_definitions(kazvtest PRIVATE CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
target_link_libraries(kazvtest
PRIVATE Catch2::Catch2WithMain
PRIVATE kazv
PRIVATE kazveventemitter
PRIVATE kazvjob
PRIVATE nlohmann_json::nlohmann_json
PRIVATE immer
PRIVATE lager
PRIVATE zug
PRIVATE kazvtestfixtures
)
add_test(NAME kazvtest COMMAND kazvtest "~[needs-internet]")
diff --git a/src/tests/client/client-test.cpp b/src/tests/client/client-test.cpp
new file mode 100644
index 0000000..4bf583b
--- /dev/null
+++ b/src/tests/client/client-test.cpp
@@ -0,0 +1,43 @@
+/*
+ * This file is part of libkazv.
+ * SPDX-FileCopyrightText: 2021-2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <libkazv-config.hpp>
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <client/client-model.hpp>
+#include <client/actions/encryption.hpp>
+
+#include "factory.hpp"
+
+using namespace Kazv;
+using namespace Kazv::Factory;
+
+TEST_CASE("ClientModel copying should not invoke Crypto copy-constructor", "[client][copy]")
+{
+ ClientModel m = makeClient(withCrypto(makeCrypto()));
+
+ auto m2 = m;
+
+ REQUIRE(m.crypto.value().get() == m2.crypto.value().get());
+}
+
+TEST_CASE("Modifying Crypto in Client when it is not unique should invoke Crypto's copy constructor", "[client][copy]")
+{
+ ClientModel m = makeClient(
+ withCrypto(makeCrypto())
+ | withRoom(makeRoom(
+ withRoomEncrypted(true)
+ | withRoomTimeline({
+ makeEvent(withEventType("m.room.encrypted"))
+ })))
+ );
+
+ auto m2 = m;
+
+ auto m3 = tryDecryptEvents(std::move(m));
+ REQUIRE(!(m3.crypto.value().get() == m2.crypto.value().get()));
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 8:30 PM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55436
Default Alt Text
(3 KB)
Attached To
Mode
rL libkazv
Attached
Detach File
Event Timeline
Log In to Comment