Swiftgram/AsyncDisplayKitTests/ArrayDiffingTests.m
Levi McCallum 6a2903f2ec Revert "Update LCS diffing to support insertions before deletions"
This reverts commit 8d90f1bccda0b7d99639085e0bfa3488c3c01dbe.
2016-02-10 11:44:10 -08:00

78 lines
1.7 KiB
Objective-C

//
// 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],
],
@[
@[@"bob", @"alice", @"dave", @"judy"],
@[@"judy", @"dave", @"alice", @"bob"],
@[@1, @2, @3],
@[@0, @1, @2],
],
];
for (NSArray *test in tests) {
NSIndexSet *insertions, *deletions;
[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