Skip to content

Commit

Permalink
fix: missing source for some quotes, add tests to prevent this in future
Browse files Browse the repository at this point in the history
fixes #6
  • Loading branch information
dmyTRUEk committed Mar 29, 2024
1 parent fe5fd0d commit b8d8f7c
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 22 deletions.
22 changes: 22 additions & 0 deletions data/quotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3161,89 +3161,111 @@ Double Dealing Character

Actually, ya did surprise me there when your head took off.
Marisa Kirisame
Double Dealing Character
whom_to: Sekibanki

Do you want to see me do that again?
Sekibanki
Double Dealing Character
whom_to: Marisa Kirisame

Wh-What's with you? You're actually strong!
Sekibanki
Double Dealing Character
whom_to: Marisa Kirisame

'Course I am. If I were weak, I'd be sleepin' at home.
Marisa Kirisame
Double Dealing Character
whom_to: Sekibanki

A mermaid in the lake? Do you mean Wakasagihime?
Kagerou Imaizumi
Double Dealing Character
whom_to: Marisa Kirisame

Yeah. Do ya know each other?
Marisa Kirisame
Double Dealing Character
whom_to: Kagerou Imaizumi

Somewhat, thanks to the grassroots youkai network. Though I also tried to eat her once by mistake.
Kagerou Imaizumi
Double Dealing Character
whom_to: Marisa Kirisame

Did I even once say that I was weak? But... My expectations were off.
Sakuya Izayoi
Double Dealing Character
whom_to: Sekibanki

Wh-What do you mean?
Sekibanki
Double Dealing Character
whom_to: Sakuya Izayoi

Because I never needed to cut off your neck at all.
Sakuya Izayoi
Double Dealing Character
whom_to: Sekibanki

Gyah!
Sekibanki
Double Dealing Character
whom_to: Sakuya Izayoi

Do you think you can defeat me?
Kagerou Imaizumi
Double Dealing Character
whom_to: Sakuya Izayoi

Yes, I believe I can.
Sakuya Izayoi
Double Dealing Character
whom_to: Kagerou Imaizumi

O-Oh, a quick answer.
Kagerou Imaizumi
Double Dealing Character
whom_to: Sakuya Izayoi


Who should it be but a wolfman!
Sakuya Izayoi
Double Dealing Character
whom_to: Kagerou Imaizumi

I'm a wolf-woman!
Kagerou Imaizumi
Double Dealing Character
whom_to: Sakuya Izayoi

Well, either way. Your blood will coat my knife.
Sakuya Izayoi
Double Dealing Character
whom_to: Kagerou Imaizumi

Eek!
Kagerou Imaizumi
Double Dealing Character
whom_to: Sakuya Izayoi

The drummers in the outside world have a saying. \"Awaken your caveman spirit, for it doesn't need brains to beat a drum!\"
Raiko Horikawa
Double Dealing Character
whom_to: Reimu Hakurei

Huh...The outside world seems barbaric.
Reimu Hakurei
Double Dealing Character
whom_to: Raiko Horikawa

I don't want to go back to a life of being hit and stepped on.
Raiko Horikawa
Double Dealing Character
whom_to: Sakuya Izayoi

You are a drum, yes? How could you not want to be hit?
Sakuya Izayoi
Double Dealing Character
whom_to: Raiko Horikawa
11 changes: 11 additions & 0 deletions generate_quotes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# generate rust quotes file

from dataclasses import dataclass
from pprint import pprint

from generate_lib import *

Expand Down Expand Up @@ -77,6 +78,7 @@ class Quote:
whom_about: None | str

