znt/module/metric/test/model/replacecrlf.php

40 lines
2.3 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 metricModel::replaceCRLF();
timeout=0
cid=17155
- 测试步骤1使用R替换包含多种换行符的字符串 @hello R Zentao ZentaoPHP R R Rhello world.
- 测试步骤2使用~替换包含多种换行符的字符串 @hello ~ Zentao ZentaoPHP ~ ~ ~hello world.
- 测试步骤3测试不包含真实换行符的字符串 @hello \n\r
- 测试步骤4测试空字符串输入 @0
- 测试步骤5测试只包含换行符的字符串 @0
- 测试步骤6测试使用默认分号替换符 @test;line;break;here
- 测试步骤7测试包含空格和换行符的边界情况 @0
- 测试步骤8测试不包含换行符的普通文本 @only text without newlines
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/calc.unittest.class.php';
$metric = new metricTest();
$str1 = "hello \n\r Zentao ZentaoPHP \n \r \r\nhello world.";
$str2 = 'hello \n\r';
$str3 = '';
$str4 = "\n\r\r\n";
$str5 = " \n \r ";
$str7 = "only text without newlines";
$str6 = "test\nline\rbreak\r\nhere";
r($metric->replaceCRLFTest($str1, 'R')) && p() && e('hello R Zentao ZentaoPHP R R Rhello world.'); // 测试步骤1使用R替换包含多种换行符的字符串
r($metric->replaceCRLFTest($str1, '~')) && p() && e('hello ~ Zentao ZentaoPHP ~ ~ ~hello world.'); // 测试步骤2使用~替换包含多种换行符的字符串
r($metric->replaceCRLFTest($str2, '~')) && p() && e('hello \n\r'); // 测试步骤3测试不包含真实换行符的字符串
r($metric->replaceCRLFTest($str3, 'X')) && p() && e('0'); // 测试步骤4测试空字符串输入
r($metric->replaceCRLFTest($str4, '*')) && p() && e('0'); // 测试步骤5测试只包含换行符的字符串
r($metric->replaceCRLFTest($str6)) && p() && e('test;line;break;here'); // 测试步骤6测试使用默认分号替换符
r($metric->replaceCRLFTest($str5, '|')) && p() && e('0'); // 测试步骤7测试包含空格和换行符的边界情况
r($metric->replaceCRLFTest($str7, '@')) && p() && e('only text without newlines'); // 测试步骤8测试不包含换行符的普通文本