comparison tests/js-elapsedtimer/main.cpp @ 111:1ed760f6e0c6

Irccd: new brace styles, #487
author David Demelier <markand@malikania.fr>
date Wed, 27 Apr 2016 21:37:09 +0200
parents af84dd3d585b
children dc7d6ba08122
comparison
equal deleted inserted replaced
110:5d71d270a2dd 111:1ed760f6e0c6
38 }; 38 };
39 39
40 TEST_F(TestElapsedTimer, standard) 40 TEST_F(TestElapsedTimer, standard)
41 { 41 {
42 try { 42 try {
43 if (duk::pevalString(m_context, "timer = new Irccd.ElapsedTimer();") != 0) 43 if (duk::pevalString(m_context, "timer = new Irccd.ElapsedTimer();") != 0) {
44 throw duk::error(m_context, -1); 44 throw duk::error(m_context, -1);
45 }
45 46
46 std::this_thread::sleep_for(300ms); 47 std::this_thread::sleep_for(300ms);
47 48
48 if (duk::pevalString(m_context, "result = timer.elapsed();") != 0) 49 if (duk::pevalString(m_context, "result = timer.elapsed();") != 0) {
49 throw duk::error(m_context, -1); 50 throw duk::error(m_context, -1);
51 }
50 52
51 ASSERT_GE(duk::getGlobal<int>(m_context, "result"), 250); 53 ASSERT_GE(duk::getGlobal<int>(m_context, "result"), 250);
52 ASSERT_LE(duk::getGlobal<int>(m_context, "result"), 350); 54 ASSERT_LE(duk::getGlobal<int>(m_context, "result"), 350);
53 } catch (const std::exception &ex) { 55 } catch (const std::exception &ex) {
54 FAIL() << ex.what(); 56 FAIL() << ex.what();
56 } 58 }
57 59
58 TEST_F(TestElapsedTimer, reset) 60 TEST_F(TestElapsedTimer, reset)
59 { 61 {
60 try { 62 try {
61 if (duk::pevalString(m_context, "timer = new Irccd.ElapsedTimer();") != 0) 63 if (duk::pevalString(m_context, "timer = new Irccd.ElapsedTimer();") != 0) {
62 throw duk::error(m_context, -1); 64 throw duk::error(m_context, -1);
65 }
63 66
64 std::this_thread::sleep_for(300ms); 67 std::this_thread::sleep_for(300ms);
65 68
66 if (duk::pevalString(m_context, "timer.reset(); result = timer.elapsed();") != 0) 69 if (duk::pevalString(m_context, "timer.reset(); result = timer.elapsed();") != 0) {
67 throw duk::error(m_context, -1); 70 throw duk::error(m_context, -1);
71 }
68 72
69 ASSERT_LE(duk::getGlobal<int>(m_context, "result"), 100); 73 ASSERT_LE(duk::getGlobal<int>(m_context, "result"), 100);
70 } catch (const std::exception &ex) { 74 } catch (const std::exception &ex) {
71 FAIL() << ex.what(); 75 FAIL() << ex.what();
72 } 76 }