Code

Remove INKSCAPE_VERSION from menus-skeleton.h
[inkscape.git] / src / verbs-test.h
3 #include <cxxtest/TestSuite.h>
5 #include "verbs.h"
7 class VerbsTest : public CxxTest::TestSuite
8 {
9 public:
11     class TestHook : public Inkscape::Verb {
12     public:
13         static int getInternalTableSize() { return _getBaseListSize(); }
15     private:
16         TestHook();
17     };
19     void testEnumLength()
20     {
21         TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) );
22         TS_ASSERT_EQUALS( static_cast<int>(SP_VERB_LAST) + 1, TestHook::getInternalTableSize() );
23     }
25     void testEnumFixed()
26     {
27         TS_ASSERT_EQUALS( 0, static_cast<int>(SP_VERB_INVALID) );
28         TS_ASSERT_EQUALS( 1, static_cast<int>(SP_VERB_NONE) );
30         TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) );
31         TS_ASSERT_DIFFERS( 1, static_cast<int>(SP_VERB_LAST) );
32     }
34     void testFetch()
35     {
36         for ( int i = 0; i < static_cast<int>(SP_VERB_LAST); i++ )
37         {
38             char tmp[16];
39             snprintf( tmp, sizeof(tmp), "Verb# %d", i );
40             tmp[sizeof(tmp)-1] = 0;
41             std::string descr(tmp);
43             Inkscape::Verb* verb = Inkscape::Verb::get(i);
44             TSM_ASSERT( descr, verb );
45             if ( verb )
46             {
47                 TSM_ASSERT_EQUALS( descr, verb->get_code(), static_cast<unsigned int>(i) );
49                 if ( i != static_cast<int>(SP_VERB_INVALID) )
50                 {
51                     TSM_ASSERT( descr, verb->get_id() );
52                     TSM_ASSERT( descr, verb->get_name() );
54                     Inkscape::Verb* bounced = verb->getbyid( verb->get_id() );
55                     // TODO - put this back once verbs are fixed
56                     //TSM_ASSERT( descr, bounced );
57                     if ( bounced )
58                     {
59                         TSM_ASSERT_EQUALS( descr, bounced->get_code(), static_cast<unsigned int>(i) );
60                     }
61                     else
62                     {
63                         TS_FAIL( std::string("Unable to getbyid() for ") + descr + std::string(" ID: '") + std::string(verb->get_id()) + std::string("'") );
64                     }
65                 }
66                 else
67                 {
68                     TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_id() );
69                     TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_name() );
70                 }
71             }
72         }
73     }
75 };
77 /*
78   Local Variables:
79   mode:c++
80   c-file-style:"stroustrup"
81   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82   indent-tabs-mode:nil
83   fill-column:99
84   End:
85 */
86 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :