unittest: rtf, test crash core dump
This commit is contained in:
parent
b98d112738
commit
2a2d141629
21
Tests/Unit/Fixtures/zentyal_crash_2058.rtf
Normal file
21
Tests/Unit/Fixtures/zentyal_crash_2058.rtf
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{\rtf1\ansi\deff3\adeflang1025
|
||||||
|
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Times New Roman;}{\f4\fs
|
||||||
|
wiss\fprq2\fcharset0 Arial;}{\f5\fnil\fprq2\fcharset1 Ubuntu;}{\f6\fnil\fprq2\fcharset0 DejaVu Sans;}{\f7\fnil\fprq2\fcharset0 Lohit Hindi;}{\f8\fnil\fprq0\fcharset1 Lohit Hindi
|
||||||
|
;}}
|
||||||
|
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||||
|
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang1033 Normal;}
|
||||||
|
{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af6\dbch\af7\afs28\loch\f4\fs28 Heading;}
|
||||||
|
{\s16\sbasedon0\snext16\sb0\sa120 Text Body;}
|
||||||
|
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af8 List;}
|
||||||
|
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af8\afs24\ai\fs24 Caption;}
|
||||||
|
{\s19\sbasedon0\snext19\noline\dbch\af8 Index;}
|
||||||
|
}{\info{\creatim\yr2014\mo8\dy4\hr16\min16}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern67175170}}\deftab709
|
||||||
|
\viewscale100
|
||||||
|
{\*\pgdsctbl
|
||||||
|
{\pgdsc0\pgdscuse451\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Default Style;}}
|
||||||
|
\formshade\paperh16838\paperw11906\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\marg
|
||||||
|
bsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||||
|
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af6\langfe2052\dbch\af7\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch\l
|
||||||
|
och\f5000
|
||||||
|
foobar}
|
||||||
|
\par }
|
|
@ -28,12 +28,17 @@ $(TEST_TOOL)_OBJC_FILES += \
|
||||||
TestNSString+Crypto.m \
|
TestNSString+Crypto.m \
|
||||||
TestNSString+URLEscaping.m \
|
TestNSString+URLEscaping.m \
|
||||||
TestNSString+Utilities.m \
|
TestNSString+Utilities.m \
|
||||||
TestNGMailAddressParser.m
|
TestNGMailAddressParser.m \
|
||||||
|
\
|
||||||
|
TestRTFHandler.m \
|
||||||
|
../../OpenChange/RTFHandler.m
|
||||||
|
# I don't know how to link against -l:SOGoBackend \
|
||||||
|
undefined reference to `__objc_class_name_SOGoMailFolder'
|
||||||
|
|
||||||
TEST_TOOL_NAME = $(TEST_TOOL)
|
TEST_TOOL_NAME = $(TEST_TOOL)
|
||||||
|
|
||||||
$(TEST_TOOL)_CPPFLAGS += \
|
$(TEST_TOOL)_CPPFLAGS += \
|
||||||
-Wall -D_GNU_SOURCE -I../../SOPE/ -I../../SoObjects/ -I../../UI/
|
-Wall -D_GNU_SOURCE -I../../SOPE/ -I../../SoObjects/ -I../../UI/ -I../../OpenChange
|
||||||
|
|
||||||
ADDITIONAL_LIB_DIRS += \
|
ADDITIONAL_LIB_DIRS += \
|
||||||
-L../../SoObjects/SOGo/SOGo.framework/Versions/Current/sogo -L../../SOPE/NGCards/obj -L../../SOPE/GDLContentStore/obj -lSOGo -lNGMime -lNGCards -lGDLContentStore -lNGExtensions -lSBJson -lobjc \
|
-L../../SoObjects/SOGo/SOGo.framework/Versions/Current/sogo -L../../SOPE/NGCards/obj -L../../SOPE/GDLContentStore/obj -lSOGo -lNGMime -lNGCards -lGDLContentStore -lNGExtensions -lSBJson -lobjc \
|
||||||
|
@ -47,3 +52,4 @@ include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||||
|
|
||||||
check :: $(TEST_TOOL)
|
check :: $(TEST_TOOL)
|
||||||
./obj/sogo-tests
|
./obj/sogo-tests
|
||||||
|
|
||||||
|
|
73
Tests/Unit/TestRTFHandler.m
Normal file
73
Tests/Unit/TestRTFHandler.m
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/* TestRTFHandler.m
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Zentyal
|
||||||
|
*
|
||||||
|
* Author: Jesús García Sáez <jgarcia@zentyal.org>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file is encoded in utf-8. */
|
||||||
|
|
||||||
|
#import "RTFHandler.h"
|
||||||
|
#import <Foundation/NSFileManager.h>
|
||||||
|
#import "SOGoTest.h"
|
||||||
|
|
||||||
|
@interface TestRTFHandler : SOGoTest
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TestRTFHandler
|
||||||
|
|
||||||
|
|
||||||
|
- (NSString *) rtf2html: (NSString *) rtf
|
||||||
|
{
|
||||||
|
if (!rtf) return @"nil";
|
||||||
|
NSData *data = [rtf dataUsingEncoding: NSUTF8StringEncoding];
|
||||||
|
RTFHandler *handler = [[RTFHandler alloc] initWithData: data];
|
||||||
|
NSMutableData *data2 = [handler parse];
|
||||||
|
NSString *html = [[NSString alloc] initWithData: data2
|
||||||
|
encoding: NSUTF8StringEncoding];
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) get_zentyal_crash_contents_of: (unsigned int) number
|
||||||
|
{
|
||||||
|
NSString *file_path = [NSString stringWithFormat: @"Fixtures/zentyal_crash_%u.rtf", number];
|
||||||
|
|
||||||
|
if(![[NSFileManager defaultManager] fileExistsAtPath: file_path]) {
|
||||||
|
NSString *error = [NSString stringWithFormat: @"File %@ doesn't exist", file_path];
|
||||||
|
testWithMessage(false, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSString stringWithContentsOfFile: file_path
|
||||||
|
encoding: NSUTF8StringEncoding
|
||||||
|
error: NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) test_does_not_crash: (unsigned int) number
|
||||||
|
{
|
||||||
|
// FIXME fork
|
||||||
|
[self rtf2html: [self get_zentyal_crash_contents_of: number]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) test_zentyal_crash_2058
|
||||||
|
{
|
||||||
|
[self test_does_not_crash: 2058];
|
||||||
|
// Output is not correct... but the original issue was segfault
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in a new issue