Permalink
Browse files

Added a bunch of old BfoxRef test cases - many of them are failing

  • Loading branch information...
1 parent de3dee9 commit 1d6ab4f4bf63ea85e9325ed9f609009265434aaf @rvenable committed Feb 10, 2011
Showing with 91 additions and 3 deletions.
  1. +22 −0 BfoxRef.xcodeproj/project.pbxproj
  2. +69 −3 BfoxRefTests/BfoxRefTests.m
@@ -47,6 +47,17 @@
79479A34130362DA0010388F /* create-synonym-lookup.php in Resources */ = {isa = PBXBuildFile; fileRef = 79479A1F130362DA0010388F /* create-synonym-lookup.php */; };
79479A35130362DA0010388F /* meta.txt in Resources */ = {isa = PBXBuildFile; fileRef = 79479A20130362DA0010388F /* meta.txt */; };
79479A36130362DA0010388F /* verse.php in Resources */ = {isa = PBXBuildFile; fileRef = 79479A21130362DA0010388F /* verse.php */; };
+ 79479A40130428130010388F /* BfoxRef.mm in Sources */ = {isa = PBXBuildFile; fileRef = 794799FE130362DA0010388F /* BfoxRef.mm */; };
+ 79479A42130428480010388F /* bfox_range_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79479A08130362DA0010388F /* bfox_range_list.cpp */; };
+ 79479A43130428480010388F /* bfox_verse_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79479A0A130362DA0010388F /* bfox_verse_list.cpp */; };
+ 79479A44130428480010388F /* NSString+BfoxRef.m in Sources */ = {isa = PBXBuildFile; fileRef = 79479A15130362DA0010388F /* NSString+BfoxRef.m */; };
+ 79479A45130428480010388F /* BfoxRefParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = 79479A00130362DA0010388F /* BfoxRefParser.mm */; };
+ 79479A46130428480010388F /* BfoxRefParseResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 79479A02130362DA0010388F /* BfoxRefParseResult.m */; };
+ 79479A47130428480010388F /* BfoxVerseList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 79479A04130362DA0010388F /* BfoxVerseList.mm */; };
+ 79479A48130428570010388F /* BfoxBookNamesDefault.strings in Resources */ = {isa = PBXBuildFile; fileRef = 79479A0C130362DA0010388F /* BfoxBookNamesDefault.strings */; };
+ 79479A49130428570010388F /* BfoxBookNamesShort.strings in Resources */ = {isa = PBXBuildFile; fileRef = 79479A0E130362DA0010388F /* BfoxBookNamesShort.strings */; };
+ 79479A4A130428570010388F /* BfoxBookRegexes.strings in Resources */ = {isa = PBXBuildFile; fileRef = 79479A10130362DA0010388F /* BfoxBookRegexes.strings */; };
+ 79479A4B130428570010388F /* BfoxBookSynonymLookup.strings in Resources */ = {isa = PBXBuildFile; fileRef = 79479A12130362DA0010388F /* BfoxBookSynonymLookup.strings */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -381,6 +392,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 79479A48130428570010388F /* BfoxBookNamesDefault.strings in Resources */,
+ 79479A49130428570010388F /* BfoxBookNamesShort.strings in Resources */,
+ 79479A4A130428570010388F /* BfoxBookRegexes.strings in Resources */,
+ 79479A4B130428570010388F /* BfoxBookSynonymLookup.strings in Resources */,
794799B8130361600010388F /* InfoPlist.strings in Resources */,
794799BB130361600010388F /* BfoxRefTests.h in Resources */,
);
@@ -428,7 +443,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 79479A42130428480010388F /* bfox_range_list.cpp in Sources */,
+ 79479A43130428480010388F /* bfox_verse_list.cpp in Sources */,
+ 79479A44130428480010388F /* NSString+BfoxRef.m in Sources */,
+ 79479A45130428480010388F /* BfoxRefParser.mm in Sources */,
+ 79479A46130428480010388F /* BfoxRefParseResult.m in Sources */,
+ 79479A47130428480010388F /* BfoxVerseList.mm in Sources */,
794799BD130361600010388F /* BfoxRefTests.m in Sources */,
+ 79479A40130428130010388F /* BfoxRef.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -7,10 +7,12 @@
//
#import "BfoxRefTests.h"
-
+#import "BfoxRef.h"
@implementation BfoxRefTests
+#define BfoxRefStringTest(refString, expected, description, ...) STAssertEqualObjects([[BfoxRef refWithString:refString] string], expected, description, ##__VA_ARGS__)
+
- (void)setUp
{
[super setUp];
@@ -25,9 +27,73 @@ - (void)tearDown
[super tearDown];
}
-- (void)testExample
+- (void)testRefStringParsing
{
- STFail(@"Unit tests are not implemented yet in BfoxRefTests");
+ // Test the typical references
+ BfoxRefStringTest(@"1 sam", @"1 Samuel", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1", @"1 Samuel 1", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1-2", @"1 Samuel 1-2", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1:1", @"1 Samuel 1:1", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1:1-5", @"1 Samuel 1:1-5", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1:1-2:5", @"1 Samuel 1-2:5", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1:2-2:5", @"1 Samuel 1:2-2:5", @"Simple Test Case");
+ BfoxRefStringTest(@"1sam 1-2:5", @"1 Samuel 1-2:5", @"Simple Test Case");
+
+ // Test periods
+ BfoxRefStringTest(@"1sam. 1", @"1 Samuel 1", @"Parsing periods after book name");
+
+ // This test was failing
+ BfoxRefStringTest(@"Judges 2:6-3:6", @"Judges 2:6-3:6", @"Specific test that used to fail");
+
+ // Test ignore words
+ BfoxRefStringTest(@"Book of Judges 2", @"Judges 2", @"Test ignore words");
+ BfoxRefStringTest(@"First Book of Judges 2", @"error", @"This one should not work, but I dont remember why not..."); // This one should not work!
+ BfoxRefStringTest(@"First Book of Samuel 2", @"1 Samuel 2", @"Test ignore words");
+
+ // Test that we can match synonyms with multiple words
+ BfoxRefStringTest(@"Song of Solomon 2", @"Song of Solomon 2", @"Test multiple word synonyms");
+
+ // This should be Gen 1:1, 1:3 - 2:3
+ BfoxRefStringTest(@"gen 1:1,3-2:3", @"Genesis 1:1,3-2:3", @"Complex, single book case");
+
+ BfoxRefStringTest(@"gen 1-100", @"Genesis", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 2-100", @"Genesis 2-50", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 49:1-100", @"Genesis 49", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 49:2-100", @"Genesis 49:2-33", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 50:1-100", @"Genesis 50", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 50:2-100", @"Genesis 50:2-26", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 50:1,2-100", @"Genesis 50", @"Test end points that are greater than last chapter/verse");
+ BfoxRefStringTest(@"gen 50:1,3-100", @"Genesis 50:1,3-26", @"Test end points that are greater than last chapter/verse");
+
+ // Test min/max in Romans 14
+ BfoxRefStringTest(@"rom 14:2-100", @"Romans 14:2-26", @"Test min/max in Romans 14");
+ BfoxRefStringTest(@"rom 14:1-22", @"Romans 14:1-22", @"Test min/max in Romans 14");
+ BfoxRefStringTest(@"rom 14:1-23", @"Romans 14", @"Test min/max in Romans 14");
+ BfoxRefStringTest(@"rom 14:2-23", @"Romans 14:2-26", @"Test min/max in Romans 14");
+
+ // Test having consecutive books
+ BfoxRefStringTest(@"Gen 2-100, Exodus", @"Genesis 2-50; Exodus", @"Test consecutive books");
+ BfoxRefStringTest(@"Gen 2-100, Exodus, Lev", @"Genesis 2-50; Exodus; Leviticus", @"Test consecutive books");
+
+ // Test long strings with lots of garbage
+ BfoxRefStringTest(@"hello dude genesis 1,;,2 gen 5 1 sam 4, song ;of song 3", @"Genesis 1-2; 5; 1 Samuel 4; Song of Solomon", @"Test long strings with lots of garbage"); // TODO3: words like song get detected as the entire book Song of Solomon
+ BfoxRefStringTest(@"<xml>\
+ <p>I like Gen 1.</p>\
+ <p>What do you think? john. 21 Do you prefer<d><d> ex 2 or 1sam 3 - 4 or 1 th 4? gen 3:4-8:2 gen 3ddd:2 fff- 1 1 3 </p>\
+ <p>exodus lala yoyo 4:5</p>\
+ </xml>\
+ ", @"Genesis 1; 3-8:2; Exodus; 1 Samuel 3-4; John 21; 1 Thessalonians 4", @"Test long strings with lots of garbage"); // TODO3: "ex" is not detected because it is only 2 letters
+
+ // Test non-existent chapter
+ BfoxRefStringTest(@"2jhn 2", @"Invalid", @"non-existent chapter");
+ BfoxRefStringTest(@"hag 3", @"Invalid", @"non-existent chapter");
+ BfoxRefStringTest(@"hag 2-3", @"Haggai 2", @"ends with non-existent chapter");
+ BfoxRefStringTest(@"hag 1-3", @"Haggai", @"ends with non-existent chapter");
+ BfoxRefStringTest(@"hag 5-7", @"Invalid", @"non-existent chapters");
+ BfoxRefStringTest(@"hag 1:100-2:4", @"Haggai 2:1-4", @"begins with non-existent verse");
+
+ // This test fails unless parsing in reverse
+ BfoxRefStringTest(@"Genesis 3; 1 Samuel 5", @"Genesis 3; 1 Samuel 5", @"Only works in reverse");
}
@end

0 comments on commit 1d6ab4f

Please sign in to comment.