Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Mar 23, 2022
1 parent b696dcc commit ef3b2b2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
24 changes: 13 additions & 11 deletions toxcore/crypto_core_test.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "crypto_core.h"
#include "util.h"

#include <gtest/gtest.h>

#include <algorithm>
#include <array>
#include <vector>

namespace
{
#include "util.h"

namespace {

using ExtPublicKey = std::array<uint8_t, EXT_PUBLIC_KEY_SIZE>;
using ExtSecretKey = std::array<uint8_t, EXT_SECRET_KEY_SIZE>;
Expand All @@ -20,14 +20,14 @@ TEST(CryptoCore, IncrementNonce)
Nonce nonce{};
increment_nonce(nonce.data());
EXPECT_EQ(
nonce, (Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}));
nonce, (Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}));

for (int i = 0; i < 0x1F4; ++i) {
increment_nonce(nonce.data());
}

EXPECT_EQ(nonce,
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xF5}}));
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xF5}}));
}

TEST(CryptoCore, IncrementNonceNumber)
Expand All @@ -36,16 +36,16 @@ TEST(CryptoCore, IncrementNonceNumber)

increment_nonce_number(nonce.data(), 0x1F5);
EXPECT_EQ(nonce,
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xF5}}));
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xF5}}));

increment_nonce_number(nonce.data(), 0x1F5);
EXPECT_EQ(nonce,
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03, 0xEA}}));
(Nonce{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03, 0xEA}}));

increment_nonce_number(nonce.data(), 0x12345678);
EXPECT_EQ(nonce,
(Nonce{
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12, 0x34, 0x5A, 0x62}}));
(Nonce{
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12, 0x34, 0x5A, 0x62}}));
}

TEST(CryptoCore, Signatures)
Expand All @@ -60,8 +60,10 @@ TEST(CryptoCore, Signatures)
// Try a few different sizes, including empty 0 length message.
for (uint8_t i = 0; i < 100; ++i) {
Signature signature;
EXPECT_TRUE(crypto_signature_create(signature.data(), message.data(), message.size(), get_sig_sk(sk.data())));
EXPECT_TRUE(crypto_signature_verify(signature.data(), message.data(), message.size(), get_sig_pk(pk.data())));
EXPECT_TRUE(crypto_signature_create(
signature.data(), message.data(), message.size(), get_sig_sk(sk.data())));
EXPECT_TRUE(crypto_signature_verify(
signature.data(), message.data(), message.size(), get_sig_pk(pk.data())));
message.push_back(random_u08());
}
}
Expand Down
51 changes: 25 additions & 26 deletions toxcore/group_moderation_fuzz_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "group_moderation.h"

namespace
{
namespace {

void TestUnpackFunctions(const uint8_t *data, size_t size)
{
Expand All @@ -16,33 +15,33 @@ void TestUnpackFunctions(const uint8_t *data, size_t size)
const uint8_t NUM_FUNCS = 3;

switch (func % NUM_FUNCS) {
case 0: {
if (size < 1) {
return;
}

const uint16_t num_mods = data[0];
++data;
--size;
Moderation mods{};
mod_list_unpack(&mods, data, size, num_mods);
mod_list_cleanup(&mods);
break;
case 0: {
if (size < 1) {
return;
}

case 1: {
Mod_Sanction sanctions[10];
Mod_Sanction_Creds creds;
uint16_t processed_data_len;
sanctions_list_unpack(sanctions, &creds, 10, data, size, &processed_data_len);
break;
}
const uint16_t num_mods = data[0];
++data;
--size;
Moderation mods{};
mod_list_unpack(&mods, data, size, num_mods);
mod_list_cleanup(&mods);
break;
}

case 2: {
Mod_Sanction_Creds creds;
sanctions_creds_unpack(&creds, data);
break;
}
case 1: {
Mod_Sanction sanctions[10];
Mod_Sanction_Creds creds;
uint16_t processed_data_len;
sanctions_list_unpack(sanctions, &creds, 10, data, size, &processed_data_len);
break;
}

case 2: {
Mod_Sanction_Creds creds;
sanctions_creds_unpack(&creds, data);
break;
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions toxcore/group_moderation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#include "crypto_core.h"

namespace
{
namespace {

using ModerationHash = std::array<uint8_t, MOD_MODERATION_HASH_SIZE>;

Expand Down

0 comments on commit ef3b2b2

Please sign in to comment.