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:
parent
fb4e96919a
commit
64c2b7f0fd
21 changed files with 614 additions and 0 deletions
4
examples/rust-wordcount/Cargo.toml
Normal file
4
examples/rust-wordcount/Cargo.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[package]
|
||||
name = "wordcount"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
29
examples/rust-wordcount/PROTOKOLL.md
Normal file
29
examples/rust-wordcount/PROTOKOLL.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Demo-Protokoll: rust-wordcount
|
||||
|
||||
## Lauf 1
|
||||
|
||||
**Datum:**
|
||||
**Befehl:**
|
||||
```
|
||||
/optimize "Ergänze --lines (Zeilenzählung) und --chars (Zeichenzählung) als CLI-Flags.
|
||||
Ohne Flag: Standardausgabe wie bisher (Wörter).
|
||||
Schreibe Tests für alle drei Modi." \
|
||||
--test-cmd "cargo test"
|
||||
```
|
||||
**Startzeit:**
|
||||
**Endzeit:**
|
||||
**Dauer /optimize (min):**
|
||||
**Runden:**
|
||||
**Endergebnis /optimize:** PASS / PASS WITH CONCERNS / SHIP / NO-SHIP
|
||||
|
||||
**Befehl /version:**
|
||||
```
|
||||
/version
|
||||
```
|
||||
**Startzeit /version:**
|
||||
**Endzeit /version:**
|
||||
**Gewählter Bump:** patch / minor / major
|
||||
**Gesetzter Tag:**
|
||||
**Besonderheiten / Beobachtungen:**
|
||||
|
||||
---
|
||||
50
examples/rust-wordcount/README.md
Normal file
50
examples/rust-wordcount/README.md
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Rust Word Counter
|
||||
|
||||
Liest stdin und gibt die Anzahl der Wörter aus.
|
||||
Zeilen- und Zeichenzählung sowie CLI-Flags fehlen noch.
|
||||
|
||||
## Aktueller Stand
|
||||
|
||||
```
|
||||
src/main.rs count_words() — nur Wortzählung, kein Argument-Parsing
|
||||
Cargo.toml Version 0.1.0
|
||||
```
|
||||
|
||||
## Demo 1: `/optimize` mit Cargo-Test-Integration
|
||||
|
||||
```
|
||||
/optimize "Ergänze --lines (Zeilenzählung) und --chars (Zeichenzählung) als CLI-Flags.
|
||||
Ohne Flag: Standardausgabe wie bisher (Wörter).
|
||||
Schreibe Tests für alle drei Modi." \
|
||||
--test-cmd "cargo test"
|
||||
```
|
||||
|
||||
**Was pi-coder hier zeigt:**
|
||||
- Rust-Toolchain wird automatisch erkannt
|
||||
- `cargo test`-Output geht an den Judge
|
||||
- Mehrere Compile-Test-Fix-Zyklen möglich
|
||||
|
||||
## Demo 2: `/version` nach dem Feature
|
||||
|
||||
**Voraussetzung:** Das Verzeichnis muss ein git-Repo mit mindestens einem Commit sein.
|
||||
Falls noch kein Repo existiert, vorher einmalig:
|
||||
|
||||
```bash
|
||||
git init && git add -A && git commit -m "feat: initial wordcount"
|
||||
git tag v0.1.0
|
||||
```
|
||||
|
||||
```
|
||||
/version
|
||||
```
|
||||
|
||||
Analysiert die Commits seit `v0.1.0`, erkennt `feat:`-Commits → schlägt `minor`-Bump vor
|
||||
und setzt den Git-Tag `v0.2.0`.
|
||||
|
||||
## Manueller Test
|
||||
|
||||
```bash
|
||||
cargo test
|
||||
echo "Hallo Welt" | cargo run
|
||||
echo -e "Zeile 1\nZeile 2" | cargo run -- --lines
|
||||
```
|
||||
36
examples/rust-wordcount/src/main.rs
Normal file
36
examples/rust-wordcount/src/main.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue