Commit f7dd1b814ea16412cc0c660bdb7ca93db4fde83a
1 parent
b4589f11
Make compliant to coding standards.
Showing
2 changed files
with
66 additions
and
41 deletions
test/test_GApplication.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * test_GApplication.cpp - test GApplication classes * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file test_GApplication.cpp |
| 23 | - * @brief Testing of application classes. | |
| 23 | + * @brief Testing of application classes | |
| 24 | 24 | * @author J. Knodlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -28,39 +28,51 @@ |
| 28 | 28 | #ifdef HAVE_CONFIG_H |
| 29 | 29 | #include <config.h> |
| 30 | 30 | #endif |
| 31 | -#include "GammaLib.hpp" | |
| 32 | 31 | #include "test_GApplication.hpp" |
| 33 | -#include <iostream> | |
| 34 | -#include <stdexcept> | |
| 35 | -#include <stdlib.h> | |
| 36 | 32 | |
| 37 | 33 | /* __ Globals ____________________________________________________________ */ |
| 38 | 34 | |
| 39 | -void TestGApplication::set(void){ | |
| 35 | + | |
| 36 | +/***********************************************************************//** | |
| 37 | + * @brief Set parameters and tests | |
| 38 | + **************************************************************************/ | |
| 39 | +void TestGApplication::set(void) | |
| 40 | +{ | |
| 40 | 41 | // Test name |
| 41 | 42 | name("GApplication"); |
| 42 | 43 | |
| 43 | - //add tests | |
| 44 | - add_test(static_cast<pfunction>(&TestGApplication::test_constructor),"GLog constructor"); | |
| 45 | - add_test(static_cast<pfunction>(&TestGApplication::test_stream_logger),"stream logger"); | |
| 46 | - add_test(static_cast<pfunction>(&TestGApplication::test_C_logger),"C logger"); | |
| 44 | + // Append tests | |
| 45 | + append(static_cast<pfunction>(&TestGApplication::test_constructor), "Test GLog constructor"); | |
| 46 | + append(static_cast<pfunction>(&TestGApplication::test_stream_logger), "Test stream logger"); | |
| 47 | + append(static_cast<pfunction>(&TestGApplication::test_C_logger), "Test C logger"); | |
| 47 | 48 | |
| 49 | + // Return | |
| 48 | 50 | return; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | |
| 52 | -// Test constructor | |
| 54 | +/***********************************************************************//** | |
| 55 | + * @brief Test GLog constructor | |
| 56 | + **************************************************************************/ | |
| 53 | 57 | void TestGApplication::test_constructor(void) |
| 54 | 58 | { |
| 59 | + // Void constructor | |
| 55 | 60 | GLog log1; |
| 61 | + | |
| 62 | + // Copy constructor | |
| 56 | 63 | GLog log2 = log1; |
| 57 | 64 | |
| 65 | + // Return | |
| 58 | 66 | return; |
| 59 | 67 | } |
| 60 | 68 | |
| 61 | -// Test stream logger | |
| 69 | + | |
| 70 | +/***********************************************************************//** | |
| 71 | + * @brief Test stream logger | |
| 72 | + **************************************************************************/ | |
| 62 | 73 | void TestGApplication::test_stream_logger(void) |
| 63 | 74 | { |
| 75 | + // Test | |
| 64 | 76 | GLog log; |
| 65 | 77 | log.date(true); |
| 66 | 78 | log.name("Test"); |
| ... | ... | @@ -73,12 +85,17 @@ void TestGApplication::test_stream_logger(void) |
| 73 | 85 | log << "6. This is a C string: " << "a" << std::endl; |
| 74 | 86 | log << "7. This is a Boolean: " << true << std::endl; |
| 75 | 87 | |
| 88 | + // Return | |
| 76 | 89 | return; |
| 77 | 90 | } |
| 78 | 91 | |
| 79 | -// Test C logger | |
| 92 | + | |
| 93 | +/***********************************************************************//** | |
| 94 | + * @brief Test C logger | |
| 95 | + **************************************************************************/ | |
| 80 | 96 | void TestGApplication::test_C_logger(void) |
| 81 | 97 | { |
| 98 | + // Test | |
| 82 | 99 | GLog log; |
| 83 | 100 | log.date(true); |
| 84 | 101 | log.name("Test"); |
| ... | ... | @@ -88,30 +105,34 @@ void TestGApplication::test_C_logger(void) |
| 88 | 105 | log("%s %f", "10. This is a single precision:", float(1.23456789)); |
| 89 | 106 | log("%s %f", "11. This is a double precision:", double(1.23456789)); |
| 90 | 107 | |
| 108 | + // Return | |
| 91 | 109 | return; |
| 92 | 110 | } |
| 93 | 111 | |
| 112 | + | |
| 94 | 113 | /*************************************************************************** |
| 95 | - * Main test function * | |
| 114 | + * @brief Main entry point for test executable | |
| 96 | 115 | ***************************************************************************/ |
| 97 | 116 | int main(void) |
| 98 | 117 | { |
| 118 | + // Allocate test suit container | |
| 99 | 119 | GTestSuites testsuites("GApplication"); |
| 100 | 120 | |
| 101 | - bool was_successful=true; | |
| 121 | + // Initially assume that we pass all tests | |
| 122 | + bool success = true; | |
| 102 | 123 | |
| 103 | - //Create a test suite | |
| 124 | + // Create a test suite | |
| 104 | 125 | TestGApplication test; |
| 105 | 126 | |
| 106 | - //Append to the container | |
| 127 | + // Append test suite to the container | |
| 107 | 128 | testsuites.append(test); |
| 108 | 129 | |
| 109 | - //Run | |
| 110 | - was_successful=testsuites.run(); | |
| 130 | + // Run the testsuites | |
| 131 | + success = testsuites.run(); | |
| 111 | 132 | |
| 112 | - //save xml report | |
| 133 | + // Save test report | |
| 113 | 134 | testsuites.save("reports/GApplication.xml"); |
| 114 | 135 | |
| 115 | - // Return | |
| 116 | - return was_successful ? 0:1; | |
| 136 | + // Return success status | |
| 137 | + return (success ? 0 : 1); | |
| 117 | 138 | } | ... | ... |
test/test_GApplication.hpp
| ... | ... | @@ -18,32 +18,36 @@ |
| 18 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 19 | 19 | * * |
| 20 | 20 | ***************************************************************************/ |
| 21 | +/** | |
| 22 | + * @file test_GApplication.hpp | |
| 23 | + * @brief Definition of unit tests for GApplication classes | |
| 24 | + * @author Jean-Baptiste Cayrou | |
| 25 | + */ | |
| 21 | 26 | |
| 22 | 27 | #ifndef TEST_GAPPLICATION_HPP |
| 23 | 28 | #define TEST_GAPPLICATION_HPP |
| 24 | 29 | |
| 25 | 30 | /* __ Includes ___________________________________________________________ */ |
| 26 | 31 | #include "GammaLib.hpp" |
| 27 | -#include <iostream> // cout, cerr | |
| 28 | 32 | |
| 29 | -class TestGApplication : public GTestSuite | |
| 30 | -{ | |
| 31 | - public: | |
| 32 | - // Constructors and destructors | |
| 33 | - TestGApplication(void) : GTestSuite(){ return; } | |
| 34 | - virtual ~TestGApplication(void){ return; } | |
| 35 | - | |
| 36 | - // Methods | |
| 37 | - virtual void set(void); | |
| 38 | - | |
| 39 | - void test_constructor(void); | |
| 40 | - void test_stream_logger(void); | |
| 41 | - void test_C_logger(void); | |
| 42 | - | |
| 43 | - | |
| 44 | - // Private methods | |
| 45 | - private: | |
| 46 | 33 | |
| 34 | +/***********************************************************************//** | |
| 35 | + * @class TestGApplication | |
| 36 | + * | |
| 37 | + * @brief Test suite for GApplication class testing | |
| 38 | + ***************************************************************************/ | |
| 39 | +class TestGApplication : public GTestSuite { | |
| 40 | + | |
| 41 | +public: | |
| 42 | + // Constructors and destructors | |
| 43 | + TestGApplication(void) : GTestSuite() {} | |
| 44 | + virtual ~TestGApplication(void) {} | |
| 45 | + | |
| 46 | + // Methods | |
| 47 | + virtual void set(void); | |
| 48 | + void test_constructor(void); | |
| 49 | + void test_stream_logger(void); | |
| 50 | + void test_C_logger(void); | |
| 47 | 51 | }; |
| 48 | 52 | |
| 49 | 53 | #endif /* TEST_GAPPLICATION_HPP */ | ... | ... |