<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>UnitTests-Info.plist</filename>
    </added>
    <added>
      <filename>tests/NeoTextViewTest.h</filename>
    </added>
    <added>
      <filename>tests/NeoTextViewTest.m</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -9,6 +9,8 @@
 /* Begin PBXBuildFile section */
 		1DDD582C0DA1D0D100B32029 /* NeoDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58280DA1D0D100B32029 /* NeoDocument.xib */; };
 		1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; };
+		77B489B40ECA62EF00534EB4 /* NeoTextViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B489B30ECA62EF00534EB4 /* NeoTextViewTest.m */; };
+		77B489DD0ECA65A200534EB4 /* NeoTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891A80EC47EBF002CA36A /* NeoTextView.m */; };
 		77D1762F0EC66CCC00E788AD /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77D1762E0EC66CCC00E788AD /* ApplicationServices.framework */; };
 		77F891690EC473A2002CA36A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891650EC473A2002CA36A /* main.m */; };
 		77F8916A0EC473A2002CA36A /* NeoDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891670EC473A2002CA36A /* NeoDocument.m */; };
@@ -27,6 +29,10 @@
 		2A37F4BAFDCFA73011CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = English; path = English.lproj/Credits.rtf; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2A37F4C4FDCFA73011CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
 		2A37F4C5FDCFA73011CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
+		77B489A20ECA618A00534EB4 /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = UnitTests.octest; path = build/Debug/UnitTests.octest; sourceTree = &quot;&lt;group&gt;&quot;; };
+		77B489A30ECA618A00534EB4 /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = &quot;UnitTests-Info.plist&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
+		77B489B20ECA62EF00534EB4 /* NeoTextViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoTextViewTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+		77B489B30ECA62EF00534EB4 /* NeoTextViewTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoTextViewTest.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77D1762E0EC66CCC00E788AD /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
 		77F891650EC473A2002CA36A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77F891660EC473A2002CA36A /* NeoDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoDocument.h; sourceTree = &quot;&lt;group&gt;&quot;; };
@@ -39,6 +45,13 @@
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
+		77B4899F0ECA618A00534EB4 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		8D15AC330486D014006FF6A4 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -74,6 +87,7 @@
 			isa = PBXGroup;
 			children = (
 				8D15AC370486D014006FF6A4 /* Neuro.app */,
+				77B489A20ECA618A00534EB4 /* UnitTests.octest */,
 			);
 			name = Products;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -82,9 +96,11 @@
 			isa = PBXGroup;
 			children = (
 				77F891640EC473A2002CA36A /* src */,
+				77B489B10ECA62BD00534EB4 /* tests */,
 				2A37F4B8FDCFA73011CA2CEA /* Resources */,
 				2A37F4C3FDCFA73011CA2CEA /* Frameworks */,
 				19C28FB0FE9D524F11CA2CBB /* Products */,
+				77B489A30ECA618A00534EB4 /* UnitTests-Info.plist */,
 			);
 			name = Neuro;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -110,6 +126,15 @@
 			name = Frameworks;
 			sourceTree = &quot;&lt;group&gt;&quot;;
 		};
+		77B489B10ECA62BD00534EB4 /* tests */ = {
+			isa = PBXGroup;
+			children = (
+				77B489B20ECA62EF00534EB4 /* NeoTextViewTest.h */,
+				77B489B30ECA62EF00534EB4 /* NeoTextViewTest.m */,
+			);
+			path = tests;
+			sourceTree = &quot;&lt;group&gt;&quot;;
+		};
 		77F891640EC473A2002CA36A /* src */ = {
 			isa = PBXGroup;
 			children = (
@@ -126,6 +151,24 @@
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
+		77B489A10ECA618A00534EB4 /* UnitTests */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 77B489A60ECA618B00534EB4 /* Build configuration list for PBXNativeTarget &quot;UnitTests&quot; */;
+			buildPhases = (
+				77B4899D0ECA618A00534EB4 /* Resources */,
+				77B4899E0ECA618A00534EB4 /* Sources */,
+				77B4899F0ECA618A00534EB4 /* Frameworks */,
+				77B489A00ECA618A00534EB4 /* ShellScript */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = UnitTests;
+			productName = UnitTests;
+			productReference = 77B489A20ECA618A00534EB4 /* UnitTests.octest */;
+			productType = &quot;com.apple.product-type.bundle&quot;;
+		};
 		8D15AC270486D014006FF6A4 /* Neuro */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = C05733C708A9546B00998B17 /* Build configuration list for PBXNativeTarget &quot;Neuro&quot; */;
@@ -157,11 +200,19 @@
 			projectRoot = &quot;&quot;;
 			targets = (
 				8D15AC270486D014006FF6A4 /* Neuro */,
+				77B489A10ECA618A00534EB4 /* UnitTests */,
 			);
 		};
 /* End PBXProject section */
 
 /* Begin PBXResourcesBuildPhase section */
+		77B4899D0ECA618A00534EB4 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		8D15AC2B0486D014006FF6A4 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -175,7 +226,32 @@
 		};
 /* End PBXResourcesBuildPhase section */
 
