Mercurial > malikania
comparison tests/libclient/js-rectangle/main.cpp @ 43:fabbe1759cec
Misc: switch to mlk namespace, closes #589
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 29 Nov 2016 22:25:17 +0100 |
parents | a47a4477f347 |
children | f30c84b4b9ed |
comparison
equal
deleted
inserted
replaced
42:a47a4477f347 | 43:fabbe1759cec |
---|---|
18 | 18 |
19 #include <gtest/gtest.h> | 19 #include <gtest/gtest.h> |
20 | 20 |
21 #include <malikania/js_rectangle.hpp> | 21 #include <malikania/js_rectangle.hpp> |
22 | 22 |
23 using namespace malikania; | |
24 | |
25 class TestRectangle : public testing::Test { | 23 class TestRectangle : public testing::Test { |
26 protected: | 24 protected: |
27 UniqueContext m_ctx; | 25 UniqueContext m_ctx; |
28 | 26 |
29 public: | 27 public: |
30 TestRectangle() | 28 TestRectangle() |
31 { | 29 { |
32 duk_push_object(m_ctx); | 30 duk_push_object(m_ctx); |
33 duk_put_global_string(m_ctx, "Malikania"); | 31 duk_put_global_string(m_ctx, "Malikania"); |
34 dukx_load_rect(m_ctx); | 32 mlk::dukx_load_rect(m_ctx); |
35 } | 33 } |
36 }; | 34 }; |
37 | 35 |
38 /* | 36 /* |
39 * Valid constructors | 37 * Valid constructors |
234 | 232 |
235 TEST_F(TestRectangle, requireSuccess) | 233 TEST_F(TestRectangle, requireSuccess) |
236 { | 234 { |
237 try { | 235 try { |
238 duk_push_c_function(m_ctx, [] (auto ctx) { | 236 duk_push_c_function(m_ctx, [] (auto ctx) { |
239 auto rect = dukx_require_rect(ctx, 0); | 237 auto rect = mlk::dukx_require_rect(ctx, 0); |
240 | 238 |
241 duk_push_int(ctx, rect.x()); | 239 duk_push_int(ctx, rect.x()); |
242 duk_put_global_string(ctx, "x"); | 240 duk_put_global_string(ctx, "x"); |
243 duk_push_int(ctx, rect.y()); | 241 duk_push_int(ctx, rect.y()); |
244 duk_put_global_string(ctx, "y"); | 242 duk_put_global_string(ctx, "y"); |
276 | 274 |
277 TEST_F(TestRectangle, requireFail) | 275 TEST_F(TestRectangle, requireFail) |
278 { | 276 { |
279 try { | 277 try { |
280 duk_push_c_function(m_ctx, [] (auto ctx) { | 278 duk_push_c_function(m_ctx, [] (auto ctx) { |
281 dukx_require_rect(ctx, 0); | 279 mlk::dukx_require_rect(ctx, 0); |
282 | 280 |
283 return 0; | 281 return 0; |
284 }, 1); | 282 }, 1); |
285 duk_put_global_string(m_ctx, "build"); | 283 duk_put_global_string(m_ctx, "build"); |
286 | 284 |
315 | 313 |
316 TEST_F(TestRectangle, getAdjustAll) | 314 TEST_F(TestRectangle, getAdjustAll) |
317 { | 315 { |
318 try { | 316 try { |
319 duk_push_c_function(m_ctx, [] (auto ctx) { | 317 duk_push_c_function(m_ctx, [] (auto ctx) { |
320 auto rect = dukx_get_rect(ctx, 0); | 318 auto rect = mlk::dukx_get_rect(ctx, 0); |
321 | 319 |
322 duk_push_int(ctx, rect.x()); | 320 duk_push_int(ctx, rect.x()); |
323 duk_put_global_string(ctx, "x"); | 321 duk_put_global_string(ctx, "x"); |
324 duk_push_int(ctx, rect.y()); | 322 duk_push_int(ctx, rect.y()); |
325 duk_put_global_string(ctx, "y"); | 323 duk_put_global_string(ctx, "y"); |