Files
fprime/FppTest/utils/Utils.cpp
Tiffany Chieu 15215288ee FPP v1.3.0 integration (#2103)
* Start functional tests for FPP component autocoder

* Add test components and formal param template types

* Create general formal param types and update test components

* Fix FppTest utilities

* Update test component and formal param types

* Add telemetry tests for FPP components

* Add macros to generate test code in FPP component autocoder tests

* Add telemetry tests for queued and passive FPP components

* Use formal param types in FPP port autocoder tests

* Share a main test file between FPP component tests

* Add empty FPP component test

* Add event tests for active FPP components

* Add event tests for all FPP component types

* Start parameter tests for FPP components

* Add parameter tests for FPP components

* Update parameter tests for FPP components

* Merge port tests into FPP component tests

* Update port tests for FPP components

* Format macros

* Reorganize FPP tests

* Add command tests for FPP components

* Add parameter command tests for FPP components

* Update FPP tests

* Update FPP tests

* Update FPP tests

* Remove unnecessary ports

* Add async FPP component tests

* Revise FPP port tests

* Reorganize FPP tests

* Format macros

* Update FPP tests

* Add headers

* Fix typo

* Update expected words for spell checker

* Update expected words for spell checker

* Run clang format

* Update fprime-fpp version

* Update FPP version

---------

Co-authored-by: bocchino <bocchino@jpl.nasa.gov>
2023-08-01 08:38:31 -07:00

59 lines
1.4 KiB
C++

// ======================================================================
// \title Utils.cpp
// \author T. Chieu
// \brief cpp file for Utils class
//
// \copyright
// Copyright (C) 2009-2022 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#include "STest/Pick/Pick.hpp"
#include <string>
#include <limits>
#include <iostream>
namespace FppTest {
namespace Utils {
U8 getNonzeroU8() {
return static_cast<U8>(STest::Pick::lowerUpper(
1,
std::numeric_limits<U8>::max()
));
}
U32 getNonzeroU32() {
return STest::Pick::lowerUpper(
1,
std::numeric_limits<U32>::max()
);
}
char getChar() {
return static_cast<char>(STest::Pick::lowerUpper(32, 127));
}
void setString(char* buf, U32 size) {
U32 length = STest::Pick::lowerUpper(1, size);
if (length == 0) {
buf[0] = 0;
return;
}
for (U32 i = 0; i < length - 1; i++) {
buf[i] = getChar();
}
buf[length-1] = 0;
}
} // namespace Utils
} // namespace FppTest