diff options
| author | Zeyla Hellyer <[email protected]> | 2018-07-02 09:40:48 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-07-02 09:40:48 -0700 |
| commit | 0067c3335929325f54a3a0fe3693703e16de219c (patch) | |
| tree | 119bb384af513eff15a2d93bf5b1b9e67c9289a0 /tests | |
| parent | Make guild optional on Invites (diff) | |
| download | serenity-0067c3335929325f54a3a0fe3693703e16de219c.tar.xz serenity-0067c3335929325f54a3a0fe3693703e16de219c.zip | |
Fix utils::is_nsfw string slicing
Removes string slicing on the input string, instead preferring to count chars
and work off that information.
Fixes channel names with unicode such as `général`.
Fixes #342.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_utils.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_utils.rs b/tests/test_utils.rs new file mode 100644 index 0000000..99308e4 --- /dev/null +++ b/tests/test_utils.rs @@ -0,0 +1,14 @@ +#![cfg(feature = "utils")]
+
+extern crate serenity;
+
+use serenity::utils::*;
+
+#[test]
+fn test_is_nsfw() {
+ assert!(!is_nsfw("general"));
+ assert!(is_nsfw("nsfw"));
+ assert!(is_nsfw("nsfw-test"));
+ assert!(is_nsfw("nsfw-"));
+ assert!(!is_nsfw("général"));
+}
\ No newline at end of file |