vfs: check userland buffers before reading them.
[haiku.git] / src / tests / add-ons / mail / imap / rfc3501_encoding_test.cpp
blobcf5f0859af3dd92895d8b3a8475b2d5a23f4f43e
1 /*
2 * Copyright 2013, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <stdio.h>
8 #include <stdlib.h>
10 #include "Response.h"
13 void
14 assertEquals(const char* expected, const char* result)
16 if (strcmp(expected, result) != 0) {
17 printf("Expected \"%s\", got \"%s\"\n", expected, result);
18 exit(EXIT_FAILURE);
23 int
24 main()
26 const char* samples[] = {
27 "Gelöscht", "Gel&APY-scht",
28 "&äöß", "&-&AOQA9gDf-"
31 IMAP::RFC3501Encoding encoding;
33 for (size_t i = 0; i < sizeof(samples) / sizeof(samples[0]); i += 2) {
34 BString encoded = encoding.Encode(samples[i]);
35 assertEquals(samples[i + 1], encoded);
36 BString decoded = encoding.Decode(encoded);
37 assertEquals(samples[i], decoded);