Skip to content

Commit

Permalink
General improvement of tests
Browse files Browse the repository at this point in the history
- Apply consistent format to tests name (i.e. output shown at runtime)
- Reduce the number of direct uses of std::cout in test implementation

n.b. these improvements were done in preparation for ECFLOW-1957
  • Loading branch information
marcosbento authored Sep 20, 2024
2 parents d7abfaf + 51f2ff1 commit b7e9139
Show file tree
Hide file tree
Showing 199 changed files with 1,761 additions and 1,179 deletions.
56 changes: 37 additions & 19 deletions libs/attribute/test/TestAttrSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <boost/test/unit_test.hpp>

#include "TestNaming.hpp"
#include "TestSerialisation.hpp"
#include "ecflow/attribute/AutoArchiveAttr.hpp"
#include "ecflow/attribute/AutoCancelAttr.hpp"
Expand Down Expand Up @@ -42,7 +43,7 @@ BOOST_AUTO_TEST_SUITE(U_Attributes)
BOOST_AUTO_TEST_SUITE(T_AttrSerialization)

BOOST_AUTO_TEST_CASE(test_AttrDefaultConstructor_serialisation) {
cout << "ANattr:: ...test_AttrDefaultConstructor_serialisation \n";
ECF_NAME_THIS_TEST();

doSaveAndRestore<VerifyAttr>(fileName);
doSaveAndRestore<TodayAttr>(fileName);
Expand All @@ -69,13 +70,15 @@ BOOST_AUTO_TEST_CASE(test_AttrDefaultConstructor_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_VerifyAttr_serialisation) {
cout << "ANattr:: ...test_VerifyAttr_serialisation \n";
ECF_NAME_THIS_TEST();

VerifyAttr saved(NState::COMPLETE, 10);
doSaveAndRestore(fileName, saved);
}

BOOST_AUTO_TEST_CASE(test_TodayAttr_serialisation) {
cout << "ANattr:: ...test_TodayAttr_serialisation \n";
ECF_NAME_THIS_TEST();

{
TodayAttr saved(TimeSlot(10, 12));
doSaveAndRestore(fileName, saved);
Expand All @@ -95,7 +98,8 @@ BOOST_AUTO_TEST_CASE(test_TodayAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_TimeAttr_serialisation) {
cout << "ANattr:: ...test_TimeAttr_serialisation \n";
ECF_NAME_THIS_TEST();

{
TimeAttr saved(TimeSlot(10, 12));
doSaveAndRestore(fileName, saved);
Expand All @@ -111,7 +115,8 @@ BOOST_AUTO_TEST_CASE(test_TimeAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_RepeatAttr_serialisation) {
cout << "ANattr:: ...test_RepeatAttr_serialisation \n";
ECF_NAME_THIS_TEST();

{
RepeatDate saved("varname", 20101210, 20101230, 3);
doSaveAndRestore(fileName, saved);
Expand Down Expand Up @@ -166,7 +171,8 @@ BOOST_AUTO_TEST_CASE(test_RepeatAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_LateAttr_serialisation) {
cout << "ANattr:: ...test_LateAttr_serialisation \n";
ECF_NAME_THIS_TEST();

LateAttr saved;
saved.addSubmitted(TimeSlot(10, 12));
saved.addActive(TimeSlot(10, 12));
Expand All @@ -175,7 +181,8 @@ BOOST_AUTO_TEST_CASE(test_LateAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_DayAttr_serialisation) {
cout << "ANattr:: ...test_DayAttr_serialisation\n";
ECF_NAME_THIS_TEST();

std::vector<DayAttr::Day_t> dvec;
dvec.push_back(DayAttr::SUNDAY);
dvec.push_back(DayAttr::MONDAY);
Expand All @@ -191,13 +198,15 @@ BOOST_AUTO_TEST_CASE(test_DayAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_DateAttr_serialisation) {
cout << "ANattr:: ...test_DateAttr_serialisation\n";
ECF_NAME_THIS_TEST();

DateAttr saved(1, 1, 2010);
doSaveAndRestore(fileName, saved);
}

BOOST_AUTO_TEST_CASE(test_CronAttr_serialisation) {
cout << "ANattr:: ...test_CronAttr_serialisation\n";
ECF_NAME_THIS_TEST();

CronAttr saved;
std::vector<int> weekDays;
weekDays.push_back(1);
Expand All @@ -217,7 +226,8 @@ BOOST_AUTO_TEST_CASE(test_CronAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_ClockAttr_serialisation) {
cout << "ANattr:: ...test_ClockAttr_serialisation\n";
ECF_NAME_THIS_TEST();

{
ClockAttr saved(false);
saved.date(1, 1, 2009);
Expand All @@ -232,7 +242,8 @@ BOOST_AUTO_TEST_CASE(test_ClockAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_AutoCancelAttr_serialisation) {
cout << "ANattr:: ...test_AutoCancelAttr_serialisation\n";
ECF_NAME_THIS_TEST();

{
AutoCancelAttr saved(100);
doSaveAndRestore(fileName, saved);
Expand All @@ -244,7 +255,8 @@ BOOST_AUTO_TEST_CASE(test_AutoCancelAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_AutoArchiveAttr_serialisation) {
cout << "ANattr:: ...test_AutoArchiveAttr_serialisation\n";
ECF_NAME_THIS_TEST();

{
AutoArchiveAttr saved(100);
doSaveAndRestore(fileName, saved);
Expand All @@ -264,21 +276,24 @@ BOOST_AUTO_TEST_CASE(test_AutoArchiveAttr_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_Label_serialisation) {
cout << "ANattr:: ...test_Label_serialisation\n";
ECF_NAME_THIS_TEST();

{
Label saved("labelName", "some text");
doSaveAndRestore(fileName, saved);
}
}

BOOST_AUTO_TEST_CASE(test_Variable_serialisation) {
cout << "ANattr:: ...test_Variable_serialisation\n";
ECF_NAME_THIS_TEST();

Variable saved("varname", "var value 123 12 =");
doSaveAndRestore(fileName, saved);
}

BOOST_AUTO_TEST_CASE(test_Event_serialisation) {
cout << "ANattr:: ...test_Event_serialisation\n";
ECF_NAME_THIS_TEST();

{
Event saved(3);
doSaveAndRestore(fileName, saved);
Expand All @@ -298,13 +313,15 @@ BOOST_AUTO_TEST_CASE(test_Event_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_Meter_serialisation) {
cout << "ANattr:: ...test_Meter_serialisation\n";
ECF_NAME_THIS_TEST();

Meter saved("meter", 0, 20, 20);
doSaveAndRestore(fileName, saved);
}

BOOST_AUTO_TEST_CASE(test_queue_serialisation) {
cout << "ANattr:: ...test_queue_serialisation\n";
ECF_NAME_THIS_TEST();

std::vector<std::string> queue_items;
queue_items.emplace_back("a");
queue_items.emplace_back("b");
Expand All @@ -313,7 +330,8 @@ BOOST_AUTO_TEST_CASE(test_queue_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_generic_serialisation) {
cout << "ANattr:: ...test_generic_serialisation\n";
ECF_NAME_THIS_TEST();

std::vector<std::string> queue_items;
queue_items.emplace_back("a");
queue_items.emplace_back("b");
Expand All @@ -322,7 +340,7 @@ BOOST_AUTO_TEST_CASE(test_generic_serialisation) {
}

BOOST_AUTO_TEST_CASE(test_zombie_attr_serialisation) {
cout << "ANattr:: ...test_zombie_attr_serialisation\n";
ECF_NAME_THIS_TEST();

std::vector<ecf::Child::CmdType> child_cmds = ecf::Child::list();

Expand Down
12 changes: 6 additions & 6 deletions libs/attribute/test/TestCron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <boost/test/unit_test.hpp>

#include "TestNaming.hpp"
#include "ecflow/attribute/CronAttr.hpp"
#include "ecflow/core/Calendar.hpp"
#include "ecflow/core/Str.hpp"
Expand All @@ -28,7 +29,8 @@ BOOST_AUTO_TEST_SUITE(U_Attributes)
BOOST_AUTO_TEST_SUITE(T_Cron)

BOOST_AUTO_TEST_CASE(test_cron_parsing) {
cout << "ANattr:: ...test_cron_parsing\n";
ECF_NAME_THIS_TEST();

TimeSlot start(10, 10);
TimeSlot finish(23, 10);
TimeSlot incr(0, 1);
Expand Down Expand Up @@ -214,7 +216,7 @@ BOOST_AUTO_TEST_CASE(test_cron_parsing) {
}

BOOST_AUTO_TEST_CASE(test_cron_state_parsing) {
cout << "ANattr:: ...test_cron_state_parsing\n";
ECF_NAME_THIS_TEST();

size_t index = 1; // to get over the cron
{
Expand Down Expand Up @@ -338,7 +340,7 @@ BOOST_AUTO_TEST_CASE(test_cron_state_parsing) {
}

BOOST_AUTO_TEST_CASE(test_cron_once_free_stays_free) {
cout << "ANattr:: ...test_cron_once_free_stays_free\n";
ECF_NAME_THIS_TEST();

Calendar calendar;
calendar.init(ptime(date(2010, 2, 10), minutes(0)), Calendar::REAL);
Expand Down Expand Up @@ -375,7 +377,6 @@ BOOST_AUTO_TEST_CASE(test_cron_once_free_stays_free) {
day_changed = calendar.dayChanged();
}
boost::posix_time::time_duration time = calendar.suiteTime().time_of_day();
// cout << time << " day_changed(" << day_changed << ")\n";

timeSeries.calendarChanged(calendar);
timeSeries2.calendarChanged(calendar);
Expand Down Expand Up @@ -460,7 +461,7 @@ BOOST_AUTO_TEST_CASE(test_cron_once_free_stays_free) {
}

BOOST_AUTO_TEST_CASE(test_cron_time_series) {
cout << "ANattr:: ...test_cron_time_series\n";
ECF_NAME_THIS_TEST();

// See TimeAttr.hpp for rules concerning isFree() and checkForReque()
// test time attr isFree(), and checkForRequeue
Expand Down Expand Up @@ -499,7 +500,6 @@ BOOST_AUTO_TEST_CASE(test_cron_time_series) {
day_changed = calendar.dayChanged();
}
boost::posix_time::time_duration time = calendar.suiteTime().time_of_day();
// cout << time << " day_changed(" << day_changed << ")\n";

timeSeries.calendarChanged(calendar);
timeSeries2.calendarChanged(calendar);
Expand Down
9 changes: 6 additions & 3 deletions libs/attribute/test/TestDateAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <boost/test/unit_test.hpp>

#include "TestNaming.hpp"
#include "ecflow/attribute/DateAttr.hpp"
#include "ecflow/core/PrintStyle.hpp"
#include "ecflow/core/Str.hpp"
Expand All @@ -27,7 +28,8 @@ BOOST_AUTO_TEST_SUITE(U_Attributes)
BOOST_AUTO_TEST_SUITE(T_DateAttr)

BOOST_AUTO_TEST_CASE(test_date) {
cout << "ANattr:: ...test_date\n";
ECF_NAME_THIS_TEST();

{
DateAttr empty;
DateAttr empty2;
Expand Down Expand Up @@ -79,8 +81,8 @@ static DateAttr print_and_parse_attr(DateAttr& date) {
}

BOOST_AUTO_TEST_CASE(test_date_parsing) {
ECF_NAME_THIS_TEST();

cout << "ANattr:: ...test_date_parsing\n";
{
DateAttr date("12.12.2019");
date.setFree();
Expand All @@ -107,7 +109,8 @@ BOOST_AUTO_TEST_CASE(test_date_parsing) {
}

BOOST_AUTO_TEST_CASE(test_date_errors) {
cout << "ANattr:: ...test_date_errors\n";
ECF_NAME_THIS_TEST();

{
BOOST_REQUIRE_THROW(DateAttr("-1.2.*"), std::runtime_error);
BOOST_REQUIRE_THROW(DateAttr("32.2.*"), std::runtime_error);
Expand Down
10 changes: 5 additions & 5 deletions libs/attribute/test/TestDayAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <boost/test/unit_test.hpp>

#include "TestNaming.hpp"
#include "ecflow/attribute/DayAttr.hpp"
#include "ecflow/core/Calendar.hpp"
#include "ecflow/core/PrintStyle.hpp"
Expand All @@ -28,7 +29,7 @@ BOOST_AUTO_TEST_SUITE(U_Attributes)
BOOST_AUTO_TEST_SUITE(T_DayAttr)

BOOST_AUTO_TEST_CASE(test_day_attr) {
cout << "ANattr:: ...test_day_attr\n";
ECF_NAME_THIS_TEST();

// See TimeAttr.hpp for rules concerning isFree() and checkForReque()
// test time attr isFree(), and checkForRequeue
Expand All @@ -50,8 +51,6 @@ BOOST_AUTO_TEST_CASE(test_day_attr) {
// if (calendar.dayChanged())
// day_changed++;

// cout << " day_changed(" << day_changed << ") calendar.day_of_week() = " << calendar.day_of_week() << "\n";

day.calendarChanged(calendar);

if (day.date() < calendar.date()) {
Expand All @@ -78,7 +77,8 @@ BOOST_AUTO_TEST_CASE(test_day_attr) {
}

BOOST_AUTO_TEST_CASE(test_day_attr_constructor) {
cout << "ANattr:: ...test_day_attr_constructor \n";
ECF_NAME_THIS_TEST();

{
DayAttr day;
BOOST_CHECK_MESSAGE(day.day() == DayAttr::SUNDAY, "");
Expand Down Expand Up @@ -113,8 +113,8 @@ static DayAttr print_and_parse_attr(DayAttr& day) {
}

BOOST_AUTO_TEST_CASE(test_day_parsing) {
ECF_NAME_THIS_TEST();

cout << "ANattr:: ...test_day_parsing\n";
{
DayAttr day(DayAttr::WEDNESDAY);
day.setFree();
Expand Down
4 changes: 3 additions & 1 deletion libs/attribute/test/TestLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <boost/test/unit_test.hpp>

#include "TestNaming.hpp"
#include "ecflow/attribute/NodeAttr.hpp"
#include "ecflow/core/Str.hpp"

Expand All @@ -24,7 +25,8 @@ BOOST_AUTO_TEST_SUITE(U_Attributes)
BOOST_AUTO_TEST_SUITE(T_Label)

BOOST_AUTO_TEST_CASE(test_label_parsing) {
cout << "ANattr:: ...test_label_parsing\n";
ECF_NAME_THIS_TEST();

{
std::string line = "label name \"value\"";
std::vector<string> linetokens;
Expand Down
Loading

0 comments on commit b7e9139

Please sign in to comment.