Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests #89

Merged
merged 14 commits into from
Nov 30, 2015
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: objective-c
notifications:
email: false
osx_image: xcode7.1
script: xctool -workspace "$TRAVIS_XCODE_WORKSPACE" -scheme "$TRAVIS_XCODE_SCHEME" test CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=
xcode_workspace: MMMarkdown.xcworkspace
xcode_scheme:
- MMMarkdown (iOS)
- MMMarkdown (OS X)

2 changes: 1 addition & 1 deletion Source/MMParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ - (NSArray *)_parseCodeLinesWithScanner:(MMScanner *)scanner
- (MMElement *)_parseCodeBlockWithScanner:(MMScanner *)scanner
{
NSUInteger indentation = [scanner skipIndentationUpTo:4];
if (indentation != 4)
if (indentation != 4 || scanner.atEndOfLine)
return nil;

MMElement *element = [MMElement new];
Expand Down
5 changes: 5 additions & 0 deletions Tests/MMBlockTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ - (void)testNestedBlockquote

#pragma mark - Code Block Tests

- (void)testCodeBlockWithNoCode
{
MMAssertMarkdownEqualsHTML(@" \nfoo\n", @"<p>foo</p>");
}

- (void)testCodeBlocks_blankLinesInBetween
{
NSString *markdown = @" Some Code\n"
Expand Down
4 changes: 1 addition & 3 deletions Tests/MMHTMLTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ - (void)testBlockHTMLWithUnclosedTag

- (void)testBlockHTMLCommentWithSpans
{
// An SGML comment starts and ends with "--", so you can't have an odd number of dashes before
// the closing angle bracket.
MMAssertMarkdownEqualsHTML(@"<!------> *hello*-->", @"<!------> *hello*-->");
MMAssertMarkdownEqualsString(@"<!------> *hello*-->", @"<!------><p><em>hello</em>--></p>\n");
}


Expand Down
10 changes: 10 additions & 0 deletions Tests/MMMarkdownTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,25 @@ - (void)testInlineHTMLAdvanced
[self runTestWithName:@"Inline HTML (Advanced)"];
}

#if 0
/*
* This isn't valid XML, so we can't compare it.
*/
- (void)testInlineHTMLSimple
{
[self runTestWithName:@"Inline HTML (Simple)"];
}
#endif

#if 0
/*
* XML comments can't contain `--`, so there's not a good way to do this comparison.
*/
- (void)testInlineHTMLComments
{
[self runTestWithName:@"Inline HTML comments"];
}
#endif

- (void)testLinksInlineStyle
{
Expand Down
10 changes: 10 additions & 0 deletions Tests/MMPHPMarkdownTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,30 @@ - (void)testImagesUntitled
[self runTestWithName:@"Images (Untitled)"];
}

#if 0
/*
* This isn't valid XML, so we can't compare it.
*/
- (void)testInlineHTMLSimple
{
[self runTestWithName:@"Inline HTML (Simple)"];
}
#endif

- (void)testInlineHTMLSpan
{
[self runTestWithName:@"Inline HTML (Span)"];
}

#if 0
/*
* XML comments can't contain `--`, so there's not a good way to do this comparison.
*/
- (void)testInlineHTMLComments
{
[self runTestWithName:@"Inline HTML comments"];
}
#endif

#if 0
/*
Expand Down
12 changes: 8 additions & 4 deletions Tests/MMTestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@
output = [NSString stringWithFormat:@"<test>%@</test>", output]; \
html2 = [NSString stringWithFormat:@"<test>%@</test>", html2]; \
\
NSXMLDocument *actual = [[NSXMLDocument alloc] initWithXMLString:output options:0 error:nil]; \
NSXMLDocument *expected = [[NSXMLDocument alloc] initWithXMLString:html2 options:0 error:nil]; \
XCTAssertNotNil(actual);\
NSError *actualError; \
NSError *expectedError; \
NSXMLDocument *actual = [[NSXMLDocument alloc] initWithXMLString:output options:0 error:&actualError]; \
NSXMLDocument *expected = [[NSXMLDocument alloc] initWithXMLString:html2 options:0 error:&expectedError]; \
XCTAssertNotNil(actual, "%@", actualError); \
XCTAssertNotNil(expected, "%@", expectedError); \
XCTAssertEqualObjects(actual, expected); \
} while(0)

Expand All @@ -57,7 +60,8 @@
NSError *error; \
NSString *actual = [MMMarkdown HTMLStringWithMarkdown:a1value error:&error]; \
NSString *expected = a2value; \
XCTAssertNotNil(actual);\
XCTAssertNotNil(actual); \
XCTAssertNotNil(expected); \
XCTAssertEqualObjects(actual, expected); \
} while(0)

Expand Down