aboutsummaryrefslogtreecommitdiff
path: root/high-scores/tests/high-scores.rs
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2020-12-26 17:48:38 +0000
committerFederico Igne <git@federicoigne.com>2021-11-03 18:55:08 +0000
commit02481656966b0a8dfc95cf3c22bcc049660ff7d4 (patch)
tree8e39798fcaf27931d91c2088423fd4e97adcfc2d /high-scores/tests/high-scores.rs
parent4e2052c4d792540c2f742b2c2a081b11117ed41d (diff)
downloadexercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.tar.gz
exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.zip
Move Rust exercises in a subdirectory
Diffstat (limited to 'high-scores/tests/high-scores.rs')
-rw-r--r--high-scores/tests/high-scores.rs68
1 files changed, 0 insertions, 68 deletions
diff --git a/high-scores/tests/high-scores.rs b/high-scores/tests/high-scores.rs
deleted file mode 100644
index 4d2feb7..0000000
--- a/high-scores/tests/high-scores.rs
+++ /dev/null
@@ -1,68 +0,0 @@
1use high_scores::HighScores;
2
3#[test]
4fn test_list_of_scores() {
5 let expected = [30, 50, 20, 70];
6 let high_scores = HighScores::new(&expected);
7 assert_eq!(high_scores.scores(), &expected);
8}
9
10#[test]
11fn test_latest_score() {
12 let high_scores = HighScores::new(&[100, 0, 90, 30]);
13 assert_eq!(high_scores.latest(), Some(30));
14}
15
16#[test]
17fn test_latest_score_empty() {
18 let high_scores = HighScores::new(&[]);
19 assert_eq!(high_scores.latest(), None);
20}
21
22#[test]
23fn test_personal_best() {
24 let high_scores = HighScores::new(&[40, 100, 70]);
25 assert_eq!(high_scores.personal_best(), Some(100));
26}
27
28#[test]
29fn test_personal_best_empty() {
30 let high_scores = HighScores::new(&[]);
31 assert_eq!(high_scores.personal_best(), None);
32}
33
34#[test]
35fn test_personal_top_three() {
36 let high_scores = HighScores::new(&[10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]);
37 assert_eq!(high_scores.personal_top_three(), vec![100, 90, 70]);
38}
39
40#[test]
41fn test_personal_top_three_highest_to_lowest() {
42 let high_scores = HighScores::new(&[20, 10, 30]);
43 assert_eq!(high_scores.personal_top_three(), vec![30, 20, 10]);
44}
45
46#[test]
47fn test_personal_top_three_with_tie() {
48 let high_scores = HighScores::new(&[40, 20, 40, 30]);
49 assert_eq!(high_scores.personal_top_three(), vec![40, 40, 30]);
50}
51
52#[test]
53fn test_personal_top_three_with_less_than_three_scores() {
54 let high_scores = HighScores::new(&[30, 70]);
55 assert_eq!(high_scores.personal_top_three(), vec![70, 30]);
56}
57
58#[test]
59fn test_personal_top_three_only_one_score() {
60 let high_scores = HighScores::new(&[40]);
61 assert_eq!(high_scores.personal_top_three(), vec![40]);
62}
63
64#[test]
65fn test_personal_top_three_empty() {
66 let high_scores = HighScores::new(&[]);
67 assert!(high_scores.personal_top_three().is_empty());
68}