فهرست منبع

字符对比 - 字符串对比移除对(回车、换行符)的对比,但测试报告会显示 回车和换行的内容,以保证测试报告的排版;

zhudongyong 1 سال پیش
والد
کامیت
bd3a9b3fd4

BIN
KdanAutoTest/KdanAuto.xcodeproj/project.xcworkspace/xcuserdata/zhudongyong.xcuserdatad/UserInterfaceState.xcuserstate


+ 32 - 0
KdanAutoTest/KdanAuto.xcodeproj/xcuserdata/zhudongyong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -180,5 +180,37 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "7C3E1DCE-3161-4FA0-A0D3-E3CF0A2BC17A"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KdanAuto/Class/AutoTestCase/StringAutoTest.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "160"
+            endingLineNumber = "160"
+            landmarkName = "autoTest(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "CD09136A-8DA8-4715-8DC1-B1E16639E535"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KdanAuto/Class/AutoTestCase/StringAutoTest.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "174"
+            endingLineNumber = "174"
+            landmarkName = "autoTest(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 9 - 1
KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoBackTest.swift

@@ -190,8 +190,12 @@ class StringAutoBackTest : StringAutoTest {
         return autoreleasepool {
             var checkString = check
             var resultStr = result
-            let maxSize = checkString.length
+            var maxSize = checkString.length
             var successCount = 0;
+            
+            resultStr = resultStr.replacingOccurrences(of: "\n", with: "") as NSString
+            resultStr = resultStr.replacingOccurrences(of: " ", with: "") as NSString
+            
             /**
              (A0 = B0)
              - A-1 & B-1
@@ -227,6 +231,10 @@ class StringAutoBackTest : StringAutoTest {
                     resultStr = resultStr.substring(from:1) as NSString
                     successCount = successCount + 1
                     callback(NSAttributedString(string: subc as String))
+                }else if (["\n", "\r", " "].contains(subc)) {
+                    callback(NSAttributedString(string: subc as String))
+                    maxSize -= 1;
+                    checkString = checkString.substring(from:1) as NSString
                 } else if (cRange.location != NSNotFound &&
                            rRange.location != NSNotFound) {
                     if (min(cRange.location, rRange.location) >= 2) {

+ 14 - 6
KdanAutoTest/KdanAuto/Class/AutoTestCase/StringAutoTest.swift

@@ -270,8 +270,12 @@ class StringAutoTest : AutoTest {
         return autoreleasepool {
             var checkString = check
             var resultStr = result
-            let maxSize = checkString.length
+            var maxSize = checkString.length
             var successCount = 0;
+            
+            resultStr = resultStr.replacingOccurrences(of: "\n", with: "") as NSString
+            resultStr = resultStr.replacingOccurrences(of: " ", with: "") as NSString
+            
             /**
              (A0 = B0)
              - A-1 & B-1
@@ -307,7 +311,11 @@ class StringAutoTest : AutoTest {
                     resultStr = resultStr.substring(from:1) as NSString
                     successCount = successCount + 1
                     callback(NSAttributedString(string: subc as String))
-                } else if (cRange.location != NSNotFound &&
+                }else if (["\n", "\r", " "].contains(subc)) {
+                    callback(NSAttributedString(string: subc as String))
+                    maxSize -= 1;
+                    checkString = checkString.substring(from:1) as NSString
+                }else if (cRange.location != NSNotFound &&
                            rRange.location != NSNotFound) {
                     if (min(cRange.location, rRange.location) >= 2) {
                         let nextc = checkString.substring(with: NSRange(location: 1, length: 1)) as NSString
@@ -317,11 +325,11 @@ class StringAutoTest : AutoTest {
                         
                         if (min(nrRange.location, ncRange.location) < min(cRange.location, rRange.location)) {
                             if (ncRange.location < nrRange.location) {
-                                //‘subc' 字符串有在‘resultStr’中,但'subr'不在’checkString‘中,resultStr 往后推一
+                                //‘subc' 字符串有在‘resultStr’中,但'subr'不在’checkString‘中,resultStr 往后推一
                                 skipString = skipString.appending(subc as String) as NSString
                                 checkString = checkString.substring(from:1) as NSString
                             }else {
-                                //‘subc' 字符串有在‘resultStr’中,但'subr'不在’checkString‘中,resultStr 往后推一
+                                //‘subc' 字符串有在‘resultStr’中,但'subr'不在’checkString‘中,resultStr 往后推一
                                 failString = failString.appending(subr as String) as NSString
                                 resultStr = resultStr.substring(from:1) as NSString
                             }
@@ -423,8 +431,8 @@ class StringAutoTest : AutoTest {
             var documentAttributes:NSDictionary!
             let checkAttString = NSAttributedString.init(rtf: checkData, documentAttributes: &documentAttributes)
             var checkString = NSString(string: checkAttString!.string) as NSString
-            checkString = checkString.replacingOccurrences(of: "\n", with: "") as NSString
-            checkString = checkString.replacingOccurrences(of: " ", with: "") as NSString
+//            checkString = checkString.replacingOccurrences(of: "\n", with: "") as NSString
+//            checkString = checkString.replacingOccurrences(of: " ", with: "") as NSString
             // 常规 rtf 读取失败
             
             //使用框排进行读取