Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9535


Ignore:
Timestamp:
Mar 4, 2013, 10:24:30 PM (12 years ago)
Author:
landauf
Message:

more tests

Location:
code/branches/testing
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/output/ConsoleWriter.h

    r8858 r9535  
    5050    {
    5151        public:
     52            ConsoleWriter();
     53            ConsoleWriter(const ConsoleWriter&);
     54            virtual ~ConsoleWriter();
     55
    5256            static ConsoleWriter& getInstance();
    5357
     
    5963
    6064        private:
    61             ConsoleWriter();
    62             ConsoleWriter(const ConsoleWriter&);
    63             virtual ~ConsoleWriter();
    64 
    6565            bool bEnabled_; ///< If false, the instance will not write output to the console.
    6666    };
  • code/branches/testing/src/libraries/util/output/LogWriter.h

    r8858 r9535  
    5757    {
    5858        public:
     59            LogWriter();
     60            LogWriter(const LogWriter&);
     61            virtual ~LogWriter();
     62
    5963            static LogWriter& getInstance();
    6064
     
    6569
    6670        private:
    67             LogWriter();
    68             LogWriter(const LogWriter&);
    69             virtual ~LogWriter();
    70 
    7171            void openFile();
    7272            void closeFile();
  • code/branches/testing/src/libraries/util/output/MemoryWriter.h

    r8858 r9535  
    6767
    6868        public:
     69            MemoryWriter();
     70            MemoryWriter(const MemoryWriter&);
     71            virtual ~MemoryWriter();
     72
    6973            static MemoryWriter& getInstance();
    7074
     
    7680
    7781        private:
    78             MemoryWriter();
    79             MemoryWriter(const MemoryWriter&);
    80             virtual ~MemoryWriter();
    81 
    8282            std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called.
    8383    };
  • code/branches/testing/src/libraries/util/output/OutputDefinitions.h

    r8879 r9535  
    105105        OutputContextSubID sub_id;  ///< The id of the sub-context (or context::no_subcontext if this container doesn't define a sub-context)
    106106        std::string name;           ///< The name of this context
     107
     108        inline bool operator==(const OutputContextContainer& other) const
     109        {
     110            return this->mask == other.mask && this->sub_id == other.sub_id && this->name == other.name;
     111        }
    107112    };
    108113
  • code/branches/testing/src/libraries/util/output/OutputManager.h

    r9533 r9535  
    102102            std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
    103103
    104         protected:
    105104            inline const std::vector<OutputListener*>& getListeners() const
    106105                { return this->listeners_; }
  • code/branches/testing/test/util/output/ConsoleWriterTest.cc

    r9529 r9535  
    11#include <gtest/gtest.h>
    22#include "util/Output.h"
     3#include "util/output/ConsoleWriter.h"
     4#include "util/output/OutputManager.h"
    35
    46namespace orxonox
    57{
     8    TEST(ConsoleWriterTest, Disable)
     9    {
     10        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     11        ConsoleWriter writer;
     12        EXPECT_EQ(1U, OutputManager::getInstance().getListeners().size());
     13        writer.disable();
     14        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     15    }
     16
     17    TEST(ConsoleWriterTest, Enable)
     18    {
     19        ConsoleWriter writer;
     20        writer.disable();
     21        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     22        writer.enable();
     23        EXPECT_EQ(1U, OutputManager::getInstance().getListeners().size());
     24    }
    625}
  • code/branches/testing/test/util/output/MemoryWriterTest.cc

    r9529 r9535  
    11#include <gtest/gtest.h>
     2#include <gmock/gmock.h>
    23#include "util/Output.h"
     4#include "util/output/MemoryWriter.h"
     5#include "util/output/OutputManager.h"
    36
    47namespace orxonox
    58{
     9    namespace
     10    {
     11        class MockOutputListener : public OutputListener
     12        {
     13            public:
     14                MOCK_METHOD3(output, void(OutputLevel, const OutputContextContainer&, const std::vector<std::string>&));
     15        };
     16    }
     17
     18    TEST(MemoryWriterTest, Disable)
     19    {
     20        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     21        MemoryWriter writer;
     22        EXPECT_EQ(1U, OutputManager::getInstance().getListeners().size());
     23        writer.disable();
     24        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     25    }
     26
     27    TEST(MemoryWriterTest, ResendOutput)
     28    {
     29        MemoryWriter writer;
     30
     31        std::vector<std::string> lines;
     32        lines.push_back("random line of output");
     33        lines.push_back("another line of output");
     34
     35        writer.unfilteredOutput(level::user_info, context::undefined(), lines);
     36        writer.unfilteredOutput(level::verbose, context::xml(), lines);
     37
     38        MockOutputListener other;
     39        other.setLevelMask(level::all);
     40
     41        EXPECT_CALL(other, output(level::user_info, context::undefined(), lines));
     42        EXPECT_CALL(other, output(level::verbose, context::xml(), lines));
     43
     44        writer.resendOutput(&other);
     45    }
    646}
  • code/branches/testing/test/util/output/OutputListenerTest.cc

    r9534 r9535  
    313313
    314314        std::vector<std::string> lines;
    315         EXPECT_CALL(listener, output(level, ::testing::_, lines)).Times(1);
     315        EXPECT_CALL(listener, output(level, context, lines)).Times(1);
    316316
    317317        listener.unfilteredOutput(level, context, lines);
     
    330330
    331331        std::vector<std::string> lines;
    332         EXPECT_CALL(listener, output(level, ::testing::_, lines)).Times(0);
     332        EXPECT_CALL(listener, output(level, context, lines)).Times(0);
    333333
    334334        listener.unfilteredOutput(level, context, lines);
Note: See TracChangeset for help on using the changeset viewer.