diff --git a/toxcore/crypto_core_test.cc b/toxcore/crypto_core_test.cc index 985a4cf268c..e8ac2a19019 100644 --- a/toxcore/crypto_core_test.cc +++ b/toxcore/crypto_core_test.cc @@ -1,5 +1,4 @@ #include "crypto_core.h" -#include "util.h" #include @@ -7,8 +6,9 @@ #include #include -namespace -{ +#include "util.h" + +namespace { using ExtPublicKey = std::array; using ExtSecretKey = std::array; @@ -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) @@ -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) @@ -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()); } } diff --git a/toxcore/group_moderation_fuzz_test.cc b/toxcore/group_moderation_fuzz_test.cc index 7b8856b07bb..a5aabee9ab5 100644 --- a/toxcore/group_moderation_fuzz_test.cc +++ b/toxcore/group_moderation_fuzz_test.cc @@ -1,7 +1,6 @@ #include "group_moderation.h" -namespace -{ +namespace { void TestUnpackFunctions(const uint8_t *data, size_t size) { @@ -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; + } } } diff --git a/toxcore/group_moderation_test.cc b/toxcore/group_moderation_test.cc index b1cd31e06c1..9839cac7046 100644 --- a/toxcore/group_moderation_test.cc +++ b/toxcore/group_moderation_test.cc @@ -8,8 +8,7 @@ #include "crypto_core.h" -namespace -{ +namespace { using ModerationHash = std::array;