Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch to Rakefile and loch-tests.json.

  • Loading branch information...
commit af095bd646a0107dc30ee065fc49ea278bc1f56e 1 parent 9d40615
@rentzsch authored
Showing with 240 additions and 664 deletions.
  1. +25 −0 Rakefile
  2. +0 −241 cocoa/TestLichCocoa/TestLichCocoa.xcodeproj/project.pbxproj
  3. +0 −7 cocoa/TestLichCocoa/TestLichCocoa/TestLichCocoa-Prefix.pch
  4. +0 −79 cocoa/TestLichCocoa/TestLichCocoa/TestLichCocoa.1
  5. +0 −22 cocoa/TestLichCocoa/TestLichCocoa/main.m
  6. +170 −0 cocoa/test/TestLichCocoa.m
  7. +0 −256 cocoa/test/lich-cocoa-fuzzing-harness.xcodeproj/project.pbxproj
  8. +0 −7 cocoa/test/lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness-Prefix.pch
  9. +0 −39 cocoa/test/lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness.m
  10. +45 −0 lich-tests.json
  11. +0 −1  samples/invalid/empty data with wrong size.lich
  12. +0 −1  samples/invalid/start with alpha.lich
  13. +0 −1  samples/invalid/start with curly brace.lich
  14. +0 −1  samples/invalid/start with dash.lich
  15. +0 −1  samples/invalid/start with less than.lich
  16. +0 −1  samples/invalid/start with period.lich
  17. +0 −1  samples/invalid/start with square brace.lich
  18. +0 −1  samples/valid/array with empty array.lich
  19. +0 −1  samples/valid/array with empty data.lich
  20. +0 −1  samples/valid/array with empty dictionary.lich
  21. +0 −1  samples/valid/empty array.lich
  22. +0 −1  samples/valid/empty data.lich
  23. +0 −1  samples/valid/empty dictionary.lich
