DictionaryTest.cc 711 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "Dictionary.h"
  2. #include "Data.h"
  3. #include <string>
  4. #include <cppunit/extensions/HelperMacros.h>
  5. using namespace std;
  6. class DictionaryTest:public CppUnit::TestFixture {
  7. CPPUNIT_TEST_SUITE(DictionaryTest);
  8. CPPUNIT_TEST(testGet);
  9. CPPUNIT_TEST_SUITE_END();
  10. private:
  11. public:
  12. void setUp() {
  13. }
  14. void testGet();
  15. };
  16. CPPUNIT_TEST_SUITE_REGISTRATION( DictionaryTest );
  17. void DictionaryTest::testGet() {
  18. Dictionary d;
  19. Data* data1 = new Data("aria2", 5);
  20. d.put("app_name", data1);
  21. Data* data2 = new Data("linux", 5);
  22. d.put("platform", data2);
  23. Data* dataGot = (Data*)d.get("app_name");
  24. CPPUNIT_ASSERT(dataGot != NULL);
  25. CPPUNIT_ASSERT_EQUAL(string("aria2"), dataGot->toString());
  26. }