fprime/Svc/DpWriter/test/ut/Rules/FileOpenStatus.cpp
Rob Bocchino b89b5d91c4
Add DpWriter (#2593)
* Pull in framework changes from data-products branch

* Pull in changes to DpManager from data-products branch

* Pull in DpWriter from data-products branch

* Fix spelling

* Revise FileNameString

* Fix warnings in CI

* Fix static analysis warnings

* Fix static analysis warnings

* Revise formatting and comments

* Revise banner comments

* Revise FileNameString per PR comment

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

or

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

`#include "config/H.hpp"`

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

include <config/H.hpp>

or

`#include "config/H.hpp"`

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.
2024-03-28 16:09:38 -07:00

60 lines
1.8 KiB
C++

// ======================================================================
// \title FileOpenStatus.cpp
// \author Rob Bocchino
// \brief FileOpenStatus class implementation
//
// \copyright
// Copyright (C) 2024 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government sponsorship
// acknowledged.
// ======================================================================
#include "Os/Stub/test/File.hpp"
#include "Svc/DpWriter/test/ut/Rules/FileOpenStatus.hpp"
#include "Svc/DpWriter/test/ut/Rules/Testers.hpp"
namespace Svc {
// ----------------------------------------------------------------------
// Rule definitions
// ----------------------------------------------------------------------
bool TestState ::precondition__FileOpenStatus__OK() const {
const auto& fileData = Os::Stub::File::Test::StaticData::data;
return (fileData.openStatus != Os::File::Status::OP_OK);
}
void TestState ::action__FileOpenStatus__OK() {
auto& fileData = Os::Stub::File::Test::StaticData::data;
fileData.openStatus = Os::File::Status::OP_OK;
}
bool TestState ::precondition__FileOpenStatus__Error() const {
const auto& fileData = Os::Stub::File::Test::StaticData::data;
return (fileData.openStatus == Os::File::Status::OP_OK);
}
void TestState ::action__FileOpenStatus__Error() {
auto& fileData = Os::Stub::File::Test::StaticData::data;
fileData.openStatus = DpWriterTester::pickOsFileError();
}
namespace FileOpenStatus {
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void Tester::OK() {
this->ruleError.apply(this->testState);
this->ruleOK.apply(this->testState);
}
void Tester::Error() {
this->ruleError.apply(this->testState);
}
} // namespace FileOpenStatus
} // namespace Svc