+/* Begin PBXShellScriptBuildPhase section */
+		77B489A00ECA618A00534EB4 /* ShellScript */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = &quot;# Run the unit tests in this test bundle.\n\&quot;${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\&quot;\n&quot;;
+		};
+/* End PBXShellScriptBuildPhase section */
+
 /* Begin PBXSourcesBuildPhase section */
+		77B4899E0ECA618A00534EB4 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				77B489B40ECA62EF00534EB4 /* NeoTextViewTest.m in Sources */,
+				77B489DD0ECA65A200534EB4 /* NeoTextView.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		8D15AC300486D014006FF6A4 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -224,6 +300,60 @@
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
+		77B489A40ECA618B00534EB4 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = &quot;$(DEVELOPER_LIBRARY_DIR)/Frameworks&quot;;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = &quot;$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h&quot;;
+				INFOPLIST_FILE = &quot;UnitTests-Info.plist&quot;;
+				INSTALL_PATH = &quot;$(USER_LIBRARY_DIR)/Bundles&quot;;
+				OTHER_LDFLAGS = (
+					&quot;-framework&quot;,
+					Cocoa,
+					&quot;-framework&quot;,
+					SenTestingKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = UnitTests;
+				WRAPPER_EXTENSION = octest;
+			};
+			name = Debug;
+		};
+		77B489A50ECA618B00534EB4 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = &quot;dwarf-with-dsym&quot;;
+				FRAMEWORK_SEARCH_PATHS = &quot;$(DEVELOPER_LIBRARY_DIR)/Frameworks&quot;;
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = &quot;$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h&quot;;
+				INFOPLIST_FILE = &quot;UnitTests-Info.plist&quot;;
+				INSTALL_PATH = &quot;$(USER_LIBRARY_DIR)/Bundles&quot;;
+				OTHER_LDFLAGS = (
+					&quot;-framework&quot;,
+					Cocoa,
+					&quot;-framework&quot;,
+					SenTestingKit,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = UnitTests;
+				WRAPPER_EXTENSION = octest;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
 		C05733C808A9546B00998B17 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -284,6 +414,15 @@
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
+		77B489A60ECA618B00534EB4 /* Build configuration list for PBXNativeTarget &quot;UnitTests&quot; */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				77B489A40ECA618B00534EB4 /* Debug */,
+				77B489A50ECA618B00534EB4 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		C05733C708A9546B00998B17 /* Build configuration list for PBXNativeTarget &quot;Neuro&quot; */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (</diff>
      <filename>Neuro.xcodeproj/project.pbxproj</filename>
    </modified>
    <modified>
      <diff>@@ -18,3 +18,38 @@
 
 }
 @end
