Update test cases to deal with new data

This commit is contained in:
Dirkjan Ochtman 2021-06-02 05:23:24 -07:00
parent fee2adb995
commit 3c52201fa0
1 changed files with 50 additions and 39 deletions

View File

@ -7,7 +7,11 @@ pub fn run(segmenter: &Segmenter) {
for test in TEST_CASES.iter().copied() { for test in TEST_CASES.iter().copied() {
success &= assert_segments(test, &mut search, segmenter); success &= assert_segments(test, &mut search, segmenter);
} }
success &= assert_segments(FAIL, &mut search, segmenter);
for test in FAILED.iter().copied() {
success &= assert_segments(test, &mut search, segmenter);
}
assert!(success); assert!(success);
} }
@ -82,28 +86,6 @@ pub const TEST_CASES: &[&[&str]] = &[
"of", "of",
"foolishness", "foolishness",
], ],
&[
"as",
"gregor",
"samsa",
"awoke",
"one",
"morning",
"from",
"uneasy",
"dreams",
"he",
"found",
"himself",
"transformed",
"in",
"his",
"bed",
"into",
"a",
"gigantic",
"insect",
],
&[ &[
"in", "a", "hole", "in", "the", "ground", "there", "lived", "a", "hobbit", "not", "a", "in", "a", "hole", "in", "the", "ground", "there", "lived", "a", "hobbit", "not", "a",
"nasty", "dirty", "wet", "hole", "filled", "with", "the", "ends", "of", "worms", "and", "nasty", "dirty", "wet", "hole", "filled", "with", "the", "ends", "of", "worms", "and",
@ -113,8 +95,10 @@ pub const TEST_CASES: &[&[&str]] = &[
], ],
]; ];
/// Incorrectly segmented, since the test data doesn't contain "unregarded" /// Incorrectly segmented test cases
const FAIL: &[&str] = &[ const FAILED: &[&[&str]] = &[
&[
// The SCOWL word list (at size 60) data does not contain "unregarded"
"far", "far",
"out", "out",
"in", "in",
@ -140,4 +124,31 @@ const FAIL: &[&str] = &[
"regarded", "regarded",
"yellow", "yellow",
"sun", "sun",
],
&[
// The SCOWL word list (at size 60) does not contain "gregor"
"as",
"greg",
"or",
"sam",
"s",
"a",
"awoke",
"one",
"morning",
"from",
"uneasy",
"dreams",
"he",
"found",
"himself",
"transformed",
"in",
"his",
"bed",
"into",
"a",
"gigantic",
"insect",
],
]; ];