/* * Copyright (c) 2015 Tarun Gupta. * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* * Copyright (c) 2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include #include #include #include #include #include using namespace Swift; class UserTuneParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(UserTuneParserTest); CPPUNIT_TEST(testParse_with_all_variables); CPPUNIT_TEST(testParse_with_Some_variables); CPPUNIT_TEST_SUITE_END(); public: UserTuneParserTest() {} void testParse_with_all_variables() { PayloadsParserTester parser; CPPUNIT_ASSERT(parser.parse( "" "5MinionYellowIceFireOrigin226")); UserTune* payload = dynamic_cast(parser.getPayload().get()); CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT_EQUAL(static_cast(5), payload->getRating().get()); CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get()); CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get()); CPPUNIT_ASSERT_EQUAL(std::string("Ice"), payload->getArtist().get()); CPPUNIT_ASSERT_EQUAL(std::string("Fire"), payload->getURI().get()); CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get()); CPPUNIT_ASSERT_EQUAL(static_cast(226), payload->getLength().get()); } void testParse_with_Some_variables() { PayloadsParserTester parser; CPPUNIT_ASSERT(parser.parse( "" "MinionYellowOrigin226")); UserTune* payload = dynamic_cast(parser.getPayload().get()); CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT(!payload->getRating()); CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get()); CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get()); CPPUNIT_ASSERT(!payload->getArtist()); CPPUNIT_ASSERT(!payload->getURI()); CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get()); CPPUNIT_ASSERT_EQUAL(static_cast(226), payload->getLength().get()); } }; CPPUNIT_TEST_SUITE_REGISTRATION(UserTuneParserTest);