feat: Demo-Examples (Python/Rust/Go/C) mit Protokoll-Templates und Restore-Skript

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-05-29 19:06:36 +02:00
commit 64c2b7f0fd
21 changed files with 614 additions and 0 deletions

View file

@ -0,0 +1,36 @@
use std::io::{self, Read};
fn count_words(text: &str) -> usize {
text.split_whitespace().count()
}
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!("{} words", count_words(&input));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_empty_input() {
assert_eq!(count_words(""), 0);
}
#[test]
fn test_single_word() {
assert_eq!(count_words("hallo"), 1);
}
#[test]
fn test_multiple_words() {
assert_eq!(count_words("eins zwei drei"), 3);
}
#[test]
fn test_extra_whitespace() {
assert_eq!(count_words(" a b "), 2);
}
}