diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
index c6845f5..3cf42b9 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
@@ -47,7 +47,15 @@ public function testRenderBasic($build, $expected, callable $setup_code = NULL)
       $setup_code();
     }
 
-    $this->assertSame($expected, (string) $this->renderer->renderRoot($build));
+    if (isset($build['#markup'])) {
+      $this->assertFalse(SafeMarkup::isSafe($build['#markup']), 'The #markup value is not marked safe before rendering.');
+    }
+    $render_output = $this->renderer->renderRoot($build);
+    $this->assertSame($expected, (string) $render_output);
+    if ($render_output !== '') {
+      $this->assertTrue(SafeMarkup::isSafe($render_output), 'Output of render is marked safe.');
+      $this->assertTrue(SafeMarkup::isSafe($build['#markup']), 'The #markup value is marked safe after rendering.');
+    }
   }
 
   /**
