• 对字符串做正则表达式的比较,只比较字符串,不对字符串的值进行比对


       public boolean compareRegexString(String testName, String wsValue, String expectValue) {
            boolean result = false;
            String resultInfo = LR;
            resultInfo += "WS: " +wsValue+ LR;
            resultInfo += "Expect: " +expectValue+ LR;
            /**
             * 接下来是判断和记录结果过程
             */
            if ((expectValue == null || expectValue.length() == 0) && (wsValue == null || wsValue.length() == 0)) {
                result = true;
                resultInfo = PASS + LR + resultInfo;
            } else {
                Pattern pattern = Pattern.compile(expectValue);
                Matcher matcher = pattern.matcher(wsValue);
                result = matcher.find();
                if (result == true) {
                    resultInfo = PASS + LR + resultInfo;
                    Assert.assertTrue(result);
                } else {
                    resultInfo = FAIL + LR + resultInfo;
                    Assert.assertEquals(wsValue, expectValue);
                }
            }
            setStrResultInfo(resultInfo);
            writeReportResultInfo(result);
    //            writeLog(testName);
            getReturnMap().put(testName, wsValue);
            return result;
        }

    wsValue= {"code":"10000","msg":null,"data":{"untilnow_pv":0.007830058221967192,"DirectUsage":0.007830058222127264,"Charges_pv":0.007812278694385896,"Feedin_pv":0.0}}
    expectValue="untilnow_pv":S+,"DirectUsage":S+,"Charges_pv":S+,"Feedin_pv":S+

      

  • 相关阅读:
    344. 反转字符串
    942. 增减字符串匹配
    CGO内部机制
    CGO函数调用
    CGO类型转换
    CGO基础
    Go net/http代理
    GO-中间件(Middleware )
    Go如何巧妙使用runtime.SetFinalizer
    ARM基础
  • 原文地址:https://www.cnblogs.com/hong0632/p/7866033.html
Copyright © 2020-2023  润新知