def to_lines(self) -> list[str]:
assert self.is_ok()
lines = [
"\tQuote {",
f"\t\ttext: \"{self.text}\",",
Expand All @@ -94,6 +96,15 @@ def to_lines(self) -> list[str]:
lines.append("\t},")
return lines

def is_ok(self) -> bool:
unwanted = ["text:", "char:", "src:", "whom_to", "whom_about", "\n", "\t"]
for field, value in vars(self).items():
if value is not None:
if any(map(lambda unwanted: unwanted in value, unwanted)):
pprint(self)
return False
return True



if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod characters;
mod format;
mod quote;
mod quotes;
mod quotes_tests;
mod to_str;

use crate::{
Expand Down
66 changes: 44 additions & 22 deletions src/quotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4615,135 +4615,157 @@ pub const QUOTES: &[Quote] = &[
Quote {
text: "Actually, ya did surprise me there when your head took off.",
char: Marisa_Kirisame,
src: "whom_to: Sekibanki",
src: "Double Dealing Character",
whom_to: Some(Sekibanki),
..Quote::default()
},
Quote {
text: "Do you want to see me do that again?",
char: Sekibanki,
src: "whom_to: Marisa Kirisame",
src: "Double Dealing Character",
whom_to: Some(Marisa_Kirisame),
..Quote::default()
},
Quote {
text: "Wh-What's with you? You're actually strong!",
char: Sekibanki,
src: "whom_to: Marisa Kirisame",
src: "Double Dealing Character",
whom_to: Some(Marisa_Kirisame),
..Quote::default()
},
Quote {
text: "'Course I am. If I were weak, I'd be sleepin' at home.",
char: Marisa_Kirisame,
src: "whom_to: Sekibanki",
src: "Double Dealing Character",
whom_to: Some(Sekibanki),
..Quote::default()
},
Quote {
text: "A mermaid in the lake? Do you mean Wakasagihime?",
char: Kagerou_Imaizumi,
src: "whom_to: Marisa Kirisame",
src: "Double Dealing Character",
whom_to: Some(Marisa_Kirisame),
..Quote::default()
},
Quote {
text: "Yeah. Do ya know each other?",
char: Marisa_Kirisame,
src: "whom_to: Kagerou Imaizumi",
src: "Double Dealing Character",
whom_to: Some(Kagerou_Imaizumi),
..Quote::default()
},
Quote {
text: "Somewhat, thanks to the grassroots youkai network. Though I also tried to eat her once by mistake.",
char: Kagerou_Imaizumi,
src: "whom_to: Marisa Kirisame",
src: "Double Dealing Character",
whom_to: Some(Marisa_Kirisame),
..Quote::default()
},
Quote {
text: "Did I even once say that I was weak? But... My expectations were off.",
char: Sakuya_Izayoi,
src: "whom_to: Sekibanki",
src: "Double Dealing Character",
whom_to: Some(Sekibanki),
..Quote::default()
},
Quote {
text: "Wh-What do you mean?",
char: Sekibanki,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "Because I never needed to cut off your neck at all.",
char: Sakuya_Izayoi,
src: "whom_to: Sekibanki",
src: "Double Dealing Character",
whom_to: Some(Sekibanki),
..Quote::default()
},
Quote {
text: "Gyah!",
char: Sekibanki,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "Do you think you can defeat me?",
char: Kagerou_Imaizumi,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "Yes, I believe I can.",
char: Sakuya_Izayoi,
src: "whom_to: Kagerou Imaizumi",
src: "Double Dealing Character",
whom_to: Some(Kagerou_Imaizumi),
..Quote::default()
},
Quote {
text: "O-Oh, a quick answer.",
char: Kagerou_Imaizumi,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},


Quote {
text: "Who should it be but a wolfman!",
char: Sakuya_Izayoi,
src: "whom_to: Kagerou Imaizumi",
src: "Double Dealing Character",
whom_to: Some(Kagerou_Imaizumi),
..Quote::default()
},
Quote {
text: "I'm a wolf-woman!",
char: Kagerou_Imaizumi,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "Well, either way. Your blood will coat my knife.",
char: Sakuya_Izayoi,
src: "whom_to: Kagerou Imaizumi",
src: "Double Dealing Character",
whom_to: Some(Kagerou_Imaizumi),
..Quote::default()
},
Quote {
text: "Eek!",
char: Kagerou_Imaizumi,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "The drummers in the outside world have a saying. \"Awaken your caveman spirit, for it doesn't need brains to beat a drum!\"",
char: Raiko_Horikawa,
src: "whom_to: Reimu Hakurei",
src: "Double Dealing Character",
whom_to: Some(Reimu_Hakurei),
..Quote::default()
},
Quote {
text: "Huh...The outside world seems barbaric.",
char: Reimu_Hakurei,
src: "whom_to: Raiko Horikawa",
src: "Double Dealing Character",
whom_to: Some(Raiko_Horikawa),
..Quote::default()
},
Quote {
text: "I don't want to go back to a life of being hit and stepped on.",
char: Raiko_Horikawa,
src: "whom_to: Sakuya Izayoi",
src: "Double Dealing Character",
whom_to: Some(Sakuya_Izayoi),
..Quote::default()
},
Quote {
text: "You are a drum, yes? How could you not want to be hit?",
char: Sakuya_Izayoi,
src: "whom_to: Raiko Horikawa",
src: "Double Dealing Character",
whom_to: Some(Raiko_Horikawa),
..Quote::default()
},
];
25 changes: 25 additions & 0 deletions src/quotes_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Tests for `quotes.rs`

#[cfg(test)]
mod tests {
use crate::{quote::Quote, quotes::QUOTES};

#[test]
fn dont_contain_unwanted_text() {
const UNWANTED: &[&str] = &[
"text:",
"char:",
"src:",
"whom_to",
"whom_about",
"\n",
"\t",
];
for Quote { text, src, .. } in QUOTES {
for unwanted in UNWANTED {
assert!(!text.to_lowercase().contains(unwanted), "unwanted=`{unwanted}`, text=`{text}`");
assert!(!src.to_lowercase().contains(unwanted), "unwanted=`{unwanted}`, src=`{src}`");
}
}
}
}

0 comments on commit b8d8f7c

Please sign in to comment.