diff options
| author | Marvin W <git@larma.de> | 2026-10-04 14:42:16 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2026-10-23 16:59:59 +0200 |
| commit | dba577f39c489b9db29960f2bf5cc78ac4f29d7b (patch) | |
| tree | a8354c9fc328c1442d5e8c5c2adec4b428c92f44 /plugins/omemo/tests/native/common.vala | |
| parent | 2413442905e31f34cb0f77c9167003b3725760fe (diff) | |
Move OMEMO, OpenPGP and RTP plugins into main/libdino
Diffstat (limited to 'plugins/omemo/tests/native/common.vala')
| -rw-r--r-- | plugins/omemo/tests/native/common.vala | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/plugins/omemo/tests/native/common.vala b/plugins/omemo/tests/native/common.vala deleted file mode 100644 index af0f7250..00000000 --- a/plugins/omemo/tests/native/common.vala +++ /dev/null @@ -1,92 +0,0 @@ -namespace Omemo.Test { - -int main(string[] args) { - GLib.Test.init(ref args); - GLib.Test.set_nonfatal_assertions(); - TestSuite.get_root().add_suite(new Curve25519().get_suite()); - TestSuite.get_root().add_suite(new SessionBuilderTest().get_suite()); - TestSuite.get_root().add_suite(new HKDF().get_suite()); - return GLib.Test.run(); -} - -Store setup_test_store_context(Context global_context) { - Store store = global_context.create_store(); - try { - store.identity_key_store.local_registration_id = (Random.next_int() % 16380) + 1; - - ECKeyPair key_pair = global_context.generate_key_pair(); - store.identity_key_store.identity_key_private = new Bytes(key_pair.private.serialize()); - store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize()); - } catch (Error e) { - fail_if_reached(); - } - return store; -} - -ECPublicKey? create_test_ec_public_key(Context context) { - try { - return context.generate_key_pair().public; - } catch (Error e) { - fail_if_reached(); - return null; - } -} - -bool fail_if(bool exp, string? reason = null) { - if (exp) { - if (reason != null) GLib.Test.message(reason); - GLib.Test.fail(); - return true; - } - return false; -} - -void fail_if_reached(string? reason = null) { - fail_if(true, reason); -} - -delegate void ErrorFunc() throws Error; - -void fail_if_not_error_code(ErrorFunc func, int expectedCode, string? reason = null) { - try { - func(); - fail_if_reached(@"$(reason + ": " ?? "")no error thrown"); - } catch (Error e) { - fail_if_not_eq_int(e.code, expectedCode, @"$(reason + ": " ?? "")caught unexpected error"); - } -} - -bool fail_if_not(bool exp, string? reason = null) { - return fail_if(!exp, reason); -} - -bool fail_if_eq_int(int left, int right, string? reason = null) { - return fail_if(left == right, @"$(reason + ": " ?? "")$left == $right"); -} - -bool fail_if_not_eq_int(int left, int right, string? reason = null) { - return fail_if_not(left == right, @"$(reason + ": " ?? "")$left != $right"); -} - -bool fail_if_not_eq_str(string left, string right, string? reason = null) { - return fail_if_not(left == right, @"$(reason + ": " ?? "")$left != $right"); -} - -bool fail_if_not_eq_uint8_arr(uint8[] left, uint8[] right, string? reason = null) { - if (fail_if_not_eq_int(left.length, right.length, @"$(reason + ": " ?? "")array length not equal")) return true; - return fail_if_not_eq_str(Base64.encode(left), Base64.encode(right), reason); -} - -bool fail_if_not_zero_int(int zero, string? reason = null) { - return fail_if_not_eq_int(zero, 0, reason); -} - -bool fail_if_zero_int(int zero, string? reason = null) { - return fail_if_eq_int(zero, 0, reason); -} - -bool fail_if_null(void* what, string? reason = null) { - return fail_if(what == null || (size_t)what == 0, reason); -} - -} |
