dda29597012dd9033f6bbf3334ab4d7af77a459btweenk * @brief Unit tests for the Preferences object
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk * Krzysztof KosiĆski <tweenk.pl@gmail.com>
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk * This file is released into the public domain.
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk// test observer
dda29597012dd9033f6bbf3334ab4d7af77a459btweenkclass TestObserver : public Inkscape::Preferences::Observer {
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk virtual void notify(Inkscape::Preferences::Entry const &val)
ed8f6fa0f86221f8752699a14c481a164c6f3379Jon A. Cruz TS_ASSERT_DIFFERS(prefs, static_cast<void*>(0));
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getInt("/test/intvalue"), 321);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getInt("/this/path/does/not/exist", 123), 123);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk // simple case
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 500), 123);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk // the below may seem quirky but this behaviour is intended
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 1001, 5000), 123);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk // corner cases
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 1000), 1000);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 1000, 5000), 1000);
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(obs.value, 10); // value should not change
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk // test that filtering works properly
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk Inkscape::Preferences::Entry val = prefs->getEntry("/test/prefentry");
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk Local Variables:
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk c-file-style:"stroustrup"
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk indent-tabs-mode:nil
dda29597012dd9033f6bbf3334ab4d7af77a459btweenk fill-column:99
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :