F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ArrayToStringTest.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title ArrayToStringTest.cpp
3// \author T. Chieu
4// \brief cpp file for ArrayToStringTest class
5//
6// \copyright
7// Copyright (C) 2009-2022 California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12
13#include "FppTest/array/EnumArrayAc.hpp"
14#include "FppTest/array/StringArrayAc.hpp"
15#include "FppTest/array/StructArrayAc.hpp"
16#include "FppTest/array/Uint32ArrayArrayAc.hpp"
17
19
20#include "gtest/gtest.h"
21
22#include <sstream>
23
24// Test array string functions
25template <typename ArrayType>
26class ArrayToStringTest : public ::testing::Test {
27protected:
28 void SetUp() override {
29 FppTest::Array::setTestVals<ArrayType>(testVals);
30 }
31
32 typename ArrayType::ElementType testVals[ArrayType::SIZE];
33};
34
35using ArrayTypes = ::testing::Types<
36 Enum,
37 String,
38 Struct,
39 Uint32Array
40>;
42
43// Test array toString() and ostream operator functions
45 TypeParam a(this->testVals);
46 std::stringstream buf1, buf2;
47
48 buf1 << a;
49
50 buf2 << "[ ";
51 for (U32 i = 0; i < TypeParam::SIZE; i++) {
52 buf2 << this->testVals[i] << " ";
53 }
54 buf2 << "]";
55
56 ASSERT_STREQ(
57 buf1.str().c_str(),
58 buf2.str().c_str()
59 );
60}
::testing::Types< Enum, String, Struct, Uint32Array > ArrayTypes
TYPED_TEST_SUITE(ArrayToStringTest, ArrayTypes)
TYPED_TEST(ArrayToStringTest, ToString)
void SetUp() override
ArrayType::ElementType testVals[ArrayType::SIZE]