Mercurial > malikania
comparison tests/libclient/js-point/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_point.hpp> | 21 #include <malikania/js_point.hpp> |
22 | 22 |
23 using namespace malikania; | |
24 | |
25 class TestPoint : public testing::Test { | 23 class TestPoint : public testing::Test { |
26 protected: | 24 protected: |
27 UniqueContext m_ctx; | 25 UniqueContext m_ctx; |
28 | 26 |
29 public: | 27 public: |
30 TestPoint() | 28 TestPoint() |
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_point(m_ctx); | 32 mlk::dukx_load_point(m_ctx); |
35 } | 33 } |
36 }; | 34 }; |
37 | 35 |
38 /* | 36 /* |
39 * Valid constructors | 37 * Valid constructors |
175 | 173 |
176 TEST_F(TestPoint, requireSuccess) | 174 TEST_F(TestPoint, requireSuccess) |
177 { | 175 { |
178 try { | 176 try { |
179 duk_push_c_function(m_ctx, [] (auto ctx) { | 177 duk_push_c_function(m_ctx, [] (auto ctx) { |
180 auto point = dukx_require_point(ctx, 0); | 178 auto point = mlk::dukx_require_point(ctx, 0); |
181 | 179 |
182 duk_push_int(ctx, point.x()); | 180 duk_push_int(ctx, point.x()); |
183 duk_put_global_string(ctx, "x"); | 181 duk_put_global_string(ctx, "x"); |
184 duk_push_int(ctx, point.y()); | 182 duk_push_int(ctx, point.y()); |
185 duk_put_global_string(ctx, "y"); | 183 duk_put_global_string(ctx, "y"); |
207 | 205 |
208 TEST_F(TestPoint, requireFail) | 206 TEST_F(TestPoint, requireFail) |
209 { | 207 { |
210 try { | 208 try { |
211 duk_push_c_function(m_ctx, [] (auto ctx) { | 209 duk_push_c_function(m_ctx, [] (auto ctx) { |
212 dukx_require_point(ctx, 0); | 210 mlk::dukx_require_point(ctx, 0); |
213 | 211 |
214 return 0; | 212 return 0; |
215 }, 1); | 213 }, 1); |
216 duk_put_global_string(m_ctx, "build"); | 214 duk_put_global_string(m_ctx, "build"); |
217 | 215 |
246 | 244 |
247 TEST_F(TestPoint, getAdjustAll) | 245 TEST_F(TestPoint, getAdjustAll) |
248 { | 246 { |
249 try { | 247 try { |
250 duk_push_c_function(m_ctx, [] (auto ctx) { | 248 duk_push_c_function(m_ctx, [] (auto ctx) { |
251 auto point = dukx_get_point(ctx, 0); | 249 auto point = mlk::dukx_get_point(ctx, 0); |
252 | 250 |
253 duk_push_int(ctx, point.x()); | 251 duk_push_int(ctx, point.x()); |
254 duk_put_global_string(ctx, "x"); | 252 duk_put_global_string(ctx, "x"); |
255 duk_push_int(ctx, point.y()); | 253 duk_push_int(ctx, point.y()); |
256 duk_put_global_string(ctx, "y"); | 254 duk_put_global_string(ctx, "y"); |