Archived
1

Removed Prefix/Suffix Placeholder (not needed)

Added Operator Constants
Removed NSMutableString from NSMutableExpression (not needed)
Implemented -description
Added Tests for: -description, -copy, -mutableCopy
Some Logical Corrections.
This commit is contained in:
Kim Wittenburg
2014-04-20 14:34:42 +02:00
parent 0c16b92aea
commit 8b5a69b885
4 changed files with 110 additions and 70 deletions

View File

@@ -154,7 +154,62 @@
XCTAssertEqualObjects(expression2, expression3);
}
// TODO: Test prefix- and suffix operators via -description method
- (void)testDescription {
// Test Simple Expressions
MPExpression *testExpression = [[MPExpression alloc] initWithString:@"1234"];
XCTAssertEqualObjects([testExpression description], @"1234");
testExpression = [[MPExpression alloc] initWithFunction:[[MPFunction alloc] init]];
XCTAssertEqualObjects([testExpression description], @"[]");
// Test function after literal without explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[@"123", [[MPFunction alloc] init]]];
XCTAssertEqualObjects([testExpression description], @"123*[]");
// Test function after literal with explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[@"123+", [[MPFunction alloc] init]]];
XCTAssertEqualObjects([testExpression description], @"123+[]");
// Test literal after function without explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[[[MPFunction alloc] init], @"123"]];
XCTAssertEqualObjects([testExpression description], @"[]*123");
// Test literal after function with explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[[[MPFunction alloc] init], @"-123"]];
XCTAssertEqualObjects([testExpression description], @"[]-123");
// Test function after function without explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[[[MPFunction alloc] init], [[MPFunction alloc] init]]];
XCTAssertEqualObjects([testExpression description], @"[]*[]");
// Test function after function with explicit operator
testExpression = [[MPExpression alloc] initWithSymbols:@[[[MPFunction alloc] init], @"-", [[MPFunction alloc] init]]];
XCTAssertEqualObjects([testExpression description], @"[]-[]");
// Test whitespaces in literal
testExpression = [[MPExpression alloc] initWithSymbols:@[@" 123 + ", [[MPFunction alloc] init]]];
XCTAssertEqualObjects([testExpression description], @"123 +[]");
}
- (void)testCopying {
MPExpression *baseExpression = [[MPExpression alloc] initWithFunction:[[MPFunction alloc] init]];
MPExpression *copy = [baseExpression copy];
XCTAssertNotEqual(copy, baseExpression);
XCTAssertNotEqual([baseExpression symbolAtIndex:0], [copy symbolAtIndex:0]);
}
- (void)testMutableCopying {
MPExpression *baseExpression = [[MPExpression alloc] initWithString:@"123"];
MPMutableExpression *expression1 = [baseExpression mutableCopy];
[expression1 appendFunction:[[MPFunction alloc] init]];
MPExpression *expression2 = [[MPExpression alloc] initWithSymbols:@[@"123", [[MPFunction alloc] init]]];
XCTAssertEqualObjects(expression1, expression2);
XCTAssertNotEqualObjects(baseExpression, expression1);
}
// TODO: Test evaluating expressions
@end