libpobsd 0.4.0

Library to interact with the PlayOnBSD database
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
//! Provides a representations of the game in the PlayOnBSD database.
use crate::{
    models::{
        field::Field,
        game_status::{GameStatus, Status},
        store_links::StoreLinks,
    },
    SearchType, Store,
};

use chrono::NaiveDate;
use paste::paste;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{
    cmp::{Ordering, PartialOrd},
    fmt,
};

macro_rules! game_contains {
    (name) => {
        /// Returns true if the name field of a [`Game`] contains the given pattern, false otherwise.
        /// The search can be case sensitive or not depending on the [`SearchType`] variant.
        pub fn name_contains(&self, pattern: &str, search_type: &SearchType) -> bool {
            match search_type {
                SearchType::CaseSensitive => self.name.contains(pattern),
                SearchType::NotCaseSensitive => {
                    self.name.to_lowercase().contains(&pattern.to_lowercase())
                }
            }
        }
    };
    ($field:ident) => {
        paste! {
            /// Returns true if the chosen field of a [`Game`] contains the given pattern, false otherwise.
            /// The search can be case sensitive or not depending on the [`SearchType`] variant.
            pub fn [<$field _contains>](&self, pattern: &str, search_type: &SearchType) -> bool {
            match search_type {
                SearchType::CaseSensitive => self.[<$field>].as_ref().is_some_and(|v| v.contains(pattern)),
                SearchType::NotCaseSensitive => self
                    .[< $field>]
                    .as_ref()
                    .is_some_and(|v| v.to_lowercase().contains(&pattern.to_lowercase())),
                }
            }
        }
    };
    (array $field:ident) => {
        paste! {
            /// Returns true if the chosen field of a [`Game`] contains the given pattern, false otherwise.
            /// The search can be case sensitive or not depending on the [`SearchType`] variant.
            pub fn [<$field _contains>](&self, value: &str, search_type: &SearchType) -> bool {
                match search_type {
                    SearchType::CaseSensitive => match self.[<$field>].as_ref() {
                        Some(items) => {
                            !items
                            .iter().filter(|x| x.contains(value))
                            .collect::<Vec<&String>>()
                            .is_empty()
                            },
                        None => false,
                    },
                    SearchType::NotCaseSensitive => match self.[<$field>].as_ref() {
                        Some(items) => {
                            !items
                            .iter().filter(|x| x.to_lowercase().contains(&value.to_lowercase()))
                            .collect::<Vec<&String>>()
                            .is_empty()
                            },
                        None => false,
                    },
                }
            }
        }
    };
}

/// Representation of a game of the PlayOnBSD database.
///
/// It also includes an additional [`Game::uid`] field
/// derived from the name of the game as well as the date to
/// which the game was added to the database. It therefore
/// provides an unique identifier under the assumption that no
/// game with the same name will be added the same date into
/// the database.
///
/// The name of some fields differs from the one used
/// in the database itself: Genre and Store are plural
/// since there can be more than one item for each
/// and Pub translate to publi since pub is a reserved
/// keyword in Rust.
///
/// ### Display
/// The [`Game`] struct implement the [`core::fmt::Display`] trait
/// and will be displayed as it would appear in the
/// PlayOnBSD database.
///
/// ### PartialOrd
/// The [`Game`] struct implements the [`core::cmp::PartialOrd`] trait
/// and [`Game`] objects are ordered according to their name (without The or A).

#[derive(Clone, Default, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Game {
    /// Unique identifier generated from the name and added fields
    pub uid: u32,
    /// Name of the game.
    pub name: String,
    /// Cover of the game.
    pub cover: Option<String>,
    /// Engine used by the game.
    pub engine: Option<String>,
    /// Step(s) to setup the game.
    pub setup: Option<String>,
    /// Executable in the package.
    pub runtime: Option<String>,
    /// Vector with store urls.
    pub stores: Option<StoreLinks>,
    /// Hints (as the name imply).
    pub hints: Option<String>,
    /// Vector of genres associated with the game.
    pub genres: Option<Vec<String>>,
    /// Vector of tags associated with the game.
    pub tags: Option<Vec<String>>,
    /// Released year (can be text such as "early access".
    pub year: Option<String>,
    /// Developer.
    #[cfg_attr(feature = "serde", serde(rename = "dev"))]
    pub devs: Option<Vec<String>>,
    /// Publisher.
    #[cfg_attr(feature = "serde", serde(rename = "pub"))]
    pub publis: Option<Vec<String>>,
    /// Version of the game.
    pub version: Option<String>,
    /// When tested on -current.
    pub status: GameStatus,
    /// When added
    pub added: NaiveDate,
    /// When updated
    pub updated: NaiveDate,
    /// IGDB Id of the game
    pub igdb_id: Option<usize>,
}

