From: Johannes Schanda Date: Wed, 16 Jan 2013 13:51:47 +0000 (+0100) Subject: Test uses expectations X-Git-Tag: genivi_release_2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2b595737983552ea2b192de51e199dcd1f355b8;p=profile%2Fivi%2Fcommon-api-dbus-runtime.git Test uses expectations --- diff --git a/src/test/DBusVariantTest.cpp b/src/test/DBusVariantTest.cpp index 0000c29..4ba6981 100644 --- a/src/test/DBusVariantTest.cpp +++ b/src/test/DBusVariantTest.cpp @@ -1,60 +1,101 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +/* Copyright (C) 2013 BMW Group + * Author: Manfred Bathelt (manfred.bathelt@bmw.de) + * Author: Juergen Gehring (juergen.gehring@bmw.de) + * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include -#include -#include -#include +#include #include using namespace CommonAPI; +class VariantTest: public ::testing::Test { + + void SetUp() { + } + + void TearDown() { + } +}; + +TEST_F(VariantTest, VariantTestPack) { -int main(int argc, char** argv) { int fromInt = 5; double fromDouble = 12.344d; - std::string fromString = "123abc!"; + std::string fromString = "123abcsadfaljkawlöfasklöerklöfjasklfjysklfjaskfjsklösdfdko4jdfasdjioögjopefgip3rtgjiprg!"; Variant myVariant(fromInt); + Variant* myVariants = new Variant(fromString); + Variant myVariantf(fromDouble); - Variant* myVariants = new Variant(fromString); bool success; + std::string myString = myVariants->get(success); + std::cout << "myString = " << myString << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); + const int& myInt = myVariant.get(success); std::cout << "myInt = " << myInt << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); Variant myVariant2 = myVariant; const int& myInt2 = myVariant2.get(success); std::cout << "myInt2 = " << myInt2 << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); Variant myVariant3 = fromInt; const int& myInt3 = myVariant3.get(success); std::cout << "myInt3 = " << myInt3 << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); + + myString = myVariants->get(success); + std::cout << "myString = " << myString << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); Variant myVariantCopy(myVariant); const int& myIntCopy = myVariantCopy.get(success); std::cout << "myIntCopy = " << myIntCopy << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); std::cout << "myIntCopy equals myInt= " << "(" << std::boolalpha << (myVariant == myVariantCopy) << ")\n"; + EXPECT_TRUE((myVariant == myVariantCopy)); const int& myFake = myVariant.get(success); std::cout << "myFake = " << myFake << " (" << std::boolalpha << success << ")\n"; + EXPECT_FALSE(success); std::cout << "myInt is int = " << " (" << std::boolalpha << myVariant.isType() << ")\n"; + EXPECT_TRUE(myVariant.isType()); + std::cout << "myInt is std::string = " << " (" << std::boolalpha << myVariant.isType() << ")\n"; + EXPECT_FALSE(myVariant.isType()); - const int& myDouble = myVariantf.get(success); + const double& myDouble = myVariantf.get(success); std::cout << "myDouble = " << myDouble << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); - const std::string& myString = myVariants->get(success); + Variant myVariantsCopy(*myVariants); + std::string myStringCopy = myVariantsCopy.get(success); + std::cout << "myStringCopy = " << myStringCopy << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); +// EXPECT_TRUE((myVariants == myVariantsCopy)); + + bool s2; + myVariants->set(std::string("Hello World"), s2); + myString = myVariants->get(success); std::cout << "myString = " << myString << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); - delete myVariants; + myStringCopy = myVariantsCopy.get(success); + std::cout << "myStringCopy = " << myStringCopy << " (" << std::boolalpha << success << ")\n"; + EXPECT_TRUE(success); - return 0; + delete myVariants; } - +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}