1 /* 2 * Copyright 2013, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <stdio.h> 8 #include <stdlib.h> 9 10 #include "Response.h" 11 12 13 void 14 assertEquals(const char* expected, const char* result) 15 { 16 if (strcmp(expected, result) != 0) { 17 printf("Expected \"%s\", got \"%s\"\n", expected, result); 18 exit(EXIT_FAILURE); 19 } 20 } 21 22 23 int 24 main() 25 { 26 const char* samples[] = { 27 "Gelöscht", "Gel&APY-scht", 28 "&äöß", "&-&AOQA9gDf-" 29 }; 30 31 IMAP::RFC3501Encoding encoding; 32 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); 38 } 39 } 40