impl<'a> Game {
    /// Create a new [`Game`]. Equivalent to Default.
    pub fn new() -> Self {
        Self::default()
    }
    fn get_ordering_name(&'a self) -> String {
        if let Some(name) = self.name.strip_prefix("the ") {
            name.to_lowercase()
        } else if let Some(name) = self.name.strip_prefix("The ") {
            name.to_lowercase()
        } else if let Some(name) = self.name.strip_prefix("a ") {
            name.to_lowercase()
        } else if let Some(name) = self.name.strip_prefix("A ") {
            name.to_lowercase()
        } else {
            self.name.to_lowercase()
        }
    }

    game_contains!(name);
    game_contains!(engine);
    game_contains!(runtime);
    game_contains!(year);

    game_contains!(array genres);
    game_contains!(array tags);
    game_contains!(array devs);
    game_contains!(array publis);

    /// Return true if the [`Status`] of the [`Game`] correspond to a given [`Status`],
    /// false otherwise. Note that the argument provided can be [`Status`] or
    /// [`crate::models::GameStatus`].
    pub fn status_is(&self, status: &impl AsRef<Status>) -> bool {
        self.status.status.eq(status.as_ref())
    }
    /// Returns the Steam id of a [`Game`] if it has any.
    pub fn get_steam_id(&self) -> Option<usize> {
        if let Some(ref stores) = self.stores {
            if stores.has_steam() {
                for store in stores.inner_ref() {
                    match store.store {
                        Store::Steam => return store.id.to_owned(),
                        _ => continue,
                    };
                }
            }
        }
        None
    }
}

impl PartialOrd for Game {
    fn partial_cmp(&self, other: &Game) -> Option<Ordering> {
        Some(self.cmp(other))
    }
    fn lt(&self, other: &Game) -> bool {
        self.get_ordering_name().lt(&other.get_ordering_name())
    }
    fn le(&self, other: &Game) -> bool {
        self.get_ordering_name().le(&other.get_ordering_name())
    }
    fn gt(&self, other: &Game) -> bool {
        self.get_ordering_name().gt(&other.get_ordering_name())
    }
    fn ge(&self, other: &Game) -> bool {
        self.get_ordering_name().ge(&other.get_ordering_name())
    }
}

impl Ord for Game {
    fn cmp(&self, other: &Game) -> Ordering {
        self.get_ordering_name().cmp(&other.get_ordering_name())
    }
}

impl AsRef<Game> for Game {
    fn as_ref(&self) -> &Game {
        self
    }
}

/// Displays the game as it would appears in the database.
/// See <https://github.com/playonbsd/OpenBSD-Games-Database>
/// for details.
impl fmt::Display for Game {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
            Field::Game(Some(self.name.to_string())),
            Field::Cover(self.cover.to_owned()),
            Field::Engine(self.engine.to_owned()),
            Field::Setup(self.setup.to_owned()),
            Field::Runtime(self.runtime.to_owned()),
            Field::Store(self.stores.to_owned()),
            Field::Hints(self.hints.to_owned()),
            Field::Genres(self.genres.to_owned()),
            Field::Tags(self.tags.to_owned()),
            Field::Year(self.year.to_owned()),
            Field::Dev(self.devs.to_owned()),
            Field::Publi(self.publis.to_owned()),
            Field::Version(self.version.to_owned()),
            Field::Status(self.status.to_owned()),
            Field::Added(self.added.to_owned()),
            Field::Updated(self.updated.to_owned()),
            Field::IgdbId(self.igdb_id.to_owned()),
        )
    }
}

/* ------------------------- TESTS --------------------------*/

#[cfg(test)]
mod game_tests {
    use crate::models::store_links::StoreLink;

