diff options
| author | Zeyla Hellyer <[email protected]> | 2017-04-25 15:48:13 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-25 15:48:13 -0700 |
| commit | 0f41ffc811827fdd45e4e631884909e33fa8769e (patch) | |
| tree | 40c6d5091097ee86ed72e9868f77350bdaed078a /tests | |
| parent | Fix decoding for `CurrentUser.discriminator` (diff) | |
| download | serenity-0f41ffc811827fdd45e4e631884909e33fa8769e.tar.xz serenity-0f41ffc811827fdd45e4e631884909e33fa8769e.zip | |
Make `User.discriminator` a u16
Change the User struct's `discriminator` field to a u16 for performance.
The User struct's `discriminator` field was previously a u16 but changed
to a `String` for ease-of-use. Lately the library has been gearing more
towards performance where possible while not sacrificing ergonomics
_too much_ in most scenarios.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_formatters.rs | 2 | ||||
| -rw-r--r-- | tests/test_user.rs | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/tests/test_formatters.rs b/tests/test_formatters.rs index 3b52dac..fa36832 100644 --- a/tests/test_formatters.rs +++ b/tests/test_formatters.rs @@ -49,7 +49,7 @@ fn test_mention() { id: UserId(6), avatar: None, bot: false, - discriminator: "4132".to_owned(), + discriminator: 4132, name: "fake".to_owned(), }; let member = Member { diff --git a/tests/test_user.rs b/tests/test_user.rs index dd51f44..790243e 100644 --- a/tests/test_user.rs +++ b/tests/test_user.rs @@ -7,7 +7,7 @@ fn gen() -> User { id: UserId(210), avatar: Some("abc".to_owned()), bot: true, - discriminator: "1432".to_owned(), + discriminator: 1432, name: "test".to_owned(), } } @@ -31,14 +31,14 @@ fn test_core() { fn default_avatars() { let mut user = gen(); - user.discriminator = "0".to_owned(); - assert!(user.default_avatar_url().unwrap().ends_with("0.png")); - user.discriminator = "1".to_owned(); - assert!(user.default_avatar_url().unwrap().ends_with("1.png")); - user.discriminator = "2".to_owned(); - assert!(user.default_avatar_url().unwrap().ends_with("2.png")); - user.discriminator = "3".to_owned(); - assert!(user.default_avatar_url().unwrap().ends_with("3.png")); - user.discriminator = "4".to_owned(); - assert!(user.default_avatar_url().unwrap().ends_with("4.png")); + user.discriminator = 0; + assert!(user.default_avatar_url().ends_with("0.png")); + user.discriminator = 1; + assert!(user.default_avatar_url().ends_with("1.png")); + user.discriminator = 2; + assert!(user.default_avatar_url().ends_with("2.png")); + user.discriminator = 3; + assert!(user.default_avatar_url().ends_with("3.png")); + user.discriminator = 4; + assert!(user.default_avatar_url().ends_with("4.png")); } |