From 4b754af222fdbcd84fbfa11b16975820ca4b2d5b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 20 Mar 2015 00:26:59 -0700 Subject: [PATCH] test coverage of invalid font files --- src/glyphs.cpp | 2 +- test/test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/glyphs.cpp b/src/glyphs.cpp index 417a72d..30d51fd 100644 --- a/src/glyphs.cpp +++ b/src/glyphs.cpp @@ -234,7 +234,7 @@ void RangeAsync(uv_work_t* req) { { FT_Error face_error = FT_New_Face(library, baton->file_name.c_str(), i, &ft_face); if (face_error) { - baton->error_name = std::string("could not open Face") + baton->file_name; + baton->error_name = std::string("could not open Face: '") + baton->file_name + "'"; return; } diff --git a/test/test.js b/test/test.js index c3c84dc..c91d8ab 100644 --- a/test/test.js +++ b/test/test.js @@ -48,6 +48,14 @@ describe('load', function() { done(); }); + it('non existent font loading', function(done) { + var doesnotexistsans = opensans.replace('Regular','baloney'); + fontnik.load(doesnotexistsans, function(err, faces) { + assert.ok(err.message.indexOf('could not open face')); + done(); + }); + }); + it('load typeerror callback', function(done) { assert.throws(function() { fontnik.load(firasans); @@ -89,6 +97,14 @@ describe('range', function() { }); }); + it('range filepath does not exist', function(done) { + var doesnotexistsans = opensans.replace('Regular','baloney'); + fontnik.range(doesnotexistsans, 0, 256, function(err, faces) { + assert.ok(err.message.indexOf('could not open face')); + done(); + }); + }); + it('range typeerror filepath', function(done) { assert.throws(function() { fontnik.range(12, 0, 256, function(err, data) {});