aboutsummaryrefslogtreecommitdiff
path: root/tests/test_olm_decrypt.cpp
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2019-04-22 10:12:42 -0400
committerHubert Chathi <hubert@uhoreg.ca>2019-04-22 10:12:42 -0400
commitea13edcae00cc4ab1805e85322e73b7aa2faba7a (patch)
tree1960e726574ebcb8ce52230c0cc86ecce4833f91 /tests/test_olm_decrypt.cpp
parent157c0fa67e1ccdaac5a66983004dab8e978f2b4f (diff)
don't use variable length or zero-length arrays in test files
as some compilers don't handle that
Diffstat (limited to 'tests/test_olm_decrypt.cpp')
-rw-r--r--tests/test_olm_decrypt.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/test_olm_decrypt.cpp b/tests/test_olm_decrypt.cpp
index 4a1fb97..0c8feb8 100644
--- a/tests/test_olm_decrypt.cpp
+++ b/tests/test_olm_decrypt.cpp
@@ -1,6 +1,8 @@
#include "olm/olm.h"
#include "unittest.hh"
+#include <vector>
+
struct test_case {
const char *msghex;
const char *expected_error;
@@ -37,14 +39,14 @@ void decode_hex(
}
void decrypt_case(int message_type, const test_case * test_case) {
- std::uint8_t session_memory[olm_session_size()];
- ::OlmSession * session = ::olm_session(session_memory);
+ std::vector<std::uint8_t> session_memory(olm_session_size());
+ ::OlmSession * session = ::olm_session(session_memory.data());
- std::uint8_t pickled[strlen(session_data)];
- ::memcpy(pickled, session_data, sizeof(pickled));
+ std::vector<std::uint8_t> pickled(strlen(session_data));
+ ::memcpy(pickled.data(), session_data, pickled.size());
assert_not_equals(
::olm_error(),
- ::olm_unpickle_session(session, "", 0, pickled, sizeof(pickled))
+ ::olm_unpickle_session(session, "", 0, pickled.data(), pickled.size())
);
std::size_t message_length = strlen(test_case->msghex) / 2;
@@ -67,12 +69,12 @@ void decrypt_case(int message_type, const test_case * test_case) {
assert_not_equals(::olm_error(), max_length);
- uint8_t plaintext[max_length];
+ std::vector<uint8_t> plaintext(max_length);
decode_hex(test_case->msghex, message, message_length);
olm_decrypt(
session, message_type,
message, message_length,
- plaintext, max_length
+ plaintext.data(), max_length
);
free(message);
}