Update out-of-date tests

This commit is contained in:
Thomas Goyne 2014-04-25 08:46:01 -07:00
parent b9509289aa
commit 882afc5111
2 changed files with 7 additions and 29 deletions

View file

@ -158,26 +158,11 @@ TEST_F(lagi_cajun, UnknownIsIndexable) {
EXPECT_NO_THROW(unk_obj["Integer"]); EXPECT_NO_THROW(unk_obj["Integer"]);
EXPECT_EQ(1, (json::Integer)unk_obj["Integer"]); EXPECT_EQ(1, (json::Integer)unk_obj["Integer"]);
EXPECT_THROW(unk_obj[0], json::Exception);
EXPECT_NO_THROW(unk_obj["Nonexistent Key"]); EXPECT_NO_THROW(unk_obj["Nonexistent Key"]);
json::UnknownElement const& const_unk_obj = obj; json::UnknownElement const& const_unk_obj = obj;
EXPECT_NO_THROW(const_unk_obj["Integer"]); EXPECT_NO_THROW(const_unk_obj["Integer"]);
EXPECT_THROW(const_unk_obj["Another nonexistent Key"], json::Exception); EXPECT_THROW(const_unk_obj["Another nonexistent Key"], json::Exception);
json::Array arr;
arr.push_back(1);
json::UnknownElement unk_arr = arr;
EXPECT_NO_THROW(unk_arr[0]);
EXPECT_EQ(1, (json::Integer)unk_arr[0]);
EXPECT_THROW(unk_arr["Integer"], json::Exception);
json::Integer number = 1;
json::UnknownElement const& unk_num = number;
EXPECT_THROW(unk_num[0], json::Exception);
EXPECT_THROW(unk_num[""], json::Exception);
} }
TEST_F(lagi_cajun, ObjectStoreInteger) { TEST_F(lagi_cajun, ObjectStoreInteger) {

View file

@ -18,17 +18,10 @@
using namespace agi::signal; using namespace agi::signal;
struct increment {
int *num;
increment(int &num) : num(&num) { }
void operator()() const { ++*num; }
void operator()(int n) const { *num += n; }
};
TEST(lagi_signal, basic) { TEST(lagi_signal, basic) {
Signal<> s; Signal<> s;
int x = 0; int x = 0;
Connection c = s.Connect(increment(x)); Connection c = s.Connect([&] { ++x; });
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
s(); s();
@ -38,8 +31,8 @@ TEST(lagi_signal, basic) {
TEST(lagi_signal, multiple) { TEST(lagi_signal, multiple) {
Signal<> s; Signal<> s;
int x = 0; int x = 0;
Connection c1 = s.Connect(increment(x)); Connection c1 = s.Connect([&] { ++x; });
Connection c2 = s.Connect(increment(x)); Connection c2 = s.Connect([&] { ++x; });
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
s(); s();
@ -48,7 +41,7 @@ TEST(lagi_signal, multiple) {
TEST(lagi_signal, manual_disconnect) { TEST(lagi_signal, manual_disconnect) {
Signal<> s; Signal<> s;
int x = 0; int x = 0;
Connection c1 = s.Connect(increment(x)); Connection c1 = s.Connect([&] { ++x; });
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
s(); s();
EXPECT_EQ(1, x); EXPECT_EQ(1, x);
@ -63,7 +56,7 @@ TEST(lagi_signal, auto_disconnect) {
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
{ {
Connection c = s.Connect(increment(x)); Connection c = s.Connect([&] { ++x; });
s(); s();
EXPECT_EQ(1, x); EXPECT_EQ(1, x);
} }
@ -78,7 +71,7 @@ TEST(lagi_signal, connection_outlives_slot) {
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
{ {
Signal<> s; Signal<> s;
c = s.Connect(increment(x)); c = s.Connect([&] { ++x; });
s(); s();
EXPECT_EQ(1, x); EXPECT_EQ(1, x);
} }
@ -89,7 +82,7 @@ TEST(lagi_signal, one_arg) {
Signal<int> s; Signal<int> s;
int x = 0; int x = 0;
Connection c = s.Connect(increment(x)); Connection c = s.Connect([&](int v) { x += v; });
s(0); s(0);
EXPECT_EQ(0, x); EXPECT_EQ(0, x);
s(10); s(10);