private:
void load();
void int_as_float();
+ void overload();
void bad_keyword();
void bad_signature();
};
{
add(&LoaderTests::load, "Load");
add(&LoaderTests::int_as_float, "Int -> float");
+ add(&LoaderTests::overload, "Overload resolution");
add(&LoaderTests::bad_keyword, "Bad keyword").expect_throw<DataFile::data_error>();
add(&LoaderTests::bad_signature, "Bad signature").expect_throw<DataFile::data_error>();
}
EXPECT_EQUAL(obj.f, 2);
}
+void LoaderTests::overload()
+{
+ const char input[] =
+ "o 1.0;\n"
+ "o 2;\n";
+
+ TestObject obj;
+ IO::Memory mem(input, sizeof(input)-1);
+ DataFile::Parser parser(mem, "-");
+ TestObject::Loader loader(obj);
+ loader.load(parser);
+
+ EXPECT_EQUAL(obj.f, 1.0f);
+ EXPECT_EQUAL(obj.i, 2);
+}
+
void LoaderTests::bad_keyword()
{
const char input[] =
{
add("i", &TestObject::i);
add("f", &TestObject::f);
+ add("o", &TestObject::i);
+ add("o", &TestObject::f);
add("s", &TestObject::s);
add("c", &Loader::func);
}