summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c666e8)
raw | patch | inline | side by side (parent: 4c666e8)
author | joncruz <joncruz@users.sourceforge.net> | |
Fri, 28 Apr 2006 08:48:09 +0000 (08:48 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Fri, 28 Apr 2006 08:48:09 +0000 (08:48 +0000) |
ChangeLog | patch | blob | history | |
src/Makefile_insert | patch | blob | history | |
src/MultiPrinter.h | patch | blob | history | |
src/verbs-test.h | [new file with mode: 0644] | patch | blob |
src/verbs.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 5add0270a1c03c615738ef4c5422a9d73763a3e4..30b8ddbf070520000aa70a6cf6249966d67de370 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-04-28 Jon A. Cruz <jon@joncruz.org>
+
+ * src/Makefile_insert, src/MultiPrinter.h, src/verbs.h,
+ src/verbs-test.h:
+ Adding unit test for verbs.
+
2006-04-27 verbalshadow <verbalshadow@gmail.com>
* src/io/resource.h, src/io/resource.cpp,
Added CREATE v0.1 support for gradients/swatches/patterns
Support for Linux & Win32. Mac support waiting final support
Directory info.
-
-
+
2006-04-26 Jon A. Cruz <jon@joncruz.org>
* src/Makefile.am, src/MultiPrinter.h, src/PylogFormatter.h,
diff --git a/src/Makefile_insert b/src/Makefile_insert
index ce0007a1561de47750788959d5a9dbaa8247a27e..a797984e92d59b8996b4f7dab315403c44c1a2d1 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
test_all_includes = \
attributes-test.h \
- color-profile-test.h
+ color-profile-test.h \
+ verbs-test.h
diff --git a/src/MultiPrinter.h b/src/MultiPrinter.h
index 1792a744fc6da94a1ec7c76c73e3d66743875e33..944eead0650f6f9fb56e5d96f2e4b250a9b8ef50 100644 (file)
--- a/src/MultiPrinter.h
+++ b/src/MultiPrinter.h
virtual ~MultiPrinter()
{
- std::cout << "CLOSING OUT TEST" << std::endl;
_xmlFile.close();
_logFile.close();
}
diff --git a/src/verbs-test.h b/src/verbs-test.h
--- /dev/null
+++ b/src/verbs-test.h
@@ -0,0 +1,86 @@
+
+
+#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(), 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(), i );
+ }
+ else
+ {
+ TS_WARN( 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:encoding=utf-8:textwidth=99 :
diff --git a/src/verbs.h b/src/verbs.h
index d715466e7c7016e39cd63b0c614377eacf916264..f77085d7a3400827331c7ed96053e89960055668 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
void delete_view (Inkscape::UI::View::View * view);
void sensitive (SPDocument * in_doc = NULL, bool in_sensitive = true);
+
+// Yes, multiple public, protected and private sections are bad. We'll clean that up later
+protected:
+ /** \brief Returns the size of the internal base verb array.
+ \return The size in elements of the internal base array.
+
+ This is an inline function intended for testing. This should normally not be used.
+ For testing, a subclass that returns this value can be created to verify that the
+ length matches the enum values, etc.
+ */
+ static int _getBaseListSize() {return G_N_ELEMENTS(_base_verbs);}
+
}; /* Verb class */