MCPcopy Create free account
hub / github.com/AI45Lab/Code / string

Method string

core/tests/test_persisted_schema_roundtrip.rs:102–124  ·  view source on GitHub ↗

A string drawn from a pool of round-trip hazards: empty, unicode, embedded quotes/newlines, and JSON-looking text (the last is the trap for the untagged `ToolResultContentField` — a string that looks* like an array must still come back as `Text`, not `Blocks`).

(&mut self)

Source from the content-addressed store, hash-verified

100 /// trap for the untagged `ToolResultContentField` — a string that
101 /// *looks* like an array must still come back as `Text`, not `Blocks`).
102 fn string(&mut self) -> String {
103 const POOL: &[&str] = &[
104 "",
105 "ok",
106 "hello world",
107 "with \"double\" quotes",
108 "line\nbreak\tand tab",
109 "unicode ü ñ 日本語 🚀",
110 "{\"looks\":\"like json\"}",
111 "[1, 2, 3]",
112 "null",
113 "12345",
114 "trailing space ",
115 "ümlaut-prefixed",
116 ];
117 let base = POOL[self.usize_below(POOL.len() as u64)].to_string();
118 // Occasionally suffix with the seed so distinct generations differ.
119 if self.boolean() {
120 format!("{base}#{}", self.below(1000))
121 } else {
122 base
123 }
124 }
125 fn opt_string(&mut self) -> Option<String> {
126 if self.boolean() {
127 Some(self.string())

Callers 15

opt_stringMethod · 0.80
string_vecMethod · 0.80
json_valueMethod · 0.80
gen_image_sourceFunction · 0.80
gen_tool_result_contentFunction · 0.80
gen_tool_result_fieldFunction · 0.80
gen_content_blockFunction · 0.80
gen_verification_checkFunction · 0.80
gen_verification_reportFunction · 0.80
gen_trace_eventFunction · 0.80
gen_subagent_taskFunction · 0.80
gen_agent_eventFunction · 0.80

Calls 3

usize_belowMethod · 0.80
booleanMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected