-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves ggez#569
- Loading branch information
Showing
1 changed file
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,59 @@ | ||
// #[cfg(all(test, has_display))] | ||
|
||
// use crate::*; | ||
// use crate::tests; | ||
// use std::env; | ||
// use std::path; | ||
use crate::*; | ||
use crate::tests; | ||
|
||
|
||
/* TODO; the font API has changed and I don't want to deal with it now | ||
#[test] | ||
fn test_calculated_text_width() { | ||
let ctx = &mut make_context(); | ||
let (ctx, _ev) = &mut tests::make_context(); | ||
let font = graphics::Font::default(); | ||
|
||
let text = "Hello There"; | ||
let text = graphics::Text::new(("Hello There", font, 24.0)); | ||
|
||
let expected_width = text.width(ctx); | ||
// For now we just test against a known value, since rendering it | ||
// is odd. | ||
assert_eq!(expected_width, 123); | ||
// let rendered_width = graphics::Text::new((text, font, 24)).unwrap().width(); | ||
|
||
// println!("Text: {:?}, expected: {}, rendered: {}", text, expected_width, rendered_width); | ||
// assert_eq!(expected_width as usize, rendered_width as usize); | ||
} | ||
|
||
|
||
let expected_width = font.width(text); | ||
let rendered_width = graphics::Text::new((text, font, 24)).unwrap().width(); | ||
/// Make sure that the "height" of text with ascenders/descenders | ||
/// is the same as text without | ||
#[test] | ||
fn test_calculated_text_height() { | ||
let (ctx, _ev) = &mut tests::make_context(); | ||
let font = graphics::Font::default(); | ||
|
||
let text1 = graphics::Text::new(("strength", font, 24.0)); | ||
let text2 = graphics::Text::new(("moves", font, 24.0)); | ||
|
||
println!("Text: {:?}, expected: {}, rendered: {}", text, expected_width, rendered_width); | ||
assert_eq!(expected_width as usize, rendered_width as usize); | ||
let h1 = text1.height(ctx); | ||
let h2 = text2.height(ctx); | ||
assert_eq!(h1, h2); | ||
} | ||
|
||
|
||
#[test] | ||
fn test_monospace_text_is_actually_monospace() { | ||
let ctx = &mut make_context(); | ||
let font = graphics::Font::new(ctx, "/DejaVuSansMono.ttf"); | ||
let (ctx, _ev) = &mut tests::make_context(); | ||
let font = graphics::Font::new(ctx, "/DejaVuSansMono.ttf").unwrap(); | ||
|
||
let text1 = "Hello 1"; | ||
let text2 = "Hello 2"; | ||
let text3 = "Hello 3"; | ||
let text4 = "Hello 4"; | ||
let text1 = graphics::Text::new(("Hello 1", font, 24.0)); | ||
let text2 = graphics::Text::new(("Hello 2", font, 24.0));; | ||
let text3 = graphics::Text::new(("Hello 3", font, 24.0));; | ||
let text4 = graphics::Text::new(("Hello 4", font, 24.0));; | ||
|
||
let width1 = font.width(text1); | ||
let width2 = font.width(text2); | ||
let width3 = font.width(text3); | ||
let width4 = font.width(text4); | ||
let width1 = text1.width(ctx); | ||
let width2 = text3.width(ctx); | ||
let width3 = text2.width(ctx); | ||
let width4 = text4.width(ctx); | ||
|
||
assert_eq!(width1, width2); | ||
assert_eq!(width2, width3); | ||
assert_eq!(width3, width4); | ||
} | ||
*/ |