+
+
+
+// ----------------------------------------------------------------
+// Utilities
+// ----------------------------------------------------------------
+/**
+ * Returns a Boolean value that indicates whether
+ * a specified position is in a given range.
+ */
+NS_INLINE Boolean StkLocationInCFRange(CFIndex loc, CFRange range) {
+  const CFIndex t = loc - range.location;
+  return t &gt;= 0 &amp;&amp; t &lt; range.length;
+}
+
+/**
+ * Returns an NSRange from a CFRange
+ */
+NS_INLINE NSRange StkNSRangeFromCFRange(CFRange range) {
+  return NSMakeRange(range.location, range.length);
+}
+
+
+// ----------------------------------------------------------------
+// Core Text Utilities
+// ----------------------------------------------------------------
+/**
+ * Returns the lowest index of the matching line in the frame,
+ * or -1 if no line in the frame matched.
+ */
+extern CFIndex MTFrameGetFirstLine(
+  CTFrameRef frame,
+  CFIndex charIndex,
+  CTLineRef *found,
+  CFRange *characterRange);</diff>
      <filename>src/NeoTextView.h</filename>
    </modified>
    <modified>
      <diff>@@ -4,21 +4,6 @@
 // ----------------------------------------------------------------
 // Utilities
 // ----------------------------------------------------------------
-/**
- * Returns a Boolean value that indicates whether
- * a specified position is in a given range.
- */
-NS_INLINE Boolean StkLocationInCFRange(CFIndex loc, CFRange range) {
-  const CFIndex t = loc - range.location;
-  return t &gt;= 0 &amp;&amp; t &lt; range.length;
-}
-
-/**
- * Returns an NSRange from a CFRange
- */
-NS_INLINE NSRange StkNSRangeFromCFRange(CFRange range) {
-  return NSMakeRange(range.location, range.length);
-}
 
 static void StkLogFormat(const char *funcname, const char *filename, int lineno, NSString *fmt, ...) {
   va_list ap;
@@ -49,12 +34,11 @@ NS_INLINE CGRect MTFrameGetBoundingBox(CTFrameRef frame) {
   return path != NULL ? CGPathGetBoundingBox(path) : CGRectZero;
 }
 
-/**
- * Returns the lowest index of the matching line in the frame,
- * or -1 if no line in the frame matched.
- */
-static CFIndex MTFrameGetFirstLine(CTFrameRef frame, CFIndex charIndex, CTLineRef *found, CFRange *characterRange)
-{
+
+// ----------------------------------------------------------------
+// Core Text Utilities
+// ----------------------------------------------------------------
+CFIndex MTFrameGetFirstLine(CTFrameRef frame, CFIndex charIndex, CTLineRef *found, CFRange *characterRange) {
   const CFArrayRef lines = CTFrameGetLines(frame);
   CFIndex l = 0, u = CFArrayGetCount(lines);
   while (l &lt; u) {
@@ -64,7 +48,7 @@ static CFIndex MTFrameGetFirstLine(CTFrameRef frame, CFIndex charIndex, CTLineRe
     const CFIndex t = charIndex - range.location;
 
     if (t &lt; 0) u = m;
-    else if (t &gt;= range.length) l = m;
+    else if (t &gt;= range.length) l = m + 1;
     else {
       if (found != NULL) *found = line;
       if (characterRange != NULL) *characterRange = range;
@@ -75,10 +59,6 @@ static CFIndex MTFrameGetFirstLine(CTFrameRef frame, CFIndex charIndex, CTLineRe
   return -1;
 }
 
-
-// ----------------------------------------------------------------
-// Core Text Utilities
-// ----------------------------------------------------------------
 /**
  * Returns a line origin for a frame.
  */</diff>
      <filename>src/NeoTextView.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2729fd9357bb7727e56f4c8bccfa55d40c2aa07b</id>
    </parent>
  </parents>
  <author>
    <name>Takanori Ishikawa</name>
    <email>takanori.ishikawa@gmail.com</email>
  </author>
  <url>http://github.com/ishikawa/neuro/commit/fb2819217e52a0ae8861e19616eaa84a0fa9d987</url>
  <id>fb2819217e52a0ae8861e19616eaa84a0fa9d987</id>
  <committed-date>2008-11-11T18:15:30-08:00</committed-date>
  <authored-date>2008-11-11T18:15:30-08:00</authored-date>
  <message>Added NeoTextViewTest</message>
  <tree>c4e7eaa29e8b9f220e9deabba15f921f3e27d5d0</tree>
  <committer>
    <name>Takanori Ishikawa</name>
    <email>takanori.ishikawa@gmail.com</email>
  </committer>
</commit>