View
25 Rakefile
@@ -0,0 +1,25 @@
+desc 'Build'
+task :build do
+ puts "\n=== Building ==="
+
+ system('cd cocoa && clang -o test/TestLichCocoa -Wno-unused-value -framework Foundation -I. -Ideps *.m deps/JRErr.m test/TestLichCocoa.m')
+ puts '!!! FAILED !!!' if $?.exitstatus != 0
+end
+
+desc 'Test'
+task :test => [:build] do
+ puts "\n=== Testing ==="
+
+ system('cocoa/test/TestLichCocoa lich-tests.json')
+ puts '!!! FAILED !!!' if $?.exitstatus != 0
+
+ system('rm cocoa/test/TestLichCocoa')
+end
+
+desc 'Clean up'
+task :clean do
+ puts "\n=== Cleaning ==="
+ system('rm cocoa/test/TestLichCocoa')
+end
+
+task :default => [:clean, :test, :clean]
View
241 cocoa/TestLichCocoa/TestLichCocoa.xcodeproj/project.pbxproj
@@ -1,241 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 793C4428161D209600A54E3D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 793C4427161D209600A54E3D /* Foundation.framework */; };
- 793C442B161D209600A54E3D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 793C442A161D209600A54E3D /* main.m */; };
- 793C442F161D209600A54E3D /* TestLichCocoa.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 793C442E161D209600A54E3D /* TestLichCocoa.1 */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXCopyFilesBuildPhase section */
- 793C4421161D209600A54E3D /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- 793C442F161D209600A54E3D /* TestLichCocoa.1 in CopyFiles */,
- );
- runOnlyForDeploymentPostprocessing = 1;
- };
-/* End PBXCopyFilesBuildPhase section */
-
-/* Begin PBXFileReference section */
- 793C4423161D209600A54E3D /* TestLichCocoa */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestLichCocoa; sourceTree = BUILT_PRODUCTS_DIR; };
- 793C4427161D209600A54E3D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 793C442A161D209600A54E3D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- 793C442D161D209600A54E3D /* TestLichCocoa-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TestLichCocoa-Prefix.pch"; sourceTree = "<group>"; };
- 793C442E161D209600A54E3D /* TestLichCocoa.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = TestLichCocoa.1; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 793C4420161D209600A54E3D /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 793C4428161D209600A54E3D /* Foundation.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 793C4418161D209600A54E3D = {
- isa = PBXGroup;
- children = (
- 793C4429161D209600A54E3D /* TestLichCocoa */,
- 793C4426161D209600A54E3D /* Frameworks */,
- 793C4424161D209600A54E3D /* Products */,
- );
- sourceTree = "<group>";
- };
- 793C4424161D209600A54E3D /* Products */ = {
- isa = PBXGroup;
- children = (
- 793C4423161D209600A54E3D /* TestLichCocoa */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 793C4426161D209600A54E3D /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 793C4427161D209600A54E3D /* Foundation.framework */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 793C4429161D209600A54E3D /* TestLichCocoa */ = {
- isa = PBXGroup;
- children = (
- 793C442A161D209600A54E3D /* main.m */,
- 793C442E161D209600A54E3D /* TestLichCocoa.1 */,
- 793C442C161D209600A54E3D /* Supporting Files */,
- );
- path = TestLichCocoa;
- sourceTree = "<group>";
- };
- 793C442C161D209600A54E3D /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 793C442D161D209600A54E3D /* TestLichCocoa-Prefix.pch */,
- );
- name = "Supporting Files";
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 793C4422161D209600A54E3D /* TestLichCocoa */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 793C4432161D209600A54E3D /* Build configuration list for PBXNativeTarget "TestLichCocoa" */;
- buildPhases = (
- 793C441F161D209600A54E3D /* Sources */,
- 793C4420161D209600A54E3D /* Frameworks */,
- 793C4421161D209600A54E3D /* CopyFiles */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = TestLichCocoa;
- productName = TestLichCocoa;
- productReference = 793C4423161D209600A54E3D /* TestLichCocoa */;
- productType = "com.apple.product-type.tool";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 793C441A161D209600A54E3D /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0450;
- ORGANIZATIONNAME = "Jonathan 'Wolf' Rentzsch";
- };
- buildConfigurationList = 793C441D161D209600A54E3D /* Build configuration list for PBXProject "TestLichCocoa" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- );
- mainGroup = 793C4418161D209600A54E3D;
- productRefGroup = 793C4424161D209600A54E3D /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 793C4422161D209600A54E3D /* TestLichCocoa */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXSourcesBuildPhase section */
- 793C441F161D209600A54E3D /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 793C442B161D209600A54E3D /* main.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
- 793C4430161D209600A54E3D /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = NO;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
- ONLY_ACTIVE_ARCH = YES;
- SDKROOT = macosx;
- };
- name = Debug;
- };
- 793C4431161D209600A54E3D /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
- SDKROOT = macosx;
- };
- name = Release;
- };
- 793C4433161D209600A54E3D /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "TestLichCocoa/TestLichCocoa-Prefix.pch";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Debug;
- };
- 793C4434161D209600A54E3D /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "TestLichCocoa/TestLichCocoa-Prefix.pch";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 793C441D161D209600A54E3D /* Build configuration list for PBXProject "TestLichCocoa" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 793C4430161D209600A54E3D /* Debug */,
- 793C4431161D209600A54E3D /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 793C4432161D209600A54E3D /* Build configuration list for PBXNativeTarget "TestLichCocoa" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 793C4433161D209600A54E3D /* Debug */,
- 793C4434161D209600A54E3D /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 793C441A161D209600A54E3D /* Project object */;
-}
View
7 cocoa/TestLichCocoa/TestLichCocoa/TestLichCocoa-Prefix.pch
@@ -1,7 +0,0 @@
-//
-// Prefix header for all source files of the 'TestLichCocoa' target in the 'TestLichCocoa' project
-//
-
-#ifdef __OBJC__
- #import <Foundation/Foundation.h>
-#endif
View
79 cocoa/TestLichCocoa/TestLichCocoa/TestLichCocoa.1
@@ -1,79 +0,0 @@
-.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
-.\"See Also:
-.\"man mdoc.samples for a complete listing of options
-.\"man mdoc for the short list of editing options
-.\"/usr/share/misc/mdoc.template
-.Dd 10/3/12 \" DATE
-.Dt TestLichCocoa 1 \" Program name and manual section number
-.Os Darwin
-.Sh NAME \" Section Header - required - don't modify
-.Nm TestLichCocoa,
-.\" The following lines are read in generating the apropos(man -k) database. Use only key
-.\" words here as the database is built based on the words here and in the .ND line.
-.Nm Other_name_for_same_program(),
-.Nm Yet another name for the same program.
-.\" Use .Nm macro to designate other names for the documented program.
-.Nd This line parsed for whatis database.
-.Sh SYNOPSIS \" Section Header - required - don't modify
-.Nm
-.Op Fl abcd \" [-abcd]
-.Op Fl a Ar path \" [-a path]
-.Op Ar file \" [file]
-.Op Ar \" [file ...]
-.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
-arg2 ... \" Arguments
-.Sh DESCRIPTION \" Section Header - required - don't modify
-Use the .Nm macro to refer to your program throughout the man page like such:
-.Nm
-Underlining is accomplished with the .Ar macro like this:
-.Ar underlined text .
-.Pp \" Inserts a space
-A list of items with descriptions:
-.Bl -tag -width -indent \" Begins a tagged list
-.It item a \" Each item preceded by .It macro
-Description of item a
-.It item b
-Description of item b
-.El \" Ends the list
-.Pp
-A list of flags and their descriptions:
-.Bl -tag -width -indent \" Differs from above in tag removed
-.It Fl a \"-a flag as a list item
-Description of -a flag
-.It Fl b
-Description of -b flag
-.El \" Ends the list
-.Pp
-.\" .Sh ENVIRONMENT \" May not be needed
-.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
-.\" .It Ev ENV_VAR_1
-.\" Description of ENV_VAR_1
-.\" .It Ev ENV_VAR_2
-.\" Description of ENV_VAR_2
-.\" .El
-.Sh FILES \" File used or created by the topic of the man page
-.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
-.It Pa /usr/share/file_name
-FILE_1 description
-.It Pa /Users/joeuser/Library/really_long_file_name
-FILE_2 description
-.El \" Ends the list
-.\" .Sh DIAGNOSTICS \" May not be needed
-.\" .Bl -diag
-.\" .It Diagnostic Tag
-.\" Diagnostic informtion here.
-.\" .It Diagnostic Tag
-.\" Diagnostic informtion here.
-.\" .El
-.Sh SEE ALSO
-.\" List links in ascending order by section, alphabetically within a section.
-.\" Please do not reference files that do not exist without filing a bug report
-.Xr a 1 ,
-.Xr b 1 ,
-.Xr c 1 ,
-.Xr a 2 ,
-.Xr b 2 ,
-.Xr a 3 ,
-.Xr b 3
-.\" .Sh BUGS \" Document known, unremedied bugs
-.\" .Sh HISTORY \" Document history if command behaves in a unique manner
View
22 cocoa/TestLichCocoa/TestLichCocoa/main.m
@@ -1,22 +0,0 @@
-//
-// main.m
-// TestLichCocoa
-//
-// Created by Wolf Rentzsch on 10/3/12.
-// Copyright (c) 2012 Jonathan 'Wolf' Rentzsch. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-int main(int argc, const char * argv[])
-{
-
- @autoreleasepool {
-
- // insert code here...
- NSLog(@"Hello, World!");
-
- }
- return 0;
-}
-
View
170 cocoa/test/TestLichCocoa.m
@@ -0,0 +1,170 @@
+#import <Foundation/Foundation.h>
+#import "LichCocoa.h"
+#import "JRErr.h"
+
+static id convertNSStringToNSData(id input) {
+ id result = input;
+ if ([input isKindOfClass:[NSMutableArray class]]) {
+ NSMutableArray *array = input;
+
+ NSUInteger elementIdx = 0, elementCount = [array count];
+ for (; elementIdx < elementCount; elementIdx++) {
+ id element = array[elementIdx];
+ if ([element isKindOfClass:[NSString class]]) {
+ [array replaceObjectAtIndex:elementIdx withObject:[element dataUsingEncoding:NSASCIIStringEncoding]];
+ } else if ([element isKindOfClass:[NSMutableArray class]]
+ || [element isKindOfClass:[NSMutableDictionary class]])
+ {
+ convertNSStringToNSData(element);
+ }
+ }
+ } else if ([input isKindOfClass:[NSMutableDictionary class]]) {
+ NSMutableDictionary *dictionary = input;
+
+ NSMutableArray *keysToConvertToData = [NSMutableArray array];
+ NSMutableArray *keyValuesToConvertToData = [NSMutableArray array];
+ NSMutableArray *keysValueToRecurse = [NSMutableArray array];
+
+ for (id key in dictionary) {
+ if ([key isKindOfClass:[NSString class]]) {
+ [keysToConvertToData addObject:key];
+ }
+
+ id value = dictionary[key];
+ if ([value isKindOfClass:[NSString class]]) {
+ [keyValuesToConvertToData addObject:key];
+ } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
+ [keysValueToRecurse addObject:key];
+ }
+ }
+ for (id key in keyValuesToConvertToData) {
+ NSString *valueString = dictionary[key];
+ NSData *valueData = [valueString dataUsingEncoding:NSASCIIStringEncoding];
+ dictionary[key] = valueData;
+ }
+ for (id key in keysValueToRecurse) {
+ convertNSStringToNSData(dictionary[key]);
+ }
+ for (id keyString in keysToConvertToData) {
+ NSData *keyData = [keyString dataUsingEncoding:NSASCIIStringEncoding];
+ [dictionary setObject:dictionary[keyString]
+ forKey:keyData];
+ [dictionary removeObjectForKey:keyString];
+ }
+ } else if ([input isKindOfClass:[NSString class]]) {
+ result = [input dataUsingEncoding:NSASCIIStringEncoding];
+ }
+ return result;
+}
+
+int main(int argc, const char *argv[]) {
+ int result = 0;
+ @autoreleasepool {
+ @try {
+ NSArray *args = [[NSProcessInfo processInfo] arguments];
+ if ([args count] != 2) {
+ printf("usage: TestLichCocoa path/to/tests.json\n");
+ exit(2);
+ }
+
+ NSData *data = JRThrowErr([NSData dataWithContentsOfFile:args[1]
+ options:0
+ error:jrErrRef]);
+
+ NSDictionary *tests = JRThrowErr([NSJSONSerialization JSONObjectWithData:data
+ options:NSJSONReadingMutableContainers
+ error:jrErrRef]);
+
+ {{
+ NSArray *validStrings = [tests objectForKey:@"valid"];
+ for (NSString *validString in validStrings) {
+ //printf("^%s\n", [validString UTF8String]);
+ NSData *validData = JRThrowErr([validString dataUsingEncoding:NSASCIIStringEncoding]);
+ LichDecoder *decoder = [[[LichDecoder alloc] init] autorelease];
+ @try {
+ if ([validString length]) {
+ JRThrowErr([decoder decodeData:validData error:jrErrRef]);
+ }
+ } @catch (JRErrException *x){
+ printf("FAILED to decode supposedly valid string %s\n",
+ [validString UTF8String]);
+ exit(1);
+ }
+ }
+ }}
+ {{
+ NSArray *invalidSpecs = [tests objectForKey:@"invalid"];
+ for (NSArray *invalidSpec in invalidSpecs) {
+ NSString *invalidStr = JRThrowErr(invalidSpec[0]);
+ NSString *expectedError = JRThrowErr(invalidSpec[1]);
+ NSNumber *expectedErrorPos = JRThrowErr(invalidSpec[2]);
+
+ NSData *invalidData = JRThrowErr([invalidStr dataUsingEncoding:NSASCIIStringEncoding]);
+
+ NSError *actualError = nil;
+
+ LichDecoder *decoder = [[[LichDecoder alloc] init] autorelease];
+ if ([decoder decodeData:invalidData error:&actualError]) {
+ assert(!actualError);
+
+ printf("FAILED expected error %s at %s not encountered for %s\n",
+ [expectedError UTF8String],
+ [[expectedErrorPos description] UTF8String],
+ [invalidStr UTF8String]);
+ exit(1);
+ } else {
+ assert(actualError);
+
+ NSString *actualErrorStr = NSStringFromLichTokenizerErrorCode((LichTokenizerErrorCode)[actualError code]);
+ if (![expectedError isEqualToString:actualErrorStr]) {
+ printf("FAILED expected error code %s != actual %s\n",
+ [expectedError UTF8String],
+ [actualErrorStr UTF8String]);
+ }
+
+ NSNumber *actualErrPos = [[actualError userInfo] objectForKey:@"error position"];
+ if (![expectedErrorPos isEqualToNumber:actualErrPos]) {
+ printf("FAILED expected error position %s, got %s\n",
+ [[expectedErrorPos description] UTF8String],
+ [[actualErrPos description] UTF8String]);
+ exit(1);
+ }
+ }
+ }
+ }}
+ {{
+ NSArray *encodingSpecs = [tests objectForKey:@"encoding"];
+ for (NSArray *encodingSpec in encodingSpecs) {
+ id originalObject = JRThrowErr(encodingSpec[0]);
+ NSString *expectedStr = JRThrowErr(encodingSpec[1]);
+ NSData *expectedData = JRThrowErr([expectedStr dataUsingEncoding:NSASCIIStringEncoding]);
+
+ id object = convertNSStringToNSData(originalObject);
+
+ LichEncoder *encoder = [[[LichEncoder alloc] init] autorelease];
+ NSData *actualData = JRThrowErr([encoder encodeObject:object error:jrErrRef]);
+
+ if (![expectedData isEqualToData:actualData]) {
+ printf("FAILED expected data %s (%s) for %s but got %s (%s)\n",
+ [[expectedData description] UTF8String],
+ [expectedStr UTF8String],
+ [[originalObject description] UTF8String],
+ [[actualData description] UTF8String],
+ [[[[NSString alloc] initWithData:actualData encoding:NSASCIIStringEncoding] autorelease] UTF8String]
+ );
+ exit(1);
+ }
+ }
+ }}
+ } @catch (JRErrException *x){}
+
+ if (jrErr) {
+ result = 1;
+ } else {
+ printf("***** success *****\n");
+ }
+ LogJRErr();
+ }
+ return result;
+}
+
View
256 cocoa/test/lich-cocoa-fuzzing-harness.xcodeproj/project.pbxproj
@@ -1,256 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 793C4392161BE7EC00A54E3D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 793C4391161BE7EC00A54E3D /* Foundation.framework */; };
- 793C4395161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness.m in Sources */ = {isa = PBXBuildFile; fileRef = 793C4394161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness.m */; };
- 793C440A161BEC4F00A54E3D /* LichCocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = 793C4407161BEC4F00A54E3D /* LichCocoa.m */; };
- 793C440B161BEC4F00A54E3D /* LichTokenizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 793C4409161BEC4F00A54E3D /* LichTokenizer.m */; };
- 793C440F161BEC5900A54E3D /* JRErr.m in Sources */ = {isa = PBXBuildFile; fileRef = 793C440E161BEC5900A54E3D /* JRErr.m */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXCopyFilesBuildPhase section */
- 793C438B161BE7EC00A54E3D /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
- };
-/* End PBXCopyFilesBuildPhase section */
-
-/* Begin PBXFileReference section */
- 793C438D161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lich-cocoa-fuzzing-harness"; sourceTree = BUILT_PRODUCTS_DIR; };
- 793C4391161BE7EC00A54E3D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 793C4394161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "lich-cocoa-fuzzing-harness.m"; sourceTree = "<group>"; };
- 793C4397161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "lich-cocoa-fuzzing-harness-Prefix.pch"; sourceTree = "<group>"; };
- 793C4406161BEC4F00A54E3D /* LichCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LichCocoa.h; path = ../../LichCocoa.h; sourceTree = "<group>"; };
- 793C4407161BEC4F00A54E3D /* LichCocoa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LichCocoa.m; path = ../../LichCocoa.m; sourceTree = "<group>"; };
- 793C4408161BEC4F00A54E3D /* LichTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LichTokenizer.h; path = ../../LichTokenizer.h; sourceTree = "<group>"; };
- 793C4409161BEC4F00A54E3D /* LichTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LichTokenizer.m; path = ../../LichTokenizer.m; sourceTree = "<group>"; };
- 793C440D161BEC5900A54E3D /* JRErr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JRErr.h; path = ../../deps/JRErr.h; sourceTree = "<group>"; };
- 793C440E161BEC5900A54E3D /* JRErr.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JRErr.m; path = ../../deps/JRErr.m; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 793C438A161BE7EC00A54E3D /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 793C4392161BE7EC00A54E3D /* Foundation.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 793C4382161BE7EC00A54E3D = {
- isa = PBXGroup;
- children = (
- 793C4393161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */,
- 793C4390161BE7EC00A54E3D /* Frameworks */,
- 793C438E161BE7EC00A54E3D /* Products */,
- );
- sourceTree = "<group>";
- };
- 793C438E161BE7EC00A54E3D /* Products */ = {
- isa = PBXGroup;
- children = (
- 793C438D161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 793C4390161BE7EC00A54E3D /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 793C4391161BE7EC00A54E3D /* Foundation.framework */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 793C4393161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */ = {
- isa = PBXGroup;
- children = (
- 793C4394161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness.m */,
- 793C4406161BEC4F00A54E3D /* LichCocoa.h */,
- 793C4407161BEC4F00A54E3D /* LichCocoa.m */,
- 793C4408161BEC4F00A54E3D /* LichTokenizer.h */,
- 793C4409161BEC4F00A54E3D /* LichTokenizer.m */,
- 793C440D161BEC5900A54E3D /* JRErr.h */,
- 793C440E161BEC5900A54E3D /* JRErr.m */,
- 793C4396161BE7EC00A54E3D /* Supporting Files */,
- );
- path = "lich-cocoa-fuzzing-harness";
- sourceTree = "<group>";
- };
- 793C4396161BE7EC00A54E3D /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 793C4397161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness-Prefix.pch */,
- );
- name = "Supporting Files";
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 793C438C161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 793C439C161BE7EC00A54E3D /* Build configuration list for PBXNativeTarget "lich-cocoa-fuzzing-harness" */;
- buildPhases = (
- 793C4389161BE7EC00A54E3D /* Sources */,
- 793C438A161BE7EC00A54E3D /* Frameworks */,
- 793C438B161BE7EC00A54E3D /* CopyFiles */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = "lich-cocoa-fuzzing-harness";
- productName = "lich-cocoa-fuzzing-harness";
- productReference = 793C438D161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */;
- productType = "com.apple.product-type.tool";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 793C4384161BE7EC00A54E3D /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0450;
- ORGANIZATIONNAME = "Jonathan 'Wolf' Rentzsch";
- };
- buildConfigurationList = 793C4387161BE7EC00A54E3D /* Build configuration list for PBXProject "lich-cocoa-fuzzing-harness" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- );
- mainGroup = 793C4382161BE7EC00A54E3D;
- productRefGroup = 793C438E161BE7EC00A54E3D /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 793C438C161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXSourcesBuildPhase section */
- 793C4389161BE7EC00A54E3D /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 793C4395161BE7EC00A54E3D /* lich-cocoa-fuzzing-harness.m in Sources */,
- 793C440A161BEC4F00A54E3D /* LichCocoa.m in Sources */,
- 793C440B161BEC4F00A54E3D /* LichTokenizer.m in Sources */,
- 793C440F161BEC5900A54E3D /* JRErr.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
- 793C439A161BE7EC00A54E3D /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = NO;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
- ONLY_ACTIVE_ARCH = YES;
- SDKROOT = macosx;
- };
- name = Debug;
- };
- 793C439B161BE7EC00A54E3D /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.8;
- SDKROOT = macosx;
- };
- name = Release;
- };
- 793C439D161BE7EC00A54E3D /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness-Prefix.pch";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Debug;
- };
- 793C439E161BE7EC00A54E3D /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness-Prefix.pch";
- PRODUCT_NAME = "$(TARGET_NAME)";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 793C4387161BE7EC00A54E3D /* Build configuration list for PBXProject "lich-cocoa-fuzzing-harness" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 793C439A161BE7EC00A54E3D /* Debug */,
- 793C439B161BE7EC00A54E3D /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 793C439C161BE7EC00A54E3D /* Build configuration list for PBXNativeTarget "lich-cocoa-fuzzing-harness" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 793C439D161BE7EC00A54E3D /* Debug */,
- 793C439E161BE7EC00A54E3D /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 793C4384161BE7EC00A54E3D /* Project object */;
-}
View
7 cocoa/test/lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness-Prefix.pch
@@ -1,7 +0,0 @@
-//
-// Prefix header for all source files of the 'lich-cocoa-fuzzing-harness' target in the 'lich-cocoa-fuzzing-harness' project
-//
-
-#ifdef __OBJC__
- #import <Foundation/Foundation.h>
-#endif
View
39 cocoa/test/lich-cocoa-fuzzing-harness/lich-cocoa-fuzzing-harness.m
@@ -1,39 +0,0 @@
-#import <Foundation/Foundation.h>
-#import "LichCocoa.h"
-#import "JRErr.h"
-
-int main(int argc, const char * argv[]) {
- int result = 0;
- @autoreleasepool {
- @try {
- NSArray *args = [[NSProcessInfo processInfo] arguments];
- if ([args count] != 2) {
- printf("usage: lich-cocoa-fuzzing-harness path/to/data.lich\n");
- exit(2);
- }
-
- NSData *data = JRThrowErr([NSData dataWithContentsOfFile:args[1]
- options:0
- error:jrErrRef]);
-
-
-
-
-
- LichDecoder *decoder = [[[LichDecoder alloc] init] autorelease];
-
- JRThrowErr([decoder decodeData:data error:jrErrRef]);
- } @catch (JRErrException *x){}
-
- if (jrErr) {
- result = 1;
- }
- if ([[jrErr domain] isEqualToString:LichTokenizerErrorDomain]) {
- printf("%s\n", [NSStringFromLichTokenizerErrorCode((LichTokenizerErrorCode)[jrErr code]) UTF8String]);
- } else {
- LogJRErr();
- }
- }
- return result;
-}
-
View
45 lich-tests.json
@@ -0,0 +1,45 @@
+{
+ "valid": [
+ "",
+ "0<>",
+ "0[]",
+ "0{}",
+ "0<>0<>",
+ "1<z>",
+ "1<z>1<z>",
+ "1<z>1<z>1<z>",
+ "3[0<>]",
+ "6{0<>0<>}",
+ "6[0<>0<>]",
+ "6[3[0<>]]"
+ ],
+ "invalid": [
+ ["x", "LichTokenizerError_MissingSizePrefix", 0],
+ ["-", "LichTokenizerError_MissingSizePrefix", 0],
+ [".", "LichTokenizerError_MissingSizePrefix", 0],
+ ["<", "LichTokenizerError_MissingSizePrefix", 0],
+ ["[", "LichTokenizerError_MissingSizePrefix", 0],
+ ["{", "LichTokenizerError_MissingSizePrefix", 0],
+ [">", "LichTokenizerError_MissingSizePrefix", 0],
+ ["]", "LichTokenizerError_MissingSizePrefix", 0],
+ ["}", "LichTokenizerError_MissingSizePrefix", 0],
+ ["(", "LichTokenizerError_MissingSizePrefix", 0],
+ [")", "LichTokenizerError_MissingSizePrefix", 0],
+
+ ["1<>", "LichTokenizerError_MissingClosingMarker", 3],
+ ["2<>", "LichTokenizerError_IncompleteData", 3],
+ ["9<>", "LichTokenizerError_IncompleteData", 3],
+ ["3[0<>0<>]", "LichTokenizerError_IncorrectClosingMarker", 5]
+ ],
+ "encoding": [
+ ["", "0<>"],
+ ["x", "1<x>"],
+ [[], "0[]"],
+ [[""], "3[0<>]"],
+ [{}, "0{}"],
+ [{"":""}, "6{0<>0<>}"],
+ [{"a":""}, "7{1<a>0<>}"],
+ [{"k1":"v1", "k2":"v2"}, "20{2<k1>2<v1>2<k2>2<v2>}"],
+ [{"k1":["x"]}, "12{2<k1>4[1<x>]}"]
+ ]
+}
View
1  samples/invalid/empty data with wrong size.lich
@@ -1 +0,0 @@
-1<>
View
1  samples/invalid/start with alpha.lich
@@ -1 +0,0 @@
-x
View
1  samples/invalid/start with curly brace.lich
@@ -1 +0,0 @@
-{
View
1  samples/invalid/start with dash.lich
@@ -1 +0,0 @@
--
View
1  samples/invalid/start with less than.lich
@@ -1 +0,0 @@
-<
View
1  samples/invalid/start with period.lich
@@ -1 +0,0 @@
-.
View
1  samples/invalid/start with square brace.lich
@@ -1 +0,0 @@
-[
View
1  samples/valid/array with empty array.lich
@@ -1 +0,0 @@
-3[0[]]
View
1  samples/valid/array with empty data.lich
@@ -1 +0,0 @@
-3[0<>]
View
1  samples/valid/array with empty dictionary.lich
@@ -1 +0,0 @@
-3[0{}]
View
1  samples/valid/empty array.lich
@@ -1 +0,0 @@
-0[]
View
1  samples/valid/empty data.lich
@@ -1 +0,0 @@
-0<>
View
1  samples/valid/empty dictionary.lich
@@ -1 +0,0 @@
-0{}
Please sign in to comment.
Something went wrong with that request. Please try again.