diff --git a/.gitignore b/.gitignore index 10772d9d..6b527b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ tests/*/*-lib *.gcov *.gcda *.gcno +core.* diff --git a/tests/lib/.gitignore b/tests/lib/.gitignore index 22d9cb43..7eb63247 100644 --- a/tests/lib/.gitignore +++ b/tests/lib/.gitignore @@ -1,2 +1,3 @@ lib colmgr +model diff --git a/tests/lib/Sconscript b/tests/lib/Sconscript index 50075453..590bd1ca 100644 --- a/tests/lib/Sconscript +++ b/tests/lib/Sconscript @@ -25,6 +25,7 @@ res = TestList("lib", [ LibTest("lib.cpp", "gtkmm-3.0"), LibTest("colmgr.cpp"), + LibTest("model.cpp"), ]).prepare() diff --git a/tests/lib/model.cpp b/tests/lib/model.cpp new file mode 100644 index 00000000..b7c697a3 --- /dev/null +++ b/tests/lib/model.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include +#include +#include +#include + +static void test_qmodel() +{ + QueueModel model(library :: get_queue()); + Gtk::TreePath path; + Gtk::TreeIter iter; + Gtk::TreeRow row; + bool valid; + + test_equal(model.get_flags(), Gtk::TREE_MODEL_LIST_ONLY); + test_equal(model.get_n_columns(), 10); + + for (unsigned int i = 0; i < 10; i++) { + if ((i == 0) || (i == 5) || (i == 7)) + test_equal(model.get_column_type(i), G_TYPE_UINT); + else + test_equal(model.get_column_type(i), G_TYPE_STRING); + } + + path = Gtk::TreePath("42"); + iter = model.get_iter(path); + valid = (iter ? true : false); + test_equal(valid, false); + + path = Gtk::TreePath("19"); + iter = model.get_iter(path); + valid = (iter ? true : false); + test_equal(valid, true); + + test_equal(model.get_path(iter), path); + test_equal(model.get_iter(path), iter); + + test_equal(model.iter_to_id(iter), (unsigned)19); + test_equal(model.path_to_id(path), (unsigned)15); + + valid = (++iter ? true : false); + test_equal(valid, false); +} + +int main(int argc, char **argv) +{ + Gtk::Main ocarina(&argc, &argv); + test :: cp_data_dir(); + lib :: init(&argc, &argv, "ocarina6.glade"); + + run_test("QueueModel Test", test_qmodel); + return 0; +}