aboutsummaryrefslogtreecommitdiff
path: root/docs/pages/14-testing.md
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-11 16:03:20 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-11 16:03:20 +0800
commit810536fb1f068f969af316be0450a1edacfe8e28 (patch)
treeece6a67f196afda364d4443e17687c2076e132c4 /docs/pages/14-testing.md
parent4bf23c20f2d7cdfcc988b654a93abae1cd211ad8 (diff)
docs: migrate renderers from `r_println!` to `RenderResult` return type
Diffstat (limited to 'docs/pages/14-testing.md')
-rw-r--r--docs/pages/14-testing.md9
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/pages/14-testing.md b/docs/pages/14-testing.md
index 789da96..fa196b0 100644
--- a/docs/pages/14-testing.md
+++ b/docs/pages/14-testing.md
@@ -13,16 +13,17 @@ Renderer is the easiest to test — call the function, assert the result:
```rust
@@@pack!(ResultName = String);
-// Returns String instead of ()
#[renderer]
-fn render_name(name: ResultName) -> String {
- r_println!("Hello, {}!", *name);
+fn render_greet(result: ResultName) -> RenderResult {
+ let mut r = RenderResult::new();
+ writeln!(r, "Hello, {}!", *result).ok();
+ r
}
#[test]
fn test_render_name() {
let result = render_name(ResultName::new("Alice".to_string()));
- assert_eq!(result, "Hello, Alice!\n");
+ assert_eq!(result.to_string().as_str(), "Hello, Alice!\n");
}
```