// Tester for the tag parser. // // Copyright (C) 2005, 2008 Daniel Burrows // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. #ifdef HAVE_CONFIG_H #include #endif // TODO: These tests need updating for recent (2012-06-30) changes // to out interface to debtags. #if 0 #include #include #include #include std::ostream &operator<<(std::ostream &out, const tag &t) { return out << t.str(); } #define CPPUNIT_ASSERT_GT(a, b) \ do { if(!((a) > (b))) \ {std::ostringstream out; \ out << "comparison assertion failed" << std::endl; \ out << "\"" << (a) << "\" is not > \"" << (b) << "\"" << std::endl; \ CppUnit :: Asserter :: fail(out.str()); } } while(0) #define CPPUNIT_ASSERT_LT(a, b) \ do { if(!((a) < (b))) \ {std::ostringstream out; \ out << "comparison assertion failed" << std::endl; \ out << "\"" << (a) << "\" is not < \"" << (b) << "\"" << std::endl; \ CppUnit :: Asserter :: fail(out.str()); } } while(0) #define CPPUNIT_ASSERT_LTEQUAL(a, b) \ do { if(!((a) <= (b))) \ {std::ostringstream out; \ out << "comparison assertion failed" << std::endl; \ out << "\"" << (a) << "\" is not <= \"" << (b) << "\"" << std::endl; \ CppUnit :: Asserter :: fail(out.str()); } } while(0) #define CPPUNIT_ASSERT_GTEQUAL(a, b) \ do { if(!((a) >= (b))) \ {std::ostringstream out; \ out << "comparison assertion failed" << std::endl; \ out << "\"" << (a) << "\" is not >= \"" << (b) << "\"" << std::endl; \ CppUnit :: Asserter :: fail(out.str()); } } while(0) class TagTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TagTest); CPPUNIT_TEST(testTagTraverse); CPPUNIT_TEST(testTagStr); CPPUNIT_TEST(testTagEqual); CPPUNIT_TEST(testTagOrder); CPPUNIT_TEST(testTagListTraverse); CPPUNIT_TEST_SUITE_END(); private: static tag parseTag(const std::string &s) { return tag(s.begin(), s.end()); } // These should all parse to (tag1, tag2, tag3): static const char *basicTagEntries[]; // Erroneous entries. Should parse as having no tags at all. static const char *badEntry1; static const char *badEntry2; static const char *badEntry3; static const char *badEntry4; // Tag order checks. The tag ordering function should say that // forall n . tagorder[n]