diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /testfiles/src/cxxtests-to-migrate/verbs-test.h | |
parent | Initial commit. (diff) | |
download | inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testfiles/src/cxxtests-to-migrate/verbs-test.h')
-rw-r--r-- | testfiles/src/cxxtests-to-migrate/verbs-test.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/testfiles/src/cxxtests-to-migrate/verbs-test.h b/testfiles/src/cxxtests-to-migrate/verbs-test.h new file mode 100644 index 0000000..b8fd299 --- /dev/null +++ b/testfiles/src/cxxtests-to-migrate/verbs-test.h @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * TODO: insert short description here + *//* + * Authors: see git history + * + * Copyright (C) 2016 Authors + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + + +#include <cxxtest/TestSuite.h> + +#include "verbs.h" + +class VerbsTest : public CxxTest::TestSuite +{ +public: + + class TestHook : public Inkscape::Verb { + public: + static int getInternalTableSize() { return _getBaseListSize(); } + + private: + TestHook(); + }; + + void testEnumLength() + { + TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) ); + TS_ASSERT_EQUALS( static_cast<int>(SP_VERB_LAST) + 1, TestHook::getInternalTableSize() ); + } + + void testEnumFixed() + { + TS_ASSERT_EQUALS( 0, static_cast<int>(SP_VERB_INVALID) ); + TS_ASSERT_EQUALS( 1, static_cast<int>(SP_VERB_NONE) ); + + TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) ); + TS_ASSERT_DIFFERS( 1, static_cast<int>(SP_VERB_LAST) ); + } + + void testFetch() + { + for ( int i = 0; i < static_cast<int>(SP_VERB_LAST); i++ ) + { + char tmp[16]; + snprintf( tmp, sizeof(tmp), "Verb# %d", i ); + tmp[sizeof(tmp)-1] = 0; + std::string descr(tmp); + + Inkscape::Verb* verb = Inkscape::Verb::get(i); + TSM_ASSERT( descr, verb ); + if ( verb ) + { + TSM_ASSERT_EQUALS( descr, verb->get_code(), static_cast<unsigned int>(i) ); + + if ( i != static_cast<int>(SP_VERB_INVALID) ) + { + TSM_ASSERT( descr, verb->get_id() ); + TSM_ASSERT( descr, verb->get_name() ); + + Inkscape::Verb* bounced = verb->getbyid( verb->get_id() ); + // TODO - put this back once verbs are fixed + //TSM_ASSERT( descr, bounced ); + if ( bounced ) + { + TSM_ASSERT_EQUALS( descr, bounced->get_code(), static_cast<unsigned int>(i) ); + } + else + { + TS_FAIL( std::string("Unable to getbyid() for ") + descr + std::string(" ID: '") + std::string(verb->get_id()) + std::string("'") ); + } + } + else + { + TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_id() ); + TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_name() ); + } + } + } + } + +}; + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |