DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
testStreamOperators.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Cody R. Drisko. All rights reserved.
2// Licensed under the MIT License. See the LICENSE file in the project root for more information.
3//
4// Name: testStreamOperators.hpp
5// Author: crdrisko
6// Date: 09/17/2020-09:50:41
7// Description: Provides ~100% unit test coverage over the overloaded stream functions
8
9#ifndef DRYCHEM_CPP_UNITS_TESTS_TESTOPERATORS_TESTSTREAMOPERATORS_HPP
10#define DRYCHEM_CPP_UNITS_TESTS_TESTOPERATORS_TESTSTREAMOPERATORS_HPP
11
12#include <iostream>
13#include <string>
14
15#include <gtest/gtest.h>
16
18
19using namespace CppUnits;
20using namespace CppUnits::Literals;
21
22GTEST_TEST(testStreamOperators, overloadedStreamOperatorPrintsMagnitudeToStandardOut)
23{
24 testing::internal::CaptureStdout();
25
26 Length length = 5.0_m;
27 Time time = 2.5_s;
28 Velocity vel = length / time;
29
30 std::cout << length << " m / " << time << " s = " << vel << " m/s" << std::endl;
31
32 std::string output = testing::internal::GetCapturedStdout();
33 ASSERT_EQ(output, "5 m / 2.5 s = 2 m/s\n");
34}
35
36#endif
Definition physicalQuantities.hpp:94
Definition basicMath.hpp:17
PhysicalQuantity< Dimensionality< 1, 0, -1 > > Velocity
Definition physicalQuantities.hpp:36
PhysicalQuantity< Dimensionality< 0, 0, 1 > > Time
Definition physicalQuantities.hpp:32
PhysicalQuantity< Dimensionality< 1, 0, 0 > > Length
Definition physicalQuantities.hpp:37
GTEST_TEST(testStreamOperators, overloadedStreamOperatorPrintsMagnitudeToStandardOut)
Definition testStreamOperators.hpp:22