mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Add tests to LCS array category
This commit is contained in:
72
AsyncDisplayKitTests/ArrayDiffingTests.m
Normal file
72
AsyncDisplayKitTests/ArrayDiffingTests.m
Normal file
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// ArrayDiffingTests.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Levi McCallum on 1/29/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "NSArray+Diffing.h"
|
||||
|
||||
@interface ArrayDiffingTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation ArrayDiffingTests
|
||||
|
||||
- (void)testDiffing {
|
||||
NSArray<NSArray *> *tests = @[
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave"],
|
||||
@[@"bob", @"alice", @"dave", @"gary"],
|
||||
@[@3],
|
||||
@[],
|
||||
],
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave"],
|
||||
@[@"bob", @"gary", @"alice", @"dave"],
|
||||
@[@1],
|
||||
@[],
|
||||
],
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave"],
|
||||
@[@"bob", @"alice"],
|
||||
@[],
|
||||
@[@2],
|
||||
],
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave"],
|
||||
@[],
|
||||
@[],
|
||||
@[@0, @1, @2],
|
||||
],
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave"],
|
||||
@[@"gary", @"alice", @"dave", @"jack"],
|
||||
@[@0, @3],
|
||||
@[@0],
|
||||
],
|
||||
@[
|
||||
@[@"bob", @"alice", @"dave", @"judy", @"lynda", @"tony"],
|
||||
@[@"gary", @"bob", @"suzy", @"tony"],
|
||||
@[@0, @2],
|
||||
@[@1, @2, @3, @4],
|
||||
],
|
||||
];
|
||||
|
||||
for (NSArray *test in tests) {
|
||||
NSMutableIndexSet *insertions = [NSMutableIndexSet indexSet];
|
||||
NSMutableIndexSet *deletions = [NSMutableIndexSet indexSet];
|
||||
[test[0] asdk_diffWithArray:test[1] insertions:&insertions deletions:&deletions];
|
||||
for (NSNumber *index in (NSArray *)test[2]) {
|
||||
XCTAssert([insertions containsIndex:[index integerValue]]);
|
||||
}
|
||||
for (NSNumber *index in (NSArray *)test[3]) {
|
||||
XCTAssert([deletions containsIndex:[index integerValue]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user