    use super::*;
    fn create_game() -> Game {
        let mut game = Game::default();
        let tags: Vec<String> = vec!["tag1".to_string(), "tag2".to_string()];
        let genres: Vec<String> = vec!["genre1".to_string(), "genre2".to_string()];
        let stores: Vec<String> = vec!["store1".to_string(), "store2".to_string()];
        let store_links: Vec<StoreLink> = stores.into_iter().map(|a| StoreLink::from(&a)).collect();
        let stores = StoreLinks(store_links);
        game.uid = 1221;
        game.name = "game name".to_string();
        game.cover = Some("cover.jpg".to_string());
        game.engine = Some("game engine".to_string());
        game.setup = Some("game setup".to_string());
        game.runtime = Some("game runtime".to_string());
        game.stores = Some(stores);
        game.hints = Some("game hints".to_string());
        game.genres = Some(genres);
        game.tags = Some(tags);
        game.year = Some("1980".to_string());
        game.devs = Some(vec!["game dev".to_string()]);
        game.publis = Some(vec!["game publi".to_string()]);
        game.version = Some("game version".to_string());
        game.status = GameStatus::new(Status::DoesNotRun, Some("game status".to_string()));
        game.added = NaiveDate::parse_from_str("2012-12-03", "%Y-%m-%d").unwrap();
        game.updated = NaiveDate::parse_from_str("2014-12-03", "%Y-%m-%d").unwrap();
        game
    }
    #[test]
    fn test_default_equivalent_to_new() {
        let game = Game::default();
        let game_bis = Game::new();
        assert!(game == game_bis);
    }
    #[test]
    fn test_get_ordering_name_with_a() {
        let mut game = create_game();
        game.name = "A champion".into();
        assert_eq!(game.get_ordering_name(), "champion");
        game.name = "a champion".into();
        assert_eq!(game.get_ordering_name(), "champion");
    }
    #[test]
    fn test_get_ordering_name_with_a_2() {
        let mut game = create_game();
        game.name = "Achampion".into();
        assert_eq!(game.get_ordering_name(), "achampion");
        game.name = "achampion".into();
        assert_eq!(game.get_ordering_name(), "achampion");
    }
    #[test]
    fn test_get_ordering_name_with_the() {
        let mut game = create_game();
        game.name = "The champion".into();
        assert_eq!(game.get_ordering_name(), "champion");
        game.name = "the champion".into();
        assert_eq!(game.get_ordering_name(), "champion");
    }
    #[test]
    fn test_get_ordering_name_with_the_2() {
        let mut game = create_game();
        game.name = "Thechampion".into();
        assert_eq!(game.get_ordering_name(), "thechampion");
        game.name = "thechampion".into();
        assert_eq!(game.get_ordering_name(), "thechampion");
    }
    #[test]
    fn test_ordering() {
        use std::cmp::Ordering;
        let mut game1 = create_game();
        let mut game2 = create_game();
        game1.name = "Abc".into();
        game2.name = "Def".into();
        assert!(game2.gt(&game1));
        assert!(game2.ge(&game1));
        assert!(game1.le(&game2));
        assert!(game1.lt(&game2));
        assert_eq!(game2.cmp(&game1), Ordering::Greater);
        assert_eq!(game1.cmp(&game2), Ordering::Less);
        assert_eq!(game2.cmp(&game2), Ordering::Equal);
        assert_eq!(game2.partial_cmp(&game1), Some(Ordering::Greater));
        assert_eq!(game1.partial_cmp(&game2), Some(Ordering::Less));
        assert_eq!(game2.partial_cmp(&game2), Some(Ordering::Equal));
        game1.name = "The Abc".into();
        game2.name = "def".into();
        assert!(game2.gt(&game1));
        assert!(game2.ge(&game1));
        assert!(game1.le(&game2));
        assert!(game1.lt(&game2));
        game1.name = "The Abc".into();
        game2.name = "A def".into();
        assert!(game2.gt(&game1));
        assert!(game2.ge(&game1));
        assert!(game1.le(&game2));
        assert!(game1.lt(&game2));
    }
    #[test]
    fn test_display_1() {
        let game_str = "Game\tAaaaaAAaaaAAAaaAAAAaAAAAA!!! for the Awesome
Cover\tAaaaaA_for_the_Awesome_Cover.jpg
Engine
Setup
Runtime\tHumblePlay
Store\thttps://www.humblebundle.com/store/aaaaaaaaaaaaaaaaaaaaaaaaa-for-the-awesome
Hints\tDemo on HumbleBundle store page
Genre
Tags
Year\t2011
Dev
Pub
Version
Status
Added\t1970-01-01
Updated\t1970-01-01
IgdbId";
        let game = Game {
            uid: 12,
            name: "AaaaaAAaaaAAAaaAAAAaAAAAA!!! for the Awesome".to_string(),
            cover: Some("AaaaaA_for_the_Awesome_Cover.jpg".to_string()),
            engine: None,
            setup: None,
            runtime: Some("HumblePlay".to_string()),
            stores: Some(StoreLinks(vec![StoreLink::from(
                "https://www.humblebundle.com/store/aaaaaaaaaaaaaaaaaaaaaaaaa-for-the-awesome",
            )])),
            hints: Some("Demo on HumbleBundle store page".to_string()),
            genres: None,
            tags: None,
            year: Some("2011".to_string()),
            devs: None,
            publis: None,
            version: None,
            status: GameStatus::default(),
            added: NaiveDate::default(),
            updated: NaiveDate::default(),
            igdb_id: None,
        };
        assert_eq!(format!("{}", game), game_str);
    }
    #[test]
    fn test_display_2() {
        let game_str = "Game\tAaaaaAAaaaAAAaaAAAAaAAAAA!!! for the Awesome
Cover
Engine\tEngine1
Setup\tSetup1
Runtime
Store
Hints
Genre\tgenre1, genre2
Tags\ttag1, tag2
Year
Dev\tdev1
Pub\tpub1
Version\tver1
Status\t0 fine
Added\t1970-01-01
Updated\t1970-01-02
IgdbId\t1234";
        let game = Game {
            uid: 12,
            name: "AaaaaAAaaaAAAaaAAAAaAAAAA!!! for the Awesome".to_string(),
            cover: None,
            engine: Some("Engine1".to_string()),
            setup: Some("Setup1".to_string()),
            runtime: None,
            stores: None,
            hints: None,
            genres: Some(vec!["genre1".to_string(), "genre2".to_string()]),
            tags: Some(vec!["tag1".to_string(), "tag2".to_string()]),
            year: None,
            devs: Some(vec!["dev1".to_string()]),
            publis: Some(vec!["pub1".to_string()]),
            version: Some("ver1".to_string()),
            status: GameStatus::new(Status::DoesNotRun, Some("fine".to_string())),
            added: NaiveDate::parse_from_str("1970-01-01", "%Y-%m-%d").unwrap(),
            updated: NaiveDate::parse_from_str("1970-01-02", "%Y-%m-%d").unwrap(),
            igdb_id: Some(1234),
        };
        assert_eq!(format!("{}", game), game_str);
    }
    #[test]
    fn test_name_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.name_contains("game", &st));
        assert!(game.name_contains("name", &st));
        assert!(game.name_contains("game name", &st));
        assert!(!game.name_contains("not name", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.name_contains("game", &st));
        assert!(game.name_contains("name", &st));
        assert!(game.name_contains("game name", &st));
        assert!(!game.name_contains("not name", &st));
    }
    #[test]
    fn test_name_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.name_contains("name", &st));
        assert!(!game.name_contains("Name", &st));
    }
    #[test]
    fn test_name_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.name_contains("name", &st));
        assert!(game.name_contains("Name", &st));
    }
    #[test]
    fn test_engine_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.engine_contains("game", &st));
        assert!(game.engine_contains("engine", &st));
        assert!(game.engine_contains("game engine", &st));
        assert!(!game.engine_contains("not engine", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.engine_contains("game", &st));
        assert!(game.engine_contains("engine", &st));
        assert!(game.engine_contains("game engine", &st));
        assert!(!game.engine_contains("not engine", &st));
    }
    #[test]
    fn test_engine_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.engine_contains("engine", &st));
        assert!(!game.engine_contains("Engine", &st));
    }
    #[test]
    fn test_engine_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.engine_contains("engine", &st));
        assert!(game.engine_contains("Engine", &st));
    }
    #[test]
    fn test_runtime_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.runtime_contains("game", &st));
        assert!(game.runtime_contains("runtime", &st));
        assert!(game.runtime_contains("game runtime", &st));
        assert!(!game.runtime_contains("not runtime", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.runtime_contains("game", &st));
        assert!(game.runtime_contains("runtime", &st));
        assert!(game.runtime_contains("game runtime", &st));
        assert!(!game.runtime_contains("not runtime", &st));
    }
    #[test]
    fn test_runtime_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.runtime_contains("runtime", &st));
        assert!(!game.runtime_contains("Runtime", &st));
    }
    #[test]
    fn test_runtime_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.runtime_contains("runtime", &st));
        assert!(game.runtime_contains("Runtime", &st));
    }
    #[test]
    fn test_year_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.year_contains("1980", &st));
        assert!(!game.year_contains("2000", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.year_contains("1980", &st));
        assert!(!game.year_contains("2000", &st));
    }
    #[test]
    fn test_year_contains_is_case_sensitive() {
        let mut game = create_game();
        let st = SearchType::CaseSensitive;
        game.year = Some("early access".into());
        assert!(game.year_contains("early", &st));
        assert!(!game.year_contains("Early", &st));
    }
    #[test]
    fn test_year_contains_is_not_case_sensitive() {
        let mut game = create_game();
        let st = SearchType::NotCaseSensitive;
        game.year = Some("early access".into());
        assert!(game.year_contains("early", &st));
        assert!(game.year_contains("Early", &st));
    }
    #[test]
    fn test_status_contains() {
        let game = create_game();
        let status = Status::DoesNotRun;
        assert!(game.status_is(&status));
    }
    #[test]
    fn test_genres_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.genres_contains("genre1", &st));
        assert!(game.genres_contains("genre2", &st));
        assert!(game.genres_contains("genre", &st));
        assert!(!game.genres_contains("coucou", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.genres_contains("genre1", &st));
        assert!(game.genres_contains("genre2", &st));
        assert!(game.genres_contains("genre", &st));
        assert!(!game.genres_contains("coucou", &st));
    }
    #[test]
    fn test_genres_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.genres_contains("genre", &st));
        assert!(!game.genres_contains("Genre", &st));
    }
    #[test]
    fn test_genres_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.genres_contains("genre", &st));
        assert!(game.genres_contains("Genre", &st));
    }
    #[test]
    fn test_tags_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.tags_contains("tag1", &st));
        assert!(game.tags_contains("tag2", &st));
        assert!(game.tags_contains("tag", &st));
        assert!(!game.tags_contains("coucou", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.tags_contains("tag1", &st));
        assert!(game.tags_contains("tag2", &st));
        assert!(game.tags_contains("tag", &st));
        assert!(!game.tags_contains("coucou", &st));
    }
    #[test]
    fn test_tags_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.tags_contains("tag", &st));
        assert!(!game.tags_contains("Tag", &st));
    }
    #[test]
    fn test_tags_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.tags_contains("tag", &st));
        assert!(game.tags_contains("Tag", &st));
    }
    #[test]
    fn test_devs_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.devs_contains("game", &st));
        assert!(game.devs_contains("dev", &st));
        assert!(game.devs_contains("game dev", &st));
        assert!(!game.devs_contains("coucou", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.devs_contains("game", &st));
        assert!(game.devs_contains("dev", &st));
        assert!(game.devs_contains("game dev", &st));
        assert!(!game.devs_contains("coucou", &st));
    }
    #[test]
    fn test_devs_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.devs_contains("game", &st));
        assert!(!game.devs_contains("Game", &st));
    }
    #[test]
    fn test_devs_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.devs_contains("game", &st));
        assert!(game.devs_contains("Game", &st));
    }
    #[test]
    fn test_publis_contains() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.publis_contains("game", &st));
        assert!(game.publis_contains("publi", &st));
        assert!(game.publis_contains("game publi", &st));
        assert!(!game.publis_contains("coucou", &st));
        let st = SearchType::NotCaseSensitive;
        assert!(game.publis_contains("game", &st));
        assert!(game.publis_contains("publi", &st));
        assert!(game.publis_contains("game publi", &st));
        assert!(!game.publis_contains("coucou", &st));
    }
    #[test]
    fn test_publis_contains_is_case_sensitive() {
        let game = create_game();
        let st = SearchType::CaseSensitive;
        assert!(game.publis_contains("game", &st));
        assert!(!game.publis_contains("Game", &st));
    }
    #[test]
    fn test_publis_contains_is_not_case_sensitive() {
        let game = create_game();
        let st = SearchType::NotCaseSensitive;
        assert!(game.publis_contains("game", &st));
        assert!(game.publis_contains("Game", &st));
    }
}