我正在创建这个字符串
'Your maximum heart rate is ' . $int . ' Your body mass index is ' . $float . ' Your body fat percentage is ' . $float '%.'
并返回
我的断言是
$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is %f%.';
$this->assertStringMatchesFormat($stringFormat, $actualResultm, 'message');
当测试运行时,我收到此错误
FatControllerTest::testBodyInfo
message
Failed asserting that format description matches text.
--- Expected
+++ Actual
@@ @@
-Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is %f%.
+Your maximum heart rate is 193. Your body mass index is 43.181818181818. Your body fat percentage is 6.32302%.
现在我想它一定与我告诉它期望一个无符号的 int 和两个浮点数并且它返回一个长字符串有关,但如果是这种情况,我如何测试像我列出的字符串一样,它将有 3 个区域因大小写而异? 如果不是这样,那我做错了什么?
我想你有双倍空格。
$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is %f%.';
^ extra space