Reviewed By: akotulski Differential Revision: D4666223 fbshipit-source-id: 2c88ce8master
parent
b742df7626
commit
612e501dfc
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <stdlib.h>
|
||||||
|
|
||||||
|
@interface NSData_models_tests : NSObject
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSData_models_tests
|
||||||
|
|
||||||
|
+ (NSData*)randomBytes:(NSUInteger)numOfBytes {
|
||||||
|
uint8_t* buffer = malloc(numOfBytes);
|
||||||
|
NSData* data = [NSData dataWithBytesNoCopy:buffer length:numOfBytes];
|
||||||
|
if (data) {
|
||||||
|
return data;
|
||||||
|
} else {
|
||||||
|
free(buffer);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*)readDataOfLength:(NSUInteger)length {
|
||||||
|
size_t bytesLength = length;
|
||||||
|
void* bytes = malloc(bytesLength);
|
||||||
|
if (bytes == NULL) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return [[NSData alloc] initWithBytesNoCopy:bytes length:5 freeWhenDone:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*)decodedImageData:(size_t)dataLength {
|
||||||
|
void* data = calloc(dataLength, 1);
|
||||||
|
return [[NSData alloc] initWithBytesNoCopy:data length:dataLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*)macForIV:(NSData*)IV {
|
||||||
|
uint8_t* result = malloc(10);
|
||||||
|
return [NSData dataWithBytesNoCopy:result length:10];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in new issue